@@ -1,2 +1,2 | |||||
1 | 3081d1f9bb20b2b64a192585337a292a9804e0c5 LFR_basic-parameters |
|
1 | 3081d1f9bb20b2b64a192585337a292a9804e0c5 LFR_basic-parameters | |
2 | 058c1234c2defe215d3dd655a7ef65abb33c922d header/lfr_common_headers |
|
2 | 21ada91882790323b08a38518ed1af5a36fa4deb header/lfr_common_headers |
@@ -1,1005 +1,1005 | |||||
1 | /** General usage functions and RTEMS tasks. |
|
1 | /** General usage functions and RTEMS tasks. | |
2 | * |
|
2 | * | |
3 | * @file |
|
3 | * @file | |
4 | * @author P. LEROY |
|
4 | * @author P. LEROY | |
5 | * |
|
5 | * | |
6 | */ |
|
6 | */ | |
7 |
|
7 | |||
8 | #include "fsw_misc.h" |
|
8 | #include "fsw_misc.h" | |
9 |
|
9 | |||
10 | int16_t hk_lfr_sc_v_f3_as_int16 = 0; |
|
10 | int16_t hk_lfr_sc_v_f3_as_int16 = 0; | |
11 | int16_t hk_lfr_sc_e1_f3_as_int16 = 0; |
|
11 | int16_t hk_lfr_sc_e1_f3_as_int16 = 0; | |
12 | int16_t hk_lfr_sc_e2_f3_as_int16 = 0; |
|
12 | int16_t hk_lfr_sc_e2_f3_as_int16 = 0; | |
13 |
|
13 | |||
14 | void timer_configure(unsigned char timer, unsigned int clock_divider, |
|
14 | void timer_configure(unsigned char timer, unsigned int clock_divider, | |
15 | unsigned char interrupt_level, rtems_isr (*timer_isr)() ) |
|
15 | unsigned char interrupt_level, rtems_isr (*timer_isr)() ) | |
16 | { |
|
16 | { | |
17 | /** This function configures a GPTIMER timer instantiated in the VHDL design. |
|
17 | /** This function configures a GPTIMER timer instantiated in the VHDL design. | |
18 | * |
|
18 | * | |
19 | * @param gptimer_regs points to the APB registers of the GPTIMER IP core. |
|
19 | * @param gptimer_regs points to the APB registers of the GPTIMER IP core. | |
20 | * @param timer is the number of the timer in the IP core (several timers can be instantiated). |
|
20 | * @param timer is the number of the timer in the IP core (several timers can be instantiated). | |
21 | * @param clock_divider is the divider of the 1 MHz clock that will be configured. |
|
21 | * @param clock_divider is the divider of the 1 MHz clock that will be configured. | |
22 | * @param interrupt_level is the interrupt level that the timer drives. |
|
22 | * @param interrupt_level is the interrupt level that the timer drives. | |
23 | * @param timer_isr is the interrupt subroutine that will be attached to the IRQ driven by the timer. |
|
23 | * @param timer_isr is the interrupt subroutine that will be attached to the IRQ driven by the timer. | |
24 | * |
|
24 | * | |
25 | * Interrupt levels are described in the SPARC documentation sparcv8.pdf p.76 |
|
25 | * Interrupt levels are described in the SPARC documentation sparcv8.pdf p.76 | |
26 | * |
|
26 | * | |
27 | */ |
|
27 | */ | |
28 |
|
28 | |||
29 | rtems_status_code status; |
|
29 | rtems_status_code status; | |
30 | rtems_isr_entry old_isr_handler; |
|
30 | rtems_isr_entry old_isr_handler; | |
31 |
|
31 | |||
32 | old_isr_handler = NULL; |
|
32 | old_isr_handler = NULL; | |
33 |
|
33 | |||
34 | gptimer_regs->timer[timer].ctrl = INIT_CHAR; // reset the control register |
|
34 | gptimer_regs->timer[timer].ctrl = INIT_CHAR; // reset the control register | |
35 |
|
35 | |||
36 | status = rtems_interrupt_catch( timer_isr, interrupt_level, &old_isr_handler) ; // see sparcv8.pdf p.76 for interrupt levels |
|
36 | status = rtems_interrupt_catch( timer_isr, interrupt_level, &old_isr_handler) ; // see sparcv8.pdf p.76 for interrupt levels | |
37 | if (status!=RTEMS_SUCCESSFUL) |
|
37 | if (status!=RTEMS_SUCCESSFUL) | |
38 | { |
|
38 | { | |
39 | PRINTF("in configure_timer *** ERR rtems_interrupt_catch\n") |
|
39 | PRINTF("in configure_timer *** ERR rtems_interrupt_catch\n") | |
40 | } |
|
40 | } | |
41 |
|
41 | |||
42 | timer_set_clock_divider( timer, clock_divider); |
|
42 | timer_set_clock_divider( timer, clock_divider); | |
43 | } |
|
43 | } | |
44 |
|
44 | |||
45 | void timer_start(unsigned char timer) |
|
45 | void timer_start(unsigned char timer) | |
46 | { |
|
46 | { | |
47 | /** This function starts a GPTIMER timer. |
|
47 | /** This function starts a GPTIMER timer. | |
48 | * |
|
48 | * | |
49 | * @param gptimer_regs points to the APB registers of the GPTIMER IP core. |
|
49 | * @param gptimer_regs points to the APB registers of the GPTIMER IP core. | |
50 | * @param timer is the number of the timer in the IP core (several timers can be instantiated). |
|
50 | * @param timer is the number of the timer in the IP core (several timers can be instantiated). | |
51 | * |
|
51 | * | |
52 | */ |
|
52 | */ | |
53 |
|
53 | |||
54 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | GPTIMER_CLEAR_IRQ; |
|
54 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | GPTIMER_CLEAR_IRQ; | |
55 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | GPTIMER_LD; |
|
55 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | GPTIMER_LD; | |
56 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | GPTIMER_EN; |
|
56 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | GPTIMER_EN; | |
57 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | GPTIMER_RS; |
|
57 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | GPTIMER_RS; | |
58 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | GPTIMER_IE; |
|
58 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | GPTIMER_IE; | |
59 | } |
|
59 | } | |
60 |
|
60 | |||
61 | void timer_stop(unsigned char timer) |
|
61 | void timer_stop(unsigned char timer) | |
62 | { |
|
62 | { | |
63 | /** This function stops a GPTIMER timer. |
|
63 | /** This function stops a GPTIMER timer. | |
64 | * |
|
64 | * | |
65 | * @param gptimer_regs points to the APB registers of the GPTIMER IP core. |
|
65 | * @param gptimer_regs points to the APB registers of the GPTIMER IP core. | |
66 | * @param timer is the number of the timer in the IP core (several timers can be instantiated). |
|
66 | * @param timer is the number of the timer in the IP core (several timers can be instantiated). | |
67 | * |
|
67 | * | |
68 | */ |
|
68 | */ | |
69 |
|
69 | |||
70 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl & GPTIMER_EN_MASK; |
|
70 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl & GPTIMER_EN_MASK; | |
71 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl & GPTIMER_IE_MASK; |
|
71 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl & GPTIMER_IE_MASK; | |
72 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | GPTIMER_CLEAR_IRQ; |
|
72 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | GPTIMER_CLEAR_IRQ; | |
73 | } |
|
73 | } | |
74 |
|
74 | |||
75 | void timer_set_clock_divider(unsigned char timer, unsigned int clock_divider) |
|
75 | void timer_set_clock_divider(unsigned char timer, unsigned int clock_divider) | |
76 | { |
|
76 | { | |
77 | /** This function sets the clock divider of a GPTIMER timer. |
|
77 | /** This function sets the clock divider of a GPTIMER timer. | |
78 | * |
|
78 | * | |
79 | * @param gptimer_regs points to the APB registers of the GPTIMER IP core. |
|
79 | * @param gptimer_regs points to the APB registers of the GPTIMER IP core. | |
80 | * @param timer is the number of the timer in the IP core (several timers can be instantiated). |
|
80 | * @param timer is the number of the timer in the IP core (several timers can be instantiated). | |
81 | * @param clock_divider is the divider of the 1 MHz clock that will be configured. |
|
81 | * @param clock_divider is the divider of the 1 MHz clock that will be configured. | |
82 | * |
|
82 | * | |
83 | */ |
|
83 | */ | |
84 |
|
84 | |||
85 | gptimer_regs->timer[timer].reload = clock_divider; // base clock frequency is 1 MHz |
|
85 | gptimer_regs->timer[timer].reload = clock_divider; // base clock frequency is 1 MHz | |
86 | } |
|
86 | } | |
87 |
|
87 | |||
88 | // WATCHDOG |
|
88 | // WATCHDOG | |
89 |
|
89 | |||
90 | rtems_isr watchdog_isr( rtems_vector_number vector ) |
|
90 | rtems_isr watchdog_isr( rtems_vector_number vector ) | |
91 | { |
|
91 | { | |
92 | rtems_status_code status_code; |
|
92 | rtems_status_code status_code; | |
93 |
|
93 | |||
94 | status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_12 ); |
|
94 | status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_12 ); | |
95 |
|
95 | |||
96 | PRINTF("watchdog_isr *** this is the end, exit(0)\n"); |
|
96 | PRINTF("watchdog_isr *** this is the end, exit(0)\n"); | |
97 |
|
97 | |||
98 | exit(0); |
|
98 | exit(0); | |
99 | } |
|
99 | } | |
100 |
|
100 | |||
101 | void watchdog_configure(void) |
|
101 | void watchdog_configure(void) | |
102 | { |
|
102 | { | |
103 | /** This function configure the watchdog. |
|
103 | /** This function configure the watchdog. | |
104 | * |
|
104 | * | |
105 | * @param gptimer_regs points to the APB registers of the GPTIMER IP core. |
|
105 | * @param gptimer_regs points to the APB registers of the GPTIMER IP core. | |
106 | * @param timer is the number of the timer in the IP core (several timers can be instantiated). |
|
106 | * @param timer is the number of the timer in the IP core (several timers can be instantiated). | |
107 | * |
|
107 | * | |
108 | * The watchdog is a timer provided by the GPTIMER IP core of the GRLIB. |
|
108 | * The watchdog is a timer provided by the GPTIMER IP core of the GRLIB. | |
109 | * |
|
109 | * | |
110 | */ |
|
110 | */ | |
111 |
|
111 | |||
112 | LEON_Mask_interrupt( IRQ_GPTIMER_WATCHDOG ); // mask gptimer/watchdog interrupt during configuration |
|
112 | LEON_Mask_interrupt( IRQ_GPTIMER_WATCHDOG ); // mask gptimer/watchdog interrupt during configuration | |
113 |
|
113 | |||
114 | timer_configure( TIMER_WATCHDOG, CLKDIV_WATCHDOG, IRQ_SPARC_GPTIMER_WATCHDOG, watchdog_isr ); |
|
114 | timer_configure( TIMER_WATCHDOG, CLKDIV_WATCHDOG, IRQ_SPARC_GPTIMER_WATCHDOG, watchdog_isr ); | |
115 |
|
115 | |||
116 | LEON_Clear_interrupt( IRQ_GPTIMER_WATCHDOG ); // clear gptimer/watchdog interrupt |
|
116 | LEON_Clear_interrupt( IRQ_GPTIMER_WATCHDOG ); // clear gptimer/watchdog interrupt | |
117 | } |
|
117 | } | |
118 |
|
118 | |||
119 | void watchdog_stop(void) |
|
119 | void watchdog_stop(void) | |
120 | { |
|
120 | { | |
121 | LEON_Mask_interrupt( IRQ_GPTIMER_WATCHDOG ); // mask gptimer/watchdog interrupt line |
|
121 | LEON_Mask_interrupt( IRQ_GPTIMER_WATCHDOG ); // mask gptimer/watchdog interrupt line | |
122 | timer_stop( TIMER_WATCHDOG ); |
|
122 | timer_stop( TIMER_WATCHDOG ); | |
123 | LEON_Clear_interrupt( IRQ_GPTIMER_WATCHDOG ); // clear gptimer/watchdog interrupt |
|
123 | LEON_Clear_interrupt( IRQ_GPTIMER_WATCHDOG ); // clear gptimer/watchdog interrupt | |
124 | } |
|
124 | } | |
125 |
|
125 | |||
126 | void watchdog_reload(void) |
|
126 | void watchdog_reload(void) | |
127 | { |
|
127 | { | |
128 | /** This function reloads the watchdog timer counter with the timer reload value. |
|
128 | /** This function reloads the watchdog timer counter with the timer reload value. | |
129 | * |
|
129 | * | |
130 | * @param void |
|
130 | * @param void | |
131 | * |
|
131 | * | |
132 | * @return void |
|
132 | * @return void | |
133 | * |
|
133 | * | |
134 | */ |
|
134 | */ | |
135 |
|
135 | |||
136 | gptimer_regs->timer[TIMER_WATCHDOG].ctrl = gptimer_regs->timer[TIMER_WATCHDOG].ctrl | GPTIMER_LD; |
|
136 | gptimer_regs->timer[TIMER_WATCHDOG].ctrl = gptimer_regs->timer[TIMER_WATCHDOG].ctrl | GPTIMER_LD; | |
137 | } |
|
137 | } | |
138 |
|
138 | |||
139 | void watchdog_start(void) |
|
139 | void watchdog_start(void) | |
140 | { |
|
140 | { | |
141 | /** This function starts the watchdog timer. |
|
141 | /** This function starts the watchdog timer. | |
142 | * |
|
142 | * | |
143 | * @param gptimer_regs points to the APB registers of the GPTIMER IP core. |
|
143 | * @param gptimer_regs points to the APB registers of the GPTIMER IP core. | |
144 | * @param timer is the number of the timer in the IP core (several timers can be instantiated). |
|
144 | * @param timer is the number of the timer in the IP core (several timers can be instantiated). | |
145 | * |
|
145 | * | |
146 | */ |
|
146 | */ | |
147 |
|
147 | |||
148 | LEON_Clear_interrupt( IRQ_GPTIMER_WATCHDOG ); |
|
148 | LEON_Clear_interrupt( IRQ_GPTIMER_WATCHDOG ); | |
149 |
|
149 | |||
150 | gptimer_regs->timer[TIMER_WATCHDOG].ctrl = gptimer_regs->timer[TIMER_WATCHDOG].ctrl | GPTIMER_CLEAR_IRQ; |
|
150 | gptimer_regs->timer[TIMER_WATCHDOG].ctrl = gptimer_regs->timer[TIMER_WATCHDOG].ctrl | GPTIMER_CLEAR_IRQ; | |
151 | gptimer_regs->timer[TIMER_WATCHDOG].ctrl = gptimer_regs->timer[TIMER_WATCHDOG].ctrl | GPTIMER_LD; |
|
151 | gptimer_regs->timer[TIMER_WATCHDOG].ctrl = gptimer_regs->timer[TIMER_WATCHDOG].ctrl | GPTIMER_LD; | |
152 | gptimer_regs->timer[TIMER_WATCHDOG].ctrl = gptimer_regs->timer[TIMER_WATCHDOG].ctrl | GPTIMER_EN; |
|
152 | gptimer_regs->timer[TIMER_WATCHDOG].ctrl = gptimer_regs->timer[TIMER_WATCHDOG].ctrl | GPTIMER_EN; | |
153 | gptimer_regs->timer[TIMER_WATCHDOG].ctrl = gptimer_regs->timer[TIMER_WATCHDOG].ctrl | GPTIMER_IE; |
|
153 | gptimer_regs->timer[TIMER_WATCHDOG].ctrl = gptimer_regs->timer[TIMER_WATCHDOG].ctrl | GPTIMER_IE; | |
154 |
|
154 | |||
155 | LEON_Unmask_interrupt( IRQ_GPTIMER_WATCHDOG ); |
|
155 | LEON_Unmask_interrupt( IRQ_GPTIMER_WATCHDOG ); | |
156 |
|
156 | |||
157 | } |
|
157 | } | |
158 |
|
158 | |||
159 | int enable_apbuart_transmitter( void ) // set the bit 1, TE Transmitter Enable to 1 in the APBUART control register |
|
159 | int enable_apbuart_transmitter( void ) // set the bit 1, TE Transmitter Enable to 1 in the APBUART control register | |
160 | { |
|
160 | { | |
161 | struct apbuart_regs_str *apbuart_regs = (struct apbuart_regs_str *) REGS_ADDR_APBUART; |
|
161 | struct apbuart_regs_str *apbuart_regs = (struct apbuart_regs_str *) REGS_ADDR_APBUART; | |
162 |
|
162 | |||
163 | apbuart_regs->ctrl = APBUART_CTRL_REG_MASK_TE; |
|
163 | apbuart_regs->ctrl = APBUART_CTRL_REG_MASK_TE; | |
164 |
|
164 | |||
165 | return 0; |
|
165 | return 0; | |
166 | } |
|
166 | } | |
167 |
|
167 | |||
168 | void set_apbuart_scaler_reload_register(unsigned int regs, unsigned int value) |
|
168 | void set_apbuart_scaler_reload_register(unsigned int regs, unsigned int value) | |
169 | { |
|
169 | { | |
170 | /** This function sets the scaler reload register of the apbuart module |
|
170 | /** This function sets the scaler reload register of the apbuart module | |
171 | * |
|
171 | * | |
172 | * @param regs is the address of the apbuart registers in memory |
|
172 | * @param regs is the address of the apbuart registers in memory | |
173 | * @param value is the value that will be stored in the scaler register |
|
173 | * @param value is the value that will be stored in the scaler register | |
174 | * |
|
174 | * | |
175 | * The value shall be set by the software to get data on the serial interface. |
|
175 | * The value shall be set by the software to get data on the serial interface. | |
176 | * |
|
176 | * | |
177 | */ |
|
177 | */ | |
178 |
|
178 | |||
179 | struct apbuart_regs_str *apbuart_regs = (struct apbuart_regs_str *) regs; |
|
179 | struct apbuart_regs_str *apbuart_regs = (struct apbuart_regs_str *) regs; | |
180 |
|
180 | |||
181 | apbuart_regs->scaler = value; |
|
181 | apbuart_regs->scaler = value; | |
182 |
|
182 | |||
183 | BOOT_PRINTF1("OK *** apbuart port scaler reload register set to 0x%x\n", value) |
|
183 | BOOT_PRINTF1("OK *** apbuart port scaler reload register set to 0x%x\n", value) | |
184 | } |
|
184 | } | |
185 |
|
185 | |||
186 | //************ |
|
186 | //************ | |
187 | // RTEMS TASKS |
|
187 | // RTEMS TASKS | |
188 |
|
188 | |||
189 | rtems_task load_task(rtems_task_argument argument) |
|
189 | rtems_task load_task(rtems_task_argument argument) | |
190 | { |
|
190 | { | |
191 | BOOT_PRINTF("in LOAD *** \n") |
|
191 | BOOT_PRINTF("in LOAD *** \n") | |
192 |
|
192 | |||
193 | rtems_status_code status; |
|
193 | rtems_status_code status; | |
194 | unsigned int i; |
|
194 | unsigned int i; | |
195 | unsigned int j; |
|
195 | unsigned int j; | |
196 | rtems_name name_watchdog_rate_monotonic; // name of the watchdog rate monotonic |
|
196 | rtems_name name_watchdog_rate_monotonic; // name of the watchdog rate monotonic | |
197 | rtems_id watchdog_period_id; // id of the watchdog rate monotonic period |
|
197 | rtems_id watchdog_period_id; // id of the watchdog rate monotonic period | |
198 |
|
198 | |||
199 | watchdog_period_id = RTEMS_ID_NONE; |
|
199 | watchdog_period_id = RTEMS_ID_NONE; | |
200 |
|
200 | |||
201 | name_watchdog_rate_monotonic = rtems_build_name( 'L', 'O', 'A', 'D' ); |
|
201 | name_watchdog_rate_monotonic = rtems_build_name( 'L', 'O', 'A', 'D' ); | |
202 |
|
202 | |||
203 | status = rtems_rate_monotonic_create( name_watchdog_rate_monotonic, &watchdog_period_id ); |
|
203 | status = rtems_rate_monotonic_create( name_watchdog_rate_monotonic, &watchdog_period_id ); | |
204 | if( status != RTEMS_SUCCESSFUL ) { |
|
204 | if( status != RTEMS_SUCCESSFUL ) { | |
205 | PRINTF1( "in LOAD *** rtems_rate_monotonic_create failed with status of %d\n", status ) |
|
205 | PRINTF1( "in LOAD *** rtems_rate_monotonic_create failed with status of %d\n", status ) | |
206 | } |
|
206 | } | |
207 |
|
207 | |||
208 | i = 0; |
|
208 | i = 0; | |
209 | j = 0; |
|
209 | j = 0; | |
210 |
|
210 | |||
211 | watchdog_configure(); |
|
211 | watchdog_configure(); | |
212 |
|
212 | |||
213 | watchdog_start(); |
|
213 | watchdog_start(); | |
214 |
|
214 | |||
215 | set_sy_lfr_watchdog_enabled( true ); |
|
215 | set_sy_lfr_watchdog_enabled( true ); | |
216 |
|
216 | |||
217 | while(1){ |
|
217 | while(1){ | |
218 | status = rtems_rate_monotonic_period( watchdog_period_id, WATCHDOG_PERIOD ); |
|
218 | status = rtems_rate_monotonic_period( watchdog_period_id, WATCHDOG_PERIOD ); | |
219 | watchdog_reload(); |
|
219 | watchdog_reload(); | |
220 | i = i + 1; |
|
220 | i = i + 1; | |
221 | if ( i == WATCHDOG_LOOP_PRINTF ) |
|
221 | if ( i == WATCHDOG_LOOP_PRINTF ) | |
222 | { |
|
222 | { | |
223 | i = 0; |
|
223 | i = 0; | |
224 | j = j + 1; |
|
224 | j = j + 1; | |
225 | PRINTF1("%d\n", j) |
|
225 | PRINTF1("%d\n", j) | |
226 | } |
|
226 | } | |
227 | #ifdef DEBUG_WATCHDOG |
|
227 | #ifdef DEBUG_WATCHDOG | |
228 | if (j == WATCHDOG_LOOP_DEBUG ) |
|
228 | if (j == WATCHDOG_LOOP_DEBUG ) | |
229 | { |
|
229 | { | |
230 | status = rtems_task_delete(RTEMS_SELF); |
|
230 | status = rtems_task_delete(RTEMS_SELF); | |
231 | } |
|
231 | } | |
232 | #endif |
|
232 | #endif | |
233 | } |
|
233 | } | |
234 | } |
|
234 | } | |
235 |
|
235 | |||
236 | rtems_task hous_task(rtems_task_argument argument) |
|
236 | rtems_task hous_task(rtems_task_argument argument) | |
237 | { |
|
237 | { | |
238 | rtems_status_code status; |
|
238 | rtems_status_code status; | |
239 | rtems_status_code spare_status; |
|
239 | rtems_status_code spare_status; | |
240 | rtems_id queue_id; |
|
240 | rtems_id queue_id; | |
241 | rtems_rate_monotonic_period_status period_status; |
|
241 | rtems_rate_monotonic_period_status period_status; | |
242 | bool isSynchronized; |
|
242 | bool isSynchronized; | |
243 |
|
243 | |||
244 | queue_id = RTEMS_ID_NONE; |
|
244 | queue_id = RTEMS_ID_NONE; | |
245 | memset(&period_status, 0, sizeof(rtems_rate_monotonic_period_status)); |
|
245 | memset(&period_status, 0, sizeof(rtems_rate_monotonic_period_status)); | |
246 | isSynchronized = false; |
|
246 | isSynchronized = false; | |
247 |
|
247 | |||
248 | status = get_message_queue_id_send( &queue_id ); |
|
248 | status = get_message_queue_id_send( &queue_id ); | |
249 | if (status != RTEMS_SUCCESSFUL) |
|
249 | if (status != RTEMS_SUCCESSFUL) | |
250 | { |
|
250 | { | |
251 | PRINTF1("in HOUS *** ERR get_message_queue_id_send %d\n", status) |
|
251 | PRINTF1("in HOUS *** ERR get_message_queue_id_send %d\n", status) | |
252 | } |
|
252 | } | |
253 |
|
253 | |||
254 | BOOT_PRINTF("in HOUS ***\n"); |
|
254 | BOOT_PRINTF("in HOUS ***\n"); | |
255 |
|
255 | |||
256 | if (rtems_rate_monotonic_ident( name_hk_rate_monotonic, &HK_id) != RTEMS_SUCCESSFUL) { |
|
256 | if (rtems_rate_monotonic_ident( name_hk_rate_monotonic, &HK_id) != RTEMS_SUCCESSFUL) { | |
257 | status = rtems_rate_monotonic_create( name_hk_rate_monotonic, &HK_id ); |
|
257 | status = rtems_rate_monotonic_create( name_hk_rate_monotonic, &HK_id ); | |
258 | if( status != RTEMS_SUCCESSFUL ) { |
|
258 | if( status != RTEMS_SUCCESSFUL ) { | |
259 | PRINTF1( "rtems_rate_monotonic_create failed with status of %d\n", status ); |
|
259 | PRINTF1( "rtems_rate_monotonic_create failed with status of %d\n", status ); | |
260 | } |
|
260 | } | |
261 | } |
|
261 | } | |
262 |
|
262 | |||
263 | status = rtems_rate_monotonic_cancel(HK_id); |
|
263 | status = rtems_rate_monotonic_cancel(HK_id); | |
264 | if( status != RTEMS_SUCCESSFUL ) { |
|
264 | if( status != RTEMS_SUCCESSFUL ) { | |
265 | PRINTF1( "ERR *** in HOUS *** rtems_rate_monotonic_cancel(HK_id) ***code: %d\n", status ); |
|
265 | PRINTF1( "ERR *** in HOUS *** rtems_rate_monotonic_cancel(HK_id) ***code: %d\n", status ); | |
266 | } |
|
266 | } | |
267 | else { |
|
267 | else { | |
268 | DEBUG_PRINTF("OK *** in HOUS *** rtems_rate_monotonic_cancel(HK_id)\n"); |
|
268 | DEBUG_PRINTF("OK *** in HOUS *** rtems_rate_monotonic_cancel(HK_id)\n"); | |
269 | } |
|
269 | } | |
270 |
|
270 | |||
271 | // startup phase |
|
271 | // startup phase | |
272 | status = rtems_rate_monotonic_period( HK_id, SY_LFR_TIME_SYN_TIMEOUT_in_ticks ); |
|
272 | status = rtems_rate_monotonic_period( HK_id, SY_LFR_TIME_SYN_TIMEOUT_in_ticks ); | |
273 | status = rtems_rate_monotonic_get_status( HK_id, &period_status ); |
|
273 | status = rtems_rate_monotonic_get_status( HK_id, &period_status ); | |
274 | DEBUG_PRINTF1("startup HK, HK_id status = %d\n", period_status.state) |
|
274 | DEBUG_PRINTF1("startup HK, HK_id status = %d\n", period_status.state) | |
275 | while( (period_status.state != RATE_MONOTONIC_EXPIRED) |
|
275 | while( (period_status.state != RATE_MONOTONIC_EXPIRED) | |
276 | && (isSynchronized == false) ) // after SY_LFR_TIME_SYN_TIMEOUT ms, starts HK anyway |
|
276 | && (isSynchronized == false) ) // after SY_LFR_TIME_SYN_TIMEOUT ms, starts HK anyway | |
277 | { |
|
277 | { | |
278 | if ((time_management_regs->coarse_time & VAL_LFR_SYNCHRONIZED) == INT32_ALL_0) // check time synchronization |
|
278 | if ((time_management_regs->coarse_time & VAL_LFR_SYNCHRONIZED) == INT32_ALL_0) // check time synchronization | |
279 | { |
|
279 | { | |
280 | isSynchronized = true; |
|
280 | isSynchronized = true; | |
281 | } |
|
281 | } | |
282 | else |
|
282 | else | |
283 | { |
|
283 | { | |
284 | status = rtems_rate_monotonic_get_status( HK_id, &period_status ); |
|
284 | status = rtems_rate_monotonic_get_status( HK_id, &period_status ); | |
285 |
|
285 | |||
286 | status = rtems_task_wake_after( HK_SYNC_WAIT ); // wait HK_SYNCH_WAIT 100 ms = 10 * 10 ms |
|
286 | status = rtems_task_wake_after( HK_SYNC_WAIT ); // wait HK_SYNCH_WAIT 100 ms = 10 * 10 ms | |
287 | } |
|
287 | } | |
288 | } |
|
288 | } | |
289 | status = rtems_rate_monotonic_cancel(HK_id); |
|
289 | status = rtems_rate_monotonic_cancel(HK_id); | |
290 | DEBUG_PRINTF1("startup HK, HK_id status = %d\n", period_status.state) |
|
290 | DEBUG_PRINTF1("startup HK, HK_id status = %d\n", period_status.state) | |
291 |
|
291 | |||
292 | set_hk_lfr_reset_cause( POWER_ON ); |
|
292 | set_hk_lfr_reset_cause( POWER_ON ); | |
293 |
|
293 | |||
294 | while(1){ // launch the rate monotonic task |
|
294 | while(1){ // launch the rate monotonic task | |
295 | status = rtems_rate_monotonic_period( HK_id, HK_PERIOD ); |
|
295 | status = rtems_rate_monotonic_period( HK_id, HK_PERIOD ); | |
296 | if ( status != RTEMS_SUCCESSFUL ) { |
|
296 | if ( status != RTEMS_SUCCESSFUL ) { | |
297 | PRINTF1( "in HOUS *** ERR period: %d\n", status); |
|
297 | PRINTF1( "in HOUS *** ERR period: %d\n", status); | |
298 | spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_6 ); |
|
298 | spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_6 ); | |
299 | } |
|
299 | } | |
300 | else { |
|
300 | else { | |
301 | housekeeping_packet.packetSequenceControl[BYTE_0] = (unsigned char) (sequenceCounterHK >> SHIFT_1_BYTE); |
|
301 | housekeeping_packet.packetSequenceControl[BYTE_0] = (unsigned char) (sequenceCounterHK >> SHIFT_1_BYTE); | |
302 | housekeeping_packet.packetSequenceControl[BYTE_1] = (unsigned char) (sequenceCounterHK ); |
|
302 | housekeeping_packet.packetSequenceControl[BYTE_1] = (unsigned char) (sequenceCounterHK ); | |
303 | increment_seq_counter( &sequenceCounterHK ); |
|
303 | increment_seq_counter( &sequenceCounterHK ); | |
304 |
|
304 | |||
305 | housekeeping_packet.time[BYTE_0] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_3_BYTES); |
|
305 | housekeeping_packet.time[BYTE_0] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_3_BYTES); | |
306 | housekeeping_packet.time[BYTE_1] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_2_BYTES); |
|
306 | housekeeping_packet.time[BYTE_1] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_2_BYTES); | |
307 | housekeeping_packet.time[BYTE_2] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_1_BYTE); |
|
307 | housekeeping_packet.time[BYTE_2] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_1_BYTE); | |
308 | housekeeping_packet.time[BYTE_3] = (unsigned char) (time_management_regs->coarse_time); |
|
308 | housekeeping_packet.time[BYTE_3] = (unsigned char) (time_management_regs->coarse_time); | |
309 | housekeeping_packet.time[BYTE_4] = (unsigned char) (time_management_regs->fine_time >> SHIFT_1_BYTE); |
|
309 | housekeeping_packet.time[BYTE_4] = (unsigned char) (time_management_regs->fine_time >> SHIFT_1_BYTE); | |
310 | housekeeping_packet.time[BYTE_5] = (unsigned char) (time_management_regs->fine_time); |
|
310 | housekeeping_packet.time[BYTE_5] = (unsigned char) (time_management_regs->fine_time); | |
311 |
|
311 | |||
312 | spacewire_update_hk_lfr_link_state( &housekeeping_packet.lfr_status_word[0] ); |
|
312 | spacewire_update_hk_lfr_link_state( &housekeeping_packet.lfr_status_word[0] ); | |
313 |
|
313 | |||
314 | spacewire_read_statistics(); |
|
314 | spacewire_read_statistics(); | |
315 |
|
315 | |||
316 | update_hk_with_grspw_stats(); |
|
316 | update_hk_with_grspw_stats(); | |
317 |
|
317 | |||
318 | set_hk_lfr_time_not_synchro(); |
|
318 | set_hk_lfr_time_not_synchro(); | |
319 |
|
319 | |||
320 | housekeeping_packet.hk_lfr_q_sd_fifo_size_max = hk_lfr_q_sd_fifo_size_max; |
|
320 | housekeeping_packet.hk_lfr_q_sd_fifo_size_max = hk_lfr_q_sd_fifo_size_max; | |
321 | housekeeping_packet.hk_lfr_q_rv_fifo_size_max = hk_lfr_q_rv_fifo_size_max; |
|
321 | housekeeping_packet.hk_lfr_q_rv_fifo_size_max = hk_lfr_q_rv_fifo_size_max; | |
322 | housekeeping_packet.hk_lfr_q_p0_fifo_size_max = hk_lfr_q_p0_fifo_size_max; |
|
322 | housekeeping_packet.hk_lfr_q_p0_fifo_size_max = hk_lfr_q_p0_fifo_size_max; | |
323 | housekeeping_packet.hk_lfr_q_p1_fifo_size_max = hk_lfr_q_p1_fifo_size_max; |
|
323 | housekeeping_packet.hk_lfr_q_p1_fifo_size_max = hk_lfr_q_p1_fifo_size_max; | |
324 | housekeeping_packet.hk_lfr_q_p2_fifo_size_max = hk_lfr_q_p2_fifo_size_max; |
|
324 | housekeeping_packet.hk_lfr_q_p2_fifo_size_max = hk_lfr_q_p2_fifo_size_max; | |
325 |
|
325 | |||
326 | housekeeping_packet.sy_lfr_common_parameters_spare = parameter_dump_packet.sy_lfr_common_parameters_spare; |
|
326 | housekeeping_packet.sy_lfr_common_parameters_spare = parameter_dump_packet.sy_lfr_common_parameters_spare; | |
327 | housekeeping_packet.sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters; |
|
327 | housekeeping_packet.sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters; | |
328 | get_temperatures( housekeeping_packet.hk_lfr_temp_scm ); |
|
328 | get_temperatures( housekeeping_packet.hk_lfr_temp_scm ); | |
329 | get_v_e1_e2_f3( housekeeping_packet.hk_lfr_sc_v_f3 ); |
|
329 | get_v_e1_e2_f3( housekeeping_packet.hk_lfr_sc_v_f3 ); | |
330 | get_cpu_load( (unsigned char *) &housekeeping_packet.hk_lfr_cpu_load ); |
|
330 | get_cpu_load( (unsigned char *) &housekeeping_packet.hk_lfr_cpu_load ); | |
331 |
|
331 | |||
332 | hk_lfr_le_me_he_update(); |
|
332 | hk_lfr_le_me_he_update(); | |
333 |
|
333 | |||
334 | housekeeping_packet.hk_lfr_sc_rw1_rw2_f_flags = cp_rpw_sc_rw1_rw2_f_flags; |
|
334 | housekeeping_packet.hk_lfr_sc_rw1_rw2_f_flags = cp_rpw_sc_rw1_rw2_f_flags; | |
335 | housekeeping_packet.hk_lfr_sc_rw3_rw4_f_flags = cp_rpw_sc_rw3_rw4_f_flags; |
|
335 | housekeeping_packet.hk_lfr_sc_rw3_rw4_f_flags = cp_rpw_sc_rw3_rw4_f_flags; | |
336 |
|
336 | |||
337 | // SEND PACKET |
|
337 | // SEND PACKET | |
338 | status = rtems_message_queue_send( queue_id, &housekeeping_packet, |
|
338 | status = rtems_message_queue_send( queue_id, &housekeeping_packet, | |
339 | PACKET_LENGTH_HK + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES); |
|
339 | PACKET_LENGTH_HK + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES); | |
340 | if (status != RTEMS_SUCCESSFUL) { |
|
340 | if (status != RTEMS_SUCCESSFUL) { | |
341 | PRINTF1("in HOUS *** ERR send: %d\n", status) |
|
341 | PRINTF1("in HOUS *** ERR send: %d\n", status) | |
342 | } |
|
342 | } | |
343 | } |
|
343 | } | |
344 | } |
|
344 | } | |
345 |
|
345 | |||
346 | PRINTF("in HOUS *** deleting task\n") |
|
346 | PRINTF("in HOUS *** deleting task\n") | |
347 |
|
347 | |||
348 | status = rtems_task_delete( RTEMS_SELF ); // should not return |
|
348 | status = rtems_task_delete( RTEMS_SELF ); // should not return | |
349 |
|
349 | |||
350 | return; |
|
350 | return; | |
351 | } |
|
351 | } | |
352 |
|
352 | |||
353 | rtems_task avgv_task(rtems_task_argument argument) |
|
353 | rtems_task avgv_task(rtems_task_argument argument) | |
354 | { |
|
354 | { | |
355 | #define MOVING_AVERAGE 16 |
|
355 | #define MOVING_AVERAGE 16 | |
356 | rtems_status_code status; |
|
356 | rtems_status_code status; | |
357 | static unsigned int v[MOVING_AVERAGE] = {0}; |
|
357 | static unsigned int v[MOVING_AVERAGE] = {0}; | |
358 | static unsigned int e1[MOVING_AVERAGE] = {0}; |
|
358 | static unsigned int e1[MOVING_AVERAGE] = {0}; | |
359 | static unsigned int e2[MOVING_AVERAGE] = {0}; |
|
359 | static unsigned int e2[MOVING_AVERAGE] = {0}; | |
360 | float average_v; |
|
360 | float average_v; | |
361 | float average_e1; |
|
361 | float average_e1; | |
362 | float average_e2; |
|
362 | float average_e2; | |
363 | float newValue_v; |
|
363 | float newValue_v; | |
364 | float newValue_e1; |
|
364 | float newValue_e1; | |
365 | float newValue_e2; |
|
365 | float newValue_e2; | |
366 | unsigned char k; |
|
366 | unsigned char k; | |
367 | unsigned char indexOfOldValue; |
|
367 | unsigned char indexOfOldValue; | |
368 |
|
368 | |||
369 | BOOT_PRINTF("in AVGV ***\n"); |
|
369 | BOOT_PRINTF("in AVGV ***\n"); | |
370 |
|
370 | |||
371 | if (rtems_rate_monotonic_ident( name_avgv_rate_monotonic, &HK_id) != RTEMS_SUCCESSFUL) { |
|
371 | if (rtems_rate_monotonic_ident( name_avgv_rate_monotonic, &HK_id) != RTEMS_SUCCESSFUL) { | |
372 | status = rtems_rate_monotonic_create( name_avgv_rate_monotonic, &AVGV_id ); |
|
372 | status = rtems_rate_monotonic_create( name_avgv_rate_monotonic, &AVGV_id ); | |
373 | if( status != RTEMS_SUCCESSFUL ) { |
|
373 | if( status != RTEMS_SUCCESSFUL ) { | |
374 | PRINTF1( "rtems_rate_monotonic_create failed with status of %d\n", status ); |
|
374 | PRINTF1( "rtems_rate_monotonic_create failed with status of %d\n", status ); | |
375 | } |
|
375 | } | |
376 | } |
|
376 | } | |
377 |
|
377 | |||
378 | status = rtems_rate_monotonic_cancel(AVGV_id); |
|
378 | status = rtems_rate_monotonic_cancel(AVGV_id); | |
379 | if( status != RTEMS_SUCCESSFUL ) { |
|
379 | if( status != RTEMS_SUCCESSFUL ) { | |
380 | PRINTF1( "ERR *** in AVGV *** rtems_rate_monotonic_cancel(AVGV_id) ***code: %d\n", status ); |
|
380 | PRINTF1( "ERR *** in AVGV *** rtems_rate_monotonic_cancel(AVGV_id) ***code: %d\n", status ); | |
381 | } |
|
381 | } | |
382 | else { |
|
382 | else { | |
383 | DEBUG_PRINTF("OK *** in AVGV *** rtems_rate_monotonic_cancel(AVGV_id)\n"); |
|
383 | DEBUG_PRINTF("OK *** in AVGV *** rtems_rate_monotonic_cancel(AVGV_id)\n"); | |
384 | } |
|
384 | } | |
385 |
|
385 | |||
386 | // initialize values |
|
386 | // initialize values | |
387 | indexOfOldValue = MOVING_AVERAGE - 1; |
|
387 | indexOfOldValue = MOVING_AVERAGE - 1; | |
388 | average_v = INIT_FLOAT; |
|
388 | average_v = INIT_FLOAT; | |
389 | average_e1 = INIT_FLOAT; |
|
389 | average_e1 = INIT_FLOAT; | |
390 | average_e2 = INIT_FLOAT; |
|
390 | average_e2 = INIT_FLOAT; | |
391 | newValue_v = INIT_FLOAT; |
|
391 | newValue_v = INIT_FLOAT; | |
392 | newValue_e1 = INIT_FLOAT; |
|
392 | newValue_e1 = INIT_FLOAT; | |
393 | newValue_e2 = INIT_FLOAT; |
|
393 | newValue_e2 = INIT_FLOAT; | |
394 |
|
394 | |||
395 | k = INIT_CHAR; |
|
395 | k = INIT_CHAR; | |
396 |
|
396 | |||
397 | while(1) |
|
397 | while(1) | |
398 | { // launch the rate monotonic task |
|
398 | { // launch the rate monotonic task | |
399 | status = rtems_rate_monotonic_period( AVGV_id, AVGV_PERIOD ); |
|
399 | status = rtems_rate_monotonic_period( AVGV_id, AVGV_PERIOD ); | |
400 | if ( status != RTEMS_SUCCESSFUL ) |
|
400 | if ( status != RTEMS_SUCCESSFUL ) | |
401 | { |
|
401 | { | |
402 | PRINTF1( "in AVGV *** ERR period: %d\n", status); |
|
402 | PRINTF1( "in AVGV *** ERR period: %d\n", status); | |
403 | } |
|
403 | } | |
404 | else |
|
404 | else | |
405 | { |
|
405 | { | |
406 | // get new values |
|
406 | // get new values | |
407 | newValue_v = waveform_picker_regs->v; |
|
407 | newValue_v = waveform_picker_regs->v; | |
408 | newValue_e1 = waveform_picker_regs->e1; |
|
408 | newValue_e1 = waveform_picker_regs->e1; | |
409 | newValue_e2 = waveform_picker_regs->e2; |
|
409 | newValue_e2 = waveform_picker_regs->e2; | |
410 |
|
410 | |||
411 | // compute the moving average |
|
411 | // compute the moving average | |
412 | average_v = average_v + newValue_v - v[k]; |
|
412 | average_v = average_v + newValue_v - v[k]; | |
413 | average_e1 = average_e1 + newValue_e1 - e1[k]; |
|
413 | average_e1 = average_e1 + newValue_e1 - e1[k]; | |
414 | average_e2 = average_e2 + newValue_e2 - e2[k]; |
|
414 | average_e2 = average_e2 + newValue_e2 - e2[k]; | |
415 |
|
415 | |||
416 | // store new values in buffers |
|
416 | // store new values in buffers | |
417 | v[k] = newValue_v; |
|
417 | v[k] = newValue_v; | |
418 | e1[k] = newValue_e1; |
|
418 | e1[k] = newValue_e1; | |
419 | e2[k] = newValue_e2; |
|
419 | e2[k] = newValue_e2; | |
420 | } |
|
420 | } | |
421 | if (k == (MOVING_AVERAGE-1)) |
|
421 | if (k == (MOVING_AVERAGE-1)) | |
422 | { |
|
422 | { | |
423 | k = 0; |
|
423 | k = 0; | |
424 | PRINTF("tick\n"); |
|
424 | PRINTF("tick\n"); | |
425 | } |
|
425 | } | |
426 | else |
|
426 | else | |
427 | { |
|
427 | { | |
428 | k++; |
|
428 | k++; | |
429 | } |
|
429 | } | |
430 | //update int16 values |
|
430 | //update int16 values | |
431 | hk_lfr_sc_v_f3_as_int16 = (int16_t) (average_v / ((float) MOVING_AVERAGE) ); |
|
431 | hk_lfr_sc_v_f3_as_int16 = (int16_t) (average_v / ((float) MOVING_AVERAGE) ); | |
432 | hk_lfr_sc_e1_f3_as_int16 = (int16_t) (average_e1 / ((float) MOVING_AVERAGE) ); |
|
432 | hk_lfr_sc_e1_f3_as_int16 = (int16_t) (average_e1 / ((float) MOVING_AVERAGE) ); | |
433 | hk_lfr_sc_e2_f3_as_int16 = (int16_t) (average_e2 / ((float) MOVING_AVERAGE) ); |
|
433 | hk_lfr_sc_e2_f3_as_int16 = (int16_t) (average_e2 / ((float) MOVING_AVERAGE) ); | |
434 | } |
|
434 | } | |
435 |
|
435 | |||
436 | PRINTF("in AVGV *** deleting task\n"); |
|
436 | PRINTF("in AVGV *** deleting task\n"); | |
437 |
|
437 | |||
438 | status = rtems_task_delete( RTEMS_SELF ); // should not return |
|
438 | status = rtems_task_delete( RTEMS_SELF ); // should not return | |
439 |
|
439 | |||
440 | return; |
|
440 | return; | |
441 | } |
|
441 | } | |
442 |
|
442 | |||
443 | rtems_task dumb_task( rtems_task_argument unused ) |
|
443 | rtems_task dumb_task( rtems_task_argument unused ) | |
444 | { |
|
444 | { | |
445 | /** This RTEMS taks is used to print messages without affecting the general behaviour of the software. |
|
445 | /** This RTEMS taks is used to print messages without affecting the general behaviour of the software. | |
446 | * |
|
446 | * | |
447 | * @param unused is the starting argument of the RTEMS task |
|
447 | * @param unused is the starting argument of the RTEMS task | |
448 | * |
|
448 | * | |
449 | * The DUMB taks waits for RTEMS events and print messages depending on the incoming events. |
|
449 | * The DUMB taks waits for RTEMS events and print messages depending on the incoming events. | |
450 | * |
|
450 | * | |
451 | */ |
|
451 | */ | |
452 |
|
452 | |||
453 | unsigned int i; |
|
453 | unsigned int i; | |
454 | unsigned int intEventOut; |
|
454 | unsigned int intEventOut; | |
455 | unsigned int coarse_time = 0; |
|
455 | unsigned int coarse_time = 0; | |
456 | unsigned int fine_time = 0; |
|
456 | unsigned int fine_time = 0; | |
457 | rtems_event_set event_out; |
|
457 | rtems_event_set event_out; | |
458 |
|
458 | |||
459 | event_out = EVENT_SETS_NONE_PENDING; |
|
459 | event_out = EVENT_SETS_NONE_PENDING; | |
460 |
|
460 | |||
461 | BOOT_PRINTF("in DUMB *** \n") |
|
461 | BOOT_PRINTF("in DUMB *** \n") | |
462 |
|
462 | |||
463 | while(1){ |
|
463 | while(1){ | |
464 | rtems_event_receive(RTEMS_EVENT_0 | RTEMS_EVENT_1 | RTEMS_EVENT_2 | RTEMS_EVENT_3 |
|
464 | rtems_event_receive(RTEMS_EVENT_0 | RTEMS_EVENT_1 | RTEMS_EVENT_2 | RTEMS_EVENT_3 | |
465 | | RTEMS_EVENT_4 | RTEMS_EVENT_5 | RTEMS_EVENT_6 | RTEMS_EVENT_7 |
|
465 | | RTEMS_EVENT_4 | RTEMS_EVENT_5 | RTEMS_EVENT_6 | RTEMS_EVENT_7 | |
466 | | RTEMS_EVENT_8 | RTEMS_EVENT_9 | RTEMS_EVENT_12 | RTEMS_EVENT_13 |
|
466 | | RTEMS_EVENT_8 | RTEMS_EVENT_9 | RTEMS_EVENT_12 | RTEMS_EVENT_13 | |
467 | | RTEMS_EVENT_14, |
|
467 | | RTEMS_EVENT_14, | |
468 | RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT |
|
468 | RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT | |
469 | intEventOut = (unsigned int) event_out; |
|
469 | intEventOut = (unsigned int) event_out; | |
470 | for ( i=0; i<NB_RTEMS_EVENTS; i++) |
|
470 | for ( i=0; i<NB_RTEMS_EVENTS; i++) | |
471 | { |
|
471 | { | |
472 | if ( ((intEventOut >> i) & 1) != 0) |
|
472 | if ( ((intEventOut >> i) & 1) != 0) | |
473 | { |
|
473 | { | |
474 | coarse_time = time_management_regs->coarse_time; |
|
474 | coarse_time = time_management_regs->coarse_time; | |
475 | fine_time = time_management_regs->fine_time; |
|
475 | fine_time = time_management_regs->fine_time; | |
476 | if (i==EVENT_12) |
|
476 | if (i==EVENT_12) | |
477 | { |
|
477 | { | |
478 | PRINTF1("%s\n", DUMB_MESSAGE_12) |
|
478 | PRINTF1("%s\n", DUMB_MESSAGE_12) | |
479 | } |
|
479 | } | |
480 | if (i==EVENT_13) |
|
480 | if (i==EVENT_13) | |
481 | { |
|
481 | { | |
482 | PRINTF1("%s\n", DUMB_MESSAGE_13) |
|
482 | PRINTF1("%s\n", DUMB_MESSAGE_13) | |
483 | } |
|
483 | } | |
484 | if (i==EVENT_14) |
|
484 | if (i==EVENT_14) | |
485 | { |
|
485 | { | |
486 | PRINTF1("%s\n", DUMB_MESSAGE_1) |
|
486 | PRINTF1("%s\n", DUMB_MESSAGE_1) | |
487 | } |
|
487 | } | |
488 | } |
|
488 | } | |
489 | } |
|
489 | } | |
490 | } |
|
490 | } | |
491 | } |
|
491 | } | |
492 |
|
492 | |||
493 | //***************************** |
|
493 | //***************************** | |
494 | // init housekeeping parameters |
|
494 | // init housekeeping parameters | |
495 |
|
495 | |||
496 | void init_housekeeping_parameters( void ) |
|
496 | void init_housekeeping_parameters( void ) | |
497 | { |
|
497 | { | |
498 | /** This function initialize the housekeeping_packet global variable with default values. |
|
498 | /** This function initialize the housekeeping_packet global variable with default values. | |
499 | * |
|
499 | * | |
500 | */ |
|
500 | */ | |
501 |
|
501 | |||
502 | unsigned int i = 0; |
|
502 | unsigned int i = 0; | |
503 | unsigned char *parameters; |
|
503 | unsigned char *parameters; | |
504 | unsigned char sizeOfHK; |
|
504 | unsigned char sizeOfHK; | |
505 |
|
505 | |||
506 | sizeOfHK = sizeof( Packet_TM_LFR_HK_t ); |
|
506 | sizeOfHK = sizeof( Packet_TM_LFR_HK_t ); | |
507 |
|
507 | |||
508 | parameters = (unsigned char*) &housekeeping_packet; |
|
508 | parameters = (unsigned char*) &housekeeping_packet; | |
509 |
|
509 | |||
510 | for(i = 0; i< sizeOfHK; i++) |
|
510 | for(i = 0; i< sizeOfHK; i++) | |
511 | { |
|
511 | { | |
512 | parameters[i] = INIT_CHAR; |
|
512 | parameters[i] = INIT_CHAR; | |
513 | } |
|
513 | } | |
514 |
|
514 | |||
515 | housekeeping_packet.targetLogicalAddress = CCSDS_DESTINATION_ID; |
|
515 | housekeeping_packet.targetLogicalAddress = CCSDS_DESTINATION_ID; | |
516 | housekeeping_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID; |
|
516 | housekeeping_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID; | |
517 | housekeeping_packet.reserved = DEFAULT_RESERVED; |
|
517 | housekeeping_packet.reserved = DEFAULT_RESERVED; | |
518 | housekeeping_packet.userApplication = CCSDS_USER_APP; |
|
518 | housekeeping_packet.userApplication = CCSDS_USER_APP; | |
519 | housekeeping_packet.packetID[0] = (unsigned char) (APID_TM_HK >> SHIFT_1_BYTE); |
|
519 | housekeeping_packet.packetID[0] = (unsigned char) (APID_TM_HK >> SHIFT_1_BYTE); | |
520 | housekeeping_packet.packetID[1] = (unsigned char) (APID_TM_HK); |
|
520 | housekeeping_packet.packetID[1] = (unsigned char) (APID_TM_HK); | |
521 | housekeeping_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; |
|
521 | housekeeping_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; | |
522 | housekeeping_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT; |
|
522 | housekeeping_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT; | |
523 | housekeeping_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_HK >> SHIFT_1_BYTE); |
|
523 | housekeeping_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_HK >> SHIFT_1_BYTE); | |
524 | housekeeping_packet.packetLength[1] = (unsigned char) (PACKET_LENGTH_HK ); |
|
524 | housekeeping_packet.packetLength[1] = (unsigned char) (PACKET_LENGTH_HK ); | |
525 | housekeeping_packet.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2; |
|
525 | housekeeping_packet.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2; | |
526 | housekeeping_packet.serviceType = TM_TYPE_HK; |
|
526 | housekeeping_packet.serviceType = TM_TYPE_HK; | |
527 | housekeeping_packet.serviceSubType = TM_SUBTYPE_HK; |
|
527 | housekeeping_packet.serviceSubType = TM_SUBTYPE_HK; | |
528 | housekeeping_packet.destinationID = TM_DESTINATION_ID_GROUND; |
|
528 | housekeeping_packet.destinationID = TM_DESTINATION_ID_GROUND; | |
529 | housekeeping_packet.sid = SID_HK; |
|
529 | housekeeping_packet.sid = SID_HK; | |
530 |
|
530 | |||
531 | // init status word |
|
531 | // init status word | |
532 | housekeeping_packet.lfr_status_word[0] = DEFAULT_STATUS_WORD_BYTE0; |
|
532 | housekeeping_packet.lfr_status_word[0] = DEFAULT_STATUS_WORD_BYTE0; | |
533 | housekeeping_packet.lfr_status_word[1] = DEFAULT_STATUS_WORD_BYTE1; |
|
533 | housekeeping_packet.lfr_status_word[1] = DEFAULT_STATUS_WORD_BYTE1; | |
534 | // init software version |
|
534 | // init software version | |
535 | housekeeping_packet.lfr_sw_version[0] = SW_VERSION_N1; |
|
535 | housekeeping_packet.lfr_sw_version[0] = SW_VERSION_N1; | |
536 | housekeeping_packet.lfr_sw_version[1] = SW_VERSION_N2; |
|
536 | housekeeping_packet.lfr_sw_version[1] = SW_VERSION_N2; | |
537 | housekeeping_packet.lfr_sw_version[BYTE_2] = SW_VERSION_N3; |
|
537 | housekeeping_packet.lfr_sw_version[BYTE_2] = SW_VERSION_N3; | |
538 | housekeeping_packet.lfr_sw_version[BYTE_3] = SW_VERSION_N4; |
|
538 | housekeeping_packet.lfr_sw_version[BYTE_3] = SW_VERSION_N4; | |
539 | // init fpga version |
|
539 | // init fpga version | |
540 | parameters = (unsigned char *) (REGS_ADDR_VHDL_VERSION); |
|
540 | parameters = (unsigned char *) (REGS_ADDR_VHDL_VERSION); | |
541 | housekeeping_packet.lfr_fpga_version[BYTE_0] = parameters[BYTE_1]; // n1 |
|
541 | housekeeping_packet.lfr_fpga_version[BYTE_0] = parameters[BYTE_1]; // n1 | |
542 | housekeeping_packet.lfr_fpga_version[BYTE_1] = parameters[BYTE_2]; // n2 |
|
542 | housekeeping_packet.lfr_fpga_version[BYTE_1] = parameters[BYTE_2]; // n2 | |
543 | housekeeping_packet.lfr_fpga_version[BYTE_2] = parameters[BYTE_3]; // n3 |
|
543 | housekeeping_packet.lfr_fpga_version[BYTE_2] = parameters[BYTE_3]; // n3 | |
544 |
|
544 | |||
545 | housekeeping_packet.hk_lfr_q_sd_fifo_size = MSG_QUEUE_COUNT_SEND; |
|
545 | housekeeping_packet.hk_lfr_q_sd_fifo_size = MSG_QUEUE_COUNT_SEND; | |
546 | housekeeping_packet.hk_lfr_q_rv_fifo_size = MSG_QUEUE_COUNT_RECV; |
|
546 | housekeeping_packet.hk_lfr_q_rv_fifo_size = MSG_QUEUE_COUNT_RECV; | |
547 | housekeeping_packet.hk_lfr_q_p0_fifo_size = MSG_QUEUE_COUNT_PRC0; |
|
547 | housekeeping_packet.hk_lfr_q_p0_fifo_size = MSG_QUEUE_COUNT_PRC0; | |
548 | housekeeping_packet.hk_lfr_q_p1_fifo_size = MSG_QUEUE_COUNT_PRC1; |
|
548 | housekeeping_packet.hk_lfr_q_p1_fifo_size = MSG_QUEUE_COUNT_PRC1; | |
549 | housekeeping_packet.hk_lfr_q_p2_fifo_size = MSG_QUEUE_COUNT_PRC2; |
|
549 | housekeeping_packet.hk_lfr_q_p2_fifo_size = MSG_QUEUE_COUNT_PRC2; | |
550 | } |
|
550 | } | |
551 |
|
551 | |||
552 | void increment_seq_counter( unsigned short *packetSequenceControl ) |
|
552 | void increment_seq_counter( unsigned short *packetSequenceControl ) | |
553 | { |
|
553 | { | |
554 | /** This function increment the sequence counter passes in argument. |
|
554 | /** This function increment the sequence counter passes in argument. | |
555 | * |
|
555 | * | |
556 | * The increment does not affect the grouping flag. In case of an overflow, the counter is reset to 0. |
|
556 | * The increment does not affect the grouping flag. In case of an overflow, the counter is reset to 0. | |
557 | * |
|
557 | * | |
558 | */ |
|
558 | */ | |
559 |
|
559 | |||
560 | unsigned short segmentation_grouping_flag; |
|
560 | unsigned short segmentation_grouping_flag; | |
561 | unsigned short sequence_cnt; |
|
561 | unsigned short sequence_cnt; | |
562 |
|
562 | |||
563 | segmentation_grouping_flag = TM_PACKET_SEQ_CTRL_STANDALONE << SHIFT_1_BYTE; // keep bits 7 downto 6 |
|
563 | segmentation_grouping_flag = TM_PACKET_SEQ_CTRL_STANDALONE << SHIFT_1_BYTE; // keep bits 7 downto 6 | |
564 | sequence_cnt = (*packetSequenceControl) & SEQ_CNT_MASK; // [0011 1111 1111 1111] |
|
564 | sequence_cnt = (*packetSequenceControl) & SEQ_CNT_MASK; // [0011 1111 1111 1111] | |
565 |
|
565 | |||
566 | if ( sequence_cnt < SEQ_CNT_MAX) |
|
566 | if ( sequence_cnt < SEQ_CNT_MAX) | |
567 | { |
|
567 | { | |
568 | sequence_cnt = sequence_cnt + 1; |
|
568 | sequence_cnt = sequence_cnt + 1; | |
569 | } |
|
569 | } | |
570 | else |
|
570 | else | |
571 | { |
|
571 | { | |
572 | sequence_cnt = 0; |
|
572 | sequence_cnt = 0; | |
573 | } |
|
573 | } | |
574 |
|
574 | |||
575 | *packetSequenceControl = segmentation_grouping_flag | sequence_cnt ; |
|
575 | *packetSequenceControl = segmentation_grouping_flag | sequence_cnt ; | |
576 | } |
|
576 | } | |
577 |
|
577 | |||
578 | void getTime( unsigned char *time) |
|
578 | void getTime( unsigned char *time) | |
579 | { |
|
579 | { | |
580 | /** This function write the current local time in the time buffer passed in argument. |
|
580 | /** This function write the current local time in the time buffer passed in argument. | |
581 | * |
|
581 | * | |
582 | */ |
|
582 | */ | |
583 |
|
583 | |||
584 | time[0] = (unsigned char) (time_management_regs->coarse_time>>SHIFT_3_BYTES); |
|
584 | time[0] = (unsigned char) (time_management_regs->coarse_time>>SHIFT_3_BYTES); | |
585 | time[1] = (unsigned char) (time_management_regs->coarse_time>>SHIFT_2_BYTES); |
|
585 | time[1] = (unsigned char) (time_management_regs->coarse_time>>SHIFT_2_BYTES); | |
586 | time[2] = (unsigned char) (time_management_regs->coarse_time>>SHIFT_1_BYTE); |
|
586 | time[2] = (unsigned char) (time_management_regs->coarse_time>>SHIFT_1_BYTE); | |
587 | time[3] = (unsigned char) (time_management_regs->coarse_time); |
|
587 | time[3] = (unsigned char) (time_management_regs->coarse_time); | |
588 | time[4] = (unsigned char) (time_management_regs->fine_time>>SHIFT_1_BYTE); |
|
588 | time[4] = (unsigned char) (time_management_regs->fine_time>>SHIFT_1_BYTE); | |
589 | time[5] = (unsigned char) (time_management_regs->fine_time); |
|
589 | time[5] = (unsigned char) (time_management_regs->fine_time); | |
590 | } |
|
590 | } | |
591 |
|
591 | |||
592 | unsigned long long int getTimeAsUnsignedLongLongInt( ) |
|
592 | unsigned long long int getTimeAsUnsignedLongLongInt( ) | |
593 | { |
|
593 | { | |
594 | /** This function write the current local time in the time buffer passed in argument. |
|
594 | /** This function write the current local time in the time buffer passed in argument. | |
595 | * |
|
595 | * | |
596 | */ |
|
596 | */ | |
597 | unsigned long long int time; |
|
597 | unsigned long long int time; | |
598 |
|
598 | |||
599 | time = ( (unsigned long long int) (time_management_regs->coarse_time & COARSE_TIME_MASK) << SHIFT_2_BYTES ) |
|
599 | time = ( (unsigned long long int) (time_management_regs->coarse_time & COARSE_TIME_MASK) << SHIFT_2_BYTES ) | |
600 | + time_management_regs->fine_time; |
|
600 | + time_management_regs->fine_time; | |
601 |
|
601 | |||
602 | return time; |
|
602 | return time; | |
603 | } |
|
603 | } | |
604 |
|
604 | |||
605 | void send_dumb_hk( void ) |
|
605 | void send_dumb_hk( void ) | |
606 | { |
|
606 | { | |
607 | Packet_TM_LFR_HK_t dummy_hk_packet; |
|
607 | Packet_TM_LFR_HK_t dummy_hk_packet; | |
608 | unsigned char *parameters; |
|
608 | unsigned char *parameters; | |
609 | unsigned int i; |
|
609 | unsigned int i; | |
610 | rtems_id queue_id; |
|
610 | rtems_id queue_id; | |
611 |
|
611 | |||
612 | queue_id = RTEMS_ID_NONE; |
|
612 | queue_id = RTEMS_ID_NONE; | |
613 |
|
613 | |||
614 | dummy_hk_packet.targetLogicalAddress = CCSDS_DESTINATION_ID; |
|
614 | dummy_hk_packet.targetLogicalAddress = CCSDS_DESTINATION_ID; | |
615 | dummy_hk_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID; |
|
615 | dummy_hk_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID; | |
616 | dummy_hk_packet.reserved = DEFAULT_RESERVED; |
|
616 | dummy_hk_packet.reserved = DEFAULT_RESERVED; | |
617 | dummy_hk_packet.userApplication = CCSDS_USER_APP; |
|
617 | dummy_hk_packet.userApplication = CCSDS_USER_APP; | |
618 | dummy_hk_packet.packetID[0] = (unsigned char) (APID_TM_HK >> SHIFT_1_BYTE); |
|
618 | dummy_hk_packet.packetID[0] = (unsigned char) (APID_TM_HK >> SHIFT_1_BYTE); | |
619 | dummy_hk_packet.packetID[1] = (unsigned char) (APID_TM_HK); |
|
619 | dummy_hk_packet.packetID[1] = (unsigned char) (APID_TM_HK); | |
620 | dummy_hk_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; |
|
620 | dummy_hk_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; | |
621 | dummy_hk_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT; |
|
621 | dummy_hk_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT; | |
622 | dummy_hk_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_HK >> SHIFT_1_BYTE); |
|
622 | dummy_hk_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_HK >> SHIFT_1_BYTE); | |
623 | dummy_hk_packet.packetLength[1] = (unsigned char) (PACKET_LENGTH_HK ); |
|
623 | dummy_hk_packet.packetLength[1] = (unsigned char) (PACKET_LENGTH_HK ); | |
624 | dummy_hk_packet.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2; |
|
624 | dummy_hk_packet.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2; | |
625 | dummy_hk_packet.serviceType = TM_TYPE_HK; |
|
625 | dummy_hk_packet.serviceType = TM_TYPE_HK; | |
626 | dummy_hk_packet.serviceSubType = TM_SUBTYPE_HK; |
|
626 | dummy_hk_packet.serviceSubType = TM_SUBTYPE_HK; | |
627 | dummy_hk_packet.destinationID = TM_DESTINATION_ID_GROUND; |
|
627 | dummy_hk_packet.destinationID = TM_DESTINATION_ID_GROUND; | |
628 | dummy_hk_packet.time[0] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_3_BYTES); |
|
628 | dummy_hk_packet.time[0] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_3_BYTES); | |
629 | dummy_hk_packet.time[1] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_2_BYTES); |
|
629 | dummy_hk_packet.time[1] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_2_BYTES); | |
630 | dummy_hk_packet.time[BYTE_2] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_1_BYTE); |
|
630 | dummy_hk_packet.time[BYTE_2] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_1_BYTE); | |
631 | dummy_hk_packet.time[BYTE_3] = (unsigned char) (time_management_regs->coarse_time); |
|
631 | dummy_hk_packet.time[BYTE_3] = (unsigned char) (time_management_regs->coarse_time); | |
632 | dummy_hk_packet.time[BYTE_4] = (unsigned char) (time_management_regs->fine_time >> SHIFT_1_BYTE); |
|
632 | dummy_hk_packet.time[BYTE_4] = (unsigned char) (time_management_regs->fine_time >> SHIFT_1_BYTE); | |
633 | dummy_hk_packet.time[BYTE_5] = (unsigned char) (time_management_regs->fine_time); |
|
633 | dummy_hk_packet.time[BYTE_5] = (unsigned char) (time_management_regs->fine_time); | |
634 | dummy_hk_packet.sid = SID_HK; |
|
634 | dummy_hk_packet.sid = SID_HK; | |
635 |
|
635 | |||
636 | // init status word |
|
636 | // init status word | |
637 | dummy_hk_packet.lfr_status_word[0] = INT8_ALL_F; |
|
637 | dummy_hk_packet.lfr_status_word[0] = INT8_ALL_F; | |
638 | dummy_hk_packet.lfr_status_word[1] = INT8_ALL_F; |
|
638 | dummy_hk_packet.lfr_status_word[1] = INT8_ALL_F; | |
639 | // init software version |
|
639 | // init software version | |
640 | dummy_hk_packet.lfr_sw_version[0] = SW_VERSION_N1; |
|
640 | dummy_hk_packet.lfr_sw_version[0] = SW_VERSION_N1; | |
641 | dummy_hk_packet.lfr_sw_version[1] = SW_VERSION_N2; |
|
641 | dummy_hk_packet.lfr_sw_version[1] = SW_VERSION_N2; | |
642 | dummy_hk_packet.lfr_sw_version[BYTE_2] = SW_VERSION_N3; |
|
642 | dummy_hk_packet.lfr_sw_version[BYTE_2] = SW_VERSION_N3; | |
643 | dummy_hk_packet.lfr_sw_version[BYTE_3] = SW_VERSION_N4; |
|
643 | dummy_hk_packet.lfr_sw_version[BYTE_3] = SW_VERSION_N4; | |
644 | // init fpga version |
|
644 | // init fpga version | |
645 | parameters = (unsigned char *) (REGS_ADDR_WAVEFORM_PICKER + APB_OFFSET_VHDL_REV); |
|
645 | parameters = (unsigned char *) (REGS_ADDR_WAVEFORM_PICKER + APB_OFFSET_VHDL_REV); | |
646 | dummy_hk_packet.lfr_fpga_version[BYTE_0] = parameters[BYTE_1]; // n1 |
|
646 | dummy_hk_packet.lfr_fpga_version[BYTE_0] = parameters[BYTE_1]; // n1 | |
647 | dummy_hk_packet.lfr_fpga_version[BYTE_1] = parameters[BYTE_2]; // n2 |
|
647 | dummy_hk_packet.lfr_fpga_version[BYTE_1] = parameters[BYTE_2]; // n2 | |
648 | dummy_hk_packet.lfr_fpga_version[BYTE_2] = parameters[BYTE_3]; // n3 |
|
648 | dummy_hk_packet.lfr_fpga_version[BYTE_2] = parameters[BYTE_3]; // n3 | |
649 |
|
649 | |||
650 | parameters = (unsigned char *) &dummy_hk_packet.hk_lfr_cpu_load; |
|
650 | parameters = (unsigned char *) &dummy_hk_packet.hk_lfr_cpu_load; | |
651 |
|
651 | |||
652 | for (i=0; i<(BYTE_POS_HK_REACTION_WHEELS_FREQUENCY - BYTE_POS_HK_LFR_CPU_LOAD); i++) |
|
652 | for (i=0; i<(BYTE_POS_HK_REACTION_WHEELS_FREQUENCY - BYTE_POS_HK_LFR_CPU_LOAD); i++) | |
653 | { |
|
653 | { | |
654 | parameters[i] = INT8_ALL_F; |
|
654 | parameters[i] = INT8_ALL_F; | |
655 | } |
|
655 | } | |
656 |
|
656 | |||
657 | get_message_queue_id_send( &queue_id ); |
|
657 | get_message_queue_id_send( &queue_id ); | |
658 |
|
658 | |||
659 | rtems_message_queue_send( queue_id, &dummy_hk_packet, |
|
659 | rtems_message_queue_send( queue_id, &dummy_hk_packet, | |
660 | PACKET_LENGTH_HK + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES); |
|
660 | PACKET_LENGTH_HK + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES); | |
661 | } |
|
661 | } | |
662 |
|
662 | |||
663 | void get_temperatures( unsigned char *temperatures ) |
|
663 | void get_temperatures( unsigned char *temperatures ) | |
664 | { |
|
664 | { | |
665 | unsigned char* temp_scm_ptr; |
|
665 | unsigned char* temp_scm_ptr; | |
666 | unsigned char* temp_pcb_ptr; |
|
666 | unsigned char* temp_pcb_ptr; | |
667 | unsigned char* temp_fpga_ptr; |
|
667 | unsigned char* temp_fpga_ptr; | |
668 |
|
668 | |||
669 | // SEL1 SEL0 |
|
669 | // SEL1 SEL0 | |
670 | // 0 0 => PCB |
|
670 | // 0 0 => PCB | |
671 | // 0 1 => FPGA |
|
671 | // 0 1 => FPGA | |
672 | // 1 0 => SCM |
|
672 | // 1 0 => SCM | |
673 |
|
673 | |||
674 | temp_scm_ptr = (unsigned char *) &time_management_regs->temp_scm; |
|
674 | temp_scm_ptr = (unsigned char *) &time_management_regs->temp_scm; | |
675 | temp_pcb_ptr = (unsigned char *) &time_management_regs->temp_pcb; |
|
675 | temp_pcb_ptr = (unsigned char *) &time_management_regs->temp_pcb; | |
676 | temp_fpga_ptr = (unsigned char *) &time_management_regs->temp_fpga; |
|
676 | temp_fpga_ptr = (unsigned char *) &time_management_regs->temp_fpga; | |
677 |
|
677 | |||
678 | temperatures[ BYTE_0 ] = temp_scm_ptr[ BYTE_2 ]; |
|
678 | temperatures[ BYTE_0 ] = temp_scm_ptr[ BYTE_2 ]; | |
679 | temperatures[ BYTE_1 ] = temp_scm_ptr[ BYTE_3 ]; |
|
679 | temperatures[ BYTE_1 ] = temp_scm_ptr[ BYTE_3 ]; | |
680 | temperatures[ BYTE_2 ] = temp_pcb_ptr[ BYTE_2 ]; |
|
680 | temperatures[ BYTE_2 ] = temp_pcb_ptr[ BYTE_2 ]; | |
681 | temperatures[ BYTE_3 ] = temp_pcb_ptr[ BYTE_3 ]; |
|
681 | temperatures[ BYTE_3 ] = temp_pcb_ptr[ BYTE_3 ]; | |
682 | temperatures[ BYTE_4 ] = temp_fpga_ptr[ BYTE_2 ]; |
|
682 | temperatures[ BYTE_4 ] = temp_fpga_ptr[ BYTE_2 ]; | |
683 | temperatures[ BYTE_5 ] = temp_fpga_ptr[ BYTE_3 ]; |
|
683 | temperatures[ BYTE_5 ] = temp_fpga_ptr[ BYTE_3 ]; | |
684 | } |
|
684 | } | |
685 |
|
685 | |||
686 | void get_v_e1_e2_f3( unsigned char *spacecraft_potential ) |
|
686 | void get_v_e1_e2_f3( unsigned char *spacecraft_potential ) | |
687 | { |
|
687 | { | |
688 | unsigned char* v_ptr; |
|
688 | unsigned char* v_ptr; | |
689 | unsigned char* e1_ptr; |
|
689 | unsigned char* e1_ptr; | |
690 | unsigned char* e2_ptr; |
|
690 | unsigned char* e2_ptr; | |
691 |
|
691 | |||
692 | v_ptr = (unsigned char *) &hk_lfr_sc_v_f3_as_int16; |
|
692 | v_ptr = (unsigned char *) &hk_lfr_sc_v_f3_as_int16; | |
693 | e1_ptr = (unsigned char *) &hk_lfr_sc_e1_f3_as_int16; |
|
693 | e1_ptr = (unsigned char *) &hk_lfr_sc_e1_f3_as_int16; | |
694 | e2_ptr = (unsigned char *) &hk_lfr_sc_e2_f3_as_int16; |
|
694 | e2_ptr = (unsigned char *) &hk_lfr_sc_e2_f3_as_int16; | |
695 |
|
695 | |||
696 | spacecraft_potential[BYTE_0] = v_ptr[0]; |
|
696 | spacecraft_potential[BYTE_0] = v_ptr[0]; | |
697 | spacecraft_potential[BYTE_1] = v_ptr[1]; |
|
697 | spacecraft_potential[BYTE_1] = v_ptr[1]; | |
698 | spacecraft_potential[BYTE_2] = e1_ptr[0]; |
|
698 | spacecraft_potential[BYTE_2] = e1_ptr[0]; | |
699 | spacecraft_potential[BYTE_3] = e1_ptr[1]; |
|
699 | spacecraft_potential[BYTE_3] = e1_ptr[1]; | |
700 | spacecraft_potential[BYTE_4] = e2_ptr[0]; |
|
700 | spacecraft_potential[BYTE_4] = e2_ptr[0]; | |
701 | spacecraft_potential[BYTE_5] = e2_ptr[1]; |
|
701 | spacecraft_potential[BYTE_5] = e2_ptr[1]; | |
702 | } |
|
702 | } | |
703 |
|
703 | |||
704 | void get_cpu_load( unsigned char *resource_statistics ) |
|
704 | void get_cpu_load( unsigned char *resource_statistics ) | |
705 | { |
|
705 | { | |
706 | unsigned char cpu_load; |
|
706 | unsigned char cpu_load; | |
707 |
|
707 | |||
708 | cpu_load = lfr_rtems_cpu_usage_report(); |
|
708 | cpu_load = lfr_rtems_cpu_usage_report(); | |
709 |
|
709 | |||
710 | // HK_LFR_CPU_LOAD |
|
710 | // HK_LFR_CPU_LOAD | |
711 | resource_statistics[0] = cpu_load; |
|
711 | resource_statistics[0] = cpu_load; | |
712 |
|
712 | |||
713 | // HK_LFR_CPU_LOAD_MAX |
|
713 | // HK_LFR_CPU_LOAD_MAX | |
714 | if (cpu_load > resource_statistics[1]) |
|
714 | if (cpu_load > resource_statistics[1]) | |
715 | { |
|
715 | { | |
716 | resource_statistics[1] = cpu_load; |
|
716 | resource_statistics[1] = cpu_load; | |
717 | } |
|
717 | } | |
718 |
|
718 | |||
719 | // CPU_LOAD_AVE |
|
719 | // CPU_LOAD_AVE | |
720 | resource_statistics[BYTE_2] = 0; |
|
720 | resource_statistics[BYTE_2] = 0; | |
721 |
|
721 | |||
722 | #ifndef PRINT_TASK_STATISTICS |
|
722 | #ifndef PRINT_TASK_STATISTICS | |
723 | rtems_cpu_usage_reset(); |
|
723 | rtems_cpu_usage_reset(); | |
724 | #endif |
|
724 | #endif | |
725 |
|
725 | |||
726 | } |
|
726 | } | |
727 |
|
727 | |||
728 | void set_hk_lfr_sc_potential_flag( bool state ) |
|
728 | void set_hk_lfr_sc_potential_flag( bool state ) | |
729 | { |
|
729 | { | |
730 | if (state == true) |
|
730 | if (state == true) | |
731 | { |
|
731 | { | |
732 | housekeeping_packet.lfr_status_word[1] = |
|
732 | housekeeping_packet.lfr_status_word[1] = | |
733 | housekeeping_packet.lfr_status_word[1] | STATUS_WORD_SC_POTENTIAL_FLAG_BIT; // [0100 0000] |
|
733 | housekeeping_packet.lfr_status_word[1] | STATUS_WORD_SC_POTENTIAL_FLAG_BIT; // [0100 0000] | |
734 | } |
|
734 | } | |
735 | else |
|
735 | else | |
736 | { |
|
736 | { | |
737 | housekeeping_packet.lfr_status_word[1] = |
|
737 | housekeeping_packet.lfr_status_word[1] = | |
738 | housekeeping_packet.lfr_status_word[1] & STATUS_WORD_SC_POTENTIAL_FLAG_MASK; // [1011 1111] |
|
738 | housekeeping_packet.lfr_status_word[1] & STATUS_WORD_SC_POTENTIAL_FLAG_MASK; // [1011 1111] | |
739 | } |
|
739 | } | |
740 | } |
|
740 | } | |
741 |
|
741 | |||
742 | void set_sy_lfr_pas_filter_enabled( bool state ) |
|
742 | void set_sy_lfr_pas_filter_enabled( bool state ) | |
743 | { |
|
743 | { | |
744 | if (state == true) |
|
744 | if (state == true) | |
745 | { |
|
745 | { | |
746 | housekeeping_packet.lfr_status_word[1] = |
|
746 | housekeeping_packet.lfr_status_word[1] = | |
747 |
housekeeping_packet.lfr_status_word[1] | STATUS_WORD_ |
|
747 | housekeeping_packet.lfr_status_word[1] | STATUS_WORD_PAS_FILTER_ENABLED_BIT; // [0010 0000] | |
748 | } |
|
748 | } | |
749 | else |
|
749 | else | |
750 | { |
|
750 | { | |
751 | housekeeping_packet.lfr_status_word[1] = |
|
751 | housekeeping_packet.lfr_status_word[1] = | |
752 |
housekeeping_packet.lfr_status_word[1] & STATUS_WORD_ |
|
752 | housekeeping_packet.lfr_status_word[1] & STATUS_WORD_PAS_FILTER_ENABLED_MASK; // [1101 1111] | |
753 | } |
|
753 | } | |
754 | } |
|
754 | } | |
755 |
|
755 | |||
756 | void set_sy_lfr_watchdog_enabled( bool state ) |
|
756 | void set_sy_lfr_watchdog_enabled( bool state ) | |
757 | { |
|
757 | { | |
758 | if (state == true) |
|
758 | if (state == true) | |
759 | { |
|
759 | { | |
760 | housekeeping_packet.lfr_status_word[1] = |
|
760 | housekeeping_packet.lfr_status_word[1] = | |
761 | housekeeping_packet.lfr_status_word[1] | STATUS_WORD_WATCHDOG_BIT; // [0001 0000] |
|
761 | housekeeping_packet.lfr_status_word[1] | STATUS_WORD_WATCHDOG_BIT; // [0001 0000] | |
762 | } |
|
762 | } | |
763 | else |
|
763 | else | |
764 | { |
|
764 | { | |
765 | housekeeping_packet.lfr_status_word[1] = |
|
765 | housekeeping_packet.lfr_status_word[1] = | |
766 | housekeeping_packet.lfr_status_word[1] & STATUS_WORD_WATCHDOG_MASK; // [1110 1111] |
|
766 | housekeeping_packet.lfr_status_word[1] & STATUS_WORD_WATCHDOG_MASK; // [1110 1111] | |
767 | } |
|
767 | } | |
768 | } |
|
768 | } | |
769 |
|
769 | |||
770 | void set_hk_lfr_calib_enable( bool state ) |
|
770 | void set_hk_lfr_calib_enable( bool state ) | |
771 | { |
|
771 | { | |
772 | if (state == true) |
|
772 | if (state == true) | |
773 | { |
|
773 | { | |
774 | housekeeping_packet.lfr_status_word[1] = |
|
774 | housekeeping_packet.lfr_status_word[1] = | |
775 | housekeeping_packet.lfr_status_word[1] | STATUS_WORD_CALIB_BIT; // [0000 1000] |
|
775 | housekeeping_packet.lfr_status_word[1] | STATUS_WORD_CALIB_BIT; // [0000 1000] | |
776 | } |
|
776 | } | |
777 | else |
|
777 | else | |
778 | { |
|
778 | { | |
779 | housekeeping_packet.lfr_status_word[1] = |
|
779 | housekeeping_packet.lfr_status_word[1] = | |
780 | housekeeping_packet.lfr_status_word[1] & STATUS_WORD_CALIB_MASK; // [1111 0111] |
|
780 | housekeeping_packet.lfr_status_word[1] & STATUS_WORD_CALIB_MASK; // [1111 0111] | |
781 | } |
|
781 | } | |
782 | } |
|
782 | } | |
783 |
|
783 | |||
784 | void set_hk_lfr_reset_cause( enum lfr_reset_cause_t lfr_reset_cause ) |
|
784 | void set_hk_lfr_reset_cause( enum lfr_reset_cause_t lfr_reset_cause ) | |
785 | { |
|
785 | { | |
786 | housekeeping_packet.lfr_status_word[1] = |
|
786 | housekeeping_packet.lfr_status_word[1] = | |
787 | housekeeping_packet.lfr_status_word[1] & STATUS_WORD_RESET_CAUSE_MASK; // [1111 1000] |
|
787 | housekeeping_packet.lfr_status_word[1] & STATUS_WORD_RESET_CAUSE_MASK; // [1111 1000] | |
788 |
|
788 | |||
789 | housekeeping_packet.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1] |
|
789 | housekeeping_packet.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1] | |
790 | | (lfr_reset_cause & STATUS_WORD_RESET_CAUSE_BITS ); // [0000 0111] |
|
790 | | (lfr_reset_cause & STATUS_WORD_RESET_CAUSE_BITS ); // [0000 0111] | |
791 |
|
791 | |||
792 | } |
|
792 | } | |
793 |
|
793 | |||
794 | void increment_hk_counter( unsigned char newValue, unsigned char oldValue, unsigned int *counter ) |
|
794 | void increment_hk_counter( unsigned char newValue, unsigned char oldValue, unsigned int *counter ) | |
795 | { |
|
795 | { | |
796 | int delta; |
|
796 | int delta; | |
797 |
|
797 | |||
798 | delta = 0; |
|
798 | delta = 0; | |
799 |
|
799 | |||
800 | if (newValue >= oldValue) |
|
800 | if (newValue >= oldValue) | |
801 | { |
|
801 | { | |
802 | delta = newValue - oldValue; |
|
802 | delta = newValue - oldValue; | |
803 | } |
|
803 | } | |
804 | else |
|
804 | else | |
805 | { |
|
805 | { | |
806 | delta = (255 - oldValue) + newValue; |
|
806 | delta = (255 - oldValue) + newValue; | |
807 | } |
|
807 | } | |
808 |
|
808 | |||
809 | *counter = *counter + delta; |
|
809 | *counter = *counter + delta; | |
810 | } |
|
810 | } | |
811 |
|
811 | |||
812 | void hk_lfr_le_update( void ) |
|
812 | void hk_lfr_le_update( void ) | |
813 | { |
|
813 | { | |
814 | static hk_lfr_le_t old_hk_lfr_le = {0}; |
|
814 | static hk_lfr_le_t old_hk_lfr_le = {0}; | |
815 | hk_lfr_le_t new_hk_lfr_le; |
|
815 | hk_lfr_le_t new_hk_lfr_le; | |
816 | unsigned int counter; |
|
816 | unsigned int counter; | |
817 |
|
817 | |||
818 | counter = (((unsigned int) housekeeping_packet.hk_lfr_le_cnt[0]) * 256) + housekeeping_packet.hk_lfr_le_cnt[1]; |
|
818 | counter = (((unsigned int) housekeeping_packet.hk_lfr_le_cnt[0]) * 256) + housekeeping_packet.hk_lfr_le_cnt[1]; | |
819 |
|
819 | |||
820 | // DPU |
|
820 | // DPU | |
821 | new_hk_lfr_le.dpu_spw_parity = housekeeping_packet.hk_lfr_dpu_spw_parity; |
|
821 | new_hk_lfr_le.dpu_spw_parity = housekeeping_packet.hk_lfr_dpu_spw_parity; | |
822 | new_hk_lfr_le.dpu_spw_disconnect= housekeeping_packet.hk_lfr_dpu_spw_disconnect; |
|
822 | new_hk_lfr_le.dpu_spw_disconnect= housekeeping_packet.hk_lfr_dpu_spw_disconnect; | |
823 | new_hk_lfr_le.dpu_spw_escape = housekeeping_packet.hk_lfr_dpu_spw_escape; |
|
823 | new_hk_lfr_le.dpu_spw_escape = housekeeping_packet.hk_lfr_dpu_spw_escape; | |
824 | new_hk_lfr_le.dpu_spw_credit = housekeeping_packet.hk_lfr_dpu_spw_credit; |
|
824 | new_hk_lfr_le.dpu_spw_credit = housekeeping_packet.hk_lfr_dpu_spw_credit; | |
825 | new_hk_lfr_le.dpu_spw_write_sync= housekeeping_packet.hk_lfr_dpu_spw_write_sync; |
|
825 | new_hk_lfr_le.dpu_spw_write_sync= housekeeping_packet.hk_lfr_dpu_spw_write_sync; | |
826 | // TIMECODE |
|
826 | // TIMECODE | |
827 | new_hk_lfr_le.timecode_erroneous= housekeeping_packet.hk_lfr_timecode_erroneous; |
|
827 | new_hk_lfr_le.timecode_erroneous= housekeeping_packet.hk_lfr_timecode_erroneous; | |
828 | new_hk_lfr_le.timecode_missing = housekeeping_packet.hk_lfr_timecode_missing; |
|
828 | new_hk_lfr_le.timecode_missing = housekeeping_packet.hk_lfr_timecode_missing; | |
829 | new_hk_lfr_le.timecode_invalid = housekeeping_packet.hk_lfr_timecode_invalid; |
|
829 | new_hk_lfr_le.timecode_invalid = housekeeping_packet.hk_lfr_timecode_invalid; | |
830 | // TIME |
|
830 | // TIME | |
831 | new_hk_lfr_le.time_timecode_it = housekeeping_packet.hk_lfr_time_timecode_it; |
|
831 | new_hk_lfr_le.time_timecode_it = housekeeping_packet.hk_lfr_time_timecode_it; | |
832 | new_hk_lfr_le.time_not_synchro = housekeeping_packet.hk_lfr_time_not_synchro; |
|
832 | new_hk_lfr_le.time_not_synchro = housekeeping_packet.hk_lfr_time_not_synchro; | |
833 | new_hk_lfr_le.time_timecode_ctr = housekeeping_packet.hk_lfr_time_timecode_ctr; |
|
833 | new_hk_lfr_le.time_timecode_ctr = housekeeping_packet.hk_lfr_time_timecode_ctr; | |
834 | //AHB |
|
834 | //AHB | |
835 | new_hk_lfr_le.ahb_correctable = housekeeping_packet.hk_lfr_ahb_correctable; |
|
835 | new_hk_lfr_le.ahb_correctable = housekeeping_packet.hk_lfr_ahb_correctable; | |
836 | // housekeeping_packet.hk_lfr_dpu_spw_rx_ahb => not handled by the grspw driver |
|
836 | // housekeeping_packet.hk_lfr_dpu_spw_rx_ahb => not handled by the grspw driver | |
837 | // housekeeping_packet.hk_lfr_dpu_spw_tx_ahb => not handled by the grspw driver |
|
837 | // housekeeping_packet.hk_lfr_dpu_spw_tx_ahb => not handled by the grspw driver | |
838 |
|
838 | |||
839 | // update the le counter |
|
839 | // update the le counter | |
840 | // DPU |
|
840 | // DPU | |
841 | increment_hk_counter( new_hk_lfr_le.dpu_spw_parity, old_hk_lfr_le.dpu_spw_parity, &counter ); |
|
841 | increment_hk_counter( new_hk_lfr_le.dpu_spw_parity, old_hk_lfr_le.dpu_spw_parity, &counter ); | |
842 | increment_hk_counter( new_hk_lfr_le.dpu_spw_disconnect,old_hk_lfr_le.dpu_spw_disconnect, &counter ); |
|
842 | increment_hk_counter( new_hk_lfr_le.dpu_spw_disconnect,old_hk_lfr_le.dpu_spw_disconnect, &counter ); | |
843 | increment_hk_counter( new_hk_lfr_le.dpu_spw_escape, old_hk_lfr_le.dpu_spw_escape, &counter ); |
|
843 | increment_hk_counter( new_hk_lfr_le.dpu_spw_escape, old_hk_lfr_le.dpu_spw_escape, &counter ); | |
844 | increment_hk_counter( new_hk_lfr_le.dpu_spw_credit, old_hk_lfr_le.dpu_spw_credit, &counter ); |
|
844 | increment_hk_counter( new_hk_lfr_le.dpu_spw_credit, old_hk_lfr_le.dpu_spw_credit, &counter ); | |
845 | increment_hk_counter( new_hk_lfr_le.dpu_spw_write_sync,old_hk_lfr_le.dpu_spw_write_sync, &counter ); |
|
845 | increment_hk_counter( new_hk_lfr_le.dpu_spw_write_sync,old_hk_lfr_le.dpu_spw_write_sync, &counter ); | |
846 | // TIMECODE |
|
846 | // TIMECODE | |
847 | increment_hk_counter( new_hk_lfr_le.timecode_erroneous,old_hk_lfr_le.timecode_erroneous, &counter ); |
|
847 | increment_hk_counter( new_hk_lfr_le.timecode_erroneous,old_hk_lfr_le.timecode_erroneous, &counter ); | |
848 | increment_hk_counter( new_hk_lfr_le.timecode_missing, old_hk_lfr_le.timecode_missing, &counter ); |
|
848 | increment_hk_counter( new_hk_lfr_le.timecode_missing, old_hk_lfr_le.timecode_missing, &counter ); | |
849 | increment_hk_counter( new_hk_lfr_le.timecode_invalid, old_hk_lfr_le.timecode_invalid, &counter ); |
|
849 | increment_hk_counter( new_hk_lfr_le.timecode_invalid, old_hk_lfr_le.timecode_invalid, &counter ); | |
850 | // TIME |
|
850 | // TIME | |
851 | increment_hk_counter( new_hk_lfr_le.time_timecode_it, old_hk_lfr_le.time_timecode_it, &counter ); |
|
851 | increment_hk_counter( new_hk_lfr_le.time_timecode_it, old_hk_lfr_le.time_timecode_it, &counter ); | |
852 | increment_hk_counter( new_hk_lfr_le.time_not_synchro, old_hk_lfr_le.time_not_synchro, &counter ); |
|
852 | increment_hk_counter( new_hk_lfr_le.time_not_synchro, old_hk_lfr_le.time_not_synchro, &counter ); | |
853 | increment_hk_counter( new_hk_lfr_le.time_timecode_ctr, old_hk_lfr_le.time_timecode_ctr, &counter ); |
|
853 | increment_hk_counter( new_hk_lfr_le.time_timecode_ctr, old_hk_lfr_le.time_timecode_ctr, &counter ); | |
854 | // AHB |
|
854 | // AHB | |
855 | increment_hk_counter( new_hk_lfr_le.ahb_correctable, old_hk_lfr_le.ahb_correctable, &counter ); |
|
855 | increment_hk_counter( new_hk_lfr_le.ahb_correctable, old_hk_lfr_le.ahb_correctable, &counter ); | |
856 |
|
856 | |||
857 | // DPU |
|
857 | // DPU | |
858 | old_hk_lfr_le.dpu_spw_parity = new_hk_lfr_le.dpu_spw_parity; |
|
858 | old_hk_lfr_le.dpu_spw_parity = new_hk_lfr_le.dpu_spw_parity; | |
859 | old_hk_lfr_le.dpu_spw_disconnect= new_hk_lfr_le.dpu_spw_disconnect; |
|
859 | old_hk_lfr_le.dpu_spw_disconnect= new_hk_lfr_le.dpu_spw_disconnect; | |
860 | old_hk_lfr_le.dpu_spw_escape = new_hk_lfr_le.dpu_spw_escape; |
|
860 | old_hk_lfr_le.dpu_spw_escape = new_hk_lfr_le.dpu_spw_escape; | |
861 | old_hk_lfr_le.dpu_spw_credit = new_hk_lfr_le.dpu_spw_credit; |
|
861 | old_hk_lfr_le.dpu_spw_credit = new_hk_lfr_le.dpu_spw_credit; | |
862 | old_hk_lfr_le.dpu_spw_write_sync= new_hk_lfr_le.dpu_spw_write_sync; |
|
862 | old_hk_lfr_le.dpu_spw_write_sync= new_hk_lfr_le.dpu_spw_write_sync; | |
863 | // TIMECODE |
|
863 | // TIMECODE | |
864 | old_hk_lfr_le.timecode_erroneous= new_hk_lfr_le.timecode_erroneous; |
|
864 | old_hk_lfr_le.timecode_erroneous= new_hk_lfr_le.timecode_erroneous; | |
865 | old_hk_lfr_le.timecode_missing = new_hk_lfr_le.timecode_missing; |
|
865 | old_hk_lfr_le.timecode_missing = new_hk_lfr_le.timecode_missing; | |
866 | old_hk_lfr_le.timecode_invalid = new_hk_lfr_le.timecode_invalid; |
|
866 | old_hk_lfr_le.timecode_invalid = new_hk_lfr_le.timecode_invalid; | |
867 | // TIME |
|
867 | // TIME | |
868 | old_hk_lfr_le.time_timecode_it = new_hk_lfr_le.time_timecode_it; |
|
868 | old_hk_lfr_le.time_timecode_it = new_hk_lfr_le.time_timecode_it; | |
869 | old_hk_lfr_le.time_not_synchro = new_hk_lfr_le.time_not_synchro; |
|
869 | old_hk_lfr_le.time_not_synchro = new_hk_lfr_le.time_not_synchro; | |
870 | old_hk_lfr_le.time_timecode_ctr = new_hk_lfr_le.time_timecode_ctr; |
|
870 | old_hk_lfr_le.time_timecode_ctr = new_hk_lfr_le.time_timecode_ctr; | |
871 | //AHB |
|
871 | //AHB | |
872 | old_hk_lfr_le.ahb_correctable = new_hk_lfr_le.ahb_correctable; |
|
872 | old_hk_lfr_le.ahb_correctable = new_hk_lfr_le.ahb_correctable; | |
873 | // housekeeping_packet.hk_lfr_dpu_spw_rx_ahb => not handled by the grspw driver |
|
873 | // housekeeping_packet.hk_lfr_dpu_spw_rx_ahb => not handled by the grspw driver | |
874 | // housekeeping_packet.hk_lfr_dpu_spw_tx_ahb => not handled by the grspw driver |
|
874 | // housekeeping_packet.hk_lfr_dpu_spw_tx_ahb => not handled by the grspw driver | |
875 |
|
875 | |||
876 | // update housekeeping packet counters, convert unsigned int numbers in 2 bytes numbers |
|
876 | // update housekeeping packet counters, convert unsigned int numbers in 2 bytes numbers | |
877 | // LE |
|
877 | // LE | |
878 | housekeeping_packet.hk_lfr_le_cnt[0] = (unsigned char) ((counter & BYTE0_MASK) >> SHIFT_1_BYTE); |
|
878 | housekeeping_packet.hk_lfr_le_cnt[0] = (unsigned char) ((counter & BYTE0_MASK) >> SHIFT_1_BYTE); | |
879 | housekeeping_packet.hk_lfr_le_cnt[1] = (unsigned char) (counter & BYTE1_MASK); |
|
879 | housekeeping_packet.hk_lfr_le_cnt[1] = (unsigned char) (counter & BYTE1_MASK); | |
880 | } |
|
880 | } | |
881 |
|
881 | |||
882 | void hk_lfr_me_update( void ) |
|
882 | void hk_lfr_me_update( void ) | |
883 | { |
|
883 | { | |
884 | static hk_lfr_me_t old_hk_lfr_me = {0}; |
|
884 | static hk_lfr_me_t old_hk_lfr_me = {0}; | |
885 | hk_lfr_me_t new_hk_lfr_me; |
|
885 | hk_lfr_me_t new_hk_lfr_me; | |
886 | unsigned int counter; |
|
886 | unsigned int counter; | |
887 |
|
887 | |||
888 | counter = (((unsigned int) housekeeping_packet.hk_lfr_me_cnt[0]) * 256) + housekeeping_packet.hk_lfr_me_cnt[1]; |
|
888 | counter = (((unsigned int) housekeeping_packet.hk_lfr_me_cnt[0]) * 256) + housekeeping_packet.hk_lfr_me_cnt[1]; | |
889 |
|
889 | |||
890 | // get the current values |
|
890 | // get the current values | |
891 | new_hk_lfr_me.dpu_spw_early_eop = housekeeping_packet.hk_lfr_dpu_spw_early_eop; |
|
891 | new_hk_lfr_me.dpu_spw_early_eop = housekeeping_packet.hk_lfr_dpu_spw_early_eop; | |
892 | new_hk_lfr_me.dpu_spw_invalid_addr = housekeeping_packet.hk_lfr_dpu_spw_invalid_addr; |
|
892 | new_hk_lfr_me.dpu_spw_invalid_addr = housekeeping_packet.hk_lfr_dpu_spw_invalid_addr; | |
893 | new_hk_lfr_me.dpu_spw_eep = housekeeping_packet.hk_lfr_dpu_spw_eep; |
|
893 | new_hk_lfr_me.dpu_spw_eep = housekeeping_packet.hk_lfr_dpu_spw_eep; | |
894 | new_hk_lfr_me.dpu_spw_rx_too_big = housekeeping_packet.hk_lfr_dpu_spw_rx_too_big; |
|
894 | new_hk_lfr_me.dpu_spw_rx_too_big = housekeeping_packet.hk_lfr_dpu_spw_rx_too_big; | |
895 |
|
895 | |||
896 | // update the me counter |
|
896 | // update the me counter | |
897 | increment_hk_counter( new_hk_lfr_me.dpu_spw_early_eop, old_hk_lfr_me.dpu_spw_early_eop, &counter ); |
|
897 | increment_hk_counter( new_hk_lfr_me.dpu_spw_early_eop, old_hk_lfr_me.dpu_spw_early_eop, &counter ); | |
898 | increment_hk_counter( new_hk_lfr_me.dpu_spw_invalid_addr, old_hk_lfr_me.dpu_spw_invalid_addr, &counter ); |
|
898 | increment_hk_counter( new_hk_lfr_me.dpu_spw_invalid_addr, old_hk_lfr_me.dpu_spw_invalid_addr, &counter ); | |
899 | increment_hk_counter( new_hk_lfr_me.dpu_spw_eep, old_hk_lfr_me.dpu_spw_eep, &counter ); |
|
899 | increment_hk_counter( new_hk_lfr_me.dpu_spw_eep, old_hk_lfr_me.dpu_spw_eep, &counter ); | |
900 | increment_hk_counter( new_hk_lfr_me.dpu_spw_rx_too_big, old_hk_lfr_me.dpu_spw_rx_too_big, &counter ); |
|
900 | increment_hk_counter( new_hk_lfr_me.dpu_spw_rx_too_big, old_hk_lfr_me.dpu_spw_rx_too_big, &counter ); | |
901 |
|
901 | |||
902 | // store the counters for the next time |
|
902 | // store the counters for the next time | |
903 | old_hk_lfr_me.dpu_spw_early_eop = new_hk_lfr_me.dpu_spw_early_eop; |
|
903 | old_hk_lfr_me.dpu_spw_early_eop = new_hk_lfr_me.dpu_spw_early_eop; | |
904 | old_hk_lfr_me.dpu_spw_invalid_addr = new_hk_lfr_me.dpu_spw_invalid_addr; |
|
904 | old_hk_lfr_me.dpu_spw_invalid_addr = new_hk_lfr_me.dpu_spw_invalid_addr; | |
905 | old_hk_lfr_me.dpu_spw_eep = new_hk_lfr_me.dpu_spw_eep; |
|
905 | old_hk_lfr_me.dpu_spw_eep = new_hk_lfr_me.dpu_spw_eep; | |
906 | old_hk_lfr_me.dpu_spw_rx_too_big = new_hk_lfr_me.dpu_spw_rx_too_big; |
|
906 | old_hk_lfr_me.dpu_spw_rx_too_big = new_hk_lfr_me.dpu_spw_rx_too_big; | |
907 |
|
907 | |||
908 | // update housekeeping packet counters, convert unsigned int numbers in 2 bytes numbers |
|
908 | // update housekeeping packet counters, convert unsigned int numbers in 2 bytes numbers | |
909 | // ME |
|
909 | // ME | |
910 | housekeeping_packet.hk_lfr_me_cnt[0] = (unsigned char) ((counter & BYTE0_MASK) >> SHIFT_1_BYTE); |
|
910 | housekeeping_packet.hk_lfr_me_cnt[0] = (unsigned char) ((counter & BYTE0_MASK) >> SHIFT_1_BYTE); | |
911 | housekeeping_packet.hk_lfr_me_cnt[1] = (unsigned char) (counter & BYTE1_MASK); |
|
911 | housekeeping_packet.hk_lfr_me_cnt[1] = (unsigned char) (counter & BYTE1_MASK); | |
912 | } |
|
912 | } | |
913 |
|
913 | |||
914 | void hk_lfr_le_me_he_update() |
|
914 | void hk_lfr_le_me_he_update() | |
915 | { |
|
915 | { | |
916 |
|
916 | |||
917 | unsigned int hk_lfr_he_cnt; |
|
917 | unsigned int hk_lfr_he_cnt; | |
918 |
|
918 | |||
919 | hk_lfr_he_cnt = (((unsigned int) housekeeping_packet.hk_lfr_he_cnt[0]) * 256) + housekeeping_packet.hk_lfr_he_cnt[1]; |
|
919 | hk_lfr_he_cnt = (((unsigned int) housekeeping_packet.hk_lfr_he_cnt[0]) * 256) + housekeeping_packet.hk_lfr_he_cnt[1]; | |
920 |
|
920 | |||
921 | //update the low severity error counter |
|
921 | //update the low severity error counter | |
922 | hk_lfr_le_update( ); |
|
922 | hk_lfr_le_update( ); | |
923 |
|
923 | |||
924 | //update the medium severity error counter |
|
924 | //update the medium severity error counter | |
925 | hk_lfr_me_update(); |
|
925 | hk_lfr_me_update(); | |
926 |
|
926 | |||
927 | //update the high severity error counter |
|
927 | //update the high severity error counter | |
928 | hk_lfr_he_cnt = 0; |
|
928 | hk_lfr_he_cnt = 0; | |
929 |
|
929 | |||
930 | // update housekeeping packet counters, convert unsigned int numbers in 2 bytes numbers |
|
930 | // update housekeeping packet counters, convert unsigned int numbers in 2 bytes numbers | |
931 | // HE |
|
931 | // HE | |
932 | housekeeping_packet.hk_lfr_he_cnt[0] = (unsigned char) ((hk_lfr_he_cnt & BYTE0_MASK) >> SHIFT_1_BYTE); |
|
932 | housekeeping_packet.hk_lfr_he_cnt[0] = (unsigned char) ((hk_lfr_he_cnt & BYTE0_MASK) >> SHIFT_1_BYTE); | |
933 | housekeeping_packet.hk_lfr_he_cnt[1] = (unsigned char) (hk_lfr_he_cnt & BYTE1_MASK); |
|
933 | housekeeping_packet.hk_lfr_he_cnt[1] = (unsigned char) (hk_lfr_he_cnt & BYTE1_MASK); | |
934 |
|
934 | |||
935 | } |
|
935 | } | |
936 |
|
936 | |||
937 | void set_hk_lfr_time_not_synchro() |
|
937 | void set_hk_lfr_time_not_synchro() | |
938 | { |
|
938 | { | |
939 | static unsigned char synchroLost = 1; |
|
939 | static unsigned char synchroLost = 1; | |
940 | int synchronizationBit; |
|
940 | int synchronizationBit; | |
941 |
|
941 | |||
942 | // get the synchronization bit |
|
942 | // get the synchronization bit | |
943 | synchronizationBit = |
|
943 | synchronizationBit = | |
944 | (time_management_regs->coarse_time & VAL_LFR_SYNCHRONIZED) >> BIT_SYNCHRONIZATION; // 1000 0000 0000 0000 |
|
944 | (time_management_regs->coarse_time & VAL_LFR_SYNCHRONIZED) >> BIT_SYNCHRONIZATION; // 1000 0000 0000 0000 | |
945 |
|
945 | |||
946 | switch (synchronizationBit) |
|
946 | switch (synchronizationBit) | |
947 | { |
|
947 | { | |
948 | case 0: |
|
948 | case 0: | |
949 | if (synchroLost == 1) |
|
949 | if (synchroLost == 1) | |
950 | { |
|
950 | { | |
951 | synchroLost = 0; |
|
951 | synchroLost = 0; | |
952 | } |
|
952 | } | |
953 | break; |
|
953 | break; | |
954 | case 1: |
|
954 | case 1: | |
955 | if (synchroLost == 0 ) |
|
955 | if (synchroLost == 0 ) | |
956 | { |
|
956 | { | |
957 | synchroLost = 1; |
|
957 | synchroLost = 1; | |
958 | increase_unsigned_char_counter(&housekeeping_packet.hk_lfr_time_not_synchro); |
|
958 | increase_unsigned_char_counter(&housekeeping_packet.hk_lfr_time_not_synchro); | |
959 | update_hk_lfr_last_er_fields( RID_LE_LFR_TIME, CODE_NOT_SYNCHRO ); |
|
959 | update_hk_lfr_last_er_fields( RID_LE_LFR_TIME, CODE_NOT_SYNCHRO ); | |
960 | } |
|
960 | } | |
961 | break; |
|
961 | break; | |
962 | default: |
|
962 | default: | |
963 | PRINTF1("in hk_lfr_time_not_synchro *** unexpected value for synchronizationBit = %d\n", synchronizationBit); |
|
963 | PRINTF1("in hk_lfr_time_not_synchro *** unexpected value for synchronizationBit = %d\n", synchronizationBit); | |
964 | break; |
|
964 | break; | |
965 | } |
|
965 | } | |
966 |
|
966 | |||
967 | } |
|
967 | } | |
968 |
|
968 | |||
969 | void set_hk_lfr_ahb_correctable() // CRITICITY L |
|
969 | void set_hk_lfr_ahb_correctable() // CRITICITY L | |
970 | { |
|
970 | { | |
971 | /** This function builds the error counter hk_lfr_ahb_correctable using the statistics provided |
|
971 | /** This function builds the error counter hk_lfr_ahb_correctable using the statistics provided | |
972 | * by the Cache Control Register (ASI 2, offset 0) and in the Register Protection Control Register (ASR16) on the |
|
972 | * by the Cache Control Register (ASI 2, offset 0) and in the Register Protection Control Register (ASR16) on the | |
973 | * detected errors in the cache, in the integer unit and in the floating point unit. |
|
973 | * detected errors in the cache, in the integer unit and in the floating point unit. | |
974 | * |
|
974 | * | |
975 | * @param void |
|
975 | * @param void | |
976 | * |
|
976 | * | |
977 | * @return void |
|
977 | * @return void | |
978 | * |
|
978 | * | |
979 | * All errors are summed to set the value of the hk_lfr_ahb_correctable counter. |
|
979 | * All errors are summed to set the value of the hk_lfr_ahb_correctable counter. | |
980 | * |
|
980 | * | |
981 | */ |
|
981 | */ | |
982 |
|
982 | |||
983 | unsigned int ahb_correctable; |
|
983 | unsigned int ahb_correctable; | |
984 | unsigned int instructionErrorCounter; |
|
984 | unsigned int instructionErrorCounter; | |
985 | unsigned int dataErrorCounter; |
|
985 | unsigned int dataErrorCounter; | |
986 | unsigned int fprfErrorCounter; |
|
986 | unsigned int fprfErrorCounter; | |
987 | unsigned int iurfErrorCounter; |
|
987 | unsigned int iurfErrorCounter; | |
988 |
|
988 | |||
989 | instructionErrorCounter = 0; |
|
989 | instructionErrorCounter = 0; | |
990 | dataErrorCounter = 0; |
|
990 | dataErrorCounter = 0; | |
991 | fprfErrorCounter = 0; |
|
991 | fprfErrorCounter = 0; | |
992 | iurfErrorCounter = 0; |
|
992 | iurfErrorCounter = 0; | |
993 |
|
993 | |||
994 | CCR_getInstructionAndDataErrorCounters( &instructionErrorCounter, &dataErrorCounter); |
|
994 | CCR_getInstructionAndDataErrorCounters( &instructionErrorCounter, &dataErrorCounter); | |
995 | ASR16_get_FPRF_IURF_ErrorCounters( &fprfErrorCounter, &iurfErrorCounter); |
|
995 | ASR16_get_FPRF_IURF_ErrorCounters( &fprfErrorCounter, &iurfErrorCounter); | |
996 |
|
996 | |||
997 | ahb_correctable = instructionErrorCounter |
|
997 | ahb_correctable = instructionErrorCounter | |
998 | + dataErrorCounter |
|
998 | + dataErrorCounter | |
999 | + fprfErrorCounter |
|
999 | + fprfErrorCounter | |
1000 | + iurfErrorCounter |
|
1000 | + iurfErrorCounter | |
1001 | + housekeeping_packet.hk_lfr_ahb_correctable; |
|
1001 | + housekeeping_packet.hk_lfr_ahb_correctable; | |
1002 |
|
1002 | |||
1003 | housekeeping_packet.hk_lfr_ahb_correctable = (unsigned char) (ahb_correctable & INT8_ALL_F); // [1111 1111] |
|
1003 | housekeeping_packet.hk_lfr_ahb_correctable = (unsigned char) (ahb_correctable & INT8_ALL_F); // [1111 1111] | |
1004 |
|
1004 | |||
1005 | } |
|
1005 | } |
@@ -1,1812 +1,1795 | |||||
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 = {0}; |
|
17 | Packet_TM_LFR_KCOEFFICIENTS_DUMP_t kcoefficients_dump_1 = {0}; | |
18 | Packet_TM_LFR_KCOEFFICIENTS_DUMP_t kcoefficients_dump_2 = {0}; |
|
18 | Packet_TM_LFR_KCOEFFICIENTS_DUMP_t kcoefficients_dump_2 = {0}; | |
19 | ring_node kcoefficient_node_1 = {0}; |
|
19 | ring_node kcoefficient_node_1 = {0}; | |
20 | ring_node kcoefficient_node_2 = {0}; |
|
20 | ring_node kcoefficient_node_2 = {0}; | |
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_normal_par_consistency( TC, queue_id ); |
|
61 | flag = check_normal_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 shall not be lower than its default value |
|
103 | // sy_lfr_b_bp_p0 shall not be lower than its default value | |
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 + DATAFIELD_OFFSET, sy_lfr_b_bp_p0 ); |
|
108 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_B_BP_P0 + DATAFIELD_OFFSET, 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 shall not be lower than its default value |
|
112 | // sy_lfr_b_bp_p1 shall not be lower than its default value | |
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 + DATAFIELD_OFFSET, sy_lfr_b_bp_p1 ); |
|
117 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_B_BP_P1 + DATAFIELD_OFFSET, 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 + DATAFIELD_OFFSET, sy_lfr_b_bp_p0 ); |
|
130 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_B_BP_P0 + DATAFIELD_OFFSET, sy_lfr_b_bp_p0 ); | |
131 | flag = LFR_DEFAULT; |
|
131 | flag = LFR_DEFAULT; | |
132 | } |
|
132 | } | |
133 | } |
|
133 | } | |
134 |
|
134 | |||
135 | // SET THE PARAMETERS |
|
135 | // SET THE 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 + DATAFIELD_OFFSET, sy_lfr_s1_bp_p0 ); |
|
175 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S1_BP_P0 + DATAFIELD_OFFSET, 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 + DATAFIELD_OFFSET, sy_lfr_s1_bp_p1 ); |
|
184 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S1_BP_P1 + DATAFIELD_OFFSET, 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 * S1_BP_P0_SCALE) ) |
|
192 | aux = ( (float ) sy_lfr_s1_bp_p1 / (sy_lfr_s1_bp_p0 * S1_BP_P0_SCALE) ) | |
193 | - floor(sy_lfr_s1_bp_p1 / (sy_lfr_s1_bp_p0 * S1_BP_P0_SCALE)); |
|
193 | - floor(sy_lfr_s1_bp_p1 / (sy_lfr_s1_bp_p0 * S1_BP_P0_SCALE)); | |
194 | if (aux > FLOAT_EQUAL_ZERO) |
|
194 | if (aux > FLOAT_EQUAL_ZERO) | |
195 | { |
|
195 | { | |
196 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S1_BP_P0 + DATAFIELD_OFFSET, sy_lfr_s1_bp_p0 ); |
|
196 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S1_BP_P0 + DATAFIELD_OFFSET, sy_lfr_s1_bp_p0 ); | |
197 | flag = LFR_DEFAULT; |
|
197 | flag = LFR_DEFAULT; | |
198 | } |
|
198 | } | |
199 | } |
|
199 | } | |
200 |
|
200 | |||
201 | // SET THE PARAMETERS |
|
201 | // SET THE PARAMETERS | |
202 | if (flag == LFR_SUCCESSFUL) |
|
202 | if (flag == LFR_SUCCESSFUL) | |
203 | { |
|
203 | { | |
204 | flag = set_sy_lfr_s1_bp_p0( TC ); |
|
204 | flag = set_sy_lfr_s1_bp_p0( TC ); | |
205 | flag = set_sy_lfr_s1_bp_p1( TC ); |
|
205 | flag = set_sy_lfr_s1_bp_p1( TC ); | |
206 | } |
|
206 | } | |
207 |
|
207 | |||
208 | return flag; |
|
208 | return flag; | |
209 | } |
|
209 | } | |
210 |
|
210 | |||
211 | int action_load_sbm2_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) |
|
211 | int action_load_sbm2_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) | |
212 | { |
|
212 | { | |
213 | /** This function updates the LFR registers with the incoming sbm2 parameters. |
|
213 | /** This function updates the LFR registers with the incoming sbm2 parameters. | |
214 | * |
|
214 | * | |
215 | * @param TC points to the TeleCommand packet that is being processed |
|
215 | * @param TC points to the TeleCommand packet that is being processed | |
216 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
216 | * @param queue_id is the id of the queue which handles TM related to this execution step | |
217 | * |
|
217 | * | |
218 | */ |
|
218 | */ | |
219 |
|
219 | |||
220 | int flag; |
|
220 | int flag; | |
221 | rtems_status_code status; |
|
221 | rtems_status_code status; | |
222 | unsigned char sy_lfr_s2_bp_p0; |
|
222 | unsigned char sy_lfr_s2_bp_p0; | |
223 | unsigned char sy_lfr_s2_bp_p1; |
|
223 | unsigned char sy_lfr_s2_bp_p1; | |
224 | float aux; |
|
224 | float aux; | |
225 |
|
225 | |||
226 | flag = LFR_SUCCESSFUL; |
|
226 | flag = LFR_SUCCESSFUL; | |
227 |
|
227 | |||
228 | if ( lfrCurrentMode == LFR_MODE_SBM2 ) { |
|
228 | if ( lfrCurrentMode == LFR_MODE_SBM2 ) { | |
229 | status = send_tm_lfr_tc_exe_not_executable( TC, queue_id ); |
|
229 | status = send_tm_lfr_tc_exe_not_executable( TC, queue_id ); | |
230 | flag = LFR_DEFAULT; |
|
230 | flag = LFR_DEFAULT; | |
231 | } |
|
231 | } | |
232 |
|
232 | |||
233 | sy_lfr_s2_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P0 ]; |
|
233 | sy_lfr_s2_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P0 ]; | |
234 | sy_lfr_s2_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P1 ]; |
|
234 | sy_lfr_s2_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P1 ]; | |
235 |
|
235 | |||
236 | // sy_lfr_s2_bp_p0 |
|
236 | // sy_lfr_s2_bp_p0 | |
237 | if (flag == LFR_SUCCESSFUL) |
|
237 | if (flag == LFR_SUCCESSFUL) | |
238 | { |
|
238 | { | |
239 | if (sy_lfr_s2_bp_p0 < DEFAULT_SY_LFR_S2_BP_P0 ) |
|
239 | if (sy_lfr_s2_bp_p0 < DEFAULT_SY_LFR_S2_BP_P0 ) | |
240 | { |
|
240 | { | |
241 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S2_BP_P0 + DATAFIELD_OFFSET, sy_lfr_s2_bp_p0 ); |
|
241 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S2_BP_P0 + DATAFIELD_OFFSET, sy_lfr_s2_bp_p0 ); | |
242 | flag = WRONG_APP_DATA; |
|
242 | flag = WRONG_APP_DATA; | |
243 | } |
|
243 | } | |
244 | } |
|
244 | } | |
245 | // sy_lfr_s2_bp_p1 |
|
245 | // sy_lfr_s2_bp_p1 | |
246 | if (flag == LFR_SUCCESSFUL) |
|
246 | if (flag == LFR_SUCCESSFUL) | |
247 | { |
|
247 | { | |
248 | if (sy_lfr_s2_bp_p1 < DEFAULT_SY_LFR_S2_BP_P1 ) |
|
248 | if (sy_lfr_s2_bp_p1 < DEFAULT_SY_LFR_S2_BP_P1 ) | |
249 | { |
|
249 | { | |
250 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S2_BP_P1 + DATAFIELD_OFFSET, sy_lfr_s2_bp_p1 ); |
|
250 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S2_BP_P1 + DATAFIELD_OFFSET, sy_lfr_s2_bp_p1 ); | |
251 | flag = WRONG_APP_DATA; |
|
251 | flag = WRONG_APP_DATA; | |
252 | } |
|
252 | } | |
253 | } |
|
253 | } | |
254 | //****************************************************************** |
|
254 | //****************************************************************** | |
255 | // check the consistency between sy_lfr_s2_bp_p0 and sy_lfr_s2_bp_p1 |
|
255 | // check the consistency between sy_lfr_s2_bp_p0 and sy_lfr_s2_bp_p1 | |
256 | if (flag == LFR_SUCCESSFUL) |
|
256 | if (flag == LFR_SUCCESSFUL) | |
257 | { |
|
257 | { | |
258 | sy_lfr_s2_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P0 ]; |
|
258 | sy_lfr_s2_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P0 ]; | |
259 | sy_lfr_s2_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P1 ]; |
|
259 | sy_lfr_s2_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P1 ]; | |
260 | aux = ( (float ) sy_lfr_s2_bp_p1 / sy_lfr_s2_bp_p0 ) - floor(sy_lfr_s2_bp_p1 / sy_lfr_s2_bp_p0); |
|
260 | aux = ( (float ) sy_lfr_s2_bp_p1 / sy_lfr_s2_bp_p0 ) - floor(sy_lfr_s2_bp_p1 / sy_lfr_s2_bp_p0); | |
261 | if (aux > FLOAT_EQUAL_ZERO) |
|
261 | if (aux > FLOAT_EQUAL_ZERO) | |
262 | { |
|
262 | { | |
263 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S2_BP_P0 + DATAFIELD_OFFSET, sy_lfr_s2_bp_p0 ); |
|
263 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S2_BP_P0 + DATAFIELD_OFFSET, sy_lfr_s2_bp_p0 ); | |
264 | flag = LFR_DEFAULT; |
|
264 | flag = LFR_DEFAULT; | |
265 | } |
|
265 | } | |
266 | } |
|
266 | } | |
267 |
|
267 | |||
268 | // SET THE PARAMETERS |
|
268 | // SET THE PARAMETERS | |
269 | if (flag == LFR_SUCCESSFUL) |
|
269 | if (flag == LFR_SUCCESSFUL) | |
270 | { |
|
270 | { | |
271 | flag = set_sy_lfr_s2_bp_p0( TC ); |
|
271 | flag = set_sy_lfr_s2_bp_p0( TC ); | |
272 | flag = set_sy_lfr_s2_bp_p1( TC ); |
|
272 | flag = set_sy_lfr_s2_bp_p1( TC ); | |
273 | } |
|
273 | } | |
274 |
|
274 | |||
275 | return flag; |
|
275 | return flag; | |
276 | } |
|
276 | } | |
277 |
|
277 | |||
278 | int action_load_kcoefficients(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) |
|
278 | int action_load_kcoefficients(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) | |
279 | { |
|
279 | { | |
280 | /** This function updates the LFR registers with the incoming sbm2 parameters. |
|
280 | /** This function updates the LFR registers with the incoming sbm2 parameters. | |
281 | * |
|
281 | * | |
282 | * @param TC points to the TeleCommand packet that is being processed |
|
282 | * @param TC points to the TeleCommand packet that is being processed | |
283 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
283 | * @param queue_id is the id of the queue which handles TM related to this execution step | |
284 | * |
|
284 | * | |
285 | */ |
|
285 | */ | |
286 |
|
286 | |||
287 | int flag; |
|
287 | int flag; | |
288 |
|
288 | |||
289 | flag = LFR_DEFAULT; |
|
289 | flag = LFR_DEFAULT; | |
290 |
|
290 | |||
291 | flag = set_sy_lfr_kcoeff( TC, queue_id ); |
|
291 | flag = set_sy_lfr_kcoeff( TC, queue_id ); | |
292 |
|
292 | |||
293 | return flag; |
|
293 | return flag; | |
294 | } |
|
294 | } | |
295 |
|
295 | |||
296 | int action_load_fbins_mask(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) |
|
296 | int action_load_fbins_mask(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) | |
297 | { |
|
297 | { | |
298 | /** This function updates the LFR registers with the incoming sbm2 parameters. |
|
298 | /** This function updates the LFR registers with the incoming sbm2 parameters. | |
299 | * |
|
299 | * | |
300 | * @param TC points to the TeleCommand packet that is being processed |
|
300 | * @param TC points to the TeleCommand packet that is being processed | |
301 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
301 | * @param queue_id is the id of the queue which handles TM related to this execution step | |
302 | * |
|
302 | * | |
303 | */ |
|
303 | */ | |
304 |
|
304 | |||
305 | int flag; |
|
305 | int flag; | |
306 |
|
306 | |||
307 | flag = LFR_DEFAULT; |
|
307 | flag = LFR_DEFAULT; | |
308 |
|
308 | |||
309 | flag = set_sy_lfr_fbins( TC ); |
|
309 | flag = set_sy_lfr_fbins( TC ); | |
310 |
|
310 | |||
311 | // once the fbins masks have been stored, they have to be merged with the masks which handle the reaction wheels frequencies filtering |
|
311 | // once the fbins masks have been stored, they have to be merged with the masks which handle the reaction wheels frequencies filtering | |
312 | merge_fbins_masks(); |
|
312 | merge_fbins_masks(); | |
313 |
|
313 | |||
314 | return flag; |
|
314 | return flag; | |
315 | } |
|
315 | } | |
316 |
|
316 | |||
317 | int action_load_filter_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) |
|
317 | int action_load_filter_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) | |
318 | { |
|
318 | { | |
319 | /** This function updates the LFR registers with the incoming sbm2 parameters. |
|
319 | /** This function updates the LFR registers with the incoming sbm2 parameters. | |
320 | * |
|
320 | * | |
321 | * @param TC points to the TeleCommand packet that is being processed |
|
321 | * @param TC points to the TeleCommand packet that is being processed | |
322 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
322 | * @param queue_id is the id of the queue which handles TM related to this execution step | |
323 | * |
|
323 | * | |
324 | */ |
|
324 | */ | |
325 |
|
325 | |||
326 | int flag; |
|
326 | int flag; | |
327 | unsigned char k; |
|
327 | unsigned char k; | |
328 |
|
328 | |||
329 | flag = LFR_DEFAULT; |
|
329 | flag = LFR_DEFAULT; | |
330 | k = INIT_CHAR; |
|
330 | k = INIT_CHAR; | |
331 |
|
331 | |||
332 | flag = check_sy_lfr_filter_parameters( TC, queue_id ); |
|
332 | flag = check_sy_lfr_filter_parameters( TC, queue_id ); | |
333 |
|
333 | |||
334 | if (flag == LFR_SUCCESSFUL) |
|
334 | if (flag == LFR_SUCCESSFUL) | |
335 | { |
|
335 | { | |
336 | parameter_dump_packet.spare_sy_lfr_pas_filter_enabled = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_ENABLED ]; |
|
336 | parameter_dump_packet.spare_sy_lfr_pas_filter_enabled = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_ENABLED ]; | |
337 | parameter_dump_packet.sy_lfr_pas_filter_modulus = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_MODULUS ]; |
|
337 | parameter_dump_packet.sy_lfr_pas_filter_modulus = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_MODULUS ]; | |
338 | parameter_dump_packet.sy_lfr_pas_filter_tbad[BYTE_0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_TBAD + BYTE_0 ]; |
|
338 | parameter_dump_packet.sy_lfr_pas_filter_tbad[BYTE_0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_TBAD + BYTE_0 ]; | |
339 | parameter_dump_packet.sy_lfr_pas_filter_tbad[BYTE_1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_TBAD + BYTE_1 ]; |
|
339 | parameter_dump_packet.sy_lfr_pas_filter_tbad[BYTE_1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_TBAD + BYTE_1 ]; | |
340 | parameter_dump_packet.sy_lfr_pas_filter_tbad[BYTE_2] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_TBAD + BYTE_2 ]; |
|
340 | parameter_dump_packet.sy_lfr_pas_filter_tbad[BYTE_2] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_TBAD + BYTE_2 ]; | |
341 | parameter_dump_packet.sy_lfr_pas_filter_tbad[BYTE_3] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_TBAD + BYTE_3 ]; |
|
341 | parameter_dump_packet.sy_lfr_pas_filter_tbad[BYTE_3] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_TBAD + BYTE_3 ]; | |
342 | parameter_dump_packet.sy_lfr_pas_filter_offset = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_OFFSET ]; |
|
342 | parameter_dump_packet.sy_lfr_pas_filter_offset = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_OFFSET ]; | |
343 | parameter_dump_packet.sy_lfr_pas_filter_shift[BYTE_0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_SHIFT + BYTE_0 ]; |
|
343 | parameter_dump_packet.sy_lfr_pas_filter_shift[BYTE_0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_SHIFT + BYTE_0 ]; | |
344 | parameter_dump_packet.sy_lfr_pas_filter_shift[BYTE_1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_SHIFT + BYTE_1 ]; |
|
344 | parameter_dump_packet.sy_lfr_pas_filter_shift[BYTE_1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_SHIFT + BYTE_1 ]; | |
345 | parameter_dump_packet.sy_lfr_pas_filter_shift[BYTE_2] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_SHIFT + BYTE_2 ]; |
|
345 | parameter_dump_packet.sy_lfr_pas_filter_shift[BYTE_2] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_SHIFT + BYTE_2 ]; | |
346 | parameter_dump_packet.sy_lfr_pas_filter_shift[BYTE_3] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_SHIFT + BYTE_3 ]; |
|
346 | parameter_dump_packet.sy_lfr_pas_filter_shift[BYTE_3] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_SHIFT + BYTE_3 ]; | |
347 | parameter_dump_packet.sy_lfr_sc_rw_delta_f[BYTE_0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_SC_RW_DELTA_F + BYTE_0 ]; |
|
347 | parameter_dump_packet.sy_lfr_sc_rw_delta_f[BYTE_0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_SC_RW_DELTA_F + BYTE_0 ]; | |
348 | parameter_dump_packet.sy_lfr_sc_rw_delta_f[BYTE_1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_SC_RW_DELTA_F + BYTE_1 ]; |
|
348 | parameter_dump_packet.sy_lfr_sc_rw_delta_f[BYTE_1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_SC_RW_DELTA_F + BYTE_1 ]; | |
349 | parameter_dump_packet.sy_lfr_sc_rw_delta_f[BYTE_2] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_SC_RW_DELTA_F + BYTE_2 ]; |
|
349 | parameter_dump_packet.sy_lfr_sc_rw_delta_f[BYTE_2] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_SC_RW_DELTA_F + BYTE_2 ]; | |
350 | parameter_dump_packet.sy_lfr_sc_rw_delta_f[BYTE_3] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_SC_RW_DELTA_F + BYTE_3 ]; |
|
350 | parameter_dump_packet.sy_lfr_sc_rw_delta_f[BYTE_3] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_SC_RW_DELTA_F + BYTE_3 ]; | |
351 |
|
351 | |||
352 | //**************************** |
|
352 | //**************************** | |
353 | // store PAS filter parameters |
|
353 | // store PAS filter parameters | |
354 | // sy_lfr_pas_filter_enabled |
|
354 | // sy_lfr_pas_filter_enabled | |
355 | filterPar.spare_sy_lfr_pas_filter_enabled = parameter_dump_packet.spare_sy_lfr_pas_filter_enabled; |
|
355 | filterPar.spare_sy_lfr_pas_filter_enabled = parameter_dump_packet.spare_sy_lfr_pas_filter_enabled; | |
356 | set_sy_lfr_pas_filter_enabled( parameter_dump_packet.spare_sy_lfr_pas_filter_enabled & BIT_PAS_FILTER_ENABLED ); |
|
356 | set_sy_lfr_pas_filter_enabled( parameter_dump_packet.spare_sy_lfr_pas_filter_enabled & BIT_PAS_FILTER_ENABLED ); | |
357 | // sy_lfr_pas_filter_modulus |
|
357 | // sy_lfr_pas_filter_modulus | |
358 | filterPar.sy_lfr_pas_filter_modulus = parameter_dump_packet.sy_lfr_pas_filter_modulus; |
|
358 | filterPar.sy_lfr_pas_filter_modulus = parameter_dump_packet.sy_lfr_pas_filter_modulus; | |
359 | // sy_lfr_pas_filter_tbad |
|
359 | // sy_lfr_pas_filter_tbad | |
360 | copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_pas_filter_tbad, |
|
360 | copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_pas_filter_tbad, | |
361 | parameter_dump_packet.sy_lfr_pas_filter_tbad ); |
|
361 | parameter_dump_packet.sy_lfr_pas_filter_tbad ); | |
362 | // sy_lfr_pas_filter_offset |
|
362 | // sy_lfr_pas_filter_offset | |
363 | filterPar.sy_lfr_pas_filter_offset = parameter_dump_packet.sy_lfr_pas_filter_offset; |
|
363 | filterPar.sy_lfr_pas_filter_offset = parameter_dump_packet.sy_lfr_pas_filter_offset; | |
364 | // sy_lfr_pas_filter_shift |
|
364 | // sy_lfr_pas_filter_shift | |
365 | copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_pas_filter_shift, |
|
365 | copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_pas_filter_shift, | |
366 | parameter_dump_packet.sy_lfr_pas_filter_shift ); |
|
366 | parameter_dump_packet.sy_lfr_pas_filter_shift ); | |
367 |
|
367 | |||
368 | //**************************************************** |
|
368 | //**************************************************** | |
369 | // store the parameter sy_lfr_sc_rw_delta_f as a float |
|
369 | // store the parameter sy_lfr_sc_rw_delta_f as a float | |
370 | copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_sc_rw_delta_f, |
|
370 | copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_sc_rw_delta_f, | |
371 | parameter_dump_packet.sy_lfr_sc_rw_delta_f ); |
|
371 | parameter_dump_packet.sy_lfr_sc_rw_delta_f ); | |
372 |
|
372 | |||
373 | // copy rw.._k.. from the incoming TC to the local parameter_dump_packet |
|
373 | // copy rw.._k.. from the incoming TC to the local parameter_dump_packet | |
374 | for (k = 0; k < NB_RW_K_COEFFS * NB_BYTES_PER_RW_K_COEFF; k++) |
|
374 | for (k = 0; k < NB_RW_K_COEFFS * NB_BYTES_PER_RW_K_COEFF; k++) | |
375 | { |
|
375 | { | |
376 | parameter_dump_packet.sy_lfr_rw1_k1[k] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_RW1_K1 + k ]; |
|
376 | parameter_dump_packet.sy_lfr_rw1_k1[k] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_RW1_K1 + k ]; | |
377 | } |
|
377 | } | |
378 |
|
378 | |||
379 | //*********************************************** |
|
379 | //*********************************************** | |
380 | // store the parameter sy_lfr_rw.._k.. as a float |
|
380 | // store the parameter sy_lfr_rw.._k.. as a float | |
381 | // rw1_k |
|
381 | // rw1_k | |
382 | copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw1_k1, parameter_dump_packet.sy_lfr_rw1_k1 ); |
|
382 | copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw1_k1, parameter_dump_packet.sy_lfr_rw1_k1 ); | |
383 | copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw1_k2, parameter_dump_packet.sy_lfr_rw1_k2 ); |
|
383 | copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw1_k2, parameter_dump_packet.sy_lfr_rw1_k2 ); | |
384 | copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw1_k3, parameter_dump_packet.sy_lfr_rw1_k3 ); |
|
384 | copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw1_k3, parameter_dump_packet.sy_lfr_rw1_k3 ); | |
385 | copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw1_k4, parameter_dump_packet.sy_lfr_rw1_k4 ); |
|
385 | copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw1_k4, parameter_dump_packet.sy_lfr_rw1_k4 ); | |
386 | // rw2_k |
|
386 | // rw2_k | |
387 | copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw2_k1, parameter_dump_packet.sy_lfr_rw2_k1 ); |
|
387 | copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw2_k1, parameter_dump_packet.sy_lfr_rw2_k1 ); | |
388 | copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw2_k2, parameter_dump_packet.sy_lfr_rw2_k2 ); |
|
388 | copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw2_k2, parameter_dump_packet.sy_lfr_rw2_k2 ); | |
389 | copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw2_k3, parameter_dump_packet.sy_lfr_rw2_k3 ); |
|
389 | copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw2_k3, parameter_dump_packet.sy_lfr_rw2_k3 ); | |
390 | copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw2_k4, parameter_dump_packet.sy_lfr_rw2_k4 ); |
|
390 | copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw2_k4, parameter_dump_packet.sy_lfr_rw2_k4 ); | |
391 | // rw3_k |
|
391 | // rw3_k | |
392 | copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw3_k1, parameter_dump_packet.sy_lfr_rw3_k1 ); |
|
392 | copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw3_k1, parameter_dump_packet.sy_lfr_rw3_k1 ); | |
393 | copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw3_k2, parameter_dump_packet.sy_lfr_rw3_k2 ); |
|
393 | copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw3_k2, parameter_dump_packet.sy_lfr_rw3_k2 ); | |
394 | copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw3_k3, parameter_dump_packet.sy_lfr_rw3_k3 ); |
|
394 | copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw3_k3, parameter_dump_packet.sy_lfr_rw3_k3 ); | |
395 | copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw3_k4, parameter_dump_packet.sy_lfr_rw3_k4 ); |
|
395 | copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw3_k4, parameter_dump_packet.sy_lfr_rw3_k4 ); | |
396 | // rw4_k |
|
396 | // rw4_k | |
397 | copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw4_k1, parameter_dump_packet.sy_lfr_rw4_k1 ); |
|
397 | copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw4_k1, parameter_dump_packet.sy_lfr_rw4_k1 ); | |
398 | copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw4_k2, parameter_dump_packet.sy_lfr_rw4_k2 ); |
|
398 | copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw4_k2, parameter_dump_packet.sy_lfr_rw4_k2 ); | |
399 | copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw4_k3, parameter_dump_packet.sy_lfr_rw4_k3 ); |
|
399 | copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw4_k3, parameter_dump_packet.sy_lfr_rw4_k3 ); | |
400 | copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw4_k4, parameter_dump_packet.sy_lfr_rw4_k4 ); |
|
400 | copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw4_k4, parameter_dump_packet.sy_lfr_rw4_k4 ); | |
401 |
|
401 | |||
402 | } |
|
402 | } | |
403 |
|
403 | |||
404 | return flag; |
|
404 | return flag; | |
405 | } |
|
405 | } | |
406 |
|
406 | |||
407 | int action_dump_kcoefficients(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) |
|
407 | int action_dump_kcoefficients(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) | |
408 | { |
|
408 | { | |
409 | /** This function updates the LFR registers with the incoming sbm2 parameters. |
|
409 | /** This function updates the LFR registers with the incoming sbm2 parameters. | |
410 | * |
|
410 | * | |
411 | * @param TC points to the TeleCommand packet that is being processed |
|
411 | * @param TC points to the TeleCommand packet that is being processed | |
412 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
412 | * @param queue_id is the id of the queue which handles TM related to this execution step | |
413 | * |
|
413 | * | |
414 | */ |
|
414 | */ | |
415 |
|
415 | |||
416 | unsigned int address; |
|
416 | unsigned int address; | |
417 | rtems_status_code status; |
|
417 | rtems_status_code status; | |
418 | unsigned int freq; |
|
418 | unsigned int freq; | |
419 | unsigned int bin; |
|
419 | unsigned int bin; | |
420 | unsigned int coeff; |
|
420 | unsigned int coeff; | |
421 | unsigned char *kCoeffPtr; |
|
421 | unsigned char *kCoeffPtr; | |
422 | unsigned char *kCoeffDumpPtr; |
|
422 | unsigned char *kCoeffDumpPtr; | |
423 |
|
423 | |||
424 | // for each sy_lfr_kcoeff_frequency there is 32 kcoeff |
|
424 | // for each sy_lfr_kcoeff_frequency there is 32 kcoeff | |
425 | // F0 => 11 bins |
|
425 | // F0 => 11 bins | |
426 | // F1 => 13 bins |
|
426 | // F1 => 13 bins | |
427 | // F2 => 12 bins |
|
427 | // F2 => 12 bins | |
428 | // 36 bins to dump in two packets (30 bins max per packet) |
|
428 | // 36 bins to dump in two packets (30 bins max per packet) | |
429 |
|
429 | |||
430 | //********* |
|
430 | //********* | |
431 | // PACKET 1 |
|
431 | // PACKET 1 | |
432 | // 11 F0 bins, 13 F1 bins and 6 F2 bins |
|
432 | // 11 F0 bins, 13 F1 bins and 6 F2 bins | |
433 | kcoefficients_dump_1.destinationID = TC->sourceID; |
|
433 | kcoefficients_dump_1.destinationID = TC->sourceID; | |
434 | increment_seq_counter_destination_id_dump( kcoefficients_dump_1.packetSequenceControl, TC->sourceID ); |
|
434 | increment_seq_counter_destination_id_dump( kcoefficients_dump_1.packetSequenceControl, TC->sourceID ); | |
435 | for( freq = 0; |
|
435 | for( freq = 0; | |
436 | freq < NB_BINS_COMPRESSED_SM_F0; |
|
436 | freq < NB_BINS_COMPRESSED_SM_F0; | |
437 | freq++ ) |
|
437 | freq++ ) | |
438 | { |
|
438 | { | |
439 | kcoefficients_dump_1.kcoeff_blks[ (freq*KCOEFF_BLK_SIZE) + 1] = freq; |
|
439 | kcoefficients_dump_1.kcoeff_blks[ (freq*KCOEFF_BLK_SIZE) + 1] = freq; | |
440 | bin = freq; |
|
440 | bin = freq; | |
441 | // printKCoefficients( freq, bin, k_coeff_intercalib_f0_norm); |
|
441 | // printKCoefficients( freq, bin, k_coeff_intercalib_f0_norm); | |
442 | for ( coeff=0; coeff<NB_K_COEFF_PER_BIN; coeff++ ) |
|
442 | for ( coeff=0; coeff<NB_K_COEFF_PER_BIN; coeff++ ) | |
443 | { |
|
443 | { | |
444 | kCoeffDumpPtr = (unsigned char*) &kcoefficients_dump_1.kcoeff_blks[ |
|
444 | kCoeffDumpPtr = (unsigned char*) &kcoefficients_dump_1.kcoeff_blks[ | |
445 | (freq*KCOEFF_BLK_SIZE) + (coeff*NB_BYTES_PER_FLOAT) + KCOEFF_FREQ |
|
445 | (freq*KCOEFF_BLK_SIZE) + (coeff*NB_BYTES_PER_FLOAT) + KCOEFF_FREQ | |
446 | ]; // 2 for the kcoeff_frequency |
|
446 | ]; // 2 for the kcoeff_frequency | |
447 | kCoeffPtr = (unsigned char*) &k_coeff_intercalib_f0_norm[ (bin*NB_K_COEFF_PER_BIN) + coeff ]; |
|
447 | kCoeffPtr = (unsigned char*) &k_coeff_intercalib_f0_norm[ (bin*NB_K_COEFF_PER_BIN) + coeff ]; | |
448 | copyFloatByChar( kCoeffDumpPtr, kCoeffPtr ); |
|
448 | copyFloatByChar( kCoeffDumpPtr, kCoeffPtr ); | |
449 | } |
|
449 | } | |
450 | } |
|
450 | } | |
451 | for( freq = NB_BINS_COMPRESSED_SM_F0; |
|
451 | for( freq = NB_BINS_COMPRESSED_SM_F0; | |
452 | freq < ( NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1 ); |
|
452 | freq < ( NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1 ); | |
453 | freq++ ) |
|
453 | freq++ ) | |
454 | { |
|
454 | { | |
455 | kcoefficients_dump_1.kcoeff_blks[ (freq*KCOEFF_BLK_SIZE) + 1 ] = freq; |
|
455 | kcoefficients_dump_1.kcoeff_blks[ (freq*KCOEFF_BLK_SIZE) + 1 ] = freq; | |
456 | bin = freq - NB_BINS_COMPRESSED_SM_F0; |
|
456 | bin = freq - NB_BINS_COMPRESSED_SM_F0; | |
457 | // printKCoefficients( freq, bin, k_coeff_intercalib_f1_norm); |
|
457 | // printKCoefficients( freq, bin, k_coeff_intercalib_f1_norm); | |
458 | for ( coeff=0; coeff<NB_K_COEFF_PER_BIN; coeff++ ) |
|
458 | for ( coeff=0; coeff<NB_K_COEFF_PER_BIN; coeff++ ) | |
459 | { |
|
459 | { | |
460 | kCoeffDumpPtr = (unsigned char*) &kcoefficients_dump_1.kcoeff_blks[ |
|
460 | kCoeffDumpPtr = (unsigned char*) &kcoefficients_dump_1.kcoeff_blks[ | |
461 | (freq*KCOEFF_BLK_SIZE) + (coeff*NB_BYTES_PER_FLOAT) + KCOEFF_FREQ |
|
461 | (freq*KCOEFF_BLK_SIZE) + (coeff*NB_BYTES_PER_FLOAT) + KCOEFF_FREQ | |
462 | ]; // 2 for the kcoeff_frequency |
|
462 | ]; // 2 for the kcoeff_frequency | |
463 | kCoeffPtr = (unsigned char*) &k_coeff_intercalib_f1_norm[ (bin*NB_K_COEFF_PER_BIN) + coeff ]; |
|
463 | kCoeffPtr = (unsigned char*) &k_coeff_intercalib_f1_norm[ (bin*NB_K_COEFF_PER_BIN) + coeff ]; | |
464 | copyFloatByChar( kCoeffDumpPtr, kCoeffPtr ); |
|
464 | copyFloatByChar( kCoeffDumpPtr, kCoeffPtr ); | |
465 | } |
|
465 | } | |
466 | } |
|
466 | } | |
467 | for( freq = ( NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1 ); |
|
467 | for( freq = ( NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1 ); | |
468 | freq < KCOEFF_BLK_NR_PKT1 ; |
|
468 | freq < KCOEFF_BLK_NR_PKT1 ; | |
469 | freq++ ) |
|
469 | freq++ ) | |
470 | { |
|
470 | { | |
471 | kcoefficients_dump_1.kcoeff_blks[ (freq * KCOEFF_BLK_SIZE) + 1 ] = freq; |
|
471 | kcoefficients_dump_1.kcoeff_blks[ (freq * KCOEFF_BLK_SIZE) + 1 ] = freq; | |
472 | bin = freq - (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1); |
|
472 | bin = freq - (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1); | |
473 | // printKCoefficients( freq, bin, k_coeff_intercalib_f2); |
|
473 | // printKCoefficients( freq, bin, k_coeff_intercalib_f2); | |
474 | for ( coeff = 0; coeff <NB_K_COEFF_PER_BIN; coeff++ ) |
|
474 | for ( coeff = 0; coeff <NB_K_COEFF_PER_BIN; coeff++ ) | |
475 | { |
|
475 | { | |
476 | kCoeffDumpPtr = (unsigned char*) &kcoefficients_dump_1.kcoeff_blks[ |
|
476 | kCoeffDumpPtr = (unsigned char*) &kcoefficients_dump_1.kcoeff_blks[ | |
477 | (freq * KCOEFF_BLK_SIZE) + (coeff * NB_BYTES_PER_FLOAT) + KCOEFF_FREQ |
|
477 | (freq * KCOEFF_BLK_SIZE) + (coeff * NB_BYTES_PER_FLOAT) + KCOEFF_FREQ | |
478 | ]; // 2 for the kcoeff_frequency |
|
478 | ]; // 2 for the kcoeff_frequency | |
479 | kCoeffPtr = (unsigned char*) &k_coeff_intercalib_f2[ (bin*NB_K_COEFF_PER_BIN) + coeff ]; |
|
479 | kCoeffPtr = (unsigned char*) &k_coeff_intercalib_f2[ (bin*NB_K_COEFF_PER_BIN) + coeff ]; | |
480 | copyFloatByChar( kCoeffDumpPtr, kCoeffPtr ); |
|
480 | copyFloatByChar( kCoeffDumpPtr, kCoeffPtr ); | |
481 | } |
|
481 | } | |
482 | } |
|
482 | } | |
483 | kcoefficients_dump_1.time[BYTE_0] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_3_BYTES); |
|
483 | kcoefficients_dump_1.time[BYTE_0] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_3_BYTES); | |
484 | kcoefficients_dump_1.time[BYTE_1] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_2_BYTES); |
|
484 | kcoefficients_dump_1.time[BYTE_1] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_2_BYTES); | |
485 | kcoefficients_dump_1.time[BYTE_2] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_1_BYTE); |
|
485 | kcoefficients_dump_1.time[BYTE_2] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_1_BYTE); | |
486 | kcoefficients_dump_1.time[BYTE_3] = (unsigned char) (time_management_regs->coarse_time); |
|
486 | kcoefficients_dump_1.time[BYTE_3] = (unsigned char) (time_management_regs->coarse_time); | |
487 | kcoefficients_dump_1.time[BYTE_4] = (unsigned char) (time_management_regs->fine_time >> SHIFT_1_BYTE); |
|
487 | kcoefficients_dump_1.time[BYTE_4] = (unsigned char) (time_management_regs->fine_time >> SHIFT_1_BYTE); | |
488 | kcoefficients_dump_1.time[BYTE_5] = (unsigned char) (time_management_regs->fine_time); |
|
488 | kcoefficients_dump_1.time[BYTE_5] = (unsigned char) (time_management_regs->fine_time); | |
489 | // SEND DATA |
|
489 | // SEND DATA | |
490 | kcoefficient_node_1.status = 1; |
|
490 | kcoefficient_node_1.status = 1; | |
491 | address = (unsigned int) &kcoefficient_node_1; |
|
491 | address = (unsigned int) &kcoefficient_node_1; | |
492 | status = rtems_message_queue_send( queue_id, &address, sizeof( ring_node* ) ); |
|
492 | status = rtems_message_queue_send( queue_id, &address, sizeof( ring_node* ) ); | |
493 | if (status != RTEMS_SUCCESSFUL) { |
|
493 | if (status != RTEMS_SUCCESSFUL) { | |
494 | PRINTF1("in action_dump_kcoefficients *** ERR sending packet 1 , code %d", status) |
|
494 | PRINTF1("in action_dump_kcoefficients *** ERR sending packet 1 , code %d", status) | |
495 | } |
|
495 | } | |
496 |
|
496 | |||
497 | //******** |
|
497 | //******** | |
498 | // PACKET 2 |
|
498 | // PACKET 2 | |
499 | // 6 F2 bins |
|
499 | // 6 F2 bins | |
500 | kcoefficients_dump_2.destinationID = TC->sourceID; |
|
500 | kcoefficients_dump_2.destinationID = TC->sourceID; | |
501 | increment_seq_counter_destination_id_dump( kcoefficients_dump_2.packetSequenceControl, TC->sourceID ); |
|
501 | increment_seq_counter_destination_id_dump( kcoefficients_dump_2.packetSequenceControl, TC->sourceID ); | |
502 | for( freq = 0; |
|
502 | for( freq = 0; | |
503 | freq < KCOEFF_BLK_NR_PKT2; |
|
503 | freq < KCOEFF_BLK_NR_PKT2; | |
504 | freq++ ) |
|
504 | freq++ ) | |
505 | { |
|
505 | { | |
506 | kcoefficients_dump_2.kcoeff_blks[ (freq*KCOEFF_BLK_SIZE) + 1 ] = KCOEFF_BLK_NR_PKT1 + freq; |
|
506 | kcoefficients_dump_2.kcoeff_blks[ (freq*KCOEFF_BLK_SIZE) + 1 ] = KCOEFF_BLK_NR_PKT1 + freq; | |
507 | bin = freq + KCOEFF_BLK_NR_PKT2; |
|
507 | bin = freq + KCOEFF_BLK_NR_PKT2; | |
508 | // printKCoefficients( freq, bin, k_coeff_intercalib_f2); |
|
508 | // printKCoefficients( freq, bin, k_coeff_intercalib_f2); | |
509 | for ( coeff=0; coeff<NB_K_COEFF_PER_BIN; coeff++ ) |
|
509 | for ( coeff=0; coeff<NB_K_COEFF_PER_BIN; coeff++ ) | |
510 | { |
|
510 | { | |
511 | kCoeffDumpPtr = (unsigned char*) &kcoefficients_dump_2.kcoeff_blks[ |
|
511 | kCoeffDumpPtr = (unsigned char*) &kcoefficients_dump_2.kcoeff_blks[ | |
512 | (freq*KCOEFF_BLK_SIZE) + (coeff*NB_BYTES_PER_FLOAT) + KCOEFF_FREQ ]; // 2 for the kcoeff_frequency |
|
512 | (freq*KCOEFF_BLK_SIZE) + (coeff*NB_BYTES_PER_FLOAT) + KCOEFF_FREQ ]; // 2 for the kcoeff_frequency | |
513 | kCoeffPtr = (unsigned char*) &k_coeff_intercalib_f2[ (bin*NB_K_COEFF_PER_BIN) + coeff ]; |
|
513 | kCoeffPtr = (unsigned char*) &k_coeff_intercalib_f2[ (bin*NB_K_COEFF_PER_BIN) + coeff ]; | |
514 | copyFloatByChar( kCoeffDumpPtr, kCoeffPtr ); |
|
514 | copyFloatByChar( kCoeffDumpPtr, kCoeffPtr ); | |
515 | } |
|
515 | } | |
516 | } |
|
516 | } | |
517 | kcoefficients_dump_2.time[BYTE_0] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_3_BYTES); |
|
517 | kcoefficients_dump_2.time[BYTE_0] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_3_BYTES); | |
518 | kcoefficients_dump_2.time[BYTE_1] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_2_BYTES); |
|
518 | kcoefficients_dump_2.time[BYTE_1] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_2_BYTES); | |
519 | kcoefficients_dump_2.time[BYTE_2] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_1_BYTE); |
|
519 | kcoefficients_dump_2.time[BYTE_2] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_1_BYTE); | |
520 | kcoefficients_dump_2.time[BYTE_3] = (unsigned char) (time_management_regs->coarse_time); |
|
520 | kcoefficients_dump_2.time[BYTE_3] = (unsigned char) (time_management_regs->coarse_time); | |
521 | kcoefficients_dump_2.time[BYTE_4] = (unsigned char) (time_management_regs->fine_time >> SHIFT_1_BYTE); |
|
521 | kcoefficients_dump_2.time[BYTE_4] = (unsigned char) (time_management_regs->fine_time >> SHIFT_1_BYTE); | |
522 | kcoefficients_dump_2.time[BYTE_5] = (unsigned char) (time_management_regs->fine_time); |
|
522 | kcoefficients_dump_2.time[BYTE_5] = (unsigned char) (time_management_regs->fine_time); | |
523 | // SEND DATA |
|
523 | // SEND DATA | |
524 | kcoefficient_node_2.status = 1; |
|
524 | kcoefficient_node_2.status = 1; | |
525 | address = (unsigned int) &kcoefficient_node_2; |
|
525 | address = (unsigned int) &kcoefficient_node_2; | |
526 | status = rtems_message_queue_send( queue_id, &address, sizeof( ring_node* ) ); |
|
526 | status = rtems_message_queue_send( queue_id, &address, sizeof( ring_node* ) ); | |
527 | if (status != RTEMS_SUCCESSFUL) { |
|
527 | if (status != RTEMS_SUCCESSFUL) { | |
528 | PRINTF1("in action_dump_kcoefficients *** ERR sending packet 2, code %d", status) |
|
528 | PRINTF1("in action_dump_kcoefficients *** ERR sending packet 2, code %d", status) | |
529 | } |
|
529 | } | |
530 |
|
530 | |||
531 | return status; |
|
531 | return status; | |
532 | } |
|
532 | } | |
533 |
|
533 | |||
534 | int action_dump_par( ccsdsTelecommandPacket_t *TC, rtems_id queue_id ) |
|
534 | int action_dump_par( ccsdsTelecommandPacket_t *TC, rtems_id queue_id ) | |
535 | { |
|
535 | { | |
536 | /** This function dumps the LFR parameters by sending the appropriate TM packet to the dedicated RTEMS message queue. |
|
536 | /** This function dumps the LFR parameters by sending the appropriate TM packet to the dedicated RTEMS message queue. | |
537 | * |
|
537 | * | |
538 | * @param queue_id is the id of the queue which handles TM related to this execution step. |
|
538 | * @param queue_id is the id of the queue which handles TM related to this execution step. | |
539 | * |
|
539 | * | |
540 | * @return RTEMS directive status codes: |
|
540 | * @return RTEMS directive status codes: | |
541 | * - RTEMS_SUCCESSFUL - message sent successfully |
|
541 | * - RTEMS_SUCCESSFUL - message sent successfully | |
542 | * - RTEMS_INVALID_ID - invalid queue id |
|
542 | * - RTEMS_INVALID_ID - invalid queue id | |
543 | * - RTEMS_INVALID_SIZE - invalid message size |
|
543 | * - RTEMS_INVALID_SIZE - invalid message size | |
544 | * - RTEMS_INVALID_ADDRESS - buffer is NULL |
|
544 | * - RTEMS_INVALID_ADDRESS - buffer is NULL | |
545 | * - RTEMS_UNSATISFIED - out of message buffers |
|
545 | * - RTEMS_UNSATISFIED - out of message buffers | |
546 | * - RTEMS_TOO_MANY - queue s limit has been reached |
|
546 | * - RTEMS_TOO_MANY - queue s limit has been reached | |
547 | * |
|
547 | * | |
548 | */ |
|
548 | */ | |
549 |
|
549 | |||
550 | int status; |
|
550 | int status; | |
551 |
|
551 | |||
552 | increment_seq_counter_destination_id_dump( parameter_dump_packet.packetSequenceControl, TC->sourceID ); |
|
552 | increment_seq_counter_destination_id_dump( parameter_dump_packet.packetSequenceControl, TC->sourceID ); | |
553 | parameter_dump_packet.destinationID = TC->sourceID; |
|
553 | parameter_dump_packet.destinationID = TC->sourceID; | |
554 |
|
554 | |||
555 | // UPDATE TIME |
|
555 | // UPDATE TIME | |
556 | parameter_dump_packet.time[BYTE_0] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_3_BYTES); |
|
556 | parameter_dump_packet.time[BYTE_0] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_3_BYTES); | |
557 | parameter_dump_packet.time[BYTE_1] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_2_BYTES); |
|
557 | parameter_dump_packet.time[BYTE_1] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_2_BYTES); | |
558 | parameter_dump_packet.time[BYTE_2] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_1_BYTE); |
|
558 | parameter_dump_packet.time[BYTE_2] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_1_BYTE); | |
559 | parameter_dump_packet.time[BYTE_3] = (unsigned char) (time_management_regs->coarse_time); |
|
559 | parameter_dump_packet.time[BYTE_3] = (unsigned char) (time_management_regs->coarse_time); | |
560 | parameter_dump_packet.time[BYTE_4] = (unsigned char) (time_management_regs->fine_time >> SHIFT_1_BYTE); |
|
560 | parameter_dump_packet.time[BYTE_4] = (unsigned char) (time_management_regs->fine_time >> SHIFT_1_BYTE); | |
561 | parameter_dump_packet.time[BYTE_5] = (unsigned char) (time_management_regs->fine_time); |
|
561 | parameter_dump_packet.time[BYTE_5] = (unsigned char) (time_management_regs->fine_time); | |
562 | // SEND DATA |
|
562 | // SEND DATA | |
563 | status = rtems_message_queue_send( queue_id, ¶meter_dump_packet, |
|
563 | status = rtems_message_queue_send( queue_id, ¶meter_dump_packet, | |
564 | PACKET_LENGTH_PARAMETER_DUMP + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES); |
|
564 | PACKET_LENGTH_PARAMETER_DUMP + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES); | |
565 | if (status != RTEMS_SUCCESSFUL) { |
|
565 | if (status != RTEMS_SUCCESSFUL) { | |
566 | PRINTF1("in action_dump *** ERR sending packet, code %d", status) |
|
566 | PRINTF1("in action_dump *** ERR sending packet, code %d", status) | |
567 | } |
|
567 | } | |
568 |
|
568 | |||
569 | return status; |
|
569 | return status; | |
570 | } |
|
570 | } | |
571 |
|
571 | |||
572 | //*********************** |
|
572 | //*********************** | |
573 | // NORMAL MODE PARAMETERS |
|
573 | // NORMAL MODE PARAMETERS | |
574 |
|
574 | |||
575 | int check_normal_par_consistency( ccsdsTelecommandPacket_t *TC, rtems_id queue_id ) |
|
575 | int check_normal_par_consistency( ccsdsTelecommandPacket_t *TC, rtems_id queue_id ) | |
576 | { |
|
576 | { | |
577 | unsigned char msb; |
|
577 | unsigned char msb; | |
578 | unsigned char lsb; |
|
578 | unsigned char lsb; | |
579 | int flag; |
|
579 | int flag; | |
580 | float aux; |
|
580 | float aux; | |
581 | rtems_status_code status; |
|
581 | rtems_status_code status; | |
582 |
|
582 | |||
583 | unsigned int sy_lfr_n_swf_l; |
|
583 | unsigned int sy_lfr_n_swf_l; | |
584 | unsigned int sy_lfr_n_swf_p; |
|
584 | unsigned int sy_lfr_n_swf_p; | |
585 | unsigned int sy_lfr_n_asm_p; |
|
585 | unsigned int sy_lfr_n_asm_p; | |
586 | unsigned char sy_lfr_n_bp_p0; |
|
586 | unsigned char sy_lfr_n_bp_p0; | |
587 | unsigned char sy_lfr_n_bp_p1; |
|
587 | unsigned char sy_lfr_n_bp_p1; | |
588 | unsigned char sy_lfr_n_cwf_long_f3; |
|
588 | unsigned char sy_lfr_n_cwf_long_f3; | |
589 |
|
589 | |||
590 | flag = LFR_SUCCESSFUL; |
|
590 | flag = LFR_SUCCESSFUL; | |
591 |
|
591 | |||
592 | //*************** |
|
592 | //*************** | |
593 | // get parameters |
|
593 | // get parameters | |
594 | msb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L ]; |
|
594 | msb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L ]; | |
595 | lsb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L+1 ]; |
|
595 | lsb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L+1 ]; | |
596 | sy_lfr_n_swf_l = (msb * CONST_256) + lsb; |
|
596 | sy_lfr_n_swf_l = (msb * CONST_256) + lsb; | |
597 |
|
597 | |||
598 | msb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P ]; |
|
598 | msb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P ]; | |
599 | lsb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P+1 ]; |
|
599 | lsb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P+1 ]; | |
600 | sy_lfr_n_swf_p = (msb * CONST_256) + lsb; |
|
600 | sy_lfr_n_swf_p = (msb * CONST_256) + lsb; | |
601 |
|
601 | |||
602 | msb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P ]; |
|
602 | msb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P ]; | |
603 | lsb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P+1 ]; |
|
603 | lsb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P+1 ]; | |
604 | sy_lfr_n_asm_p = (msb * CONST_256) + lsb; |
|
604 | sy_lfr_n_asm_p = (msb * CONST_256) + lsb; | |
605 |
|
605 | |||
606 | sy_lfr_n_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P0 ]; |
|
606 | sy_lfr_n_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P0 ]; | |
607 |
|
607 | |||
608 | sy_lfr_n_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P1 ]; |
|
608 | sy_lfr_n_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P1 ]; | |
609 |
|
609 | |||
610 | sy_lfr_n_cwf_long_f3 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_CWF_LONG_F3 ]; |
|
610 | sy_lfr_n_cwf_long_f3 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_CWF_LONG_F3 ]; | |
611 |
|
611 | |||
612 | //****************** |
|
612 | //****************** | |
613 | // check consistency |
|
613 | // check consistency | |
614 | // sy_lfr_n_swf_l |
|
614 | // sy_lfr_n_swf_l | |
615 | if (sy_lfr_n_swf_l != DFLT_SY_LFR_N_SWF_L) |
|
615 | if (sy_lfr_n_swf_l != DFLT_SY_LFR_N_SWF_L) | |
616 | { |
|
616 | { | |
617 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_SWF_L + DATAFIELD_OFFSET, sy_lfr_n_swf_l ); |
|
617 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_SWF_L + DATAFIELD_OFFSET, sy_lfr_n_swf_l ); | |
618 | flag = WRONG_APP_DATA; |
|
618 | flag = WRONG_APP_DATA; | |
619 | } |
|
619 | } | |
620 | // sy_lfr_n_swf_p |
|
620 | // sy_lfr_n_swf_p | |
621 | if (flag == LFR_SUCCESSFUL) |
|
621 | if (flag == LFR_SUCCESSFUL) | |
622 | { |
|
622 | { | |
623 | if ( sy_lfr_n_swf_p < MIN_SY_LFR_N_SWF_P ) |
|
623 | if ( sy_lfr_n_swf_p < MIN_SY_LFR_N_SWF_P ) | |
624 | { |
|
624 | { | |
625 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_SWF_P + DATAFIELD_OFFSET, sy_lfr_n_swf_p ); |
|
625 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_SWF_P + DATAFIELD_OFFSET, sy_lfr_n_swf_p ); | |
626 | flag = WRONG_APP_DATA; |
|
626 | flag = WRONG_APP_DATA; | |
627 | } |
|
627 | } | |
628 | } |
|
628 | } | |
629 | // sy_lfr_n_bp_p0 |
|
629 | // sy_lfr_n_bp_p0 | |
630 | if (flag == LFR_SUCCESSFUL) |
|
630 | if (flag == LFR_SUCCESSFUL) | |
631 | { |
|
631 | { | |
632 | if (sy_lfr_n_bp_p0 < DFLT_SY_LFR_N_BP_P0) |
|
632 | if (sy_lfr_n_bp_p0 < DFLT_SY_LFR_N_BP_P0) | |
633 | { |
|
633 | { | |
634 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_BP_P0 + DATAFIELD_OFFSET, sy_lfr_n_bp_p0 ); |
|
634 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_BP_P0 + DATAFIELD_OFFSET, sy_lfr_n_bp_p0 ); | |
635 | flag = WRONG_APP_DATA; |
|
635 | flag = WRONG_APP_DATA; | |
636 | } |
|
636 | } | |
637 | } |
|
637 | } | |
638 | // sy_lfr_n_asm_p |
|
638 | // sy_lfr_n_asm_p | |
639 | if (flag == LFR_SUCCESSFUL) |
|
639 | if (flag == LFR_SUCCESSFUL) | |
640 | { |
|
640 | { | |
641 | if (sy_lfr_n_asm_p == 0) |
|
641 | if (sy_lfr_n_asm_p == 0) | |
642 | { |
|
642 | { | |
643 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_ASM_P + DATAFIELD_OFFSET, sy_lfr_n_asm_p ); |
|
643 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_ASM_P + DATAFIELD_OFFSET, sy_lfr_n_asm_p ); | |
644 | flag = WRONG_APP_DATA; |
|
644 | flag = WRONG_APP_DATA; | |
645 | } |
|
645 | } | |
646 | } |
|
646 | } | |
647 | // sy_lfr_n_asm_p shall be a whole multiple of sy_lfr_n_bp_p0 |
|
647 | // sy_lfr_n_asm_p shall be a whole multiple of sy_lfr_n_bp_p0 | |
648 | if (flag == LFR_SUCCESSFUL) |
|
648 | if (flag == LFR_SUCCESSFUL) | |
649 | { |
|
649 | { | |
650 | aux = ( (float ) sy_lfr_n_asm_p / sy_lfr_n_bp_p0 ) - floor(sy_lfr_n_asm_p / sy_lfr_n_bp_p0); |
|
650 | aux = ( (float ) sy_lfr_n_asm_p / sy_lfr_n_bp_p0 ) - floor(sy_lfr_n_asm_p / sy_lfr_n_bp_p0); | |
651 | if (aux > FLOAT_EQUAL_ZERO) |
|
651 | if (aux > FLOAT_EQUAL_ZERO) | |
652 | { |
|
652 | { | |
653 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_ASM_P + DATAFIELD_OFFSET, sy_lfr_n_asm_p ); |
|
653 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_ASM_P + DATAFIELD_OFFSET, sy_lfr_n_asm_p ); | |
654 | flag = WRONG_APP_DATA; |
|
654 | flag = WRONG_APP_DATA; | |
655 | } |
|
655 | } | |
656 | } |
|
656 | } | |
657 | // sy_lfr_n_bp_p1 |
|
657 | // sy_lfr_n_bp_p1 | |
658 | if (flag == LFR_SUCCESSFUL) |
|
658 | if (flag == LFR_SUCCESSFUL) | |
659 | { |
|
659 | { | |
660 | if (sy_lfr_n_bp_p1 < DFLT_SY_LFR_N_BP_P1) |
|
660 | if (sy_lfr_n_bp_p1 < DFLT_SY_LFR_N_BP_P1) | |
661 | { |
|
661 | { | |
662 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_BP_P1 + DATAFIELD_OFFSET, sy_lfr_n_bp_p1 ); |
|
662 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_BP_P1 + DATAFIELD_OFFSET, sy_lfr_n_bp_p1 ); | |
663 | flag = WRONG_APP_DATA; |
|
663 | flag = WRONG_APP_DATA; | |
664 | } |
|
664 | } | |
665 | } |
|
665 | } | |
666 | // sy_lfr_n_bp_p1 shall be a whole multiple of sy_lfr_n_bp_p0 |
|
666 | // sy_lfr_n_bp_p1 shall be a whole multiple of sy_lfr_n_bp_p0 | |
667 | if (flag == LFR_SUCCESSFUL) |
|
667 | if (flag == LFR_SUCCESSFUL) | |
668 | { |
|
668 | { | |
669 | aux = ( (float ) sy_lfr_n_bp_p1 / sy_lfr_n_bp_p0 ) - floor(sy_lfr_n_bp_p1 / sy_lfr_n_bp_p0); |
|
669 | aux = ( (float ) sy_lfr_n_bp_p1 / sy_lfr_n_bp_p0 ) - floor(sy_lfr_n_bp_p1 / sy_lfr_n_bp_p0); | |
670 | if (aux > FLOAT_EQUAL_ZERO) |
|
670 | if (aux > FLOAT_EQUAL_ZERO) | |
671 | { |
|
671 | { | |
672 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_BP_P1 + DATAFIELD_OFFSET, sy_lfr_n_bp_p1 ); |
|
672 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_BP_P1 + DATAFIELD_OFFSET, sy_lfr_n_bp_p1 ); | |
673 | flag = LFR_DEFAULT; |
|
673 | flag = LFR_DEFAULT; | |
674 | } |
|
674 | } | |
675 | } |
|
675 | } | |
676 | // sy_lfr_n_cwf_long_f3 |
|
676 | // sy_lfr_n_cwf_long_f3 | |
677 |
|
677 | |||
678 | return flag; |
|
678 | return flag; | |
679 | } |
|
679 | } | |
680 |
|
680 | |||
681 | int set_sy_lfr_n_swf_l( ccsdsTelecommandPacket_t *TC ) |
|
681 | int set_sy_lfr_n_swf_l( ccsdsTelecommandPacket_t *TC ) | |
682 | { |
|
682 | { | |
683 | /** This function sets the number of points of a snapshot (sy_lfr_n_swf_l). |
|
683 | /** This function sets the number of points of a snapshot (sy_lfr_n_swf_l). | |
684 | * |
|
684 | * | |
685 | * @param TC points to the TeleCommand packet that is being processed |
|
685 | * @param TC points to the TeleCommand packet that is being processed | |
686 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
686 | * @param queue_id is the id of the queue which handles TM related to this execution step | |
687 | * |
|
687 | * | |
688 | */ |
|
688 | */ | |
689 |
|
689 | |||
690 | int result; |
|
690 | int result; | |
691 |
|
691 | |||
692 | result = LFR_SUCCESSFUL; |
|
692 | result = LFR_SUCCESSFUL; | |
693 |
|
693 | |||
694 | parameter_dump_packet.sy_lfr_n_swf_l[0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L ]; |
|
694 | parameter_dump_packet.sy_lfr_n_swf_l[0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L ]; | |
695 | parameter_dump_packet.sy_lfr_n_swf_l[1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L+1 ]; |
|
695 | parameter_dump_packet.sy_lfr_n_swf_l[1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L+1 ]; | |
696 |
|
696 | |||
697 | return result; |
|
697 | return result; | |
698 | } |
|
698 | } | |
699 |
|
699 | |||
700 | int set_sy_lfr_n_swf_p(ccsdsTelecommandPacket_t *TC ) |
|
700 | int set_sy_lfr_n_swf_p(ccsdsTelecommandPacket_t *TC ) | |
701 | { |
|
701 | { | |
702 | /** This function sets the time between two snapshots, in s (sy_lfr_n_swf_p). |
|
702 | /** This function sets the time between two snapshots, in s (sy_lfr_n_swf_p). | |
703 | * |
|
703 | * | |
704 | * @param TC points to the TeleCommand packet that is being processed |
|
704 | * @param TC points to the TeleCommand packet that is being processed | |
705 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
705 | * @param queue_id is the id of the queue which handles TM related to this execution step | |
706 | * |
|
706 | * | |
707 | */ |
|
707 | */ | |
708 |
|
708 | |||
709 | int result; |
|
709 | int result; | |
710 |
|
710 | |||
711 | result = LFR_SUCCESSFUL; |
|
711 | result = LFR_SUCCESSFUL; | |
712 |
|
712 | |||
713 | parameter_dump_packet.sy_lfr_n_swf_p[0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P ]; |
|
713 | parameter_dump_packet.sy_lfr_n_swf_p[0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P ]; | |
714 | parameter_dump_packet.sy_lfr_n_swf_p[1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P+1 ]; |
|
714 | parameter_dump_packet.sy_lfr_n_swf_p[1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P+1 ]; | |
715 |
|
715 | |||
716 | return result; |
|
716 | return result; | |
717 | } |
|
717 | } | |
718 |
|
718 | |||
719 | int set_sy_lfr_n_asm_p( ccsdsTelecommandPacket_t *TC ) |
|
719 | int set_sy_lfr_n_asm_p( ccsdsTelecommandPacket_t *TC ) | |
720 | { |
|
720 | { | |
721 | /** This function sets the time between two full spectral matrices transmission, in s (SY_LFR_N_ASM_P). |
|
721 | /** This function sets the time between two full spectral matrices transmission, in s (SY_LFR_N_ASM_P). | |
722 | * |
|
722 | * | |
723 | * @param TC points to the TeleCommand packet that is being processed |
|
723 | * @param TC points to the TeleCommand packet that is being processed | |
724 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
724 | * @param queue_id is the id of the queue which handles TM related to this execution step | |
725 | * |
|
725 | * | |
726 | */ |
|
726 | */ | |
727 |
|
727 | |||
728 | int result; |
|
728 | int result; | |
729 |
|
729 | |||
730 | result = LFR_SUCCESSFUL; |
|
730 | result = LFR_SUCCESSFUL; | |
731 |
|
731 | |||
732 | parameter_dump_packet.sy_lfr_n_asm_p[0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P ]; |
|
732 | parameter_dump_packet.sy_lfr_n_asm_p[0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P ]; | |
733 | parameter_dump_packet.sy_lfr_n_asm_p[1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P+1 ]; |
|
733 | parameter_dump_packet.sy_lfr_n_asm_p[1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P+1 ]; | |
734 |
|
734 | |||
735 | return result; |
|
735 | return result; | |
736 | } |
|
736 | } | |
737 |
|
737 | |||
738 | int set_sy_lfr_n_bp_p0( ccsdsTelecommandPacket_t *TC ) |
|
738 | int set_sy_lfr_n_bp_p0( ccsdsTelecommandPacket_t *TC ) | |
739 | { |
|
739 | { | |
740 | /** This function sets the time between two basic parameter sets, in s (DFLT_SY_LFR_N_BP_P0). |
|
740 | /** This function sets the time between two basic parameter sets, in s (DFLT_SY_LFR_N_BP_P0). | |
741 | * |
|
741 | * | |
742 | * @param TC points to the TeleCommand packet that is being processed |
|
742 | * @param TC points to the TeleCommand packet that is being processed | |
743 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
743 | * @param queue_id is the id of the queue which handles TM related to this execution step | |
744 | * |
|
744 | * | |
745 | */ |
|
745 | */ | |
746 |
|
746 | |||
747 | int status; |
|
747 | int status; | |
748 |
|
748 | |||
749 | status = LFR_SUCCESSFUL; |
|
749 | status = LFR_SUCCESSFUL; | |
750 |
|
750 | |||
751 | parameter_dump_packet.sy_lfr_n_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P0 ]; |
|
751 | parameter_dump_packet.sy_lfr_n_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P0 ]; | |
752 |
|
752 | |||
753 | return status; |
|
753 | return status; | |
754 | } |
|
754 | } | |
755 |
|
755 | |||
756 | int set_sy_lfr_n_bp_p1(ccsdsTelecommandPacket_t *TC ) |
|
756 | int set_sy_lfr_n_bp_p1(ccsdsTelecommandPacket_t *TC ) | |
757 | { |
|
757 | { | |
758 | /** This function sets the time between two basic parameter sets (autocorrelation + crosscorrelation), in s (sy_lfr_n_bp_p1). |
|
758 | /** This function sets the time between two basic parameter sets (autocorrelation + crosscorrelation), in s (sy_lfr_n_bp_p1). | |
759 | * |
|
759 | * | |
760 | * @param TC points to the TeleCommand packet that is being processed |
|
760 | * @param TC points to the TeleCommand packet that is being processed | |
761 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
761 | * @param queue_id is the id of the queue which handles TM related to this execution step | |
762 | * |
|
762 | * | |
763 | */ |
|
763 | */ | |
764 |
|
764 | |||
765 | int status; |
|
765 | int status; | |
766 |
|
766 | |||
767 | status = LFR_SUCCESSFUL; |
|
767 | status = LFR_SUCCESSFUL; | |
768 |
|
768 | |||
769 | parameter_dump_packet.sy_lfr_n_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P1 ]; |
|
769 | parameter_dump_packet.sy_lfr_n_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P1 ]; | |
770 |
|
770 | |||
771 | return status; |
|
771 | return status; | |
772 | } |
|
772 | } | |
773 |
|
773 | |||
774 | int set_sy_lfr_n_cwf_long_f3(ccsdsTelecommandPacket_t *TC ) |
|
774 | int set_sy_lfr_n_cwf_long_f3(ccsdsTelecommandPacket_t *TC ) | |
775 | { |
|
775 | { | |
776 | /** This function allows to switch from CWF_F3 packets to CWF_LONG_F3 packets. |
|
776 | /** This function allows to switch from CWF_F3 packets to CWF_LONG_F3 packets. | |
777 | * |
|
777 | * | |
778 | * @param TC points to the TeleCommand packet that is being processed |
|
778 | * @param TC points to the TeleCommand packet that is being processed | |
779 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
779 | * @param queue_id is the id of the queue which handles TM related to this execution step | |
780 | * |
|
780 | * | |
781 | */ |
|
781 | */ | |
782 |
|
782 | |||
783 | int status; |
|
783 | int status; | |
784 |
|
784 | |||
785 | status = LFR_SUCCESSFUL; |
|
785 | status = LFR_SUCCESSFUL; | |
786 |
|
786 | |||
787 | parameter_dump_packet.sy_lfr_n_cwf_long_f3 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_CWF_LONG_F3 ]; |
|
787 | parameter_dump_packet.sy_lfr_n_cwf_long_f3 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_CWF_LONG_F3 ]; | |
788 |
|
788 | |||
789 | return status; |
|
789 | return status; | |
790 | } |
|
790 | } | |
791 |
|
791 | |||
792 | //********************** |
|
792 | //********************** | |
793 | // BURST MODE PARAMETERS |
|
793 | // BURST MODE PARAMETERS | |
794 | int set_sy_lfr_b_bp_p0(ccsdsTelecommandPacket_t *TC) |
|
794 | int set_sy_lfr_b_bp_p0(ccsdsTelecommandPacket_t *TC) | |
795 | { |
|
795 | { | |
796 | /** This function sets the time between two basic parameter sets, in s (SY_LFR_B_BP_P0). |
|
796 | /** This function sets the time between two basic parameter sets, in s (SY_LFR_B_BP_P0). | |
797 | * |
|
797 | * | |
798 | * @param TC points to the TeleCommand packet that is being processed |
|
798 | * @param TC points to the TeleCommand packet that is being processed | |
799 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
799 | * @param queue_id is the id of the queue which handles TM related to this execution step | |
800 | * |
|
800 | * | |
801 | */ |
|
801 | */ | |
802 |
|
802 | |||
803 | int status; |
|
803 | int status; | |
804 |
|
804 | |||
805 | status = LFR_SUCCESSFUL; |
|
805 | status = LFR_SUCCESSFUL; | |
806 |
|
806 | |||
807 | parameter_dump_packet.sy_lfr_b_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P0 ]; |
|
807 | parameter_dump_packet.sy_lfr_b_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P0 ]; | |
808 |
|
808 | |||
809 | return status; |
|
809 | return status; | |
810 | } |
|
810 | } | |
811 |
|
811 | |||
812 | int set_sy_lfr_b_bp_p1( ccsdsTelecommandPacket_t *TC ) |
|
812 | int set_sy_lfr_b_bp_p1( ccsdsTelecommandPacket_t *TC ) | |
813 | { |
|
813 | { | |
814 | /** This function sets the time between two basic parameter sets, in s (SY_LFR_B_BP_P1). |
|
814 | /** This function sets the time between two basic parameter sets, in s (SY_LFR_B_BP_P1). | |
815 | * |
|
815 | * | |
816 | * @param TC points to the TeleCommand packet that is being processed |
|
816 | * @param TC points to the TeleCommand packet that is being processed | |
817 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
817 | * @param queue_id is the id of the queue which handles TM related to this execution step | |
818 | * |
|
818 | * | |
819 | */ |
|
819 | */ | |
820 |
|
820 | |||
821 | int status; |
|
821 | int status; | |
822 |
|
822 | |||
823 | status = LFR_SUCCESSFUL; |
|
823 | status = LFR_SUCCESSFUL; | |
824 |
|
824 | |||
825 | parameter_dump_packet.sy_lfr_b_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P1 ]; |
|
825 | parameter_dump_packet.sy_lfr_b_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P1 ]; | |
826 |
|
826 | |||
827 | return status; |
|
827 | return status; | |
828 | } |
|
828 | } | |
829 |
|
829 | |||
830 | //********************* |
|
830 | //********************* | |
831 | // SBM1 MODE PARAMETERS |
|
831 | // SBM1 MODE PARAMETERS | |
832 | int set_sy_lfr_s1_bp_p0( ccsdsTelecommandPacket_t *TC ) |
|
832 | int set_sy_lfr_s1_bp_p0( ccsdsTelecommandPacket_t *TC ) | |
833 | { |
|
833 | { | |
834 | /** This function sets the time between two basic parameter sets, in s (SY_LFR_S1_BP_P0). |
|
834 | /** This function sets the time between two basic parameter sets, in s (SY_LFR_S1_BP_P0). | |
835 | * |
|
835 | * | |
836 | * @param TC points to the TeleCommand packet that is being processed |
|
836 | * @param TC points to the TeleCommand packet that is being processed | |
837 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
837 | * @param queue_id is the id of the queue which handles TM related to this execution step | |
838 | * |
|
838 | * | |
839 | */ |
|
839 | */ | |
840 |
|
840 | |||
841 | int status; |
|
841 | int status; | |
842 |
|
842 | |||
843 | status = LFR_SUCCESSFUL; |
|
843 | status = LFR_SUCCESSFUL; | |
844 |
|
844 | |||
845 | parameter_dump_packet.sy_lfr_s1_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S1_BP_P0 ]; |
|
845 | parameter_dump_packet.sy_lfr_s1_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S1_BP_P0 ]; | |
846 |
|
846 | |||
847 | return status; |
|
847 | return status; | |
848 | } |
|
848 | } | |
849 |
|
849 | |||
850 | int set_sy_lfr_s1_bp_p1( ccsdsTelecommandPacket_t *TC ) |
|
850 | int set_sy_lfr_s1_bp_p1( ccsdsTelecommandPacket_t *TC ) | |
851 | { |
|
851 | { | |
852 | /** This function sets the time between two basic parameter sets, in s (SY_LFR_S1_BP_P1). |
|
852 | /** This function sets the time between two basic parameter sets, in s (SY_LFR_S1_BP_P1). | |
853 | * |
|
853 | * | |
854 | * @param TC points to the TeleCommand packet that is being processed |
|
854 | * @param TC points to the TeleCommand packet that is being processed | |
855 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
855 | * @param queue_id is the id of the queue which handles TM related to this execution step | |
856 | * |
|
856 | * | |
857 | */ |
|
857 | */ | |
858 |
|
858 | |||
859 | int status; |
|
859 | int status; | |
860 |
|
860 | |||
861 | status = LFR_SUCCESSFUL; |
|
861 | status = LFR_SUCCESSFUL; | |
862 |
|
862 | |||
863 | parameter_dump_packet.sy_lfr_s1_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S1_BP_P1 ]; |
|
863 | parameter_dump_packet.sy_lfr_s1_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S1_BP_P1 ]; | |
864 |
|
864 | |||
865 | return status; |
|
865 | return status; | |
866 | } |
|
866 | } | |
867 |
|
867 | |||
868 | //********************* |
|
868 | //********************* | |
869 | // SBM2 MODE PARAMETERS |
|
869 | // SBM2 MODE PARAMETERS | |
870 | int set_sy_lfr_s2_bp_p0( ccsdsTelecommandPacket_t *TC ) |
|
870 | int set_sy_lfr_s2_bp_p0( ccsdsTelecommandPacket_t *TC ) | |
871 | { |
|
871 | { | |
872 | /** This function sets the time between two basic parameter sets, in s (SY_LFR_S2_BP_P0). |
|
872 | /** This function sets the time between two basic parameter sets, in s (SY_LFR_S2_BP_P0). | |
873 | * |
|
873 | * | |
874 | * @param TC points to the TeleCommand packet that is being processed |
|
874 | * @param TC points to the TeleCommand packet that is being processed | |
875 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
875 | * @param queue_id is the id of the queue which handles TM related to this execution step | |
876 | * |
|
876 | * | |
877 | */ |
|
877 | */ | |
878 |
|
878 | |||
879 | int status; |
|
879 | int status; | |
880 |
|
880 | |||
881 | status = LFR_SUCCESSFUL; |
|
881 | status = LFR_SUCCESSFUL; | |
882 |
|
882 | |||
883 | parameter_dump_packet.sy_lfr_s2_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P0 ]; |
|
883 | parameter_dump_packet.sy_lfr_s2_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P0 ]; | |
884 |
|
884 | |||
885 | return status; |
|
885 | return status; | |
886 | } |
|
886 | } | |
887 |
|
887 | |||
888 | int set_sy_lfr_s2_bp_p1( ccsdsTelecommandPacket_t *TC ) |
|
888 | int set_sy_lfr_s2_bp_p1( ccsdsTelecommandPacket_t *TC ) | |
889 | { |
|
889 | { | |
890 | /** This function sets the time between two basic parameter sets, in s (SY_LFR_S2_BP_P1). |
|
890 | /** This function sets the time between two basic parameter sets, in s (SY_LFR_S2_BP_P1). | |
891 | * |
|
891 | * | |
892 | * @param TC points to the TeleCommand packet that is being processed |
|
892 | * @param TC points to the TeleCommand packet that is being processed | |
893 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
893 | * @param queue_id is the id of the queue which handles TM related to this execution step | |
894 | * |
|
894 | * | |
895 | */ |
|
895 | */ | |
896 |
|
896 | |||
897 | int status; |
|
897 | int status; | |
898 |
|
898 | |||
899 | status = LFR_SUCCESSFUL; |
|
899 | status = LFR_SUCCESSFUL; | |
900 |
|
900 | |||
901 | parameter_dump_packet.sy_lfr_s2_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P1 ]; |
|
901 | parameter_dump_packet.sy_lfr_s2_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P1 ]; | |
902 |
|
902 | |||
903 | return status; |
|
903 | return status; | |
904 | } |
|
904 | } | |
905 |
|
905 | |||
906 | //******************* |
|
906 | //******************* | |
907 | // TC_LFR_UPDATE_INFO |
|
907 | // TC_LFR_UPDATE_INFO | |
908 | unsigned int check_update_info_hk_lfr_mode( unsigned char mode ) |
|
908 | unsigned int check_update_info_hk_lfr_mode( unsigned char mode ) | |
909 | { |
|
909 | { | |
910 | unsigned int status; |
|
910 | unsigned int status; | |
911 |
|
911 | |||
912 | status = LFR_DEFAULT; |
|
912 | status = LFR_DEFAULT; | |
913 |
|
913 | |||
914 | if ( (mode == LFR_MODE_STANDBY) || (mode == LFR_MODE_NORMAL) |
|
914 | if ( (mode == LFR_MODE_STANDBY) || (mode == LFR_MODE_NORMAL) | |
915 | || (mode == LFR_MODE_BURST) |
|
915 | || (mode == LFR_MODE_BURST) | |
916 | || (mode == LFR_MODE_SBM1) || (mode == LFR_MODE_SBM2)) |
|
916 | || (mode == LFR_MODE_SBM1) || (mode == LFR_MODE_SBM2)) | |
917 | { |
|
917 | { | |
918 | status = LFR_SUCCESSFUL; |
|
918 | status = LFR_SUCCESSFUL; | |
919 | } |
|
919 | } | |
920 | else |
|
920 | else | |
921 | { |
|
921 | { | |
922 | status = LFR_DEFAULT; |
|
922 | status = LFR_DEFAULT; | |
923 | } |
|
923 | } | |
924 |
|
924 | |||
925 | return status; |
|
925 | return status; | |
926 | } |
|
926 | } | |
927 |
|
927 | |||
928 | unsigned int check_update_info_hk_tds_mode( unsigned char mode ) |
|
928 | unsigned int check_update_info_hk_tds_mode( unsigned char mode ) | |
929 | { |
|
929 | { | |
930 | unsigned int status; |
|
930 | unsigned int status; | |
931 |
|
931 | |||
932 | status = LFR_DEFAULT; |
|
932 | status = LFR_DEFAULT; | |
933 |
|
933 | |||
934 | if ( (mode == TDS_MODE_STANDBY) || (mode == TDS_MODE_NORMAL) |
|
934 | if ( (mode == TDS_MODE_STANDBY) || (mode == TDS_MODE_NORMAL) | |
935 | || (mode == TDS_MODE_BURST) |
|
935 | || (mode == TDS_MODE_BURST) | |
936 | || (mode == TDS_MODE_SBM1) || (mode == TDS_MODE_SBM2) |
|
936 | || (mode == TDS_MODE_SBM1) || (mode == TDS_MODE_SBM2) | |
937 | || (mode == TDS_MODE_LFM)) |
|
937 | || (mode == TDS_MODE_LFM)) | |
938 | { |
|
938 | { | |
939 | status = LFR_SUCCESSFUL; |
|
939 | status = LFR_SUCCESSFUL; | |
940 | } |
|
940 | } | |
941 | else |
|
941 | else | |
942 | { |
|
942 | { | |
943 | status = LFR_DEFAULT; |
|
943 | status = LFR_DEFAULT; | |
944 | } |
|
944 | } | |
945 |
|
945 | |||
946 | return status; |
|
946 | return status; | |
947 | } |
|
947 | } | |
948 |
|
948 | |||
949 | unsigned int check_update_info_hk_thr_mode( unsigned char mode ) |
|
949 | unsigned int check_update_info_hk_thr_mode( unsigned char mode ) | |
950 | { |
|
950 | { | |
951 | unsigned int status; |
|
951 | unsigned int status; | |
952 |
|
952 | |||
953 | status = LFR_DEFAULT; |
|
953 | status = LFR_DEFAULT; | |
954 |
|
954 | |||
955 | if ( (mode == THR_MODE_STANDBY) || (mode == THR_MODE_NORMAL) |
|
955 | if ( (mode == THR_MODE_STANDBY) || (mode == THR_MODE_NORMAL) | |
956 | || (mode == THR_MODE_BURST)) |
|
956 | || (mode == THR_MODE_BURST)) | |
957 | { |
|
957 | { | |
958 | status = LFR_SUCCESSFUL; |
|
958 | status = LFR_SUCCESSFUL; | |
959 | } |
|
959 | } | |
960 | else |
|
960 | else | |
961 | { |
|
961 | { | |
962 | status = LFR_DEFAULT; |
|
962 | status = LFR_DEFAULT; | |
963 | } |
|
963 | } | |
964 |
|
964 | |||
965 | return status; |
|
965 | return status; | |
966 | } |
|
966 | } | |
967 |
|
967 | |||
968 | void set_hk_lfr_sc_rw_f_flag( unsigned char wheel, unsigned char freq, float value ) |
|
968 | void set_hk_lfr_sc_rw_f_flag( unsigned char wheel, unsigned char freq, float value ) | |
969 | { |
|
969 | { | |
970 | unsigned char flag; |
|
970 | unsigned char flag; | |
971 | unsigned char flagPosInByte; |
|
971 | unsigned char flagPosInByte; | |
972 | unsigned char newFlag; |
|
972 | unsigned char newFlag; | |
973 | unsigned char flagMask; |
|
973 | unsigned char flagMask; | |
974 |
|
974 | |||
975 | // if the frequency value is not a number, the flag is set to 0 and the frequency RWx_Fy is not filtered |
|
975 | // if the frequency value is not a number, the flag is set to 0 and the frequency RWx_Fy is not filtered | |
976 | if (isnan(value)) |
|
976 | if (isnan(value)) | |
977 | { |
|
977 | { | |
978 | flag = FLAG_NAN; |
|
978 | flag = FLAG_NAN; | |
979 | } |
|
979 | } | |
980 | else |
|
980 | else | |
981 | { |
|
981 | { | |
982 | flag = FLAG_IAN; |
|
982 | flag = FLAG_IAN; | |
983 | } |
|
983 | } | |
984 |
|
984 | |||
985 | switch(wheel) |
|
985 | switch(wheel) | |
986 | { |
|
986 | { | |
987 | case WHEEL_1: |
|
987 | case WHEEL_1: | |
988 | flagPosInByte = FLAG_OFFSET_WHEELS_1_3 - freq; |
|
988 | flagPosInByte = FLAG_OFFSET_WHEELS_1_3 - freq; | |
989 | flagMask = ~(1 << flagPosInByte); |
|
989 | flagMask = ~(1 << flagPosInByte); | |
990 | newFlag = flag << flagPosInByte; |
|
990 | newFlag = flag << flagPosInByte; | |
991 | housekeeping_packet.hk_lfr_sc_rw1_rw2_f_flags = (housekeeping_packet.hk_lfr_sc_rw1_rw2_f_flags & flagMask) | newFlag; |
|
991 | housekeeping_packet.hk_lfr_sc_rw1_rw2_f_flags = (housekeeping_packet.hk_lfr_sc_rw1_rw2_f_flags & flagMask) | newFlag; | |
992 | break; |
|
992 | break; | |
993 | case WHEEL_2: |
|
993 | case WHEEL_2: | |
994 | flagPosInByte = FLAG_OFFSET_WHEELS_2_4 - freq; |
|
994 | flagPosInByte = FLAG_OFFSET_WHEELS_2_4 - freq; | |
995 | flagMask = ~(1 << flagPosInByte); |
|
995 | flagMask = ~(1 << flagPosInByte); | |
996 | newFlag = flag << flagPosInByte; |
|
996 | newFlag = flag << flagPosInByte; | |
997 | housekeeping_packet.hk_lfr_sc_rw1_rw2_f_flags = (housekeeping_packet.hk_lfr_sc_rw1_rw2_f_flags & flagMask) | newFlag; |
|
997 | housekeeping_packet.hk_lfr_sc_rw1_rw2_f_flags = (housekeeping_packet.hk_lfr_sc_rw1_rw2_f_flags & flagMask) | newFlag; | |
998 | break; |
|
998 | break; | |
999 | case WHEEL_3: |
|
999 | case WHEEL_3: | |
1000 | flagPosInByte = FLAG_OFFSET_WHEELS_1_3 - freq; |
|
1000 | flagPosInByte = FLAG_OFFSET_WHEELS_1_3 - freq; | |
1001 | flagMask = ~(1 << flagPosInByte); |
|
1001 | flagMask = ~(1 << flagPosInByte); | |
1002 | newFlag = flag << flagPosInByte; |
|
1002 | newFlag = flag << flagPosInByte; | |
1003 | housekeeping_packet.hk_lfr_sc_rw3_rw4_f_flags = (housekeeping_packet.hk_lfr_sc_rw3_rw4_f_flags & flagMask) | newFlag; |
|
1003 | housekeeping_packet.hk_lfr_sc_rw3_rw4_f_flags = (housekeeping_packet.hk_lfr_sc_rw3_rw4_f_flags & flagMask) | newFlag; | |
1004 | break; |
|
1004 | break; | |
1005 | case WHEEL_4: |
|
1005 | case WHEEL_4: | |
1006 | flagPosInByte = FLAG_OFFSET_WHEELS_2_4 - freq; |
|
1006 | flagPosInByte = FLAG_OFFSET_WHEELS_2_4 - freq; | |
1007 | flagMask = ~(1 << flagPosInByte); |
|
1007 | flagMask = ~(1 << flagPosInByte); | |
1008 | newFlag = flag << flagPosInByte; |
|
1008 | newFlag = flag << flagPosInByte; | |
1009 | housekeeping_packet.hk_lfr_sc_rw3_rw4_f_flags = (housekeeping_packet.hk_lfr_sc_rw3_rw4_f_flags & flagMask) | newFlag; |
|
1009 | housekeeping_packet.hk_lfr_sc_rw3_rw4_f_flags = (housekeeping_packet.hk_lfr_sc_rw3_rw4_f_flags & flagMask) | newFlag; | |
1010 | break; |
|
1010 | break; | |
1011 | default: |
|
1011 | default: | |
1012 | break; |
|
1012 | break; | |
1013 | } |
|
1013 | } | |
1014 | } |
|
1014 | } | |
1015 |
|
1015 | |||
1016 | void set_hk_lfr_sc_rw_f_flags( void ) |
|
1016 | void set_hk_lfr_sc_rw_f_flags( void ) | |
1017 | { |
|
1017 | { | |
1018 | // RW1 |
|
1018 | // RW1 | |
1019 | set_hk_lfr_sc_rw_f_flag( WHEEL_1, FREQ_1, rw_f.cp_rpw_sc_rw1_f1 ); |
|
1019 | set_hk_lfr_sc_rw_f_flag( WHEEL_1, FREQ_1, rw_f.cp_rpw_sc_rw1_f1 ); | |
1020 | set_hk_lfr_sc_rw_f_flag( WHEEL_1, FREQ_2, rw_f.cp_rpw_sc_rw1_f2 ); |
|
1020 | set_hk_lfr_sc_rw_f_flag( WHEEL_1, FREQ_2, rw_f.cp_rpw_sc_rw1_f2 ); | |
1021 | set_hk_lfr_sc_rw_f_flag( WHEEL_1, FREQ_3, rw_f.cp_rpw_sc_rw1_f3 ); |
|
1021 | set_hk_lfr_sc_rw_f_flag( WHEEL_1, FREQ_3, rw_f.cp_rpw_sc_rw1_f3 ); | |
1022 | set_hk_lfr_sc_rw_f_flag( WHEEL_1, FREQ_4, rw_f.cp_rpw_sc_rw1_f4 ); |
|
1022 | set_hk_lfr_sc_rw_f_flag( WHEEL_1, FREQ_4, rw_f.cp_rpw_sc_rw1_f4 ); | |
1023 |
|
1023 | |||
1024 | // RW2 |
|
1024 | // RW2 | |
1025 | set_hk_lfr_sc_rw_f_flag( WHEEL_2, FREQ_1, rw_f.cp_rpw_sc_rw2_f1 ); |
|
1025 | set_hk_lfr_sc_rw_f_flag( WHEEL_2, FREQ_1, rw_f.cp_rpw_sc_rw2_f1 ); | |
1026 | set_hk_lfr_sc_rw_f_flag( WHEEL_2, FREQ_2, rw_f.cp_rpw_sc_rw2_f2 ); |
|
1026 | set_hk_lfr_sc_rw_f_flag( WHEEL_2, FREQ_2, rw_f.cp_rpw_sc_rw2_f2 ); | |
1027 | set_hk_lfr_sc_rw_f_flag( WHEEL_2, FREQ_3, rw_f.cp_rpw_sc_rw2_f3 ); |
|
1027 | set_hk_lfr_sc_rw_f_flag( WHEEL_2, FREQ_3, rw_f.cp_rpw_sc_rw2_f3 ); | |
1028 | set_hk_lfr_sc_rw_f_flag( WHEEL_2, FREQ_4, rw_f.cp_rpw_sc_rw2_f4 ); |
|
1028 | set_hk_lfr_sc_rw_f_flag( WHEEL_2, FREQ_4, rw_f.cp_rpw_sc_rw2_f4 ); | |
1029 |
|
1029 | |||
1030 | // RW3 |
|
1030 | // RW3 | |
1031 | set_hk_lfr_sc_rw_f_flag( WHEEL_3, FREQ_1, rw_f.cp_rpw_sc_rw3_f1 ); |
|
1031 | set_hk_lfr_sc_rw_f_flag( WHEEL_3, FREQ_1, rw_f.cp_rpw_sc_rw3_f1 ); | |
1032 | set_hk_lfr_sc_rw_f_flag( WHEEL_3, FREQ_2, rw_f.cp_rpw_sc_rw3_f2 ); |
|
1032 | set_hk_lfr_sc_rw_f_flag( WHEEL_3, FREQ_2, rw_f.cp_rpw_sc_rw3_f2 ); | |
1033 | set_hk_lfr_sc_rw_f_flag( WHEEL_3, FREQ_3, rw_f.cp_rpw_sc_rw3_f3 ); |
|
1033 | set_hk_lfr_sc_rw_f_flag( WHEEL_3, FREQ_3, rw_f.cp_rpw_sc_rw3_f3 ); | |
1034 | set_hk_lfr_sc_rw_f_flag( WHEEL_3, FREQ_4, rw_f.cp_rpw_sc_rw3_f4 ); |
|
1034 | set_hk_lfr_sc_rw_f_flag( WHEEL_3, FREQ_4, rw_f.cp_rpw_sc_rw3_f4 ); | |
1035 |
|
1035 | |||
1036 | // RW4 |
|
1036 | // RW4 | |
1037 | set_hk_lfr_sc_rw_f_flag( WHEEL_4, FREQ_1, rw_f.cp_rpw_sc_rw4_f1 ); |
|
1037 | set_hk_lfr_sc_rw_f_flag( WHEEL_4, FREQ_1, rw_f.cp_rpw_sc_rw4_f1 ); | |
1038 | set_hk_lfr_sc_rw_f_flag( WHEEL_4, FREQ_2, rw_f.cp_rpw_sc_rw4_f2 ); |
|
1038 | set_hk_lfr_sc_rw_f_flag( WHEEL_4, FREQ_2, rw_f.cp_rpw_sc_rw4_f2 ); | |
1039 | set_hk_lfr_sc_rw_f_flag( WHEEL_4, FREQ_3, rw_f.cp_rpw_sc_rw4_f3 ); |
|
1039 | set_hk_lfr_sc_rw_f_flag( WHEEL_4, FREQ_3, rw_f.cp_rpw_sc_rw4_f3 ); | |
1040 | set_hk_lfr_sc_rw_f_flag( WHEEL_4, FREQ_4, rw_f.cp_rpw_sc_rw4_f4 ); |
|
1040 | set_hk_lfr_sc_rw_f_flag( WHEEL_4, FREQ_4, rw_f.cp_rpw_sc_rw4_f4 ); | |
1041 | } |
|
1041 | } | |
1042 |
|
1042 | |||
1043 | void getReactionWheelsFrequencies( ccsdsTelecommandPacket_t *TC ) |
|
1043 | void getReactionWheelsFrequencies( ccsdsTelecommandPacket_t *TC ) | |
1044 | { |
|
1044 | { | |
1045 | /** This function get the reaction wheels frequencies in the incoming TC_LFR_UPDATE_INFO and copy the values locally. |
|
1045 | /** This function get the reaction wheels frequencies in the incoming TC_LFR_UPDATE_INFO and copy the values locally. | |
1046 | * |
|
1046 | * | |
1047 | * @param TC points to the TeleCommand packet that is being processed |
|
1047 | * @param TC points to the TeleCommand packet that is being processed | |
1048 | * |
|
1048 | * | |
1049 | */ |
|
1049 | */ | |
1050 |
|
1050 | |||
1051 | unsigned char * bytePosPtr; // pointer to the beginning of the incoming TC packet |
|
1051 | unsigned char * bytePosPtr; // pointer to the beginning of the incoming TC packet | |
1052 |
|
1052 | |||
1053 | bytePosPtr = (unsigned char *) &TC->packetID; |
|
1053 | bytePosPtr = (unsigned char *) &TC->packetID; | |
1054 |
|
1054 | |||
1055 | // rw1_f |
|
1055 | // rw1_f | |
1056 | copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw1_f1, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW1_F1 ] ); |
|
1056 | copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw1_f1, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW1_F1 ] ); | |
1057 | copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw1_f2, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW1_F2 ] ); |
|
1057 | copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw1_f2, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW1_F2 ] ); | |
1058 | copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw1_f3, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW1_F3 ] ); |
|
1058 | copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw1_f3, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW1_F3 ] ); | |
1059 | copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw1_f4, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW1_F4 ] ); |
|
1059 | copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw1_f4, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW1_F4 ] ); | |
1060 |
|
1060 | |||
1061 | // rw2_f |
|
1061 | // rw2_f | |
1062 | copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw2_f1, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW2_F1 ] ); |
|
1062 | copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw2_f1, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW2_F1 ] ); | |
1063 | copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw2_f2, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW2_F2 ] ); |
|
1063 | copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw2_f2, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW2_F2 ] ); | |
1064 | copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw2_f3, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW2_F3 ] ); |
|
1064 | copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw2_f3, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW2_F3 ] ); | |
1065 | copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw2_f4, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW2_F4 ] ); |
|
1065 | copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw2_f4, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW2_F4 ] ); | |
1066 |
|
1066 | |||
1067 | // rw3_f |
|
1067 | // rw3_f | |
1068 | copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw3_f1, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW3_F1 ] ); |
|
1068 | copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw3_f1, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW3_F1 ] ); | |
1069 | copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw3_f2, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW3_F2 ] ); |
|
1069 | copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw3_f2, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW3_F2 ] ); | |
1070 | copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw3_f3, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW3_F3 ] ); |
|
1070 | copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw3_f3, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW3_F3 ] ); | |
1071 | copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw3_f4, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW3_F4 ] ); |
|
1071 | copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw3_f4, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW3_F4 ] ); | |
1072 |
|
1072 | |||
1073 | // rw4_f |
|
1073 | // rw4_f | |
1074 | copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw4_f1, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW4_F1 ] ); |
|
1074 | copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw4_f1, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW4_F1 ] ); | |
1075 | copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw4_f2, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW4_F2 ] ); |
|
1075 | copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw4_f2, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW4_F2 ] ); | |
1076 | copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw4_f3, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW4_F3 ] ); |
|
1076 | copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw4_f3, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW4_F3 ] ); | |
1077 | copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw4_f4, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW4_F4 ] ); |
|
1077 | copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw4_f4, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW4_F4 ] ); | |
1078 |
|
1078 | |||
1079 | // test each reaction wheel frequency value. NaN means that the frequency is not filtered |
|
1079 | // test each reaction wheel frequency value. NaN means that the frequency is not filtered | |
1080 |
|
1080 | |||
1081 | } |
|
1081 | } | |
1082 |
|
1082 | |||
1083 | void setFBinMask(unsigned char *fbins_mask, float rw_f, unsigned char deltaFreq, float kcoeff ) |
|
1083 | void setFBinMask(unsigned char *fbins_mask, float rw_f, unsigned char deltaFreq, float kcoeff ) | |
1084 | { |
|
1084 | { | |
1085 | /** This function executes specific actions when a TC_LFR_UPDATE_INFO TeleCommand has been received. |
|
1085 | /** This function executes specific actions when a TC_LFR_UPDATE_INFO TeleCommand has been received. | |
1086 | * |
|
1086 | * | |
1087 | * @param fbins_mask |
|
1087 | * @param fbins_mask | |
1088 | * @param rw_f is the reaction wheel frequency to filter |
|
1088 | * @param rw_f is the reaction wheel frequency to filter | |
1089 | * @param delta_f is the frequency step between the frequency bins, it depends on the frequency channel |
|
1089 | * @param delta_f is the frequency step between the frequency bins, it depends on the frequency channel | |
1090 | * @param flag [true] filtering enabled [false] filtering disabled |
|
1090 | * @param flag [true] filtering enabled [false] filtering disabled | |
1091 | * |
|
1091 | * | |
1092 | * @return void |
|
1092 | * @return void | |
1093 | * |
|
1093 | * | |
1094 | */ |
|
1094 | */ | |
1095 |
|
1095 | |||
1096 | float f_RW_min; |
|
1096 | float f_RW_min; | |
1097 | float f_RW_MAX; |
|
1097 | float f_RW_MAX; | |
1098 | float fi_min; |
|
1098 | float fi_min; | |
1099 | float fi_MAX; |
|
1099 | float fi_MAX; | |
1100 | float fi; |
|
1100 | float fi; | |
1101 | float deltaBelow; |
|
1101 | float deltaBelow; | |
1102 | float deltaAbove; |
|
1102 | float deltaAbove; | |
1103 | int binBelow; |
|
1103 | int binBelow; | |
1104 | int binAbove; |
|
1104 | int binAbove; | |
1105 | int closestBin; |
|
1105 | int closestBin; | |
1106 | unsigned int whichByte; |
|
1106 | unsigned int whichByte; | |
1107 | int selectedByte; |
|
1107 | int selectedByte; | |
1108 | int bin; |
|
1108 | int bin; | |
1109 | int binToRemove[NB_BINS_TO_REMOVE]; |
|
1109 | int binToRemove[NB_BINS_TO_REMOVE]; | |
1110 | int i; |
|
1110 | int i; | |
1111 |
|
1111 | |||
1112 | closestBin = 0; |
|
1112 | closestBin = 0; | |
1113 | whichByte = 0; |
|
1113 | whichByte = 0; | |
1114 | bin = 0; |
|
1114 | bin = 0; | |
1115 |
|
1115 | |||
1116 | for (i = 0; i < NB_BINS_TO_REMOVE; i++) |
|
1116 | for (i = 0; i < NB_BINS_TO_REMOVE; i++) | |
1117 | { |
|
1117 | { | |
1118 | binToRemove[i] = -1; |
|
1118 | binToRemove[i] = -1; | |
1119 | } |
|
1119 | } | |
1120 |
|
1120 | |||
1121 | if (!isnan(rw_f)) |
|
1121 | if (!isnan(rw_f)) | |
1122 | { |
|
1122 | { | |
1123 |
|
1123 | |||
1124 | // compute the frequency range to filter [ rw_f - delta_f/2; rw_f + delta_f/2 ] |
|
1124 | // compute the frequency range to filter [ rw_f - delta_f/2; rw_f + delta_f/2 ] | |
1125 | f_RW_min = rw_f - ( (filterPar.sy_lfr_sc_rw_delta_f * kcoeff) / DELTAF_DIV); |
|
1125 | f_RW_min = rw_f - ( (filterPar.sy_lfr_sc_rw_delta_f * kcoeff) / DELTAF_DIV); | |
1126 | f_RW_MAX = rw_f + ( (filterPar.sy_lfr_sc_rw_delta_f * kcoeff) / DELTAF_DIV); |
|
1126 | f_RW_MAX = rw_f + ( (filterPar.sy_lfr_sc_rw_delta_f * kcoeff) / DELTAF_DIV); | |
1127 |
|
1127 | |||
1128 | // compute the index of the frequency bin immediately below rw_f |
|
1128 | // compute the index of the frequency bin immediately below rw_f | |
1129 | binBelow = (int) ( floor( ((double) rw_f) / ((double) deltaFreq)) ); |
|
1129 | binBelow = (int) ( floor( ((double) rw_f) / ((double) deltaFreq)) ); | |
1130 | deltaBelow = rw_f - binBelow * deltaFreq; |
|
1130 | deltaBelow = rw_f - binBelow * deltaFreq; | |
1131 |
|
1131 | |||
1132 | // compute the index of the frequency bin immediately above rw_f |
|
1132 | // compute the index of the frequency bin immediately above rw_f | |
1133 | binAbove = (int) ( ceil( ((double) rw_f) / ((double) deltaFreq)) ); |
|
1133 | binAbove = (int) ( ceil( ((double) rw_f) / ((double) deltaFreq)) ); | |
1134 | deltaAbove = binAbove * deltaFreq - rw_f; |
|
1134 | deltaAbove = binAbove * deltaFreq - rw_f; | |
1135 |
|
1135 | |||
1136 | // search the closest bin |
|
1136 | // search the closest bin | |
1137 | if (deltaAbove > deltaBelow) |
|
1137 | if (deltaAbove > deltaBelow) | |
1138 | { |
|
1138 | { | |
1139 | closestBin = binBelow; |
|
1139 | closestBin = binBelow; | |
1140 | } |
|
1140 | } | |
1141 | else |
|
1141 | else | |
1142 | { |
|
1142 | { | |
1143 | closestBin = binAbove; |
|
1143 | closestBin = binAbove; | |
1144 | } |
|
1144 | } | |
1145 |
|
1145 | |||
1146 | // compute the fi interval [fi - deltaFreq * 0.285, fi + deltaFreq * 0.285] |
|
1146 | // compute the fi interval [fi - deltaFreq * 0.285, fi + deltaFreq * 0.285] | |
1147 | fi = closestBin * deltaFreq; |
|
1147 | fi = closestBin * deltaFreq; | |
1148 | fi_min = fi - (deltaFreq * FI_INTERVAL_COEFF); |
|
1148 | fi_min = fi - (deltaFreq * FI_INTERVAL_COEFF); | |
1149 | fi_MAX = fi + (deltaFreq * FI_INTERVAL_COEFF); |
|
1149 | fi_MAX = fi + (deltaFreq * FI_INTERVAL_COEFF); | |
1150 |
|
1150 | |||
1151 | //************************************************************************************** |
|
1151 | //************************************************************************************** | |
1152 | // be careful here, one shall take into account that the bin 0 IS DROPPED in the spectra |
|
1152 | // be careful here, one shall take into account that the bin 0 IS DROPPED in the spectra | |
1153 | // thus, the index 0 in a mask corresponds to the bin 1 of the spectrum |
|
1153 | // thus, the index 0 in a mask corresponds to the bin 1 of the spectrum | |
1154 | //************************************************************************************** |
|
1154 | //************************************************************************************** | |
1155 |
|
1155 | |||
1156 | // 1. IF [ f_RW_min, f_RW_MAX] is included in [ fi_min; fi_MAX ] |
|
1156 | // 1. IF [ f_RW_min, f_RW_MAX] is included in [ fi_min; fi_MAX ] | |
1157 | // => remove f_(i), f_(i-1) and f_(i+1) |
|
1157 | // => remove f_(i), f_(i-1) and f_(i+1) | |
1158 | if ( ( f_RW_min > fi_min ) && ( f_RW_MAX < fi_MAX ) ) |
|
1158 | if ( ( f_RW_min > fi_min ) && ( f_RW_MAX < fi_MAX ) ) | |
1159 | { |
|
1159 | { | |
1160 | binToRemove[0] = (closestBin - 1) - 1; |
|
1160 | binToRemove[0] = (closestBin - 1) - 1; | |
1161 | binToRemove[1] = (closestBin) - 1; |
|
1161 | binToRemove[1] = (closestBin) - 1; | |
1162 | binToRemove[2] = (closestBin + 1) - 1; |
|
1162 | binToRemove[2] = (closestBin + 1) - 1; | |
1163 | } |
|
1163 | } | |
1164 | // 2. ELSE |
|
1164 | // 2. ELSE | |
1165 | // => remove the two f_(i) which are around f_RW |
|
1165 | // => remove the two f_(i) which are around f_RW | |
1166 | else |
|
1166 | else | |
1167 | { |
|
1167 | { | |
1168 | binToRemove[0] = (binBelow) - 1; |
|
1168 | binToRemove[0] = (binBelow) - 1; | |
1169 | binToRemove[1] = (binAbove) - 1; |
|
1169 | binToRemove[1] = (binAbove) - 1; | |
1170 | binToRemove[2] = (-1); |
|
1170 | binToRemove[2] = (-1); | |
1171 | } |
|
1171 | } | |
1172 |
|
1172 | |||
1173 | for (i = 0; i < NB_BINS_TO_REMOVE; i++) |
|
1173 | for (i = 0; i < NB_BINS_TO_REMOVE; i++) | |
1174 | { |
|
1174 | { | |
1175 | bin = binToRemove[i]; |
|
1175 | bin = binToRemove[i]; | |
1176 | if ( (bin >= BIN_MIN) && (bin <= BIN_MAX) ) |
|
1176 | if ( (bin >= BIN_MIN) && (bin <= BIN_MAX) ) | |
1177 | { |
|
1177 | { | |
1178 |
|
1178 | |||
1179 | whichByte = (bin >> SHIFT_3_BITS); // division by 8 |
|
1179 | whichByte = (bin >> SHIFT_3_BITS); // division by 8 | |
1180 | selectedByte = ( 1 << (bin - (whichByte * BITS_PER_BYTE)) ); |
|
1180 | selectedByte = ( 1 << (bin - (whichByte * BITS_PER_BYTE)) ); | |
1181 | fbins_mask[BYTES_PER_MASK - 1 - whichByte] = |
|
1181 | fbins_mask[BYTES_PER_MASK - 1 - whichByte] = | |
1182 | fbins_mask[BYTES_PER_MASK - 1 - whichByte] & ((unsigned char) (~selectedByte)); // bytes are ordered MSB first in the packets |
|
1182 | fbins_mask[BYTES_PER_MASK - 1 - whichByte] & ((unsigned char) (~selectedByte)); // bytes are ordered MSB first in the packets | |
1183 | } |
|
1183 | } | |
1184 | } |
|
1184 | } | |
1185 | } |
|
1185 | } | |
1186 | } |
|
1186 | } | |
1187 |
|
1187 | |||
1188 | void build_sy_lfr_rw_mask( unsigned int channel ) |
|
1188 | void build_sy_lfr_rw_mask( unsigned int channel ) | |
1189 | { |
|
1189 | { | |
1190 | unsigned char local_rw_fbins_mask[BYTES_PER_MASK]; |
|
1190 | unsigned char local_rw_fbins_mask[BYTES_PER_MASK]; | |
1191 | unsigned char *maskPtr; |
|
1191 | unsigned char *maskPtr; | |
1192 | double deltaF; |
|
1192 | double deltaF; | |
1193 | unsigned k; |
|
1193 | unsigned k; | |
1194 |
|
1194 | |||
1195 | maskPtr = NULL; |
|
1195 | maskPtr = NULL; | |
1196 | deltaF = DELTAF_F2; |
|
1196 | deltaF = DELTAF_F2; | |
1197 |
|
1197 | |||
1198 | switch (channel) |
|
1198 | switch (channel) | |
1199 | { |
|
1199 | { | |
1200 | case CHANNELF0: |
|
1200 | case CHANNELF0: | |
1201 | maskPtr = parameter_dump_packet.sy_lfr_rw_mask_f0_word1; |
|
1201 | maskPtr = parameter_dump_packet.sy_lfr_rw_mask_f0_word1; | |
1202 | deltaF = DELTAF_F0; |
|
1202 | deltaF = DELTAF_F0; | |
1203 | break; |
|
1203 | break; | |
1204 | case CHANNELF1: |
|
1204 | case CHANNELF1: | |
1205 | maskPtr = parameter_dump_packet.sy_lfr_rw_mask_f1_word1; |
|
1205 | maskPtr = parameter_dump_packet.sy_lfr_rw_mask_f1_word1; | |
1206 | deltaF = DELTAF_F1; |
|
1206 | deltaF = DELTAF_F1; | |
1207 | break; |
|
1207 | break; | |
1208 | case CHANNELF2: |
|
1208 | case CHANNELF2: | |
1209 | maskPtr = parameter_dump_packet.sy_lfr_rw_mask_f2_word1; |
|
1209 | maskPtr = parameter_dump_packet.sy_lfr_rw_mask_f2_word1; | |
1210 | deltaF = DELTAF_F2; |
|
1210 | deltaF = DELTAF_F2; | |
1211 | break; |
|
1211 | break; | |
1212 | default: |
|
1212 | default: | |
1213 | break; |
|
1213 | break; | |
1214 | } |
|
1214 | } | |
1215 |
|
1215 | |||
1216 | for (k = 0; k < BYTES_PER_MASK; k++) |
|
1216 | for (k = 0; k < BYTES_PER_MASK; k++) | |
1217 | { |
|
1217 | { | |
1218 | local_rw_fbins_mask[k] = INT8_ALL_F; |
|
1218 | local_rw_fbins_mask[k] = INT8_ALL_F; | |
1219 | } |
|
1219 | } | |
1220 |
|
1220 | |||
1221 | // RW1 |
|
1221 | // RW1 | |
1222 | setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw1_f1, deltaF, filterPar.sy_lfr_rw1_k1 ); |
|
1222 | setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw1_f1, deltaF, filterPar.sy_lfr_rw1_k1 ); | |
1223 | setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw1_f2, deltaF, filterPar.sy_lfr_rw1_k2 ); |
|
1223 | setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw1_f2, deltaF, filterPar.sy_lfr_rw1_k2 ); | |
1224 | setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw1_f3, deltaF, filterPar.sy_lfr_rw1_k3 ); |
|
1224 | setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw1_f3, deltaF, filterPar.sy_lfr_rw1_k3 ); | |
1225 | setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw1_f4, deltaF, filterPar.sy_lfr_rw1_k4 ); |
|
1225 | setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw1_f4, deltaF, filterPar.sy_lfr_rw1_k4 ); | |
1226 |
|
1226 | |||
1227 | // RW2 |
|
1227 | // RW2 | |
1228 | setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw2_f1, deltaF, filterPar.sy_lfr_rw2_k1 ); |
|
1228 | setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw2_f1, deltaF, filterPar.sy_lfr_rw2_k1 ); | |
1229 | setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw2_f2, deltaF, filterPar.sy_lfr_rw2_k2 ); |
|
1229 | setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw2_f2, deltaF, filterPar.sy_lfr_rw2_k2 ); | |
1230 | setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw2_f3, deltaF, filterPar.sy_lfr_rw2_k3 ); |
|
1230 | setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw2_f3, deltaF, filterPar.sy_lfr_rw2_k3 ); | |
1231 | setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw2_f4, deltaF, filterPar.sy_lfr_rw2_k4 ); |
|
1231 | setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw2_f4, deltaF, filterPar.sy_lfr_rw2_k4 ); | |
1232 |
|
1232 | |||
1233 | // RW3 |
|
1233 | // RW3 | |
1234 | setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw3_f1, deltaF, filterPar.sy_lfr_rw3_k1 ); |
|
1234 | setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw3_f1, deltaF, filterPar.sy_lfr_rw3_k1 ); | |
1235 | setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw3_f2, deltaF, filterPar.sy_lfr_rw3_k2 ); |
|
1235 | setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw3_f2, deltaF, filterPar.sy_lfr_rw3_k2 ); | |
1236 | setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw3_f3, deltaF, filterPar.sy_lfr_rw3_k3 ); |
|
1236 | setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw3_f3, deltaF, filterPar.sy_lfr_rw3_k3 ); | |
1237 | setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw3_f4, deltaF, filterPar.sy_lfr_rw3_k4 ); |
|
1237 | setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw3_f4, deltaF, filterPar.sy_lfr_rw3_k4 ); | |
1238 |
|
1238 | |||
1239 | // RW4 |
|
1239 | // RW4 | |
1240 | setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw4_f1, deltaF, filterPar.sy_lfr_rw4_k1 ); |
|
1240 | setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw4_f1, deltaF, filterPar.sy_lfr_rw4_k1 ); | |
1241 | setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw4_f2, deltaF, filterPar.sy_lfr_rw4_k2 ); |
|
1241 | setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw4_f2, deltaF, filterPar.sy_lfr_rw4_k2 ); | |
1242 | setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw4_f3, deltaF, filterPar.sy_lfr_rw4_k3 ); |
|
1242 | setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw4_f3, deltaF, filterPar.sy_lfr_rw4_k3 ); | |
1243 | setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw4_f4, deltaF, filterPar.sy_lfr_rw4_k4 ); |
|
1243 | setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw4_f4, deltaF, filterPar.sy_lfr_rw4_k4 ); | |
1244 |
|
1244 | |||
1245 | // update the value of the fbins related to reaction wheels frequency filtering |
|
1245 | // update the value of the fbins related to reaction wheels frequency filtering | |
1246 | if (maskPtr != NULL) |
|
1246 | if (maskPtr != NULL) | |
1247 | { |
|
1247 | { | |
1248 | for (k = 0; k < BYTES_PER_MASK; k++) |
|
1248 | for (k = 0; k < BYTES_PER_MASK; k++) | |
1249 | { |
|
1249 | { | |
1250 | maskPtr[k] = local_rw_fbins_mask[k]; |
|
1250 | maskPtr[k] = local_rw_fbins_mask[k]; | |
1251 | } |
|
1251 | } | |
1252 | } |
|
1252 | } | |
1253 | } |
|
1253 | } | |
1254 |
|
1254 | |||
1255 | void build_sy_lfr_rw_masks( void ) |
|
1255 | void build_sy_lfr_rw_masks( void ) | |
1256 | { |
|
1256 | { | |
1257 | build_sy_lfr_rw_mask( CHANNELF0 ); |
|
1257 | build_sy_lfr_rw_mask( CHANNELF0 ); | |
1258 | build_sy_lfr_rw_mask( CHANNELF1 ); |
|
1258 | build_sy_lfr_rw_mask( CHANNELF1 ); | |
1259 | build_sy_lfr_rw_mask( CHANNELF2 ); |
|
1259 | build_sy_lfr_rw_mask( CHANNELF2 ); | |
1260 | } |
|
1260 | } | |
1261 |
|
1261 | |||
1262 | void merge_fbins_masks( void ) |
|
1262 | void merge_fbins_masks( void ) | |
1263 | { |
|
1263 | { | |
1264 | unsigned char k; |
|
1264 | unsigned char k; | |
1265 |
|
1265 | |||
1266 | unsigned char *fbins_f0; |
|
1266 | unsigned char *fbins_f0; | |
1267 | unsigned char *fbins_f1; |
|
1267 | unsigned char *fbins_f1; | |
1268 | unsigned char *fbins_f2; |
|
1268 | unsigned char *fbins_f2; | |
1269 | unsigned char *rw_mask_f0; |
|
1269 | unsigned char *rw_mask_f0; | |
1270 | unsigned char *rw_mask_f1; |
|
1270 | unsigned char *rw_mask_f1; | |
1271 | unsigned char *rw_mask_f2; |
|
1271 | unsigned char *rw_mask_f2; | |
1272 |
|
1272 | |||
1273 | fbins_f0 = parameter_dump_packet.sy_lfr_fbins_f0_word1; |
|
1273 | fbins_f0 = parameter_dump_packet.sy_lfr_fbins_f0_word1; | |
1274 | fbins_f1 = parameter_dump_packet.sy_lfr_fbins_f1_word1; |
|
1274 | fbins_f1 = parameter_dump_packet.sy_lfr_fbins_f1_word1; | |
1275 | fbins_f2 = parameter_dump_packet.sy_lfr_fbins_f2_word1; |
|
1275 | fbins_f2 = parameter_dump_packet.sy_lfr_fbins_f2_word1; | |
1276 | rw_mask_f0 = parameter_dump_packet.sy_lfr_rw_mask_f0_word1; |
|
1276 | rw_mask_f0 = parameter_dump_packet.sy_lfr_rw_mask_f0_word1; | |
1277 | rw_mask_f1 = parameter_dump_packet.sy_lfr_rw_mask_f1_word1; |
|
1277 | rw_mask_f1 = parameter_dump_packet.sy_lfr_rw_mask_f1_word1; | |
1278 | rw_mask_f2 = parameter_dump_packet.sy_lfr_rw_mask_f2_word1; |
|
1278 | rw_mask_f2 = parameter_dump_packet.sy_lfr_rw_mask_f2_word1; | |
1279 |
|
1279 | |||
1280 | for( k=0; k < BYTES_PER_MASK; k++ ) |
|
1280 | for( k=0; k < BYTES_PER_MASK; k++ ) | |
1281 | { |
|
1281 | { | |
1282 | fbins_masks.merged_fbins_mask_f0[k] = fbins_f0[k] & rw_mask_f0[k]; |
|
1282 | fbins_masks.merged_fbins_mask_f0[k] = fbins_f0[k] & rw_mask_f0[k]; | |
1283 | fbins_masks.merged_fbins_mask_f1[k] = fbins_f1[k] & rw_mask_f1[k]; |
|
1283 | fbins_masks.merged_fbins_mask_f1[k] = fbins_f1[k] & rw_mask_f1[k]; | |
1284 | fbins_masks.merged_fbins_mask_f2[k] = fbins_f2[k] & rw_mask_f2[k]; |
|
1284 | fbins_masks.merged_fbins_mask_f2[k] = fbins_f2[k] & rw_mask_f2[k]; | |
1285 | } |
|
1285 | } | |
1286 | } |
|
1286 | } | |
1287 |
|
1287 | |||
1288 | //*********** |
|
1288 | //*********** | |
1289 | // FBINS MASK |
|
1289 | // FBINS MASK | |
1290 |
|
1290 | |||
1291 | int set_sy_lfr_fbins( ccsdsTelecommandPacket_t *TC ) |
|
1291 | int set_sy_lfr_fbins( ccsdsTelecommandPacket_t *TC ) | |
1292 | { |
|
1292 | { | |
1293 | int status; |
|
1293 | int status; | |
1294 | unsigned int k; |
|
1294 | unsigned int k; | |
1295 | unsigned char *fbins_mask_dump; |
|
1295 | unsigned char *fbins_mask_dump; | |
1296 | unsigned char *fbins_mask_TC; |
|
1296 | unsigned char *fbins_mask_TC; | |
1297 |
|
1297 | |||
1298 | status = LFR_SUCCESSFUL; |
|
1298 | status = LFR_SUCCESSFUL; | |
1299 |
|
1299 | |||
1300 | fbins_mask_dump = parameter_dump_packet.sy_lfr_fbins_f0_word1; |
|
1300 | fbins_mask_dump = parameter_dump_packet.sy_lfr_fbins_f0_word1; | |
1301 | fbins_mask_TC = TC->dataAndCRC; |
|
1301 | fbins_mask_TC = TC->dataAndCRC; | |
1302 |
|
1302 | |||
1303 | for (k=0; k < BYTES_PER_MASKS_SET; k++) |
|
1303 | for (k=0; k < BYTES_PER_MASKS_SET; k++) | |
1304 | { |
|
1304 | { | |
1305 | fbins_mask_dump[k] = fbins_mask_TC[k]; |
|
1305 | fbins_mask_dump[k] = fbins_mask_TC[k]; | |
1306 | } |
|
1306 | } | |
1307 |
|
1307 | |||
1308 | return status; |
|
1308 | return status; | |
1309 | } |
|
1309 | } | |
1310 |
|
1310 | |||
1311 | //*************************** |
|
1311 | //*************************** | |
1312 | // TC_LFR_LOAD_PAS_FILTER_PAR |
|
1312 | // TC_LFR_LOAD_PAS_FILTER_PAR | |
1313 |
|
1313 | |||
1314 | int check_sy_lfr_filter_parameters( ccsdsTelecommandPacket_t *TC, rtems_id queue_id ) |
|
1314 | int check_sy_lfr_filter_parameters( ccsdsTelecommandPacket_t *TC, rtems_id queue_id ) | |
1315 | { |
|
1315 | { | |
1316 | int flag; |
|
1316 | int flag; | |
1317 | rtems_status_code status; |
|
1317 | rtems_status_code status; | |
1318 |
|
1318 | |||
1319 | unsigned char sy_lfr_pas_filter_enabled; |
|
1319 | unsigned char sy_lfr_pas_filter_enabled; | |
1320 | unsigned char sy_lfr_pas_filter_modulus; |
|
1320 | unsigned char sy_lfr_pas_filter_modulus; | |
1321 | float sy_lfr_pas_filter_tbad; |
|
1321 | float sy_lfr_pas_filter_tbad; | |
1322 | unsigned char sy_lfr_pas_filter_offset; |
|
1322 | unsigned char sy_lfr_pas_filter_offset; | |
1323 | float sy_lfr_pas_filter_shift; |
|
1323 | float sy_lfr_pas_filter_shift; | |
1324 | float sy_lfr_sc_rw_delta_f; |
|
1324 | float sy_lfr_sc_rw_delta_f; | |
1325 | char *parPtr; |
|
1325 | char *parPtr; | |
1326 |
|
1326 | |||
1327 | flag = LFR_SUCCESSFUL; |
|
1327 | flag = LFR_SUCCESSFUL; | |
1328 | sy_lfr_pas_filter_tbad = INIT_FLOAT; |
|
1328 | sy_lfr_pas_filter_tbad = INIT_FLOAT; | |
1329 | sy_lfr_pas_filter_shift = INIT_FLOAT; |
|
1329 | sy_lfr_pas_filter_shift = INIT_FLOAT; | |
1330 | sy_lfr_sc_rw_delta_f = INIT_FLOAT; |
|
1330 | sy_lfr_sc_rw_delta_f = INIT_FLOAT; | |
1331 | parPtr = NULL; |
|
1331 | parPtr = NULL; | |
1332 |
|
1332 | |||
1333 | //*************** |
|
1333 | //*************** | |
1334 | // get parameters |
|
1334 | // get parameters | |
1335 | sy_lfr_pas_filter_enabled = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_ENABLED ] & BIT_PAS_FILTER_ENABLED; // [0000 0001] |
|
1335 | sy_lfr_pas_filter_enabled = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_ENABLED ] & BIT_PAS_FILTER_ENABLED; // [0000 0001] | |
1336 | sy_lfr_pas_filter_modulus = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_MODULUS ]; |
|
1336 | sy_lfr_pas_filter_modulus = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_MODULUS ]; | |
1337 | copyFloatByChar( |
|
1337 | copyFloatByChar( | |
1338 | (unsigned char*) &sy_lfr_pas_filter_tbad, |
|
1338 | (unsigned char*) &sy_lfr_pas_filter_tbad, | |
1339 | (unsigned char*) &TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_TBAD ] |
|
1339 | (unsigned char*) &TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_TBAD ] | |
1340 | ); |
|
1340 | ); | |
1341 | sy_lfr_pas_filter_offset = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_OFFSET ]; |
|
1341 | sy_lfr_pas_filter_offset = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_OFFSET ]; | |
1342 | copyFloatByChar( |
|
1342 | copyFloatByChar( | |
1343 | (unsigned char*) &sy_lfr_pas_filter_shift, |
|
1343 | (unsigned char*) &sy_lfr_pas_filter_shift, | |
1344 | (unsigned char*) &TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_SHIFT ] |
|
1344 | (unsigned char*) &TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_SHIFT ] | |
1345 | ); |
|
1345 | ); | |
1346 | copyFloatByChar( |
|
1346 | copyFloatByChar( | |
1347 | (unsigned char*) &sy_lfr_sc_rw_delta_f, |
|
1347 | (unsigned char*) &sy_lfr_sc_rw_delta_f, | |
1348 | (unsigned char*) &TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_SC_RW_DELTA_F ] |
|
1348 | (unsigned char*) &TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_SC_RW_DELTA_F ] | |
1349 | ); |
|
1349 | ); | |
1350 |
|
1350 | |||
1351 | //****************** |
|
1351 | //****************** | |
1352 | // CHECK CONSISTENCY |
|
1352 | // CHECK CONSISTENCY | |
1353 |
|
1353 | |||
1354 | //************************** |
|
1354 | //************************** | |
1355 | // sy_lfr_pas_filter_enabled |
|
1355 | // sy_lfr_pas_filter_enabled | |
1356 | // nothing to check, value is 0 or 1 |
|
1356 | // nothing to check, value is 0 or 1 | |
1357 |
|
1357 | |||
1358 | //************************** |
|
1358 | //************************** | |
1359 | // sy_lfr_pas_filter_modulus |
|
1359 | // sy_lfr_pas_filter_modulus | |
1360 | if ( (sy_lfr_pas_filter_modulus < MIN_PAS_FILTER_MODULUS) || (sy_lfr_pas_filter_modulus > MAX_PAS_FILTER_MODULUS) ) |
|
1360 | if ( (sy_lfr_pas_filter_modulus < MIN_PAS_FILTER_MODULUS) || (sy_lfr_pas_filter_modulus > MAX_PAS_FILTER_MODULUS) ) | |
1361 | { |
|
1361 | { | |
1362 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_PAS_FILTER_MODULUS + DATAFIELD_OFFSET, sy_lfr_pas_filter_modulus ); |
|
1362 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_PAS_FILTER_MODULUS + DATAFIELD_OFFSET, sy_lfr_pas_filter_modulus ); | |
1363 | flag = WRONG_APP_DATA; |
|
1363 | flag = WRONG_APP_DATA; | |
1364 | } |
|
1364 | } | |
1365 |
|
1365 | |||
1366 | //*********************** |
|
1366 | //*********************** | |
1367 | // sy_lfr_pas_filter_tbad |
|
1367 | // sy_lfr_pas_filter_tbad | |
1368 | if ( (sy_lfr_pas_filter_tbad < MIN_PAS_FILTER_TBAD) || (sy_lfr_pas_filter_tbad > MAX_PAS_FILTER_TBAD) ) |
|
1368 | if ( (sy_lfr_pas_filter_tbad < MIN_PAS_FILTER_TBAD) || (sy_lfr_pas_filter_tbad > MAX_PAS_FILTER_TBAD) ) | |
1369 | { |
|
1369 | { | |
1370 | parPtr = (char*) &sy_lfr_pas_filter_tbad; |
|
1370 | parPtr = (char*) &sy_lfr_pas_filter_tbad; | |
1371 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_PAS_FILTER_TBAD + DATAFIELD_OFFSET, parPtr[FLOAT_LSBYTE] ); |
|
1371 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_PAS_FILTER_TBAD + DATAFIELD_OFFSET, parPtr[FLOAT_LSBYTE] ); | |
1372 | flag = WRONG_APP_DATA; |
|
1372 | flag = WRONG_APP_DATA; | |
1373 | } |
|
1373 | } | |
1374 |
|
1374 | |||
1375 | //************************* |
|
1375 | //************************* | |
1376 | // sy_lfr_pas_filter_offset |
|
1376 | // sy_lfr_pas_filter_offset | |
1377 | if (flag == LFR_SUCCESSFUL) |
|
1377 | if (flag == LFR_SUCCESSFUL) | |
1378 | { |
|
1378 | { | |
1379 | if ( (sy_lfr_pas_filter_offset < MIN_PAS_FILTER_OFFSET) || (sy_lfr_pas_filter_offset > MAX_PAS_FILTER_OFFSET) ) |
|
1379 | if ( (sy_lfr_pas_filter_offset < MIN_PAS_FILTER_OFFSET) || (sy_lfr_pas_filter_offset > MAX_PAS_FILTER_OFFSET) ) | |
1380 | { |
|
1380 | { | |
1381 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_PAS_FILTER_OFFSET + DATAFIELD_OFFSET, sy_lfr_pas_filter_offset ); |
|
1381 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_PAS_FILTER_OFFSET + DATAFIELD_OFFSET, sy_lfr_pas_filter_offset ); | |
1382 | flag = WRONG_APP_DATA; |
|
1382 | flag = WRONG_APP_DATA; | |
1383 | } |
|
1383 | } | |
1384 | } |
|
1384 | } | |
1385 |
|
1385 | |||
1386 | //************************ |
|
1386 | //************************ | |
1387 | // sy_lfr_pas_filter_shift |
|
1387 | // sy_lfr_pas_filter_shift | |
1388 | if (flag == LFR_SUCCESSFUL) |
|
1388 | if (flag == LFR_SUCCESSFUL) | |
1389 | { |
|
1389 | { | |
1390 | if ( (sy_lfr_pas_filter_shift < MIN_PAS_FILTER_SHIFT) || (sy_lfr_pas_filter_shift > MAX_PAS_FILTER_SHIFT) ) |
|
1390 | if ( (sy_lfr_pas_filter_shift < MIN_PAS_FILTER_SHIFT) || (sy_lfr_pas_filter_shift > MAX_PAS_FILTER_SHIFT) ) | |
1391 | { |
|
1391 | { | |
1392 | parPtr = (char*) &sy_lfr_pas_filter_shift; |
|
1392 | parPtr = (char*) &sy_lfr_pas_filter_shift; | |
1393 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_PAS_FILTER_SHIFT + DATAFIELD_OFFSET, parPtr[FLOAT_LSBYTE] ); |
|
1393 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_PAS_FILTER_SHIFT + DATAFIELD_OFFSET, parPtr[FLOAT_LSBYTE] ); | |
1394 | flag = WRONG_APP_DATA; |
|
1394 | flag = WRONG_APP_DATA; | |
1395 | } |
|
1395 | } | |
1396 | } |
|
1396 | } | |
1397 |
|
1397 | |||
1398 | //************************************* |
|
1398 | //************************************* | |
1399 | // check global coherency of the values |
|
1399 | // check global coherency of the values | |
1400 | if (flag == LFR_SUCCESSFUL) |
|
1400 | if (flag == LFR_SUCCESSFUL) | |
1401 | { |
|
1401 | { | |
1402 | if ( (sy_lfr_pas_filter_tbad + sy_lfr_pas_filter_offset + sy_lfr_pas_filter_shift) > sy_lfr_pas_filter_modulus ) |
|
1402 | if ( (sy_lfr_pas_filter_tbad + sy_lfr_pas_filter_offset + sy_lfr_pas_filter_shift) > sy_lfr_pas_filter_modulus ) | |
1403 | { |
|
1403 | { | |
1404 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_PAS_FILTER_MODULUS + DATAFIELD_OFFSET, sy_lfr_pas_filter_modulus ); |
|
1404 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_PAS_FILTER_MODULUS + DATAFIELD_OFFSET, sy_lfr_pas_filter_modulus ); | |
1405 | flag = WRONG_APP_DATA; |
|
1405 | flag = WRONG_APP_DATA; | |
1406 | } |
|
1406 | } | |
1407 | } |
|
1407 | } | |
1408 |
|
1408 | |||
1409 | //********************* |
|
1409 | //********************* | |
1410 | // sy_lfr_sc_rw_delta_f |
|
1410 | // sy_lfr_sc_rw_delta_f | |
1411 | // nothing to check, no default value in the ICD |
|
1411 | // nothing to check, no default value in the ICD | |
1412 |
|
1412 | |||
1413 | return flag; |
|
1413 | return flag; | |
1414 | } |
|
1414 | } | |
1415 |
|
1415 | |||
1416 | //************** |
|
1416 | //************** | |
1417 | // KCOEFFICIENTS |
|
1417 | // KCOEFFICIENTS | |
1418 | int set_sy_lfr_kcoeff( ccsdsTelecommandPacket_t *TC,rtems_id queue_id ) |
|
1418 | int set_sy_lfr_kcoeff( ccsdsTelecommandPacket_t *TC,rtems_id queue_id ) | |
1419 | { |
|
1419 | { | |
1420 | unsigned int kcoeff; |
|
1420 | unsigned int kcoeff; | |
1421 | unsigned short sy_lfr_kcoeff_frequency; |
|
1421 | unsigned short sy_lfr_kcoeff_frequency; | |
1422 | unsigned short bin; |
|
1422 | unsigned short bin; | |
1423 | float *kcoeffPtr_norm; |
|
1423 | float *kcoeffPtr_norm; | |
1424 | float *kcoeffPtr_sbm; |
|
1424 | float *kcoeffPtr_sbm; | |
1425 | int status; |
|
1425 | int status; | |
1426 | unsigned char *kcoeffLoadPtr; |
|
1426 | unsigned char *kcoeffLoadPtr; | |
1427 | unsigned char *kcoeffNormPtr; |
|
1427 | unsigned char *kcoeffNormPtr; | |
1428 | unsigned char *kcoeffSbmPtr_a; |
|
1428 | unsigned char *kcoeffSbmPtr_a; | |
1429 | unsigned char *kcoeffSbmPtr_b; |
|
1429 | unsigned char *kcoeffSbmPtr_b; | |
1430 |
|
1430 | |||
1431 | sy_lfr_kcoeff_frequency = 0; |
|
1431 | sy_lfr_kcoeff_frequency = 0; | |
1432 | bin = 0; |
|
1432 | bin = 0; | |
1433 | kcoeffPtr_norm = NULL; |
|
1433 | kcoeffPtr_norm = NULL; | |
1434 | kcoeffPtr_sbm = NULL; |
|
1434 | kcoeffPtr_sbm = NULL; | |
1435 | status = LFR_SUCCESSFUL; |
|
1435 | status = LFR_SUCCESSFUL; | |
1436 |
|
1436 | |||
1437 | // copy the value of the frequency byte by byte DO NOT USE A SHORT* POINTER |
|
1437 | // copy the value of the frequency byte by byte DO NOT USE A SHORT* POINTER | |
1438 | copyInt16ByChar( (unsigned char*) &sy_lfr_kcoeff_frequency, &TC->dataAndCRC[DATAFIELD_POS_SY_LFR_KCOEFF_FREQUENCY] ); |
|
1438 | copyInt16ByChar( (unsigned char*) &sy_lfr_kcoeff_frequency, &TC->dataAndCRC[DATAFIELD_POS_SY_LFR_KCOEFF_FREQUENCY] ); | |
1439 |
|
1439 | |||
1440 |
|
1440 | |||
1441 | if ( sy_lfr_kcoeff_frequency >= NB_BINS_COMPRESSED_SM ) |
|
1441 | if ( sy_lfr_kcoeff_frequency >= NB_BINS_COMPRESSED_SM ) | |
1442 | { |
|
1442 | { | |
1443 | PRINTF1("ERR *** in set_sy_lfr_kcoeff_frequency *** sy_lfr_kcoeff_frequency = %d\n", sy_lfr_kcoeff_frequency) |
|
1443 | PRINTF1("ERR *** in set_sy_lfr_kcoeff_frequency *** sy_lfr_kcoeff_frequency = %d\n", sy_lfr_kcoeff_frequency) | |
1444 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_KCOEFF_FREQUENCY + DATAFIELD_OFFSET + 1, |
|
1444 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_KCOEFF_FREQUENCY + DATAFIELD_OFFSET + 1, | |
1445 | TC->dataAndCRC[DATAFIELD_POS_SY_LFR_KCOEFF_FREQUENCY + 1] ); // +1 to get the LSB instead of the MSB |
|
1445 | TC->dataAndCRC[DATAFIELD_POS_SY_LFR_KCOEFF_FREQUENCY + 1] ); // +1 to get the LSB instead of the MSB | |
1446 | status = LFR_DEFAULT; |
|
1446 | status = LFR_DEFAULT; | |
1447 | } |
|
1447 | } | |
1448 | else |
|
1448 | else | |
1449 | { |
|
1449 | { | |
1450 | if ( ( sy_lfr_kcoeff_frequency >= 0 ) |
|
1450 | if ( ( sy_lfr_kcoeff_frequency >= 0 ) | |
1451 | && ( sy_lfr_kcoeff_frequency < NB_BINS_COMPRESSED_SM_F0 ) ) |
|
1451 | && ( sy_lfr_kcoeff_frequency < NB_BINS_COMPRESSED_SM_F0 ) ) | |
1452 | { |
|
1452 | { | |
1453 | kcoeffPtr_norm = k_coeff_intercalib_f0_norm; |
|
1453 | kcoeffPtr_norm = k_coeff_intercalib_f0_norm; | |
1454 | kcoeffPtr_sbm = k_coeff_intercalib_f0_sbm; |
|
1454 | kcoeffPtr_sbm = k_coeff_intercalib_f0_sbm; | |
1455 | bin = sy_lfr_kcoeff_frequency; |
|
1455 | bin = sy_lfr_kcoeff_frequency; | |
1456 | } |
|
1456 | } | |
1457 | else if ( ( sy_lfr_kcoeff_frequency >= NB_BINS_COMPRESSED_SM_F0 ) |
|
1457 | else if ( ( sy_lfr_kcoeff_frequency >= NB_BINS_COMPRESSED_SM_F0 ) | |
1458 | && ( sy_lfr_kcoeff_frequency < (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1) ) ) |
|
1458 | && ( sy_lfr_kcoeff_frequency < (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1) ) ) | |
1459 | { |
|
1459 | { | |
1460 | kcoeffPtr_norm = k_coeff_intercalib_f1_norm; |
|
1460 | kcoeffPtr_norm = k_coeff_intercalib_f1_norm; | |
1461 | kcoeffPtr_sbm = k_coeff_intercalib_f1_sbm; |
|
1461 | kcoeffPtr_sbm = k_coeff_intercalib_f1_sbm; | |
1462 | bin = sy_lfr_kcoeff_frequency - NB_BINS_COMPRESSED_SM_F0; |
|
1462 | bin = sy_lfr_kcoeff_frequency - NB_BINS_COMPRESSED_SM_F0; | |
1463 | } |
|
1463 | } | |
1464 | else if ( ( sy_lfr_kcoeff_frequency >= (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1) ) |
|
1464 | else if ( ( sy_lfr_kcoeff_frequency >= (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1) ) | |
1465 | && ( sy_lfr_kcoeff_frequency < (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1 + NB_BINS_COMPRESSED_SM_F2) ) ) |
|
1465 | && ( sy_lfr_kcoeff_frequency < (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1 + NB_BINS_COMPRESSED_SM_F2) ) ) | |
1466 | { |
|
1466 | { | |
1467 | kcoeffPtr_norm = k_coeff_intercalib_f2; |
|
1467 | kcoeffPtr_norm = k_coeff_intercalib_f2; | |
1468 | kcoeffPtr_sbm = NULL; |
|
1468 | kcoeffPtr_sbm = NULL; | |
1469 | bin = sy_lfr_kcoeff_frequency - (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1); |
|
1469 | bin = sy_lfr_kcoeff_frequency - (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1); | |
1470 | } |
|
1470 | } | |
1471 | } |
|
1471 | } | |
1472 |
|
1472 | |||
1473 | if (kcoeffPtr_norm != NULL ) // update K coefficient for NORMAL data products |
|
1473 | if (kcoeffPtr_norm != NULL ) // update K coefficient for NORMAL data products | |
1474 | { |
|
1474 | { | |
1475 | for (kcoeff=0; kcoeff<NB_K_COEFF_PER_BIN; kcoeff++) |
|
1475 | for (kcoeff=0; kcoeff<NB_K_COEFF_PER_BIN; kcoeff++) | |
1476 | { |
|
1476 | { | |
1477 | // destination |
|
1477 | // destination | |
1478 | kcoeffNormPtr = (unsigned char*) &kcoeffPtr_norm[ (bin * NB_K_COEFF_PER_BIN) + kcoeff ]; |
|
1478 | kcoeffNormPtr = (unsigned char*) &kcoeffPtr_norm[ (bin * NB_K_COEFF_PER_BIN) + kcoeff ]; | |
1479 | // source |
|
1479 | // source | |
1480 | kcoeffLoadPtr = (unsigned char*) &TC->dataAndCRC[DATAFIELD_POS_SY_LFR_KCOEFF_1 + (NB_BYTES_PER_FLOAT * kcoeff)]; |
|
1480 | kcoeffLoadPtr = (unsigned char*) &TC->dataAndCRC[DATAFIELD_POS_SY_LFR_KCOEFF_1 + (NB_BYTES_PER_FLOAT * kcoeff)]; | |
1481 | // copy source to destination |
|
1481 | // copy source to destination | |
1482 | copyFloatByChar( kcoeffNormPtr, kcoeffLoadPtr ); |
|
1482 | copyFloatByChar( kcoeffNormPtr, kcoeffLoadPtr ); | |
1483 | } |
|
1483 | } | |
1484 | } |
|
1484 | } | |
1485 |
|
1485 | |||
1486 | if (kcoeffPtr_sbm != NULL ) // update K coefficient for SBM data products |
|
1486 | if (kcoeffPtr_sbm != NULL ) // update K coefficient for SBM data products | |
1487 | { |
|
1487 | { | |
1488 | for (kcoeff=0; kcoeff<NB_K_COEFF_PER_BIN; kcoeff++) |
|
1488 | for (kcoeff=0; kcoeff<NB_K_COEFF_PER_BIN; kcoeff++) | |
1489 | { |
|
1489 | { | |
1490 | // destination |
|
1490 | // destination | |
1491 | kcoeffSbmPtr_a= (unsigned char*) &kcoeffPtr_sbm[ ( (bin * NB_K_COEFF_PER_BIN) + kcoeff) * SBM_COEFF_PER_NORM_COEFF ]; |
|
1491 | kcoeffSbmPtr_a= (unsigned char*) &kcoeffPtr_sbm[ ( (bin * NB_K_COEFF_PER_BIN) + kcoeff) * SBM_COEFF_PER_NORM_COEFF ]; | |
1492 | kcoeffSbmPtr_b= (unsigned char*) &kcoeffPtr_sbm[ (((bin * NB_K_COEFF_PER_BIN) + kcoeff) * SBM_KCOEFF_PER_NORM_KCOEFF) + 1 ]; |
|
1492 | kcoeffSbmPtr_b= (unsigned char*) &kcoeffPtr_sbm[ (((bin * NB_K_COEFF_PER_BIN) + kcoeff) * SBM_KCOEFF_PER_NORM_KCOEFF) + 1 ]; | |
1493 | // source |
|
1493 | // source | |
1494 | kcoeffLoadPtr = (unsigned char*) &TC->dataAndCRC[DATAFIELD_POS_SY_LFR_KCOEFF_1 + (NB_BYTES_PER_FLOAT * kcoeff)]; |
|
1494 | kcoeffLoadPtr = (unsigned char*) &TC->dataAndCRC[DATAFIELD_POS_SY_LFR_KCOEFF_1 + (NB_BYTES_PER_FLOAT * kcoeff)]; | |
1495 | // copy source to destination |
|
1495 | // copy source to destination | |
1496 | copyFloatByChar( kcoeffSbmPtr_a, kcoeffLoadPtr ); |
|
1496 | copyFloatByChar( kcoeffSbmPtr_a, kcoeffLoadPtr ); | |
1497 | copyFloatByChar( kcoeffSbmPtr_b, kcoeffLoadPtr ); |
|
1497 | copyFloatByChar( kcoeffSbmPtr_b, kcoeffLoadPtr ); | |
1498 | } |
|
1498 | } | |
1499 | } |
|
1499 | } | |
1500 |
|
1500 | |||
1501 | // print_k_coeff(); |
|
1501 | // print_k_coeff(); | |
1502 |
|
1502 | |||
1503 | return status; |
|
1503 | return status; | |
1504 | } |
|
1504 | } | |
1505 |
|
1505 | |||
1506 | void copyFloatByChar( unsigned char *destination, unsigned char *source ) |
|
1506 | void copyFloatByChar( unsigned char *destination, unsigned char *source ) | |
1507 | { |
|
1507 | { | |
1508 | destination[BYTE_0] = source[BYTE_0]; |
|
1508 | destination[BYTE_0] = source[BYTE_0]; | |
1509 | destination[BYTE_1] = source[BYTE_1]; |
|
1509 | destination[BYTE_1] = source[BYTE_1]; | |
1510 | destination[BYTE_2] = source[BYTE_2]; |
|
1510 | destination[BYTE_2] = source[BYTE_2]; | |
1511 | destination[BYTE_3] = source[BYTE_3]; |
|
1511 | destination[BYTE_3] = source[BYTE_3]; | |
1512 | } |
|
1512 | } | |
1513 |
|
1513 | |||
1514 | void copyInt32ByChar( unsigned char *destination, unsigned char *source ) |
|
1514 | void copyInt32ByChar( unsigned char *destination, unsigned char *source ) | |
1515 | { |
|
1515 | { | |
1516 | destination[BYTE_0] = source[BYTE_0]; |
|
1516 | destination[BYTE_0] = source[BYTE_0]; | |
1517 | destination[BYTE_1] = source[BYTE_1]; |
|
1517 | destination[BYTE_1] = source[BYTE_1]; | |
1518 | destination[BYTE_2] = source[BYTE_2]; |
|
1518 | destination[BYTE_2] = source[BYTE_2]; | |
1519 | destination[BYTE_3] = source[BYTE_3]; |
|
1519 | destination[BYTE_3] = source[BYTE_3]; | |
1520 | } |
|
1520 | } | |
1521 |
|
1521 | |||
1522 | void copyInt16ByChar( unsigned char *destination, unsigned char *source ) |
|
1522 | void copyInt16ByChar( unsigned char *destination, unsigned char *source ) | |
1523 | { |
|
1523 | { | |
1524 | destination[BYTE_0] = source[BYTE_0]; |
|
1524 | destination[BYTE_0] = source[BYTE_0]; | |
1525 | destination[BYTE_1] = source[BYTE_1]; |
|
1525 | destination[BYTE_1] = source[BYTE_1]; | |
1526 | } |
|
1526 | } | |
1527 |
|
1527 | |||
1528 | void floatToChar( float value, unsigned char* ptr) |
|
1528 | void floatToChar( float value, unsigned char* ptr) | |
1529 | { |
|
1529 | { | |
1530 | unsigned char* valuePtr; |
|
1530 | unsigned char* valuePtr; | |
1531 |
|
1531 | |||
1532 | valuePtr = (unsigned char*) &value; |
|
1532 | valuePtr = (unsigned char*) &value; | |
1533 |
|
1533 | |||
1534 | ptr[BYTE_0] = valuePtr[BYTE_0]; |
|
1534 | ptr[BYTE_0] = valuePtr[BYTE_0]; | |
1535 | ptr[BYTE_1] = valuePtr[BYTE_1]; |
|
1535 | ptr[BYTE_1] = valuePtr[BYTE_1]; | |
1536 | ptr[BYTE_2] = valuePtr[BYTE_2]; |
|
1536 | ptr[BYTE_2] = valuePtr[BYTE_2]; | |
1537 | ptr[BYTE_3] = valuePtr[BYTE_3]; |
|
1537 | ptr[BYTE_3] = valuePtr[BYTE_3]; | |
1538 |
|
||||
1539 | // <TEST> |
|
|||
1540 | printf("\n\n<TEST>\n"); |
|
|||
1541 |
|
||||
1542 | float aux = NAN; |
|
|||
1543 | unsigned char* auxPtr; |
|
|||
1544 | auxPtr = (unsigned char*) &aux; |
|
|||
1545 |
|
||||
1546 | printf("aux = %f, value = %f\n", aux, value); |
|
|||
1547 |
|
||||
1548 | auxPtr[BYTE_0] = valuePtr[BYTE_0]; |
|
|||
1549 | auxPtr[BYTE_1] = valuePtr[BYTE_1]; |
|
|||
1550 | auxPtr[BYTE_2] = valuePtr[BYTE_2]; |
|
|||
1551 | auxPtr[BYTE_3] = valuePtr[BYTE_3]; |
|
|||
1552 |
|
||||
1553 | printf("aux = %f\n", aux); |
|
|||
1554 | // </TEST> |
|
|||
1555 | } |
|
1538 | } | |
1556 |
|
1539 | |||
1557 | //********** |
|
1540 | //********** | |
1558 | // init dump |
|
1541 | // init dump | |
1559 |
|
1542 | |||
1560 | void init_parameter_dump( void ) |
|
1543 | void init_parameter_dump( void ) | |
1561 | { |
|
1544 | { | |
1562 | /** This function initialize the parameter_dump_packet global variable with default values. |
|
1545 | /** This function initialize the parameter_dump_packet global variable with default values. | |
1563 | * |
|
1546 | * | |
1564 | */ |
|
1547 | */ | |
1565 |
|
1548 | |||
1566 | unsigned int k; |
|
1549 | unsigned int k; | |
1567 |
|
1550 | |||
1568 | parameter_dump_packet.targetLogicalAddress = CCSDS_DESTINATION_ID; |
|
1551 | parameter_dump_packet.targetLogicalAddress = CCSDS_DESTINATION_ID; | |
1569 | parameter_dump_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID; |
|
1552 | parameter_dump_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID; | |
1570 | parameter_dump_packet.reserved = CCSDS_RESERVED; |
|
1553 | parameter_dump_packet.reserved = CCSDS_RESERVED; | |
1571 | parameter_dump_packet.userApplication = CCSDS_USER_APP; |
|
1554 | parameter_dump_packet.userApplication = CCSDS_USER_APP; | |
1572 | parameter_dump_packet.packetID[0] = (unsigned char) (APID_TM_PARAMETER_DUMP >> SHIFT_1_BYTE); |
|
1555 | parameter_dump_packet.packetID[0] = (unsigned char) (APID_TM_PARAMETER_DUMP >> SHIFT_1_BYTE); | |
1573 | parameter_dump_packet.packetID[1] = (unsigned char) APID_TM_PARAMETER_DUMP; |
|
1556 | parameter_dump_packet.packetID[1] = (unsigned char) APID_TM_PARAMETER_DUMP; | |
1574 | parameter_dump_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; |
|
1557 | parameter_dump_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; | |
1575 | parameter_dump_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT; |
|
1558 | parameter_dump_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT; | |
1576 | parameter_dump_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_PARAMETER_DUMP >> SHIFT_1_BYTE); |
|
1559 | parameter_dump_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_PARAMETER_DUMP >> SHIFT_1_BYTE); | |
1577 | parameter_dump_packet.packetLength[1] = (unsigned char) PACKET_LENGTH_PARAMETER_DUMP; |
|
1560 | parameter_dump_packet.packetLength[1] = (unsigned char) PACKET_LENGTH_PARAMETER_DUMP; | |
1578 | // DATA FIELD HEADER |
|
1561 | // DATA FIELD HEADER | |
1579 | parameter_dump_packet.spare1_pusVersion_spare2 = SPARE1_PUSVERSION_SPARE2; |
|
1562 | parameter_dump_packet.spare1_pusVersion_spare2 = SPARE1_PUSVERSION_SPARE2; | |
1580 | parameter_dump_packet.serviceType = TM_TYPE_PARAMETER_DUMP; |
|
1563 | parameter_dump_packet.serviceType = TM_TYPE_PARAMETER_DUMP; | |
1581 | parameter_dump_packet.serviceSubType = TM_SUBTYPE_PARAMETER_DUMP; |
|
1564 | parameter_dump_packet.serviceSubType = TM_SUBTYPE_PARAMETER_DUMP; | |
1582 | parameter_dump_packet.destinationID = TM_DESTINATION_ID_GROUND; |
|
1565 | parameter_dump_packet.destinationID = TM_DESTINATION_ID_GROUND; | |
1583 | parameter_dump_packet.time[BYTE_0] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_3_BYTES); |
|
1566 | parameter_dump_packet.time[BYTE_0] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_3_BYTES); | |
1584 | parameter_dump_packet.time[BYTE_1] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_2_BYTES); |
|
1567 | parameter_dump_packet.time[BYTE_1] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_2_BYTES); | |
1585 | parameter_dump_packet.time[BYTE_2] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_1_BYTE); |
|
1568 | parameter_dump_packet.time[BYTE_2] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_1_BYTE); | |
1586 | parameter_dump_packet.time[BYTE_3] = (unsigned char) (time_management_regs->coarse_time); |
|
1569 | parameter_dump_packet.time[BYTE_3] = (unsigned char) (time_management_regs->coarse_time); | |
1587 | parameter_dump_packet.time[BYTE_4] = (unsigned char) (time_management_regs->fine_time >> SHIFT_1_BYTE); |
|
1570 | parameter_dump_packet.time[BYTE_4] = (unsigned char) (time_management_regs->fine_time >> SHIFT_1_BYTE); | |
1588 | parameter_dump_packet.time[BYTE_5] = (unsigned char) (time_management_regs->fine_time); |
|
1571 | parameter_dump_packet.time[BYTE_5] = (unsigned char) (time_management_regs->fine_time); | |
1589 | parameter_dump_packet.sid = SID_PARAMETER_DUMP; |
|
1572 | parameter_dump_packet.sid = SID_PARAMETER_DUMP; | |
1590 |
|
1573 | |||
1591 | //****************** |
|
1574 | //****************** | |
1592 | // COMMON PARAMETERS |
|
1575 | // COMMON PARAMETERS | |
1593 | parameter_dump_packet.sy_lfr_common_parameters_spare = DEFAULT_SY_LFR_COMMON0; |
|
1576 | parameter_dump_packet.sy_lfr_common_parameters_spare = DEFAULT_SY_LFR_COMMON0; | |
1594 | parameter_dump_packet.sy_lfr_common_parameters = DEFAULT_SY_LFR_COMMON1; |
|
1577 | parameter_dump_packet.sy_lfr_common_parameters = DEFAULT_SY_LFR_COMMON1; | |
1595 |
|
1578 | |||
1596 | //****************** |
|
1579 | //****************** | |
1597 | // NORMAL PARAMETERS |
|
1580 | // NORMAL PARAMETERS | |
1598 | parameter_dump_packet.sy_lfr_n_swf_l[0] = (unsigned char) (DFLT_SY_LFR_N_SWF_L >> SHIFT_1_BYTE); |
|
1581 | parameter_dump_packet.sy_lfr_n_swf_l[0] = (unsigned char) (DFLT_SY_LFR_N_SWF_L >> SHIFT_1_BYTE); | |
1599 | parameter_dump_packet.sy_lfr_n_swf_l[1] = (unsigned char) (DFLT_SY_LFR_N_SWF_L ); |
|
1582 | parameter_dump_packet.sy_lfr_n_swf_l[1] = (unsigned char) (DFLT_SY_LFR_N_SWF_L ); | |
1600 | parameter_dump_packet.sy_lfr_n_swf_p[0] = (unsigned char) (DFLT_SY_LFR_N_SWF_P >> SHIFT_1_BYTE); |
|
1583 | parameter_dump_packet.sy_lfr_n_swf_p[0] = (unsigned char) (DFLT_SY_LFR_N_SWF_P >> SHIFT_1_BYTE); | |
1601 | parameter_dump_packet.sy_lfr_n_swf_p[1] = (unsigned char) (DFLT_SY_LFR_N_SWF_P ); |
|
1584 | parameter_dump_packet.sy_lfr_n_swf_p[1] = (unsigned char) (DFLT_SY_LFR_N_SWF_P ); | |
1602 | parameter_dump_packet.sy_lfr_n_asm_p[0] = (unsigned char) (DFLT_SY_LFR_N_ASM_P >> SHIFT_1_BYTE); |
|
1585 | parameter_dump_packet.sy_lfr_n_asm_p[0] = (unsigned char) (DFLT_SY_LFR_N_ASM_P >> SHIFT_1_BYTE); | |
1603 | parameter_dump_packet.sy_lfr_n_asm_p[1] = (unsigned char) (DFLT_SY_LFR_N_ASM_P ); |
|
1586 | parameter_dump_packet.sy_lfr_n_asm_p[1] = (unsigned char) (DFLT_SY_LFR_N_ASM_P ); | |
1604 | parameter_dump_packet.sy_lfr_n_bp_p0 = (unsigned char) DFLT_SY_LFR_N_BP_P0; |
|
1587 | parameter_dump_packet.sy_lfr_n_bp_p0 = (unsigned char) DFLT_SY_LFR_N_BP_P0; | |
1605 | parameter_dump_packet.sy_lfr_n_bp_p1 = (unsigned char) DFLT_SY_LFR_N_BP_P1; |
|
1588 | parameter_dump_packet.sy_lfr_n_bp_p1 = (unsigned char) DFLT_SY_LFR_N_BP_P1; | |
1606 | parameter_dump_packet.sy_lfr_n_cwf_long_f3 = (unsigned char) DFLT_SY_LFR_N_CWF_LONG_F3; |
|
1589 | parameter_dump_packet.sy_lfr_n_cwf_long_f3 = (unsigned char) DFLT_SY_LFR_N_CWF_LONG_F3; | |
1607 |
|
1590 | |||
1608 | //***************** |
|
1591 | //***************** | |
1609 | // BURST PARAMETERS |
|
1592 | // BURST PARAMETERS | |
1610 | parameter_dump_packet.sy_lfr_b_bp_p0 = (unsigned char) DEFAULT_SY_LFR_B_BP_P0; |
|
1593 | parameter_dump_packet.sy_lfr_b_bp_p0 = (unsigned char) DEFAULT_SY_LFR_B_BP_P0; | |
1611 | parameter_dump_packet.sy_lfr_b_bp_p1 = (unsigned char) DEFAULT_SY_LFR_B_BP_P1; |
|
1594 | parameter_dump_packet.sy_lfr_b_bp_p1 = (unsigned char) DEFAULT_SY_LFR_B_BP_P1; | |
1612 |
|
1595 | |||
1613 | //**************** |
|
1596 | //**************** | |
1614 | // SBM1 PARAMETERS |
|
1597 | // SBM1 PARAMETERS | |
1615 | 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 |
|
1598 | 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 | |
1616 | parameter_dump_packet.sy_lfr_s1_bp_p1 = (unsigned char) DEFAULT_SY_LFR_S1_BP_P1; |
|
1599 | parameter_dump_packet.sy_lfr_s1_bp_p1 = (unsigned char) DEFAULT_SY_LFR_S1_BP_P1; | |
1617 |
|
1600 | |||
1618 | //**************** |
|
1601 | //**************** | |
1619 | // SBM2 PARAMETERS |
|
1602 | // SBM2 PARAMETERS | |
1620 | parameter_dump_packet.sy_lfr_s2_bp_p0 = (unsigned char) DEFAULT_SY_LFR_S2_BP_P0; |
|
1603 | parameter_dump_packet.sy_lfr_s2_bp_p0 = (unsigned char) DEFAULT_SY_LFR_S2_BP_P0; | |
1621 | parameter_dump_packet.sy_lfr_s2_bp_p1 = (unsigned char) DEFAULT_SY_LFR_S2_BP_P1; |
|
1604 | parameter_dump_packet.sy_lfr_s2_bp_p1 = (unsigned char) DEFAULT_SY_LFR_S2_BP_P1; | |
1622 |
|
1605 | |||
1623 | //************ |
|
1606 | //************ | |
1624 | // FBINS MASKS |
|
1607 | // FBINS MASKS | |
1625 | for (k=0; k < BYTES_PER_MASKS_SET; k++) |
|
1608 | for (k=0; k < BYTES_PER_MASKS_SET; k++) | |
1626 | { |
|
1609 | { | |
1627 | parameter_dump_packet.sy_lfr_fbins_f0_word1[k] = INT8_ALL_F; |
|
1610 | parameter_dump_packet.sy_lfr_fbins_f0_word1[k] = INT8_ALL_F; | |
1628 | } |
|
1611 | } | |
1629 |
|
1612 | |||
1630 | // PAS FILTER PARAMETERS |
|
1613 | // PAS FILTER PARAMETERS | |
1631 | parameter_dump_packet.pa_rpw_spare8_2 = INIT_CHAR; |
|
1614 | parameter_dump_packet.pa_rpw_spare8_2 = INIT_CHAR; | |
1632 | parameter_dump_packet.spare_sy_lfr_pas_filter_enabled = INIT_CHAR; |
|
1615 | parameter_dump_packet.spare_sy_lfr_pas_filter_enabled = INIT_CHAR; | |
1633 | parameter_dump_packet.sy_lfr_pas_filter_modulus = DEFAULT_SY_LFR_PAS_FILTER_MODULUS; |
|
1616 | parameter_dump_packet.sy_lfr_pas_filter_modulus = DEFAULT_SY_LFR_PAS_FILTER_MODULUS; | |
1634 | floatToChar( DEFAULT_SY_LFR_PAS_FILTER_TBAD, parameter_dump_packet.sy_lfr_pas_filter_tbad ); |
|
1617 | floatToChar( DEFAULT_SY_LFR_PAS_FILTER_TBAD, parameter_dump_packet.sy_lfr_pas_filter_tbad ); | |
1635 | parameter_dump_packet.sy_lfr_pas_filter_offset = DEFAULT_SY_LFR_PAS_FILTER_OFFSET; |
|
1618 | parameter_dump_packet.sy_lfr_pas_filter_offset = DEFAULT_SY_LFR_PAS_FILTER_OFFSET; | |
1636 | floatToChar( DEFAULT_SY_LFR_PAS_FILTER_SHIFT, parameter_dump_packet.sy_lfr_pas_filter_shift ); |
|
1619 | floatToChar( DEFAULT_SY_LFR_PAS_FILTER_SHIFT, parameter_dump_packet.sy_lfr_pas_filter_shift ); | |
1637 | floatToChar( DEFAULT_SY_LFR_SC_RW_DELTA_F, parameter_dump_packet.sy_lfr_sc_rw_delta_f ); |
|
1620 | floatToChar( DEFAULT_SY_LFR_SC_RW_DELTA_F, parameter_dump_packet.sy_lfr_sc_rw_delta_f ); | |
1638 |
|
1621 | |||
1639 | // RW1_K |
|
1622 | // RW1_K | |
1640 | floatToChar( DEFAULT_SY_LFR_RW_K1, parameter_dump_packet.sy_lfr_rw1_k1); |
|
1623 | floatToChar( DEFAULT_SY_LFR_RW_K1, parameter_dump_packet.sy_lfr_rw1_k1); | |
1641 | floatToChar( DEFAULT_SY_LFR_RW_K2, parameter_dump_packet.sy_lfr_rw1_k2); |
|
1624 | floatToChar( DEFAULT_SY_LFR_RW_K2, parameter_dump_packet.sy_lfr_rw1_k2); | |
1642 | floatToChar( DEFAULT_SY_LFR_RW_K3, parameter_dump_packet.sy_lfr_rw1_k3); |
|
1625 | floatToChar( DEFAULT_SY_LFR_RW_K3, parameter_dump_packet.sy_lfr_rw1_k3); | |
1643 | floatToChar( DEFAULT_SY_LFR_RW_K4, parameter_dump_packet.sy_lfr_rw1_k4); |
|
1626 | floatToChar( DEFAULT_SY_LFR_RW_K4, parameter_dump_packet.sy_lfr_rw1_k4); | |
1644 | // RW2_K |
|
1627 | // RW2_K | |
1645 | floatToChar( DEFAULT_SY_LFR_RW_K1, parameter_dump_packet.sy_lfr_rw2_k1); |
|
1628 | floatToChar( DEFAULT_SY_LFR_RW_K1, parameter_dump_packet.sy_lfr_rw2_k1); | |
1646 | floatToChar( DEFAULT_SY_LFR_RW_K2, parameter_dump_packet.sy_lfr_rw2_k2); |
|
1629 | floatToChar( DEFAULT_SY_LFR_RW_K2, parameter_dump_packet.sy_lfr_rw2_k2); | |
1647 | floatToChar( DEFAULT_SY_LFR_RW_K3, parameter_dump_packet.sy_lfr_rw2_k3); |
|
1630 | floatToChar( DEFAULT_SY_LFR_RW_K3, parameter_dump_packet.sy_lfr_rw2_k3); | |
1648 | floatToChar( DEFAULT_SY_LFR_RW_K4, parameter_dump_packet.sy_lfr_rw2_k4); |
|
1631 | floatToChar( DEFAULT_SY_LFR_RW_K4, parameter_dump_packet.sy_lfr_rw2_k4); | |
1649 | // RW3_K |
|
1632 | // RW3_K | |
1650 | floatToChar( DEFAULT_SY_LFR_RW_K1, parameter_dump_packet.sy_lfr_rw3_k1); |
|
1633 | floatToChar( DEFAULT_SY_LFR_RW_K1, parameter_dump_packet.sy_lfr_rw3_k1); | |
1651 | floatToChar( DEFAULT_SY_LFR_RW_K2, parameter_dump_packet.sy_lfr_rw3_k2); |
|
1634 | floatToChar( DEFAULT_SY_LFR_RW_K2, parameter_dump_packet.sy_lfr_rw3_k2); | |
1652 | floatToChar( DEFAULT_SY_LFR_RW_K3, parameter_dump_packet.sy_lfr_rw3_k3); |
|
1635 | floatToChar( DEFAULT_SY_LFR_RW_K3, parameter_dump_packet.sy_lfr_rw3_k3); | |
1653 | floatToChar( DEFAULT_SY_LFR_RW_K4, parameter_dump_packet.sy_lfr_rw3_k4); |
|
1636 | floatToChar( DEFAULT_SY_LFR_RW_K4, parameter_dump_packet.sy_lfr_rw3_k4); | |
1654 | // RW4_K |
|
1637 | // RW4_K | |
1655 | floatToChar( DEFAULT_SY_LFR_RW_K1, parameter_dump_packet.sy_lfr_rw4_k1); |
|
1638 | floatToChar( DEFAULT_SY_LFR_RW_K1, parameter_dump_packet.sy_lfr_rw4_k1); | |
1656 | floatToChar( DEFAULT_SY_LFR_RW_K2, parameter_dump_packet.sy_lfr_rw4_k2); |
|
1639 | floatToChar( DEFAULT_SY_LFR_RW_K2, parameter_dump_packet.sy_lfr_rw4_k2); | |
1657 | floatToChar( DEFAULT_SY_LFR_RW_K3, parameter_dump_packet.sy_lfr_rw4_k3); |
|
1640 | floatToChar( DEFAULT_SY_LFR_RW_K3, parameter_dump_packet.sy_lfr_rw4_k3); | |
1658 | floatToChar( DEFAULT_SY_LFR_RW_K4, parameter_dump_packet.sy_lfr_rw4_k4); |
|
1641 | floatToChar( DEFAULT_SY_LFR_RW_K4, parameter_dump_packet.sy_lfr_rw4_k4); | |
1659 |
|
1642 | |||
1660 | // LFR_RW_MASK |
|
1643 | // LFR_RW_MASK | |
1661 | for (k=0; k < BYTES_PER_MASKS_SET; k++) |
|
1644 | for (k=0; k < BYTES_PER_MASKS_SET; k++) | |
1662 | { |
|
1645 | { | |
1663 | parameter_dump_packet.sy_lfr_rw_mask_f0_word1[k] = INT8_ALL_F; |
|
1646 | parameter_dump_packet.sy_lfr_rw_mask_f0_word1[k] = INT8_ALL_F; | |
1664 | } |
|
1647 | } | |
1665 |
|
1648 | |||
1666 | // once the reaction wheels masks have been initialized, they have to be merged with the fbins masks |
|
1649 | // once the reaction wheels masks have been initialized, they have to be merged with the fbins masks | |
1667 | merge_fbins_masks(); |
|
1650 | merge_fbins_masks(); | |
1668 | } |
|
1651 | } | |
1669 |
|
1652 | |||
1670 | void init_kcoefficients_dump( void ) |
|
1653 | void init_kcoefficients_dump( void ) | |
1671 | { |
|
1654 | { | |
1672 | init_kcoefficients_dump_packet( &kcoefficients_dump_1, PKTNR_1, KCOEFF_BLK_NR_PKT1 ); |
|
1655 | init_kcoefficients_dump_packet( &kcoefficients_dump_1, PKTNR_1, KCOEFF_BLK_NR_PKT1 ); | |
1673 | init_kcoefficients_dump_packet( &kcoefficients_dump_2, PKTNR_2, KCOEFF_BLK_NR_PKT2 ); |
|
1656 | init_kcoefficients_dump_packet( &kcoefficients_dump_2, PKTNR_2, KCOEFF_BLK_NR_PKT2 ); | |
1674 |
|
1657 | |||
1675 | kcoefficient_node_1.previous = NULL; |
|
1658 | kcoefficient_node_1.previous = NULL; | |
1676 | kcoefficient_node_1.next = NULL; |
|
1659 | kcoefficient_node_1.next = NULL; | |
1677 | kcoefficient_node_1.sid = TM_CODE_K_DUMP; |
|
1660 | kcoefficient_node_1.sid = TM_CODE_K_DUMP; | |
1678 | kcoefficient_node_1.coarseTime = INIT_CHAR; |
|
1661 | kcoefficient_node_1.coarseTime = INIT_CHAR; | |
1679 | kcoefficient_node_1.fineTime = INIT_CHAR; |
|
1662 | kcoefficient_node_1.fineTime = INIT_CHAR; | |
1680 | kcoefficient_node_1.buffer_address = (int) &kcoefficients_dump_1; |
|
1663 | kcoefficient_node_1.buffer_address = (int) &kcoefficients_dump_1; | |
1681 | kcoefficient_node_1.status = INIT_CHAR; |
|
1664 | kcoefficient_node_1.status = INIT_CHAR; | |
1682 |
|
1665 | |||
1683 | kcoefficient_node_2.previous = NULL; |
|
1666 | kcoefficient_node_2.previous = NULL; | |
1684 | kcoefficient_node_2.next = NULL; |
|
1667 | kcoefficient_node_2.next = NULL; | |
1685 | kcoefficient_node_2.sid = TM_CODE_K_DUMP; |
|
1668 | kcoefficient_node_2.sid = TM_CODE_K_DUMP; | |
1686 | kcoefficient_node_2.coarseTime = INIT_CHAR; |
|
1669 | kcoefficient_node_2.coarseTime = INIT_CHAR; | |
1687 | kcoefficient_node_2.fineTime = INIT_CHAR; |
|
1670 | kcoefficient_node_2.fineTime = INIT_CHAR; | |
1688 | kcoefficient_node_2.buffer_address = (int) &kcoefficients_dump_2; |
|
1671 | kcoefficient_node_2.buffer_address = (int) &kcoefficients_dump_2; | |
1689 | kcoefficient_node_2.status = INIT_CHAR; |
|
1672 | kcoefficient_node_2.status = INIT_CHAR; | |
1690 | } |
|
1673 | } | |
1691 |
|
1674 | |||
1692 | void init_kcoefficients_dump_packet( Packet_TM_LFR_KCOEFFICIENTS_DUMP_t *kcoefficients_dump, unsigned char pkt_nr, unsigned char blk_nr ) |
|
1675 | void init_kcoefficients_dump_packet( Packet_TM_LFR_KCOEFFICIENTS_DUMP_t *kcoefficients_dump, unsigned char pkt_nr, unsigned char blk_nr ) | |
1693 | { |
|
1676 | { | |
1694 | unsigned int k; |
|
1677 | unsigned int k; | |
1695 | unsigned int packetLength; |
|
1678 | unsigned int packetLength; | |
1696 |
|
1679 | |||
1697 | packetLength = |
|
1680 | packetLength = | |
1698 | ((blk_nr * KCOEFF_BLK_SIZE) + BYTE_POS_KCOEFFICIENTS_PARAMETES) - CCSDS_TC_TM_PACKET_OFFSET; // 4 bytes for the CCSDS header |
|
1681 | ((blk_nr * KCOEFF_BLK_SIZE) + BYTE_POS_KCOEFFICIENTS_PARAMETES) - CCSDS_TC_TM_PACKET_OFFSET; // 4 bytes for the CCSDS header | |
1699 |
|
1682 | |||
1700 | kcoefficients_dump->targetLogicalAddress = CCSDS_DESTINATION_ID; |
|
1683 | kcoefficients_dump->targetLogicalAddress = CCSDS_DESTINATION_ID; | |
1701 | kcoefficients_dump->protocolIdentifier = CCSDS_PROTOCOLE_ID; |
|
1684 | kcoefficients_dump->protocolIdentifier = CCSDS_PROTOCOLE_ID; | |
1702 | kcoefficients_dump->reserved = CCSDS_RESERVED; |
|
1685 | kcoefficients_dump->reserved = CCSDS_RESERVED; | |
1703 | kcoefficients_dump->userApplication = CCSDS_USER_APP; |
|
1686 | kcoefficients_dump->userApplication = CCSDS_USER_APP; | |
1704 | kcoefficients_dump->packetID[0] = (unsigned char) (APID_TM_PARAMETER_DUMP >> SHIFT_1_BYTE); |
|
1687 | kcoefficients_dump->packetID[0] = (unsigned char) (APID_TM_PARAMETER_DUMP >> SHIFT_1_BYTE); | |
1705 | kcoefficients_dump->packetID[1] = (unsigned char) APID_TM_PARAMETER_DUMP; |
|
1688 | kcoefficients_dump->packetID[1] = (unsigned char) APID_TM_PARAMETER_DUMP; | |
1706 | kcoefficients_dump->packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; |
|
1689 | kcoefficients_dump->packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; | |
1707 | kcoefficients_dump->packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT; |
|
1690 | kcoefficients_dump->packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT; | |
1708 | kcoefficients_dump->packetLength[0] = (unsigned char) (packetLength >> SHIFT_1_BYTE); |
|
1691 | kcoefficients_dump->packetLength[0] = (unsigned char) (packetLength >> SHIFT_1_BYTE); | |
1709 | kcoefficients_dump->packetLength[1] = (unsigned char) packetLength; |
|
1692 | kcoefficients_dump->packetLength[1] = (unsigned char) packetLength; | |
1710 | // DATA FIELD HEADER |
|
1693 | // DATA FIELD HEADER | |
1711 | kcoefficients_dump->spare1_pusVersion_spare2 = SPARE1_PUSVERSION_SPARE2; |
|
1694 | kcoefficients_dump->spare1_pusVersion_spare2 = SPARE1_PUSVERSION_SPARE2; | |
1712 | kcoefficients_dump->serviceType = TM_TYPE_K_DUMP; |
|
1695 | kcoefficients_dump->serviceType = TM_TYPE_K_DUMP; | |
1713 | kcoefficients_dump->serviceSubType = TM_SUBTYPE_K_DUMP; |
|
1696 | kcoefficients_dump->serviceSubType = TM_SUBTYPE_K_DUMP; | |
1714 | kcoefficients_dump->destinationID= TM_DESTINATION_ID_GROUND; |
|
1697 | kcoefficients_dump->destinationID= TM_DESTINATION_ID_GROUND; | |
1715 | kcoefficients_dump->time[BYTE_0] = INIT_CHAR; |
|
1698 | kcoefficients_dump->time[BYTE_0] = INIT_CHAR; | |
1716 | kcoefficients_dump->time[BYTE_1] = INIT_CHAR; |
|
1699 | kcoefficients_dump->time[BYTE_1] = INIT_CHAR; | |
1717 | kcoefficients_dump->time[BYTE_2] = INIT_CHAR; |
|
1700 | kcoefficients_dump->time[BYTE_2] = INIT_CHAR; | |
1718 | kcoefficients_dump->time[BYTE_3] = INIT_CHAR; |
|
1701 | kcoefficients_dump->time[BYTE_3] = INIT_CHAR; | |
1719 | kcoefficients_dump->time[BYTE_4] = INIT_CHAR; |
|
1702 | kcoefficients_dump->time[BYTE_4] = INIT_CHAR; | |
1720 | kcoefficients_dump->time[BYTE_5] = INIT_CHAR; |
|
1703 | kcoefficients_dump->time[BYTE_5] = INIT_CHAR; | |
1721 | kcoefficients_dump->sid = SID_K_DUMP; |
|
1704 | kcoefficients_dump->sid = SID_K_DUMP; | |
1722 |
|
1705 | |||
1723 | kcoefficients_dump->pkt_cnt = KCOEFF_PKTCNT; |
|
1706 | kcoefficients_dump->pkt_cnt = KCOEFF_PKTCNT; | |
1724 | kcoefficients_dump->pkt_nr = PKTNR_1; |
|
1707 | kcoefficients_dump->pkt_nr = PKTNR_1; | |
1725 | kcoefficients_dump->blk_nr = blk_nr; |
|
1708 | kcoefficients_dump->blk_nr = blk_nr; | |
1726 |
|
1709 | |||
1727 | //****************** |
|
1710 | //****************** | |
1728 | // SOURCE DATA repeated N times with N in [0 .. PA_LFR_KCOEFF_BLK_NR] |
|
1711 | // SOURCE DATA repeated N times with N in [0 .. PA_LFR_KCOEFF_BLK_NR] | |
1729 | // one blk is 2 + 4 * 32 = 130 bytes, 30 blks max in one packet (30 * 130 = 3900) |
|
1712 | // one blk is 2 + 4 * 32 = 130 bytes, 30 blks max in one packet (30 * 130 = 3900) | |
1730 | for (k=0; k<(KCOEFF_BLK_NR_PKT1 * KCOEFF_BLK_SIZE); k++) |
|
1713 | for (k=0; k<(KCOEFF_BLK_NR_PKT1 * KCOEFF_BLK_SIZE); k++) | |
1731 | { |
|
1714 | { | |
1732 | kcoefficients_dump->kcoeff_blks[k] = INIT_CHAR; |
|
1715 | kcoefficients_dump->kcoeff_blks[k] = INIT_CHAR; | |
1733 | } |
|
1716 | } | |
1734 | } |
|
1717 | } | |
1735 |
|
1718 | |||
1736 | void increment_seq_counter_destination_id_dump( unsigned char *packet_sequence_control, unsigned char destination_id ) |
|
1719 | void increment_seq_counter_destination_id_dump( unsigned char *packet_sequence_control, unsigned char destination_id ) | |
1737 | { |
|
1720 | { | |
1738 | /** This function increment the packet sequence control parameter of a TC, depending on its destination ID. |
|
1721 | /** This function increment the packet sequence control parameter of a TC, depending on its destination ID. | |
1739 | * |
|
1722 | * | |
1740 | * @param packet_sequence_control points to the packet sequence control which will be incremented |
|
1723 | * @param packet_sequence_control points to the packet sequence control which will be incremented | |
1741 | * @param destination_id is the destination ID of the TM, there is one counter by destination ID |
|
1724 | * @param destination_id is the destination ID of the TM, there is one counter by destination ID | |
1742 | * |
|
1725 | * | |
1743 | * If the destination ID is not known, a dedicated counter is incremented. |
|
1726 | * If the destination ID is not known, a dedicated counter is incremented. | |
1744 | * |
|
1727 | * | |
1745 | */ |
|
1728 | */ | |
1746 |
|
1729 | |||
1747 | unsigned short sequence_cnt; |
|
1730 | unsigned short sequence_cnt; | |
1748 | unsigned short segmentation_grouping_flag; |
|
1731 | unsigned short segmentation_grouping_flag; | |
1749 | unsigned short new_packet_sequence_control; |
|
1732 | unsigned short new_packet_sequence_control; | |
1750 | unsigned char i; |
|
1733 | unsigned char i; | |
1751 |
|
1734 | |||
1752 | switch (destination_id) |
|
1735 | switch (destination_id) | |
1753 | { |
|
1736 | { | |
1754 | case SID_TC_GROUND: |
|
1737 | case SID_TC_GROUND: | |
1755 | i = GROUND; |
|
1738 | i = GROUND; | |
1756 | break; |
|
1739 | break; | |
1757 | case SID_TC_MISSION_TIMELINE: |
|
1740 | case SID_TC_MISSION_TIMELINE: | |
1758 | i = MISSION_TIMELINE; |
|
1741 | i = MISSION_TIMELINE; | |
1759 | break; |
|
1742 | break; | |
1760 | case SID_TC_TC_SEQUENCES: |
|
1743 | case SID_TC_TC_SEQUENCES: | |
1761 | i = TC_SEQUENCES; |
|
1744 | i = TC_SEQUENCES; | |
1762 | break; |
|
1745 | break; | |
1763 | case SID_TC_RECOVERY_ACTION_CMD: |
|
1746 | case SID_TC_RECOVERY_ACTION_CMD: | |
1764 | i = RECOVERY_ACTION_CMD; |
|
1747 | i = RECOVERY_ACTION_CMD; | |
1765 | break; |
|
1748 | break; | |
1766 | case SID_TC_BACKUP_MISSION_TIMELINE: |
|
1749 | case SID_TC_BACKUP_MISSION_TIMELINE: | |
1767 | i = BACKUP_MISSION_TIMELINE; |
|
1750 | i = BACKUP_MISSION_TIMELINE; | |
1768 | break; |
|
1751 | break; | |
1769 | case SID_TC_DIRECT_CMD: |
|
1752 | case SID_TC_DIRECT_CMD: | |
1770 | i = DIRECT_CMD; |
|
1753 | i = DIRECT_CMD; | |
1771 | break; |
|
1754 | break; | |
1772 | case SID_TC_SPARE_GRD_SRC1: |
|
1755 | case SID_TC_SPARE_GRD_SRC1: | |
1773 | i = SPARE_GRD_SRC1; |
|
1756 | i = SPARE_GRD_SRC1; | |
1774 | break; |
|
1757 | break; | |
1775 | case SID_TC_SPARE_GRD_SRC2: |
|
1758 | case SID_TC_SPARE_GRD_SRC2: | |
1776 | i = SPARE_GRD_SRC2; |
|
1759 | i = SPARE_GRD_SRC2; | |
1777 | break; |
|
1760 | break; | |
1778 | case SID_TC_OBCP: |
|
1761 | case SID_TC_OBCP: | |
1779 | i = OBCP; |
|
1762 | i = OBCP; | |
1780 | break; |
|
1763 | break; | |
1781 | case SID_TC_SYSTEM_CONTROL: |
|
1764 | case SID_TC_SYSTEM_CONTROL: | |
1782 | i = SYSTEM_CONTROL; |
|
1765 | i = SYSTEM_CONTROL; | |
1783 | break; |
|
1766 | break; | |
1784 | case SID_TC_AOCS: |
|
1767 | case SID_TC_AOCS: | |
1785 | i = AOCS; |
|
1768 | i = AOCS; | |
1786 | break; |
|
1769 | break; | |
1787 | case SID_TC_RPW_INTERNAL: |
|
1770 | case SID_TC_RPW_INTERNAL: | |
1788 | i = RPW_INTERNAL; |
|
1771 | i = RPW_INTERNAL; | |
1789 | break; |
|
1772 | break; | |
1790 | default: |
|
1773 | default: | |
1791 | i = GROUND; |
|
1774 | i = GROUND; | |
1792 | break; |
|
1775 | break; | |
1793 | } |
|
1776 | } | |
1794 |
|
1777 | |||
1795 | segmentation_grouping_flag = TM_PACKET_SEQ_CTRL_STANDALONE << SHIFT_1_BYTE; |
|
1778 | segmentation_grouping_flag = TM_PACKET_SEQ_CTRL_STANDALONE << SHIFT_1_BYTE; | |
1796 | sequence_cnt = sequenceCounters_TM_DUMP[ i ] & SEQ_CNT_MASK; |
|
1779 | sequence_cnt = sequenceCounters_TM_DUMP[ i ] & SEQ_CNT_MASK; | |
1797 |
|
1780 | |||
1798 | new_packet_sequence_control = segmentation_grouping_flag | sequence_cnt ; |
|
1781 | new_packet_sequence_control = segmentation_grouping_flag | sequence_cnt ; | |
1799 |
|
1782 | |||
1800 | packet_sequence_control[0] = (unsigned char) (new_packet_sequence_control >> SHIFT_1_BYTE); |
|
1783 | packet_sequence_control[0] = (unsigned char) (new_packet_sequence_control >> SHIFT_1_BYTE); | |
1801 | packet_sequence_control[1] = (unsigned char) (new_packet_sequence_control ); |
|
1784 | packet_sequence_control[1] = (unsigned char) (new_packet_sequence_control ); | |
1802 |
|
1785 | |||
1803 | // increment the sequence counter |
|
1786 | // increment the sequence counter | |
1804 | if ( sequenceCounters_TM_DUMP[ i ] < SEQ_CNT_MAX ) |
|
1787 | if ( sequenceCounters_TM_DUMP[ i ] < SEQ_CNT_MAX ) | |
1805 | { |
|
1788 | { | |
1806 | sequenceCounters_TM_DUMP[ i ] = sequenceCounters_TM_DUMP[ i ] + 1; |
|
1789 | sequenceCounters_TM_DUMP[ i ] = sequenceCounters_TM_DUMP[ i ] + 1; | |
1807 | } |
|
1790 | } | |
1808 | else |
|
1791 | else | |
1809 | { |
|
1792 | { | |
1810 | sequenceCounters_TM_DUMP[ i ] = 0; |
|
1793 | sequenceCounters_TM_DUMP[ i ] = 0; | |
1811 | } |
|
1794 | } | |
1812 | } |
|
1795 | } |
General Comments 0
You need to be logged in to leave comments.
Login now