Line data Source code
1 : /*------------------------------------------------------------------------------
2 : -- Solar Orbiter's Low Frequency Receiver Flight Software (LFR FSW),
3 : -- This file is a part of the LFR FSW
4 : -- Copyright (C) 2021, Plasma Physics Laboratory - CNRS
5 : --
6 : -- This program is free software; you can redistribute it and/or modify
7 : -- it under the terms of the GNU General Public License as published by
8 : -- the Free Software Foundation; either version 2 of the License, or
9 : -- (at your option) any later version.
10 : --
11 : -- This program is distributed in the hope that it will be useful,
12 : -- but WITHOUT ANY WARRANTY; without even the implied warranty of
13 : -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 : -- GNU General Public License for more details.
15 : --
16 : -- You should have received a copy of the GNU General Public License
17 : -- along with this program; if not, write to the Free Software
18 : -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 : -------------------------------------------------------------------------------*/
20 : /*-- Author : Alexis Jeandet
21 : -- Contact : Alexis Jeandet
22 : -- Mail : alexis.jeandet@lpp.polytechnique.fr
23 : ----------------------------------------------------------------------------*/
24 : #include "fsw_housekeeping.h"
25 : #include "fsw_debug.h"
26 : #include "fsw_globals.h"
27 : #include "fsw_misc.h"
28 : #include "lfr_cpu_usage_report.h"
29 :
30 :
31 1 : void init_housekeeping_parameters(void)
32 : {
33 : /** This function initialize the housekeeping_packet global variable with default values.
34 : *
35 : */
36 :
37 : unsigned char* parameters;
38 : unsigned char sizeOfHK;
39 :
40 1 : sizeOfHK = sizeof(Packet_TM_LFR_HK_t);
41 :
42 1 : parameters = (unsigned char*)&housekeeping_packet;
43 :
44 141 : for (int i = 0; i < sizeOfHK; i++)
45 : {
46 140 : parameters[i] = INIT_CHAR;
47 : }
48 :
49 1 : housekeeping_packet.targetLogicalAddress = CCSDS_DESTINATION_ID;
50 1 : housekeeping_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID;
51 1 : housekeeping_packet.reserved = DEFAULT_RESERVED;
52 1 : housekeeping_packet.userApplication = CCSDS_USER_APP;
53 1 : housekeeping_packet.packetID[0] = (unsigned char)(APID_TM_HK >> SHIFT_1_BYTE);
54 1 : housekeeping_packet.packetID[1] = (unsigned char)(APID_TM_HK);
55 1 : housekeeping_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
56 1 : housekeeping_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
57 1 : housekeeping_packet.packetLength[0] = (unsigned char)(PACKET_LENGTH_HK >> SHIFT_1_BYTE);
58 1 : housekeeping_packet.packetLength[1] = (unsigned char)(PACKET_LENGTH_HK);
59 1 : housekeeping_packet.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
60 1 : housekeeping_packet.serviceType = TM_TYPE_HK;
61 1 : housekeeping_packet.serviceSubType = TM_SUBTYPE_HK;
62 1 : housekeeping_packet.destinationID = TM_DESTINATION_ID_GROUND;
63 1 : housekeeping_packet.sid = SID_HK;
64 :
65 : // init status word
66 1 : housekeeping_packet.lfr_status_word[0] = DEFAULT_STATUS_WORD_BYTE0;
67 1 : housekeeping_packet.lfr_status_word[1] = DEFAULT_STATUS_WORD_BYTE1;
68 : // init software version
69 1 : housekeeping_packet.lfr_sw_version[0] = SW_VERSION_N1;
70 1 : housekeeping_packet.lfr_sw_version[1] = SW_VERSION_N2;
71 1 : housekeeping_packet.lfr_sw_version[BYTE_2] = SW_VERSION_N3;
72 1 : housekeeping_packet.lfr_sw_version[BYTE_3] = SW_VERSION_N4;
73 : // init fpga version
74 1 : parameters = (unsigned char*)(REGS_ADDR_VHDL_VERSION);
75 1 : housekeeping_packet.lfr_fpga_version[BYTE_0] = parameters[BYTE_1]; // n1
76 1 : housekeeping_packet.lfr_fpga_version[BYTE_1] = parameters[BYTE_2]; // n2
77 1 : housekeeping_packet.lfr_fpga_version[BYTE_2] = parameters[BYTE_3]; // n3
78 :
79 1 : housekeeping_packet.hk_lfr_q_sd_fifo_size = MSG_QUEUE_COUNT_SEND;
80 1 : housekeeping_packet.hk_lfr_q_rv_fifo_size = MSG_QUEUE_COUNT_RECV;
81 1 : housekeeping_packet.hk_lfr_q_p0_fifo_size = MSG_QUEUE_COUNT_PRC0;
82 1 : housekeeping_packet.hk_lfr_q_p1_fifo_size = MSG_QUEUE_COUNT_PRC1;
83 1 : housekeeping_packet.hk_lfr_q_p2_fifo_size = MSG_QUEUE_COUNT_PRC2;
84 1 : }
85 :
86 5 : void set_hk_lfr_sc_potential_flag(bool state)
87 : {
88 5 : if (state == true)
89 : {
90 5 : housekeeping_packet.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1]
91 : | STATUS_WORD_SC_POTENTIAL_FLAG_BIT; // [0100 0000]
92 : }
93 : else
94 : {
95 0 : housekeeping_packet.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1]
96 : & STATUS_WORD_SC_POTENTIAL_FLAG_MASK; // [1011 1111]
97 : }
98 5 : }
99 :
100 0 : void set_sy_lfr_pas_filter_enabled(bool state)
101 : {
102 0 : if (state == true)
103 : {
104 0 : housekeeping_packet.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1]
105 : | STATUS_WORD_PAS_FILTER_ENABLED_BIT; // [0010 0000]
106 : }
107 : else
108 : {
109 0 : housekeeping_packet.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1]
110 : & STATUS_WORD_PAS_FILTER_ENABLED_MASK; // [1101 1111]
111 : }
112 0 : }
113 :
114 1 : void set_sy_lfr_watchdog_enabled(bool state)
115 : {
116 1 : if (state == true)
117 : {
118 1 : housekeeping_packet.lfr_status_word[1]
119 1 : = housekeeping_packet.lfr_status_word[1] | STATUS_WORD_WATCHDOG_BIT; // [0001 0000]
120 : }
121 : else
122 : {
123 0 : housekeeping_packet.lfr_status_word[1]
124 0 : = housekeeping_packet.lfr_status_word[1] & STATUS_WORD_WATCHDOG_MASK; // [1110 1111]
125 : }
126 1 : }
127 :
128 1 : void set_hk_lfr_calib_enable(bool state)
129 : {
130 1 : if (state == true)
131 : {
132 0 : housekeeping_packet.lfr_status_word[1]
133 0 : = housekeeping_packet.lfr_status_word[1] | STATUS_WORD_CALIB_BIT; // [0000 1000]
134 : }
135 : else
136 : {
137 1 : housekeeping_packet.lfr_status_word[1]
138 1 : = housekeeping_packet.lfr_status_word[1] & STATUS_WORD_CALIB_MASK; // [1111 0111]
139 : }
140 1 : }
141 :
142 1 : void set_hk_lfr_reset_cause(enum lfr_reset_cause_t lfr_reset_cause)
143 : {
144 1 : housekeeping_packet.lfr_status_word[1]
145 1 : = housekeeping_packet.lfr_status_word[1] & STATUS_WORD_RESET_CAUSE_MASK; // [1111 1000]
146 :
147 1 : housekeeping_packet.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1]
148 : | (lfr_reset_cause & STATUS_WORD_RESET_CAUSE_BITS); // [0000 0111]
149 1 : }
150 :
151 0 : void increment_hk_counter(unsigned char newValue, unsigned char oldValue, unsigned int* counter)
152 : {
153 752 : int delta = 0;
154 :
155 752 : if (newValue >= oldValue)
156 : {
157 752 : delta = newValue - oldValue;
158 : }
159 : else
160 : {
161 0 : delta = (MAX_OF(unsigned char) + 1 - oldValue) + newValue;
162 : }
163 :
164 752 : *counter = *counter + delta;
165 0 : }
166 :
167 : // Low severity error counters update
168 47 : void hk_lfr_le_update(void)
169 : {
170 : static hk_lfr_le_t old_hk_lfr_le = { 0 };
171 : hk_lfr_le_t new_hk_lfr_le;
172 : unsigned int counter;
173 :
174 94 : counter = (((unsigned int)housekeeping_packet.hk_lfr_le_cnt[0]) * CONST_256)
175 47 : + housekeeping_packet.hk_lfr_le_cnt[1];
176 :
177 : // DPU
178 47 : new_hk_lfr_le.dpu_spw_parity = housekeeping_packet.hk_lfr_dpu_spw_parity;
179 47 : new_hk_lfr_le.dpu_spw_disconnect = housekeeping_packet.hk_lfr_dpu_spw_disconnect;
180 47 : new_hk_lfr_le.dpu_spw_escape = housekeeping_packet.hk_lfr_dpu_spw_escape;
181 47 : new_hk_lfr_le.dpu_spw_credit = housekeeping_packet.hk_lfr_dpu_spw_credit;
182 47 : new_hk_lfr_le.dpu_spw_write_sync = housekeeping_packet.hk_lfr_dpu_spw_write_sync;
183 : // TIMECODE
184 47 : new_hk_lfr_le.timecode_erroneous = housekeeping_packet.hk_lfr_timecode_erroneous;
185 47 : new_hk_lfr_le.timecode_missing = housekeeping_packet.hk_lfr_timecode_missing;
186 47 : new_hk_lfr_le.timecode_invalid = housekeeping_packet.hk_lfr_timecode_invalid;
187 : // TIME
188 47 : new_hk_lfr_le.time_timecode_it = housekeeping_packet.hk_lfr_time_timecode_it;
189 47 : new_hk_lfr_le.time_not_synchro = housekeeping_packet.hk_lfr_time_not_synchro;
190 47 : new_hk_lfr_le.time_timecode_ctr = housekeeping_packet.hk_lfr_time_timecode_ctr;
191 : // AHB
192 47 : new_hk_lfr_le.ahb_correctable = housekeeping_packet.hk_lfr_ahb_correctable;
193 : // housekeeping_packet.hk_lfr_dpu_spw_rx_ahb => not handled by the grspw driver
194 : // housekeeping_packet.hk_lfr_dpu_spw_tx_ahb => not handled by the grspw driver
195 :
196 : // update the le counter
197 : // DPU
198 47 : increment_hk_counter(new_hk_lfr_le.dpu_spw_parity, old_hk_lfr_le.dpu_spw_parity, &counter);
199 94 : increment_hk_counter(
200 94 : new_hk_lfr_le.dpu_spw_disconnect, old_hk_lfr_le.dpu_spw_disconnect, &counter);
201 47 : increment_hk_counter(new_hk_lfr_le.dpu_spw_escape, old_hk_lfr_le.dpu_spw_escape, &counter);
202 47 : increment_hk_counter(new_hk_lfr_le.dpu_spw_credit, old_hk_lfr_le.dpu_spw_credit, &counter);
203 94 : increment_hk_counter(
204 94 : new_hk_lfr_le.dpu_spw_write_sync, old_hk_lfr_le.dpu_spw_write_sync, &counter);
205 : // TIMECODE
206 94 : increment_hk_counter(
207 94 : new_hk_lfr_le.timecode_erroneous, old_hk_lfr_le.timecode_erroneous, &counter);
208 47 : increment_hk_counter(new_hk_lfr_le.timecode_missing, old_hk_lfr_le.timecode_missing, &counter);
209 47 : increment_hk_counter(new_hk_lfr_le.timecode_invalid, old_hk_lfr_le.timecode_invalid, &counter);
210 : // TIME
211 47 : increment_hk_counter(new_hk_lfr_le.time_timecode_it, old_hk_lfr_le.time_timecode_it, &counter);
212 47 : increment_hk_counter(new_hk_lfr_le.time_not_synchro, old_hk_lfr_le.time_not_synchro, &counter);
213 94 : increment_hk_counter(
214 94 : new_hk_lfr_le.time_timecode_ctr, old_hk_lfr_le.time_timecode_ctr, &counter);
215 : // AHB
216 47 : increment_hk_counter(new_hk_lfr_le.ahb_correctable, old_hk_lfr_le.ahb_correctable, &counter);
217 :
218 :
219 47 : old_hk_lfr_le = new_hk_lfr_le;
220 : // housekeeping_packet.hk_lfr_dpu_spw_rx_ahb => not handled by the grspw driver
221 : // housekeeping_packet.hk_lfr_dpu_spw_tx_ahb => not handled by the grspw driver
222 :
223 : // update housekeeping packet counters, convert unsigned int numbers in 2 bytes numbers
224 : // LE
225 47 : housekeeping_packet.hk_lfr_le_cnt[0] = (unsigned char)((counter & BYTE0_MASK) >> SHIFT_1_BYTE);
226 47 : housekeeping_packet.hk_lfr_le_cnt[1] = (unsigned char)(counter & BYTE1_MASK);
227 47 : }
228 :
229 : // Medium severity error counters update
230 47 : void hk_lfr_me_update(void)
231 : {
232 : static hk_lfr_me_t old_hk_lfr_me = { 0 };
233 : hk_lfr_me_t new_hk_lfr_me;
234 : unsigned int counter;
235 :
236 94 : counter = (((unsigned int)housekeeping_packet.hk_lfr_me_cnt[0]) * CONST_256)
237 47 : + housekeeping_packet.hk_lfr_me_cnt[1];
238 :
239 : // get the current values
240 47 : new_hk_lfr_me.dpu_spw_early_eop = housekeeping_packet.hk_lfr_dpu_spw_early_eop;
241 47 : new_hk_lfr_me.dpu_spw_invalid_addr = housekeeping_packet.hk_lfr_dpu_spw_invalid_addr;
242 47 : new_hk_lfr_me.dpu_spw_eep = housekeeping_packet.hk_lfr_dpu_spw_eep;
243 47 : new_hk_lfr_me.dpu_spw_rx_too_big = housekeeping_packet.hk_lfr_dpu_spw_rx_too_big;
244 :
245 : // update the me counter
246 94 : increment_hk_counter(
247 94 : new_hk_lfr_me.dpu_spw_early_eop, old_hk_lfr_me.dpu_spw_early_eop, &counter);
248 94 : increment_hk_counter(
249 94 : new_hk_lfr_me.dpu_spw_invalid_addr, old_hk_lfr_me.dpu_spw_invalid_addr, &counter);
250 47 : increment_hk_counter(new_hk_lfr_me.dpu_spw_eep, old_hk_lfr_me.dpu_spw_eep, &counter);
251 94 : increment_hk_counter(
252 94 : new_hk_lfr_me.dpu_spw_rx_too_big, old_hk_lfr_me.dpu_spw_rx_too_big, &counter);
253 :
254 : // store the counters for the next time
255 47 : old_hk_lfr_me.dpu_spw_early_eop = new_hk_lfr_me.dpu_spw_early_eop;
256 47 : old_hk_lfr_me.dpu_spw_invalid_addr = new_hk_lfr_me.dpu_spw_invalid_addr;
257 47 : old_hk_lfr_me.dpu_spw_eep = new_hk_lfr_me.dpu_spw_eep;
258 47 : old_hk_lfr_me.dpu_spw_rx_too_big = new_hk_lfr_me.dpu_spw_rx_too_big;
259 :
260 : // update housekeeping packet counters, convert unsigned int numbers in 2 bytes numbers
261 : // ME
262 47 : housekeeping_packet.hk_lfr_me_cnt[0] = (unsigned char)((counter & BYTE0_MASK) >> SHIFT_1_BYTE);
263 47 : housekeeping_packet.hk_lfr_me_cnt[1] = (unsigned char)(counter & BYTE1_MASK);
264 47 : }
265 :
266 : // High severity error counters update
267 47 : void hk_lfr_le_me_he_update()
268 : {
269 :
270 : // update the low severity error counter
271 47 : hk_lfr_le_update();
272 :
273 : // update the medium severity error counter
274 47 : hk_lfr_me_update();
275 :
276 : // update the high severity error counter
277 : // LFR has no high severity errors
278 47 : housekeeping_packet.hk_lfr_he_cnt[0] = 0;
279 47 : housekeeping_packet.hk_lfr_he_cnt[1] = 0;
280 47 : }
281 :
282 47 : void set_hk_lfr_time_not_synchro()
283 : {
284 : static unsigned char synchroLost = 1;
285 : int synchronizationBit;
286 :
287 : // get the synchronization bit
288 47 : synchronizationBit = (time_management_regs->coarse_time & VAL_LFR_SYNCHRONIZED)
289 : >> BIT_SYNCHRONIZATION; // 1000 0000 0000 0000
290 :
291 47 : switch (synchronizationBit)
292 : {
293 : case 0:
294 39 : if (synchroLost == 1)
295 : {
296 1 : synchroLost = 0;
297 : }
298 : break;
299 : case 1:
300 8 : if (synchroLost == 0)
301 : {
302 0 : synchroLost = 1;
303 0 : housekeeping_packet.hk_lfr_time_not_synchro
304 0 : = increase_unsigned_char_counter(housekeeping_packet.hk_lfr_time_not_synchro);
305 0 : update_hk_lfr_last_er_fields(RID_LE_LFR_TIME, CODE_NOT_SYNCHRO);
306 : }
307 : break;
308 : default:
309 : LFR_PRINTF(
310 : "in hk_lfr_time_not_synchro *** unexpected value for synchronizationBit = %d\n",
311 : synchronizationBit);
312 : break;
313 : }
314 47 : }
315 :
316 47 : void increment_seq_counter(unsigned short* packetSequenceControl)
317 : {
318 : /** This function increment the sequence counter passes in argument.
319 : *
320 : * The increment does not affect the grouping flag. In case of an overflow, the counter is reset
321 : * to 0.
322 : *
323 : */
324 :
325 : unsigned short segmentation_grouping_flag;
326 : unsigned short sequence_cnt;
327 :
328 47 : segmentation_grouping_flag = TM_PACKET_SEQ_CTRL_STANDALONE
329 : << SHIFT_1_BYTE; // keep bits 7 downto 6
330 47 : sequence_cnt = (*packetSequenceControl) & SEQ_CNT_MASK; // [0011 1111 1111 1111]
331 :
332 47 : if (sequence_cnt < SEQ_CNT_MAX)
333 : {
334 47 : sequence_cnt = sequence_cnt + 1;
335 : }
336 : else
337 : {
338 0 : sequence_cnt = 0;
339 : }
340 :
341 47 : *packetSequenceControl = segmentation_grouping_flag | sequence_cnt;
342 47 : }
343 :
344 90 : void update_hk_lfr_last_er_fields(unsigned int rid, unsigned char code)
345 : {
346 : const volatile unsigned char* const coarseTimePtr
347 90 : = (volatile unsigned char*)&time_management_regs->coarse_time;
348 : const volatile unsigned char* const fineTimePtr
349 90 : = (volatile unsigned char*)&time_management_regs->fine_time;
350 :
351 90 : housekeeping_packet.hk_lfr_last_er_rid[0] = (unsigned char)((rid & BYTE0_MASK) >> SHIFT_1_BYTE);
352 90 : housekeeping_packet.hk_lfr_last_er_rid[1] = (unsigned char)(rid & BYTE1_MASK);
353 90 : housekeeping_packet.hk_lfr_last_er_code = code;
354 90 : housekeeping_packet.hk_lfr_last_er_time[0] = coarseTimePtr[0];
355 90 : housekeeping_packet.hk_lfr_last_er_time[1] = coarseTimePtr[1];
356 90 : housekeeping_packet.hk_lfr_last_er_time[BYTE_2] = coarseTimePtr[BYTE_2];
357 90 : housekeeping_packet.hk_lfr_last_er_time[BYTE_3] = coarseTimePtr[BYTE_3];
358 90 : housekeeping_packet.hk_lfr_last_er_time[BYTE_4] = fineTimePtr[BYTE_2];
359 90 : housekeeping_packet.hk_lfr_last_er_time[BYTE_5] = fineTimePtr[BYTE_3];
360 90 : }
361 :
362 0 : void set_hk_lfr_ahb_correctable() // CRITICITY L
363 : {
364 : /** This function builds the error counter hk_lfr_ahb_correctable using the statistics provided
365 : * by the Cache Control Register (ASI 2, offset 0) and in the Register Protection Control
366 : * Register (ASR16) on the detected errors in the cache, in the integer unit and in the floating
367 : * point unit.
368 : *
369 : * @param void
370 : *
371 : * @return void
372 : *
373 : * All errors are summed to set the value of the hk_lfr_ahb_correctable counter.
374 : *
375 : */
376 :
377 : unsigned int ahb_correctable;
378 : unsigned int instructionErrorCounter;
379 : unsigned int dataErrorCounter;
380 : unsigned int fprfErrorCounter;
381 : unsigned int iurfErrorCounter;
382 :
383 0 : instructionErrorCounter = 0;
384 0 : dataErrorCounter = 0;
385 0 : fprfErrorCounter = 0;
386 0 : iurfErrorCounter = 0;
387 :
388 0 : CCR_getInstructionAndDataErrorCounters(&instructionErrorCounter, &dataErrorCounter);
389 0 : ASR16_get_FPRF_IURF_ErrorCounters(&fprfErrorCounter, &iurfErrorCounter);
390 :
391 0 : ahb_correctable = instructionErrorCounter + dataErrorCounter + fprfErrorCounter
392 0 : + iurfErrorCounter + housekeeping_packet.hk_lfr_ahb_correctable;
393 :
394 0 : housekeeping_packet.hk_lfr_ahb_correctable
395 0 : = (unsigned char)(ahb_correctable & INT8_ALL_F); // [1111 1111]
396 0 : }
397 :
398 :
399 27 : void getTime(unsigned char* time)
400 : {
401 : /** This function write the current local time in the time buffer passed in argument.
402 : *
403 : */
404 :
405 27 : time[0] = (unsigned char)(time_management_regs->coarse_time >> SHIFT_3_BYTES);
406 27 : time[1] = (unsigned char)(time_management_regs->coarse_time >> SHIFT_2_BYTES);
407 27 : time[2] = (unsigned char)(time_management_regs->coarse_time >> SHIFT_1_BYTE);
408 27 : time[3] = (unsigned char)(time_management_regs->coarse_time);
409 27 : time[4] = (unsigned char)(time_management_regs->fine_time >> SHIFT_1_BYTE);
410 27 : time[5] = (unsigned char)(time_management_regs->fine_time);
411 27 : }
412 :
413 0 : unsigned long long int getTimeAsUnsignedLongLongInt()
414 : {
415 : /** This function write the current local time in the time buffer passed in argument.
416 : *
417 : */
418 : unsigned long long int time;
419 :
420 0 : time = ((unsigned long long int)(time_management_regs->coarse_time & COARSE_TIME_MASK)
421 : << SHIFT_2_BYTES)
422 0 : + time_management_regs->fine_time;
423 :
424 0 : return time;
425 : }
426 :
427 :
428 : /**
429 : * @brief get_cpu_load, computes CPU load, CPU load average and CPU load max
430 : * @param resource_statistics stores:
431 : * - CPU load at index 0
432 : * - CPU load max at index 1
433 : * - CPU load average at index 2
434 : *
435 : * The CPU load average is computed on the last 60 values with a simple moving average.
436 : */
437 47 : void encode_cpu_load(Packet_TM_LFR_HK_t* hk_packet)
438 : {
439 : #define LOAD_AVG_SIZE 60
440 : static unsigned char cpu_load_hist[LOAD_AVG_SIZE] = { 0 };
441 : static char old_avg_pos = 0;
442 : static unsigned int cpu_load_avg;
443 : unsigned char cpu_load;
444 :
445 47 : cpu_load = lfr_rtems_cpu_usage_report();
446 :
447 : // HK_LFR_CPU_LOAD
448 47 : hk_packet->hk_lfr_cpu_load = cpu_load;
449 :
450 : // HK_LFR_CPU_LOAD_MAX
451 47 : if (cpu_load > hk_packet->hk_lfr_cpu_load_max)
452 : {
453 7 : hk_packet->hk_lfr_cpu_load_max = cpu_load;
454 : }
455 :
456 47 : cpu_load_avg
457 47 : = cpu_load_avg - (unsigned int)cpu_load_hist[(int)old_avg_pos] + (unsigned int)cpu_load;
458 47 : cpu_load_hist[(int)old_avg_pos] = cpu_load;
459 47 : old_avg_pos += 1;
460 47 : old_avg_pos %= LOAD_AVG_SIZE;
461 : // CPU_LOAD_AVE
462 47 : hk_packet->hk_lfr_cpu_load_aver = (unsigned char)(cpu_load_avg / LOAD_AVG_SIZE);
463 : // this will change the way LFR compute usage
464 : #ifndef PRINT_TASK_STATISTICS
465 47 : rtems_cpu_usage_reset();
466 : #endif
467 47 : }
|