##// END OF EJS Templates
Removed unused function and implemented scrubbing perriod counter...
jeandet -
r389:74df79cc7806 No PWD scrub with... draft
parent child
Show More
@@ -1,157 +1,156
1 1 #ifndef FSW_MISC_H_INCLUDED
2 2 #define FSW_MISC_H_INCLUDED
3 3
4 4 #include <rtems.h>
5 5 #include <stdio.h>
6 6 #include <grspw.h>
7 7 #include <grlib_regs.h>
8 8
9 9 #include "fsw_params.h"
10 10 #include "fsw_spacewire.h"
11 11 #include "lfr_cpu_usage_report.h"
12 12
13 13 #define WATCHDOG_LOOP_PRINTF 10
14 14 #define WATCHDOG_LOOP_DEBUG 3
15 15
16 16 #define NB_RTEMS_EVENTS 32
17 17 #define EVENT_12 12
18 18 #define EVENT_13 13
19 19 #define EVENT_14 14
20 20 #define DUMB_MESSAGE_1 "in DUMB *** timecode_irq_handler"
21 21 #define DUMB_MESSAGE_12 "WATCHDOG timer"
22 22 #define DUMB_MESSAGE_13 "TIMECODE timer"
23 23
24 24 enum lfr_reset_cause_t{
25 25 UNKNOWN_CAUSE,
26 26 POWER_ON,
27 27 TC_RESET,
28 28 WATCHDOG,
29 29 ERROR_RESET,
30 30 UNEXP_RESET
31 31 };
32 32
33 33 typedef struct{
34 34 unsigned char dpu_spw_parity;
35 35 unsigned char dpu_spw_disconnect;
36 36 unsigned char dpu_spw_escape;
37 37 unsigned char dpu_spw_credit;
38 38 unsigned char dpu_spw_write_sync;
39 39 unsigned char timecode_erroneous;
40 40 unsigned char timecode_missing;
41 41 unsigned char timecode_invalid;
42 42 unsigned char time_timecode_it;
43 43 unsigned char time_not_synchro;
44 44 unsigned char time_timecode_ctr;
45 45 unsigned char ahb_correctable;
46 46 } hk_lfr_le_t;
47 47
48 48 typedef struct{
49 49 unsigned char dpu_spw_early_eop;
50 50 unsigned char dpu_spw_invalid_addr;
51 51 unsigned char dpu_spw_eep;
52 52 unsigned char dpu_spw_rx_too_big;
53 53 } hk_lfr_me_t;
54 54
55 55 #define B00 196
56 56 #define B01 196
57 57 #define B02 0
58 58 #define B10 131
59 59 #define B11 -244
60 60 #define B12 131
61 61 #define B20 161
62 62 #define B21 -314
63 63 #define B22 161
64 64
65 65 #define A00 1
66 66 #define A01 -925
67 67 #define A02 0
68 68 #define A10 1
69 69 #define A11 -947
70 70 #define A12 439
71 71 #define A20 1
72 72 #define A21 -993
73 73 #define A22 486
74 74
75 75 #define GAIN_B0 12
76 76 #define GAIN_B1 11
77 77 #define GAIN_B2 10
78 78
79 79 #define GAIN_A0 10
80 80 #define GAIN_A1 9
81 81 #define GAIN_A2 9
82 82
83 83 #define NB_COEFFS 3
84 84 #define COEFF0 0
85 85 #define COEFF1 1
86 86 #define COEFF2 2
87 87
88 88 typedef struct filter_ctx
89 89 {
90 90 int W[NB_COEFFS][NB_COEFFS];
91 91 }filter_ctx;
92 92
93 93 extern gptimer_regs_t *gptimer_regs;
94 94 extern void ASR16_get_FPRF_IURF_ErrorCounters( unsigned int*, unsigned int* );
95 95 extern void CCR_getInstructionAndDataErrorCounters( unsigned int*, unsigned int* );
96 96
97 97 extern rtems_name name_hk_rate_monotonic; // name of the HK rate monotonic
98 98 extern rtems_id HK_id;// id of the HK rate monotonic period
99 99 extern rtems_name name_avgv_rate_monotonic; // name of the AVGV rate monotonic
100 100 extern rtems_id AVGV_id;// id of the AVGV rate monotonic period
101 101
102 102 void timer_configure( unsigned char timer, unsigned int clock_divider,
103 103 unsigned char interrupt_level, rtems_isr (*timer_isr)() );
104 104 void timer_start( unsigned char timer );
105 105 void timer_stop( unsigned char timer );
106 106 void timer_set_clock_divider(unsigned char timer, unsigned int clock_divider);
107 107
108 108 // WATCHDOG
109 109 rtems_isr watchdog_isr( rtems_vector_number vector );
110 110 void watchdog_configure(void);
111 111 void watchdog_stop(void);
112 112 void watchdog_reload(void);
113 113 void watchdog_start(void);
114 114
115 115 // SERIAL LINK
116 116 int send_console_outputs_on_apbuart_port( void );
117 117 int enable_apbuart_transmitter( void );
118 118 void set_apbuart_scaler_reload_register(unsigned int regs, unsigned int value);
119 119
120 120 // RTEMS TASKS
121 121 rtems_task load_task( rtems_task_argument argument );
122 122 rtems_task hous_task( rtems_task_argument argument );
123 123 rtems_task avgv_task( rtems_task_argument argument );
124 124 rtems_task dumb_task( rtems_task_argument unused );
125 125 rtems_task scrubbing_task( rtems_task_argument unused );
126 126 rtems_task calibration_sweep_task( rtems_task_argument unused );
127 127
128 128 void init_housekeeping_parameters( void );
129 129 void increment_seq_counter(unsigned short *packetSequenceControl);
130 130 void getTime( unsigned char *time);
131 131 unsigned long long int getTimeAsUnsignedLongLongInt( );
132 void send_dumb_hk( void );
133 132 void get_temperatures( unsigned char *temperatures );
134 133 void get_v_e1_e2_f3( unsigned char *spacecraft_potential );
135 134 void get_cpu_load( unsigned char *resource_statistics );
136 135 void set_hk_lfr_sc_potential_flag( bool state );
137 136 void set_sy_lfr_pas_filter_enabled( bool state );
138 137 void set_sy_lfr_watchdog_enabled( bool state );
139 138 void set_hk_lfr_calib_enable( bool state );
140 139 void set_hk_lfr_reset_cause( enum lfr_reset_cause_t lfr_reset_cause );
141 140 void hk_lfr_le_me_he_update();
142 141 void set_hk_lfr_time_not_synchro();
143 142
144 143 extern int sched_yield( void );
145 144 extern void rtems_cpu_usage_reset();
146 145 extern ring_node *current_ring_node_f3;
147 146 extern ring_node *ring_node_to_send_cwf_f3;
148 147 extern ring_node waveform_ring_f3[];
149 148 extern unsigned short sequenceCounterHK;
150 149
151 150 extern unsigned char hk_lfr_q_sd_fifo_size_max;
152 151 extern unsigned char hk_lfr_q_rv_fifo_size_max;
153 152 extern unsigned char hk_lfr_q_p0_fifo_size_max;
154 153 extern unsigned char hk_lfr_q_p1_fifo_size_max;
155 154 extern unsigned char hk_lfr_q_p2_fifo_size_max;
156 155
157 156 #endif // FSW_MISC_H_INCLUDED
@@ -1,44 +1,39
1 1 set(rtems_dir /opt/rtems-4.10/)
2 2
3 3 set(CMAKE_SYSTEM_NAME rtems)
4 4 set(CMAKE_C_COMPILER ${rtems_dir}/bin/sparc-rtems-gcc)
5 5 set(CMAKE_CXX_COMPILER ${rtems_dir}/bin/sparc-rtems-g++)
6 6 set(CMAKE_LINKER ${rtems_dir}/bin/sparc-rtems-g++)
7 7 SET(CMAKE_EXE_LINKER_FLAGS "-static")
8 8 option(fix-b2bst "Activate -mfix-b2bst switch to mitigate \"LEON3FT Stale Cache Entry After Store with Data Tag Parity Error\" errata, GRLIB-TN-0009" ON)
9 9
10 10 option(Coverage "Enables code coverage" OFF)
11 11
12 12
13 13 set(CMAKE_C_FLAGS_RELEASE "-O3")
14 14 set(CMAKE_C_FLAGS_DEBUG "-O0")
15 15
16 16
17 17 if(fix-b2bst)
18 18 set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -mfix-b2bst")
19 19 set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -mfix-b2bst")
20 20 endif()
21 21
22 #if(Coverage)
23 # set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -fprofile-arcs -ftest-coverage")
24 # set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -fprofile-arcs -ftest-coverage")
25 #endif()
26
27 22
28 23 set(CMAKE_C_LINK_EXECUTABLE "<CMAKE_LINKER> <FLAGS> -Xlinker -Map=<TARGET>.map <CMAKE_CXX_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>")
29 24
30 25 include_directories("${rtems_dir}/sparc-rtems/leon3/lib/include")
31 26
32 27 function (check_b2bst target bin)
33 28 add_custom_command(TARGET ${target}
34 29 POST_BUILD
35 30 COMMAND ${rtems_dir}/bin/sparc-rtems-objdump -d ${bin}/${target} | ${CMAKE_SOURCE_DIR}/sparc/leon3ft-b2bst-scan.tcl
36 31 )
37 32 endfunction()
38 33
39 34 function (build_srec target bin rev)
40 35 add_custom_command(TARGET ${target}
41 36 POST_BUILD
42 37 COMMAND ${rtems_dir}/bin/sparc-rtems-objcopy -j .data -F srec ${bin}/${target} RpwLfrApp_XXXX_data_rev-${rev}.srec && ${rtems_dir}/bin/sparc-rtems-objcopy -j .text -F srec ${bin}/${target} RpwLfrApp_XXXX_text_rev-${rev}.srec
43 38 )
44 39 endfunction()
@@ -1,125 +1,130
1 1 cmake_minimum_required (VERSION 2.6)
2 2 project (fsw)
3 3
4 4 include(sparc-rtems)
5 5 include(cppcheck)
6 6
7 7 include_directories("../header"
8 8 "../header/lfr_common_headers"
9 9 "../header/processing"
10 10 "../LFR_basic-parameters"
11 11 "../src")
12 12
13 13 set(SOURCES wf_handler.c
14 14 tc_handler.c
15 15 fsw_misc.c
16 16 fsw_init.c
17 17 fsw_globals.c
18 18 fsw_spacewire.c
19 19 tc_load_dump_parameters.c
20 20 tm_lfr_tc_exe.c
21 21 tc_acceptance.c
22 22 processing/fsw_processing.c
23 23 processing/avf0_prc0.c
24 24 processing/avf1_prc1.c
25 25 processing/avf2_prc2.c
26 26 lfr_cpu_usage_report.c
27 27 ${LFR_BP_SRC}
28 28 ../header/wf_handler.h
29 29 ../header/tc_handler.h
30 30 ../header/grlib_regs.h
31 31 ../header/fsw_misc.h
32 32 ../header/fsw_init.h
33 33 ../header/fsw_spacewire.h
34 34 ../header/tc_load_dump_parameters.h
35 35 ../header/tm_lfr_tc_exe.h
36 36 ../header/tc_acceptance.h
37 37 ../header/processing/fsw_processing.h
38 38 ../header/processing/avf0_prc0.h
39 39 ../header/processing/avf1_prc1.h
40 40 ../header/processing/avf2_prc2.h
41 41 ../header/fsw_params_wf_handler.h
42 42 ../header/lfr_cpu_usage_report.h
43 43 ../header/lfr_common_headers/ccsds_types.h
44 44 ../header/lfr_common_headers/fsw_params.h
45 45 ../header/lfr_common_headers/fsw_params_nb_bytes.h
46 46 ../header/lfr_common_headers/fsw_params_processing.h
47 47 ../header/lfr_common_headers/tm_byte_positions.h
48 48 ../LFR_basic-parameters/basic_parameters.h
49 49 ../LFR_basic-parameters/basic_parameters_params.h
50 50 ../header/GscMemoryLPP.hpp
51 51 )
52 52
53 53
54 54 option(FSW_verbose "Enable verbose LFR" OFF)
55 55 option(FSW_boot_messages "Enable LFR boot messages" OFF)
56 56 option(FSW_debug_messages "Enable LFR debug messages" OFF)
57 57 option(FSW_cpu_usage_report "Enable LFR cpu usage report" OFF)
58 58 option(FSW_stack_report "Enable LFR stack report" OFF)
59 59 option(FSW_vhdl_dev "?" OFF)
60 60 option(FSW_lpp_dpu_destid "Set to debug at LPP" OFF)
61 61 option(FSW_debug_watchdog "Enable debug watchdog" OFF)
62 62 option(FSW_debug_tch "?" OFF)
63 option(FSW_Instrument_Scrubbing "Enable scrubbing counter" OFF)
63 64
64 65 set(SW_VERSION_N1 "3" CACHE STRING "Choose N1 FSW Version." FORCE)
65 66 set(SW_VERSION_N2 "2" CACHE STRING "Choose N2 FSW Version." FORCE)
66 67 set(SW_VERSION_N3 "0" CACHE STRING "Choose N3 FSW Version." FORCE)
67 68 set(SW_VERSION_N4 "20" CACHE STRING "Choose N4 FSW Version." FORCE)
68 69
69 70 if(FSW_verbose)
70 71 add_definitions(-DPRINT_MESSAGES_ON_CONSOLE)
71 72 endif()
72 73 if(FSW_boot_messages)
73 74 add_definitions(-DBOOT_MESSAGES)
74 75 endif()
75 76 if(FSW_debug_messages)
76 77 add_definitions(-DDEBUG_MESSAGES)
77 78 endif()
78 79 if(FSW_cpu_usage_report)
79 80 add_definitions(-DPRINT_TASK_STATISTICS)
80 81 endif()
81 82 if(FSW_stack_report)
82 83 add_definitions(-DPRINT_STACK_REPORT)
83 84 endif()
84 85 if(FSW_vhdl_dev)
85 86 add_definitions(-DVHDL_DEV)
86 87 endif()
87 88 if(FSW_lpp_dpu_destid)
88 89 add_definitions(-DLPP_DPU_DESTID)
89 90 endif()
90 91 if(FSW_debug_watchdog)
91 92 add_definitions(-DDEBUG_WATCHDOG)
92 93 endif()
93 94 if(FSW_debug_tch)
94 95 add_definitions(-DDEBUG_TCH)
95 96 endif()
96 97
97 98
98 99
99 100 add_definitions(-DMSB_FIRST_TCH)
100 101
101 102 add_definitions(-DSWVERSION=-1-0)
102 103 add_definitions(-DSW_VERSION_N1=${SW_VERSION_N1})
103 104 add_definitions(-DSW_VERSION_N2=${SW_VERSION_N2})
104 105 add_definitions(-DSW_VERSION_N3=${SW_VERSION_N3})
105 106 add_definitions(-DSW_VERSION_N4=${SW_VERSION_N4})
106 107
107 108 add_executable(fsw ${SOURCES})
108 109
110 if(FSW_Instrument_Scrubbing)
111 add_definitions(-DENABLE_SCRUBBING_COUNTER)
112 endif()
113
109 114 if(Coverage)
110 115 target_link_libraries(fsw gcov)
111 116 SET_TARGET_PROPERTIES(fsw PROPERTIES COMPILE_FLAGS "-fprofile-arcs -ftest-coverage")
112 117 endif()
113 118
114 119
115 120 if(fix-b2bst)
116 121 check_b2bst(fsw ${CMAKE_CURRENT_BINARY_DIR})
117 122 endif()
118 123
119 124 if(NOT FSW_lpp_dpu_destid)
120 125 build_srec(fsw ${CMAKE_CURRENT_BINARY_DIR} "${SW_VERSION_N1}-${SW_VERSION_N2}-${SW_VERSION_N3}-${SW_VERSION_N4}")
121 126 endif()
122 127
123 128
124 129 add_test_cppcheck(fsw STYLE UNUSED_FUNCTIONS POSSIBLE_ERROR MISSING_INCLUDE)
125 130
@@ -1,1103 +1,1054
1 1 /** General usage functions and RTEMS tasks.
2 2 *
3 3 * @file
4 4 * @author P. LEROY
5 5 *
6 6 */
7 7
8 8 #include "fsw_misc.h"
9 9
10 10 int16_t hk_lfr_sc_v_f3_as_int16 = 0;
11 11 int16_t hk_lfr_sc_e1_f3_as_int16 = 0;
12 12 int16_t hk_lfr_sc_e2_f3_as_int16 = 0;
13 13
14 14 void timer_configure(unsigned char timer, unsigned int clock_divider,
15 15 unsigned char interrupt_level, rtems_isr (*timer_isr)() )
16 16 {
17 17 /** This function configures a GPTIMER timer instantiated in the VHDL design.
18 18 *
19 19 * @param gptimer_regs points to the APB registers of the GPTIMER IP core.
20 20 * @param timer is the number of the timer in the IP core (several timers can be instantiated).
21 21 * @param clock_divider is the divider of the 1 MHz clock that will be configured.
22 22 * @param interrupt_level is the interrupt level that the timer drives.
23 23 * @param timer_isr is the interrupt subroutine that will be attached to the IRQ driven by the timer.
24 24 *
25 25 * Interrupt levels are described in the SPARC documentation sparcv8.pdf p.76
26 26 *
27 27 */
28 28
29 29 rtems_status_code status;
30 30 rtems_isr_entry old_isr_handler;
31 31
32 32 old_isr_handler = NULL;
33 33
34 34 gptimer_regs->timer[timer].ctrl = INIT_CHAR; // reset the control register
35 35
36 36 status = rtems_interrupt_catch( timer_isr, interrupt_level, &old_isr_handler) ; // see sparcv8.pdf p.76 for interrupt levels
37 37 if (status!=RTEMS_SUCCESSFUL)
38 38 {
39 39 PRINTF("in configure_timer *** ERR rtems_interrupt_catch\n")
40 40 }
41 41
42 42 timer_set_clock_divider( timer, clock_divider);
43 43 }
44 44
45 45 void timer_start(unsigned char timer)
46 46 {
47 47 /** This function starts a GPTIMER timer.
48 48 *
49 49 * @param gptimer_regs points to the APB registers of the GPTIMER IP core.
50 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 54 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | GPTIMER_CLEAR_IRQ;
55 55 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | GPTIMER_LD;
56 56 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | GPTIMER_EN;
57 57 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | GPTIMER_RS;
58 58 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | GPTIMER_IE;
59 59 }
60 60
61 61 void timer_stop(unsigned char timer)
62 62 {
63 63 /** This function stops a GPTIMER timer.
64 64 *
65 65 * @param gptimer_regs points to the APB registers of the GPTIMER IP core.
66 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 70 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl & GPTIMER_EN_MASK;
71 71 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl & GPTIMER_IE_MASK;
72 72 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | GPTIMER_CLEAR_IRQ;
73 73 }
74 74
75 75 void timer_set_clock_divider(unsigned char timer, unsigned int clock_divider)
76 76 {
77 77 /** This function sets the clock divider of a GPTIMER timer.
78 78 *
79 79 * @param gptimer_regs points to the APB registers of the GPTIMER IP core.
80 80 * @param timer is the number of the timer in the IP core (several timers can be instantiated).
81 81 * @param clock_divider is the divider of the 1 MHz clock that will be configured.
82 82 *
83 83 */
84 84
85 85 gptimer_regs->timer[timer].reload = clock_divider; // base clock frequency is 1 MHz
86 86 }
87 87
88 88 // WATCHDOG
89 89
90 90 rtems_isr watchdog_isr( rtems_vector_number vector )
91 91 {
92 92 rtems_status_code status_code;
93 93
94 94 status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_12 );
95 95
96 96 PRINTF("watchdog_isr *** this is the end, exit(0)\n");
97 97
98 98 exit(0);
99 99 }
100 100
101 101 void watchdog_configure(void)
102 102 {
103 103 /** This function configure the watchdog.
104 104 *
105 105 * @param gptimer_regs points to the APB registers of the GPTIMER IP core.
106 106 * @param timer is the number of the timer in the IP core (several timers can be instantiated).
107 107 *
108 108 * The watchdog is a timer provided by the GPTIMER IP core of the GRLIB.
109 109 *
110 110 */
111 111
112 112 LEON_Mask_interrupt( IRQ_GPTIMER_WATCHDOG ); // mask gptimer/watchdog interrupt during configuration
113 113
114 114 timer_configure( TIMER_WATCHDOG, CLKDIV_WATCHDOG, IRQ_SPARC_GPTIMER_WATCHDOG, watchdog_isr );
115 115
116 116 LEON_Clear_interrupt( IRQ_GPTIMER_WATCHDOG ); // clear gptimer/watchdog interrupt
117 117 }
118 118
119 119 void watchdog_stop(void)
120 120 {
121 121 LEON_Mask_interrupt( IRQ_GPTIMER_WATCHDOG ); // mask gptimer/watchdog interrupt line
122 122 timer_stop( TIMER_WATCHDOG );
123 123 LEON_Clear_interrupt( IRQ_GPTIMER_WATCHDOG ); // clear gptimer/watchdog interrupt
124 124 }
125 125
126 126 void watchdog_reload(void)
127 127 {
128 128 /** This function reloads the watchdog timer counter with the timer reload value.
129 129 *
130 130 * @param void
131 131 *
132 132 * @return void
133 133 *
134 134 */
135 135
136 136 gptimer_regs->timer[TIMER_WATCHDOG].ctrl = gptimer_regs->timer[TIMER_WATCHDOG].ctrl | GPTIMER_LD;
137 137 }
138 138
139 139 void watchdog_start(void)
140 140 {
141 141 /** This function starts the watchdog timer.
142 142 *
143 143 * @param gptimer_regs points to the APB registers of the GPTIMER IP core.
144 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 148 LEON_Clear_interrupt( IRQ_GPTIMER_WATCHDOG );
149 149
150 150 gptimer_regs->timer[TIMER_WATCHDOG].ctrl = gptimer_regs->timer[TIMER_WATCHDOG].ctrl | GPTIMER_CLEAR_IRQ;
151 151 gptimer_regs->timer[TIMER_WATCHDOG].ctrl = gptimer_regs->timer[TIMER_WATCHDOG].ctrl | GPTIMER_LD;
152 152 gptimer_regs->timer[TIMER_WATCHDOG].ctrl = gptimer_regs->timer[TIMER_WATCHDOG].ctrl | GPTIMER_EN;
153 153 gptimer_regs->timer[TIMER_WATCHDOG].ctrl = gptimer_regs->timer[TIMER_WATCHDOG].ctrl | GPTIMER_IE;
154 154
155 155 LEON_Unmask_interrupt( IRQ_GPTIMER_WATCHDOG );
156 156
157 157 }
158 158
159 159 int enable_apbuart_transmitter( void ) // set the bit 1, TE Transmitter Enable to 1 in the APBUART control register
160 160 {
161 161 struct apbuart_regs_str *apbuart_regs = (struct apbuart_regs_str *) REGS_ADDR_APBUART;
162 162
163 163 apbuart_regs->ctrl = APBUART_CTRL_REG_MASK_TE;
164 164
165 165 return 0;
166 166 }
167 167
168 168 void set_apbuart_scaler_reload_register(unsigned int regs, unsigned int value)
169 169 {
170 170 /** This function sets the scaler reload register of the apbuart module
171 171 *
172 172 * @param regs is the address of the apbuart registers in memory
173 173 * @param value is the value that will be stored in the scaler register
174 174 *
175 175 * The value shall be set by the software to get data on the serial interface.
176 176 *
177 177 */
178 178
179 179 struct apbuart_regs_str *apbuart_regs = (struct apbuart_regs_str *) regs;
180 180
181 181 apbuart_regs->scaler = value;
182 182
183 183 BOOT_PRINTF1("OK *** apbuart port scaler reload register set to 0x%x\n", value)
184 184 }
185 185
186 186 //************
187 187 // RTEMS TASKS
188 188
189 189 rtems_task load_task(rtems_task_argument argument)
190 190 {
191 191 BOOT_PRINTF("in LOAD *** \n")
192 192
193 193 rtems_status_code status;
194 194 unsigned int i;
195 195 unsigned int j;
196 196 rtems_name name_watchdog_rate_monotonic; // name of the watchdog rate monotonic
197 197 rtems_id watchdog_period_id; // id of the watchdog rate monotonic period
198 198
199 199 watchdog_period_id = RTEMS_ID_NONE;
200 200
201 201 name_watchdog_rate_monotonic = rtems_build_name( 'L', 'O', 'A', 'D' );
202 202
203 203 status = rtems_rate_monotonic_create( name_watchdog_rate_monotonic, &watchdog_period_id );
204 204 if( status != RTEMS_SUCCESSFUL ) {
205 205 PRINTF1( "in LOAD *** rtems_rate_monotonic_create failed with status of %d\n", status )
206 206 }
207 207
208 208 i = 0;
209 209 j = 0;
210 210
211 211 watchdog_configure();
212 212
213 213 watchdog_start();
214 214
215 215 set_sy_lfr_watchdog_enabled( true );
216 216
217 217 while(1){
218 218 status = rtems_rate_monotonic_period( watchdog_period_id, WATCHDOG_PERIOD );
219 219 watchdog_reload();
220 220 i = i + 1;
221 221 if ( i == WATCHDOG_LOOP_PRINTF )
222 222 {
223 223 i = 0;
224 224 j = j + 1;
225 225 PRINTF1("%d\n", j)
226 226 }
227 227 #ifdef DEBUG_WATCHDOG
228 228 if (j == WATCHDOG_LOOP_DEBUG )
229 229 {
230 230 status = rtems_task_delete(RTEMS_SELF);
231 231 }
232 232 #endif
233 233 }
234 234 }
235 235
236 236 rtems_task hous_task(rtems_task_argument argument)
237 237 {
238 238 rtems_status_code status;
239 239 rtems_status_code spare_status;
240 240 rtems_id queue_id;
241 241 rtems_rate_monotonic_period_status period_status;
242 242 bool isSynchronized;
243 243
244 244 queue_id = RTEMS_ID_NONE;
245 245 memset(&period_status, 0, sizeof(rtems_rate_monotonic_period_status));
246 246 isSynchronized = false;
247 247
248 248 status = get_message_queue_id_send( &queue_id );
249 249 if (status != RTEMS_SUCCESSFUL)
250 250 {
251 251 PRINTF1("in HOUS *** ERR get_message_queue_id_send %d\n", status)
252 252 }
253 253
254 254 BOOT_PRINTF("in HOUS ***\n");
255 255
256 256 if (rtems_rate_monotonic_ident( name_hk_rate_monotonic, &HK_id) != RTEMS_SUCCESSFUL) {
257 257 status = rtems_rate_monotonic_create( name_hk_rate_monotonic, &HK_id );
258 258 if( status != RTEMS_SUCCESSFUL ) {
259 259 PRINTF1( "rtems_rate_monotonic_create failed with status of %d\n", status );
260 260 }
261 261 }
262 262
263 263 status = rtems_rate_monotonic_cancel(HK_id);
264 264 if( status != RTEMS_SUCCESSFUL ) {
265 265 PRINTF1( "ERR *** in HOUS *** rtems_rate_monotonic_cancel(HK_id) ***code: %d\n", status );
266 266 }
267 267 else {
268 268 DEBUG_PRINTF("OK *** in HOUS *** rtems_rate_monotonic_cancel(HK_id)\n");
269 269 }
270 270
271 271 // startup phase
272 272 status = rtems_rate_monotonic_period( HK_id, SY_LFR_TIME_SYN_TIMEOUT_in_ticks );
273 273 status = rtems_rate_monotonic_get_status( HK_id, &period_status );
274 274 DEBUG_PRINTF1("startup HK, HK_id status = %d\n", period_status.state)
275 275 while( (period_status.state != RATE_MONOTONIC_EXPIRED)
276 276 && (isSynchronized == false) ) // after SY_LFR_TIME_SYN_TIMEOUT ms, starts HK anyway
277 277 {
278 278 if ((time_management_regs->coarse_time & VAL_LFR_SYNCHRONIZED) == INT32_ALL_0) // check time synchronization
279 279 {
280 280 isSynchronized = true;
281 281 }
282 282 else
283 283 {
284 284 status = rtems_rate_monotonic_get_status( HK_id, &period_status );
285 285
286 286 status = rtems_task_wake_after( HK_SYNC_WAIT ); // wait HK_SYNCH_WAIT 100 ms = 10 * 10 ms
287 287 }
288 288 }
289 289 status = rtems_rate_monotonic_cancel(HK_id);
290 290 DEBUG_PRINTF1("startup HK, HK_id status = %d\n", period_status.state)
291 291
292 292 set_hk_lfr_reset_cause( POWER_ON );
293 293
294 294 while(1){ // launch the rate monotonic task
295 295 status = rtems_rate_monotonic_period( HK_id, HK_PERIOD );
296 296 if ( status != RTEMS_SUCCESSFUL ) {
297 297 PRINTF1( "in HOUS *** ERR period: %d\n", status);
298 298 spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_6 );
299 299 }
300 300 else {
301 301 housekeeping_packet.packetSequenceControl[BYTE_0] = (unsigned char) (sequenceCounterHK >> SHIFT_1_BYTE);
302 302 housekeeping_packet.packetSequenceControl[BYTE_1] = (unsigned char) (sequenceCounterHK );
303 303 increment_seq_counter( &sequenceCounterHK );
304 304
305 305 housekeeping_packet.time[BYTE_0] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_3_BYTES);
306 306 housekeeping_packet.time[BYTE_1] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_2_BYTES);
307 307 housekeeping_packet.time[BYTE_2] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_1_BYTE);
308 308 housekeeping_packet.time[BYTE_3] = (unsigned char) (time_management_regs->coarse_time);
309 309 housekeeping_packet.time[BYTE_4] = (unsigned char) (time_management_regs->fine_time >> SHIFT_1_BYTE);
310 310 housekeeping_packet.time[BYTE_5] = (unsigned char) (time_management_regs->fine_time);
311 311
312 312 spacewire_update_hk_lfr_link_state( &housekeeping_packet.lfr_status_word[0] );
313 313
314 314 spacewire_read_statistics();
315 315
316 316 update_hk_with_grspw_stats();
317 317
318 318 set_hk_lfr_time_not_synchro();
319 319
320 320 housekeeping_packet.hk_lfr_q_sd_fifo_size_max = hk_lfr_q_sd_fifo_size_max;
321 321 housekeeping_packet.hk_lfr_q_rv_fifo_size_max = hk_lfr_q_rv_fifo_size_max;
322 322 housekeeping_packet.hk_lfr_q_p0_fifo_size_max = hk_lfr_q_p0_fifo_size_max;
323 323 housekeeping_packet.hk_lfr_q_p1_fifo_size_max = hk_lfr_q_p1_fifo_size_max;
324 324 housekeeping_packet.hk_lfr_q_p2_fifo_size_max = hk_lfr_q_p2_fifo_size_max;
325 325
326 326 housekeeping_packet.sy_lfr_common_parameters_spare = parameter_dump_packet.sy_lfr_common_parameters_spare;
327 327 housekeeping_packet.sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters;
328 328 get_temperatures( housekeeping_packet.hk_lfr_temp_scm );
329 329 get_v_e1_e2_f3( housekeeping_packet.hk_lfr_sc_v_f3 );
330 330 get_cpu_load( (unsigned char *) &housekeeping_packet.hk_lfr_cpu_load );
331 331
332 332 hk_lfr_le_me_he_update();
333 333
334 334 // SEND PACKET
335 335 status = rtems_message_queue_send( queue_id, &housekeeping_packet,
336 336 PACKET_LENGTH_HK + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES);
337 337 if (status != RTEMS_SUCCESSFUL) {
338 338 PRINTF1("in HOUS *** ERR send: %d\n", status)
339 339 }
340 340 }
341 341 }
342 342
343 343 PRINTF("in HOUS *** deleting task\n")
344 344
345 345 status = rtems_task_delete( RTEMS_SELF ); // should not return
346 346
347 347 return;
348 348 }
349 349
350 350 int filter( int x, filter_ctx* ctx )
351 351 {
352 352 static const int b[NB_COEFFS][NB_COEFFS]={ {B00, B01, B02}, {B10, B11, B12}, {B20, B21, B22} };
353 353 static const int a[NB_COEFFS][NB_COEFFS]={ {A00, A01, A02}, {A10, A11, A12}, {A20, A21, A22} };
354 354 static const int b_gain[NB_COEFFS]={GAIN_B0, GAIN_B1, GAIN_B2};
355 355 static const int a_gain[NB_COEFFS]={GAIN_A0, GAIN_A1, GAIN_A2};
356 356
357 357 int_fast32_t W;
358 358 int i;
359 359
360 360 W = INIT_INT;
361 361 i = INIT_INT;
362 362
363 363 //Direct-Form-II
364 364 for ( i = 0; i < NB_COEFFS; i++ )
365 365 {
366 366 x = x << a_gain[i];
367 367 W = (x - ( a[i][COEFF1] * ctx->W[i][COEFF0] )
368 368 - ( a[i][COEFF2] * ctx->W[i][COEFF1] ) ) >> a_gain[i];
369 369 x = ( b[i][COEFF0] * W )
370 370 + ( b[i][COEFF1] * ctx->W[i][COEFF0] )
371 371 + ( b[i][COEFF2] * ctx->W[i][COEFF1] );
372 372 x = x >> b_gain[i];
373 373 ctx->W[i][1] = ctx->W[i][0];
374 374 ctx->W[i][0] = W;
375 375 }
376 376 return x;
377 377 }
378 378
379 379 rtems_task avgv_task(rtems_task_argument argument)
380 380 {
381 381 #define MOVING_AVERAGE 16
382 382 rtems_status_code status;
383 383 static int32_t v[MOVING_AVERAGE] = {0};
384 384 static int32_t e1[MOVING_AVERAGE] = {0};
385 385 static int32_t e2[MOVING_AVERAGE] = {0};
386 386 static int old_v = 0;
387 387 static int old_e1 = 0;
388 388 static int old_e2 = 0;
389 389 int32_t current_v;
390 390 int32_t current_e1;
391 391 int32_t current_e2;
392 392 int32_t average_v;
393 393 int32_t average_e1;
394 394 int32_t average_e2;
395 395 int32_t newValue_v;
396 396 int32_t newValue_e1;
397 397 int32_t newValue_e2;
398 398 unsigned char k;
399 399 unsigned char indexOfOldValue;
400 400
401 401 static filter_ctx ctx_v = { { {0,0,0}, {0,0,0}, {0,0,0} } };
402 402 static filter_ctx ctx_e1 = { { {0,0,0}, {0,0,0}, {0,0,0} } };
403 403 static filter_ctx ctx_e2 = { { {0,0,0}, {0,0,0}, {0,0,0} } };
404 404
405 405 BOOT_PRINTF("in AVGV ***\n");
406 406
407 407 if (rtems_rate_monotonic_ident( name_avgv_rate_monotonic, &AVGV_id) != RTEMS_SUCCESSFUL) {
408 408 status = rtems_rate_monotonic_create( name_avgv_rate_monotonic, &AVGV_id );
409 409 if( status != RTEMS_SUCCESSFUL ) {
410 410 PRINTF1( "rtems_rate_monotonic_create failed with status of %d\n", status );
411 411 }
412 412 }
413 413
414 414 status = rtems_rate_monotonic_cancel(AVGV_id);
415 415 if( status != RTEMS_SUCCESSFUL ) {
416 416 PRINTF1( "ERR *** in AVGV *** rtems_rate_monotonic_cancel(AVGV_id) ***code: %d\n", status );
417 417 }
418 418 else {
419 419 DEBUG_PRINTF("OK *** in AVGV *** rtems_rate_monotonic_cancel(AVGV_id)\n");
420 420 }
421 421
422 422 // initialize values
423 423 indexOfOldValue = MOVING_AVERAGE - 1;
424 424 current_v = 0;
425 425 current_e1 = 0;
426 426 current_e2 = 0;
427 427 average_v = 0;
428 428 average_e1 = 0;
429 429 average_e2 = 0;
430 430 newValue_v = 0;
431 431 newValue_e1 = 0;
432 432 newValue_e2 = 0;
433 433
434 434 k = INIT_CHAR;
435 435
436 436 while(1)
437 437 { // launch the rate monotonic task
438 438 status = rtems_rate_monotonic_period( AVGV_id, AVGV_PERIOD );
439 439 if ( status != RTEMS_SUCCESSFUL )
440 440 {
441 441 PRINTF1( "in AVGV *** ERR period: %d\n", status);
442 442 }
443 443 else
444 444 {
445 445 current_v = waveform_picker_regs->v;
446 446 current_e1 = waveform_picker_regs->e1;
447 447 current_e2 = waveform_picker_regs->e2;
448 448 if ( (current_v != old_v)
449 449 || (current_e1 != old_e1)
450 450 || (current_e2 != old_e2))
451 451 {
452 452 average_v = filter( current_v, &ctx_v );
453 453 average_e1 = filter( current_e1, &ctx_e1 );
454 454 average_e2 = filter( current_e2, &ctx_e2 );
455 455
456 456 //update int16 values
457 457 hk_lfr_sc_v_f3_as_int16 = (int16_t) average_v;
458 458 hk_lfr_sc_e1_f3_as_int16 = (int16_t) average_e1;
459 459 hk_lfr_sc_e2_f3_as_int16 = (int16_t) average_e2;
460 460 }
461 461 old_v = current_v;
462 462 old_e1 = current_e1;
463 463 old_e2 = current_e2;
464 464 }
465 465 }
466 466
467 467 PRINTF("in AVGV *** deleting task\n");
468 468
469 469 status = rtems_task_delete( RTEMS_SELF ); // should not return
470 470
471 471 return;
472 472 }
473 473
474 474 rtems_task dumb_task( rtems_task_argument unused )
475 475 {
476 476 /** This RTEMS taks is used to print messages without affecting the general behaviour of the software.
477 477 *
478 478 * @param unused is the starting argument of the RTEMS task
479 479 *
480 480 * The DUMB taks waits for RTEMS events and print messages depending on the incoming events.
481 481 *
482 482 */
483 483
484 484 unsigned int i;
485 485 unsigned int intEventOut;
486 486 unsigned int coarse_time = 0;
487 487 unsigned int fine_time = 0;
488 488 rtems_event_set event_out;
489 489
490 490 event_out = EVENT_SETS_NONE_PENDING;
491 491
492 492 BOOT_PRINTF("in DUMB *** \n")
493 493
494 494 while(1){
495 495 rtems_event_receive(RTEMS_EVENT_0 | RTEMS_EVENT_1 | RTEMS_EVENT_2 | RTEMS_EVENT_3
496 496 | RTEMS_EVENT_4 | RTEMS_EVENT_5 | RTEMS_EVENT_6 | RTEMS_EVENT_7
497 497 | RTEMS_EVENT_8 | RTEMS_EVENT_9 | RTEMS_EVENT_12 | RTEMS_EVENT_13
498 498 | RTEMS_EVENT_14,
499 499 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT
500 500 intEventOut = (unsigned int) event_out;
501 501 for ( i=0; i<NB_RTEMS_EVENTS; i++)
502 502 {
503 503 if ( ((intEventOut >> i) & 1) != 0)
504 504 {
505 505 coarse_time = time_management_regs->coarse_time;
506 506 fine_time = time_management_regs->fine_time;
507 507 if (i==EVENT_12)
508 508 {
509 509 PRINTF1("%s\n", DUMB_MESSAGE_12)
510 510 }
511 511 if (i==EVENT_13)
512 512 {
513 513 PRINTF1("%s\n", DUMB_MESSAGE_13)
514 514 }
515 515 if (i==EVENT_14)
516 516 {
517 517 PRINTF1("%s\n", DUMB_MESSAGE_1)
518 518 }
519 519 }
520 520 }
521 521 }
522 522 }
523 523
524 524 rtems_task scrubbing_task( rtems_task_argument unused )
525 525 {
526 526 /** This RTEMS taks is used to avoid entering IDLE task and also scrub memory to increase scubbing frequency.
527 527 *
528 528 * @param unused is the starting argument of the RTEMS task
529 529 *
530 530 * The scrubbing reads continuously memory when no other tasks are ready.
531 531 *
532 532 */
533 533
534 534 BOOT_PRINTF("in SCRUBBING *** \n");
535 535 volatile int i=0;
536 536 volatile float valuef = 1.;
537 537 volatile uint32_t* RAM=(uint32_t*)0x40000000;
538 538 volatile uint32_t value;
539 #ifdef ENABLE_SCRUBBING_COUNTER
540 housekeeping_packet.lfr_fpga_version[BYTE_0] = 0;
541 #endif
539 542 while(1){
540 543 i=(i+1)%(1024*1024);
541 544 valuef += 10.f*(float)RAM[i];
545 #ifdef ENABLE_SCRUBBING_COUNTER
546 if(i==0)
547 {
548 housekeeping_packet.lfr_fpga_version[BYTE_0] += 1;
549 }
550 #endif
542 551 }
543 552 }
544 553
545 554 rtems_task calibration_sweep_task( rtems_task_argument unused )
546 555 {
547 556 /** This RTEMS taks is used to change calibration signal smapling frequency between snapshots.
548 557 *
549 558 * @param unused is the starting argument of the RTEMS task
550 559 *
551 560 * If calibration is enabled, this task will divide by two the calibration signal smapling frequency between snapshots.
552 561 * When minimum sampling frequency is reach it will jump to maximum sampling frequency to loop indefinitely.
553 562 *
554 563 */
555 564 rtems_event_set event_out;
556 565 BOOT_PRINTF("in calibration sweep *** \n");
557 566 rtems_interval ticks_per_seconds = rtems_clock_get_ticks_per_second();
558 567 while(1){
559 568 // Waiting for next F0 snapshot
560 569 rtems_event_receive(RTEMS_EVENT_CAL_SWEEP_WAKE, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out);
561 570 if(time_management_regs->calDACCtrl & BIT_CAL_ENABLE)
562 571 {
563 572 unsigned int delta_snapshot;
564 573 delta_snapshot = (parameter_dump_packet.sy_lfr_n_swf_p[0] * CONST_256)
565 574 + parameter_dump_packet.sy_lfr_n_swf_p[1];
566 575 // We are woken almost in the center of a snapshot -> let's wait for sy_lfr_n_swf_p / 2
567 576 rtems_task_wake_after( ticks_per_seconds * delta_snapshot / 2);
568 577 if(time_management_regs->calDivisor >= CAL_F_DIVISOR_MAX){
569 578 time_management_regs->calDivisor = CAL_F_DIVISOR_MIN;
570 579 }
571 580 else{
572 581 time_management_regs->calDivisor *= 2;
573 582 }
574 583 }
575 584
576 585
577 586
578 587 }
579 588
580 589 }
581 590
582 591
583 592 //*****************************
584 593 // init housekeeping parameters
585 594
586 595 void init_housekeeping_parameters( void )
587 596 {
588 597 /** This function initialize the housekeeping_packet global variable with default values.
589 598 *
590 599 */
591 600
592 601 unsigned int i = 0;
593 602 unsigned char *parameters;
594 603 unsigned char sizeOfHK;
595 604
596 605 sizeOfHK = sizeof( Packet_TM_LFR_HK_t );
597 606
598 607 parameters = (unsigned char*) &housekeeping_packet;
599 608
600 609 for(i = 0; i< sizeOfHK; i++)
601 610 {
602 611 parameters[i] = INIT_CHAR;
603 612 }
604 613
605 614 housekeeping_packet.targetLogicalAddress = CCSDS_DESTINATION_ID;
606 615 housekeeping_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID;
607 616 housekeeping_packet.reserved = DEFAULT_RESERVED;
608 617 housekeeping_packet.userApplication = CCSDS_USER_APP;
609 618 housekeeping_packet.packetID[0] = (unsigned char) (APID_TM_HK >> SHIFT_1_BYTE);
610 619 housekeeping_packet.packetID[1] = (unsigned char) (APID_TM_HK);
611 620 housekeeping_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
612 621 housekeeping_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
613 622 housekeeping_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_HK >> SHIFT_1_BYTE);
614 623 housekeeping_packet.packetLength[1] = (unsigned char) (PACKET_LENGTH_HK );
615 624 housekeeping_packet.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
616 625 housekeeping_packet.serviceType = TM_TYPE_HK;
617 626 housekeeping_packet.serviceSubType = TM_SUBTYPE_HK;
618 627 housekeeping_packet.destinationID = TM_DESTINATION_ID_GROUND;
619 628 housekeeping_packet.sid = SID_HK;
620 629
621 630 // init status word
622 631 housekeeping_packet.lfr_status_word[0] = DEFAULT_STATUS_WORD_BYTE0;
623 632 housekeeping_packet.lfr_status_word[1] = DEFAULT_STATUS_WORD_BYTE1;
624 633 // init software version
625 634 housekeeping_packet.lfr_sw_version[0] = SW_VERSION_N1;
626 635 housekeeping_packet.lfr_sw_version[1] = SW_VERSION_N2;
627 636 housekeeping_packet.lfr_sw_version[BYTE_2] = SW_VERSION_N3;
628 637 housekeeping_packet.lfr_sw_version[BYTE_3] = SW_VERSION_N4;
629 638 // init fpga version
630 639 parameters = (unsigned char *) (REGS_ADDR_VHDL_VERSION);
631 640 housekeeping_packet.lfr_fpga_version[BYTE_0] = parameters[BYTE_1]; // n1
632 641 housekeeping_packet.lfr_fpga_version[BYTE_1] = parameters[BYTE_2]; // n2
633 642 housekeeping_packet.lfr_fpga_version[BYTE_2] = parameters[BYTE_3]; // n3
634 643
635 644 housekeeping_packet.hk_lfr_q_sd_fifo_size = MSG_QUEUE_COUNT_SEND;
636 645 housekeeping_packet.hk_lfr_q_rv_fifo_size = MSG_QUEUE_COUNT_RECV;
637 646 housekeeping_packet.hk_lfr_q_p0_fifo_size = MSG_QUEUE_COUNT_PRC0;
638 647 housekeeping_packet.hk_lfr_q_p1_fifo_size = MSG_QUEUE_COUNT_PRC1;
639 648 housekeeping_packet.hk_lfr_q_p2_fifo_size = MSG_QUEUE_COUNT_PRC2;
640 649 }
641 650
642 651 void increment_seq_counter( unsigned short *packetSequenceControl )
643 652 {
644 653 /** This function increment the sequence counter passes in argument.
645 654 *
646 655 * The increment does not affect the grouping flag. In case of an overflow, the counter is reset to 0.
647 656 *
648 657 */
649 658
650 659 unsigned short segmentation_grouping_flag;
651 660 unsigned short sequence_cnt;
652 661
653 662 segmentation_grouping_flag = TM_PACKET_SEQ_CTRL_STANDALONE << SHIFT_1_BYTE; // keep bits 7 downto 6
654 663 sequence_cnt = (*packetSequenceControl) & SEQ_CNT_MASK; // [0011 1111 1111 1111]
655 664
656 665 if ( sequence_cnt < SEQ_CNT_MAX)
657 666 {
658 667 sequence_cnt = sequence_cnt + 1;
659 668 }
660 669 else
661 670 {
662 671 sequence_cnt = 0;
663 672 }
664 673
665 674 *packetSequenceControl = segmentation_grouping_flag | sequence_cnt ;
666 675 }
667 676
668 677 void getTime( unsigned char *time)
669 678 {
670 679 /** This function write the current local time in the time buffer passed in argument.
671 680 *
672 681 */
673 682
674 683 time[0] = (unsigned char) (time_management_regs->coarse_time>>SHIFT_3_BYTES);
675 684 time[1] = (unsigned char) (time_management_regs->coarse_time>>SHIFT_2_BYTES);
676 685 time[2] = (unsigned char) (time_management_regs->coarse_time>>SHIFT_1_BYTE);
677 686 time[3] = (unsigned char) (time_management_regs->coarse_time);
678 687 time[4] = (unsigned char) (time_management_regs->fine_time>>SHIFT_1_BYTE);
679 688 time[5] = (unsigned char) (time_management_regs->fine_time);
680 689 }
681 690
682 691 unsigned long long int getTimeAsUnsignedLongLongInt( )
683 692 {
684 693 /** This function write the current local time in the time buffer passed in argument.
685 694 *
686 695 */
687 696 unsigned long long int time;
688 697
689 698 time = ( (unsigned long long int) (time_management_regs->coarse_time & COARSE_TIME_MASK) << SHIFT_2_BYTES )
690 699 + time_management_regs->fine_time;
691 700
692 701 return time;
693 702 }
694 703
695 void send_dumb_hk( void )
696 {
697 Packet_TM_LFR_HK_t dummy_hk_packet;
698 unsigned char *parameters;
699 unsigned int i;
700 rtems_id queue_id;
701
702 queue_id = RTEMS_ID_NONE;
703
704 dummy_hk_packet.targetLogicalAddress = CCSDS_DESTINATION_ID;
705 dummy_hk_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID;
706 dummy_hk_packet.reserved = DEFAULT_RESERVED;
707 dummy_hk_packet.userApplication = CCSDS_USER_APP;
708 dummy_hk_packet.packetID[0] = (unsigned char) (APID_TM_HK >> SHIFT_1_BYTE);
709 dummy_hk_packet.packetID[1] = (unsigned char) (APID_TM_HK);
710 dummy_hk_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
711 dummy_hk_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
712 dummy_hk_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_HK >> SHIFT_1_BYTE);
713 dummy_hk_packet.packetLength[1] = (unsigned char) (PACKET_LENGTH_HK );
714 dummy_hk_packet.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
715 dummy_hk_packet.serviceType = TM_TYPE_HK;
716 dummy_hk_packet.serviceSubType = TM_SUBTYPE_HK;
717 dummy_hk_packet.destinationID = TM_DESTINATION_ID_GROUND;
718 dummy_hk_packet.time[0] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_3_BYTES);
719 dummy_hk_packet.time[1] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_2_BYTES);
720 dummy_hk_packet.time[BYTE_2] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_1_BYTE);
721 dummy_hk_packet.time[BYTE_3] = (unsigned char) (time_management_regs->coarse_time);
722 dummy_hk_packet.time[BYTE_4] = (unsigned char) (time_management_regs->fine_time >> SHIFT_1_BYTE);
723 dummy_hk_packet.time[BYTE_5] = (unsigned char) (time_management_regs->fine_time);
724 dummy_hk_packet.sid = SID_HK;
725
726 // init status word
727 dummy_hk_packet.lfr_status_word[0] = INT8_ALL_F;
728 dummy_hk_packet.lfr_status_word[1] = INT8_ALL_F;
729 // init software version
730 dummy_hk_packet.lfr_sw_version[0] = SW_VERSION_N1;
731 dummy_hk_packet.lfr_sw_version[1] = SW_VERSION_N2;
732 dummy_hk_packet.lfr_sw_version[BYTE_2] = SW_VERSION_N3;
733 dummy_hk_packet.lfr_sw_version[BYTE_3] = SW_VERSION_N4;
734 // init fpga version
735 parameters = (unsigned char *) (REGS_ADDR_WAVEFORM_PICKER + APB_OFFSET_VHDL_REV);
736 dummy_hk_packet.lfr_fpga_version[BYTE_0] = parameters[BYTE_1]; // n1
737 dummy_hk_packet.lfr_fpga_version[BYTE_1] = parameters[BYTE_2]; // n2
738 dummy_hk_packet.lfr_fpga_version[BYTE_2] = parameters[BYTE_3]; // n3
739
740 parameters = (unsigned char *) &dummy_hk_packet.hk_lfr_cpu_load;
741
742 for (i=0; i<(BYTE_POS_HK_REACTION_WHEELS_FREQUENCY - BYTE_POS_HK_LFR_CPU_LOAD); i++)
743 {
744 parameters[i] = INT8_ALL_F;
745 }
746
747 get_message_queue_id_send( &queue_id );
748
749 rtems_message_queue_send( queue_id, &dummy_hk_packet,
750 PACKET_LENGTH_HK + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES);
751 }
752
753 704 void get_temperatures( unsigned char *temperatures )
754 705 {
755 706 unsigned char* temp_scm_ptr;
756 707 unsigned char* temp_pcb_ptr;
757 708 unsigned char* temp_fpga_ptr;
758 709
759 710 // SEL1 SEL0
760 711 // 0 0 => PCB
761 712 // 0 1 => FPGA
762 713 // 1 0 => SCM
763 714
764 715 temp_scm_ptr = (unsigned char *) &time_management_regs->temp_scm;
765 716 temp_pcb_ptr = (unsigned char *) &time_management_regs->temp_pcb;
766 717 temp_fpga_ptr = (unsigned char *) &time_management_regs->temp_fpga;
767 718
768 719 temperatures[ BYTE_0 ] = temp_scm_ptr[ BYTE_2 ];
769 720 temperatures[ BYTE_1 ] = temp_scm_ptr[ BYTE_3 ];
770 721 temperatures[ BYTE_2 ] = temp_pcb_ptr[ BYTE_2 ];
771 722 temperatures[ BYTE_3 ] = temp_pcb_ptr[ BYTE_3 ];
772 723 temperatures[ BYTE_4 ] = temp_fpga_ptr[ BYTE_2 ];
773 724 temperatures[ BYTE_5 ] = temp_fpga_ptr[ BYTE_3 ];
774 725 }
775 726
776 727 void get_v_e1_e2_f3( unsigned char *spacecraft_potential )
777 728 {
778 729 unsigned char* v_ptr;
779 730 unsigned char* e1_ptr;
780 731 unsigned char* e2_ptr;
781 732
782 733 v_ptr = (unsigned char *) &hk_lfr_sc_v_f3_as_int16;
783 734 e1_ptr = (unsigned char *) &hk_lfr_sc_e1_f3_as_int16;
784 735 e2_ptr = (unsigned char *) &hk_lfr_sc_e2_f3_as_int16;
785 736
786 737 spacecraft_potential[BYTE_0] = v_ptr[0];
787 738 spacecraft_potential[BYTE_1] = v_ptr[1];
788 739 spacecraft_potential[BYTE_2] = e1_ptr[0];
789 740 spacecraft_potential[BYTE_3] = e1_ptr[1];
790 741 spacecraft_potential[BYTE_4] = e2_ptr[0];
791 742 spacecraft_potential[BYTE_5] = e2_ptr[1];
792 743 }
793 744
794 745 void get_cpu_load( unsigned char *resource_statistics )
795 746 {
796 747 #define LOAD_AVG_SIZE 60
797 748 static unsigned char cpu_load_hist[LOAD_AVG_SIZE]={0};
798 749 static char old_avg_pos=0;
799 750 static unsigned int cpu_load_avg;
800 751 unsigned char cpu_load;
801 752
802 753 cpu_load = lfr_rtems_cpu_usage_report();
803 754
804 755 // HK_LFR_CPU_LOAD
805 756 resource_statistics[0] = cpu_load;
806 757
807 758 // HK_LFR_CPU_LOAD_MAX
808 759 if (cpu_load > resource_statistics[1])
809 760 {
810 761 resource_statistics[1] = cpu_load;
811 762 }
812 763
813 764 cpu_load_avg = cpu_load_avg - (unsigned int)cpu_load_hist[(int)old_avg_pos] + (unsigned int)cpu_load;
814 765 cpu_load_hist[(int)old_avg_pos] = cpu_load;
815 766 old_avg_pos += 1;
816 767 old_avg_pos %= LOAD_AVG_SIZE;
817 768 // CPU_LOAD_AVE
818 769 resource_statistics[BYTE_2] = (unsigned char)(cpu_load_avg / LOAD_AVG_SIZE);
819 770 // this will change the way LFR compute usage
820 771 #ifndef PRINT_TASK_STATISTICS
821 772 rtems_cpu_usage_reset();
822 773 #endif
823 774
824 775 }
825 776
826 777 void set_hk_lfr_sc_potential_flag( bool state )
827 778 {
828 779 if (state == true)
829 780 {
830 781 housekeeping_packet.lfr_status_word[1] =
831 782 housekeeping_packet.lfr_status_word[1] | STATUS_WORD_SC_POTENTIAL_FLAG_BIT; // [0100 0000]
832 783 }
833 784 else
834 785 {
835 786 housekeeping_packet.lfr_status_word[1] =
836 787 housekeeping_packet.lfr_status_word[1] & STATUS_WORD_SC_POTENTIAL_FLAG_MASK; // [1011 1111]
837 788 }
838 789 }
839 790
840 791 void set_sy_lfr_pas_filter_enabled( bool state )
841 792 {
842 793 if (state == true)
843 794 {
844 795 housekeeping_packet.lfr_status_word[1] =
845 796 housekeeping_packet.lfr_status_word[1] | STATUS_WORD_PAS_FILTER_ENABLED_BIT; // [0010 0000]
846 797 }
847 798 else
848 799 {
849 800 housekeeping_packet.lfr_status_word[1] =
850 801 housekeeping_packet.lfr_status_word[1] & STATUS_WORD_PAS_FILTER_ENABLED_MASK; // [1101 1111]
851 802 }
852 803 }
853 804
854 805 void set_sy_lfr_watchdog_enabled( bool state )
855 806 {
856 807 if (state == true)
857 808 {
858 809 housekeeping_packet.lfr_status_word[1] =
859 810 housekeeping_packet.lfr_status_word[1] | STATUS_WORD_WATCHDOG_BIT; // [0001 0000]
860 811 }
861 812 else
862 813 {
863 814 housekeeping_packet.lfr_status_word[1] =
864 815 housekeeping_packet.lfr_status_word[1] & STATUS_WORD_WATCHDOG_MASK; // [1110 1111]
865 816 }
866 817 }
867 818
868 819 void set_hk_lfr_calib_enable( bool state )
869 820 {
870 821 if (state == true)
871 822 {
872 823 housekeeping_packet.lfr_status_word[1] =
873 824 housekeeping_packet.lfr_status_word[1] | STATUS_WORD_CALIB_BIT; // [0000 1000]
874 825 }
875 826 else
876 827 {
877 828 housekeeping_packet.lfr_status_word[1] =
878 829 housekeeping_packet.lfr_status_word[1] & STATUS_WORD_CALIB_MASK; // [1111 0111]
879 830 }
880 831 }
881 832
882 833 void set_hk_lfr_reset_cause( enum lfr_reset_cause_t lfr_reset_cause )
883 834 {
884 835 housekeeping_packet.lfr_status_word[1] =
885 836 housekeeping_packet.lfr_status_word[1] & STATUS_WORD_RESET_CAUSE_MASK; // [1111 1000]
886 837
887 838 housekeeping_packet.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1]
888 839 | (lfr_reset_cause & STATUS_WORD_RESET_CAUSE_BITS ); // [0000 0111]
889 840
890 841 }
891 842
892 843 void increment_hk_counter( unsigned char newValue, unsigned char oldValue, unsigned int *counter )
893 844 {
894 845 int delta;
895 846
896 847 delta = 0;
897 848
898 849 if (newValue >= oldValue)
899 850 {
900 851 delta = newValue - oldValue;
901 852 }
902 853 else
903 854 {
904 855 delta = (CONST_256 - oldValue) + newValue;
905 856 }
906 857
907 858 *counter = *counter + delta;
908 859 }
909 860
910 861 void hk_lfr_le_update( void )
911 862 {
912 863 static hk_lfr_le_t old_hk_lfr_le = {0};
913 864 hk_lfr_le_t new_hk_lfr_le;
914 865 unsigned int counter;
915 866
916 867 counter = (((unsigned int) housekeeping_packet.hk_lfr_le_cnt[0]) * CONST_256) + housekeeping_packet.hk_lfr_le_cnt[1];
917 868
918 869 // DPU
919 870 new_hk_lfr_le.dpu_spw_parity = housekeeping_packet.hk_lfr_dpu_spw_parity;
920 871 new_hk_lfr_le.dpu_spw_disconnect= housekeeping_packet.hk_lfr_dpu_spw_disconnect;
921 872 new_hk_lfr_le.dpu_spw_escape = housekeeping_packet.hk_lfr_dpu_spw_escape;
922 873 new_hk_lfr_le.dpu_spw_credit = housekeeping_packet.hk_lfr_dpu_spw_credit;
923 874 new_hk_lfr_le.dpu_spw_write_sync= housekeeping_packet.hk_lfr_dpu_spw_write_sync;
924 875 // TIMECODE
925 876 new_hk_lfr_le.timecode_erroneous= housekeeping_packet.hk_lfr_timecode_erroneous;
926 877 new_hk_lfr_le.timecode_missing = housekeeping_packet.hk_lfr_timecode_missing;
927 878 new_hk_lfr_le.timecode_invalid = housekeeping_packet.hk_lfr_timecode_invalid;
928 879 // TIME
929 880 new_hk_lfr_le.time_timecode_it = housekeeping_packet.hk_lfr_time_timecode_it;
930 881 new_hk_lfr_le.time_not_synchro = housekeeping_packet.hk_lfr_time_not_synchro;
931 882 new_hk_lfr_le.time_timecode_ctr = housekeeping_packet.hk_lfr_time_timecode_ctr;
932 883 //AHB
933 884 new_hk_lfr_le.ahb_correctable = housekeeping_packet.hk_lfr_ahb_correctable;
934 885 // housekeeping_packet.hk_lfr_dpu_spw_rx_ahb => not handled by the grspw driver
935 886 // housekeeping_packet.hk_lfr_dpu_spw_tx_ahb => not handled by the grspw driver
936 887
937 888 // update the le counter
938 889 // DPU
939 890 increment_hk_counter( new_hk_lfr_le.dpu_spw_parity, old_hk_lfr_le.dpu_spw_parity, &counter );
940 891 increment_hk_counter( new_hk_lfr_le.dpu_spw_disconnect,old_hk_lfr_le.dpu_spw_disconnect, &counter );
941 892 increment_hk_counter( new_hk_lfr_le.dpu_spw_escape, old_hk_lfr_le.dpu_spw_escape, &counter );
942 893 increment_hk_counter( new_hk_lfr_le.dpu_spw_credit, old_hk_lfr_le.dpu_spw_credit, &counter );
943 894 increment_hk_counter( new_hk_lfr_le.dpu_spw_write_sync,old_hk_lfr_le.dpu_spw_write_sync, &counter );
944 895 // TIMECODE
945 896 increment_hk_counter( new_hk_lfr_le.timecode_erroneous,old_hk_lfr_le.timecode_erroneous, &counter );
946 897 increment_hk_counter( new_hk_lfr_le.timecode_missing, old_hk_lfr_le.timecode_missing, &counter );
947 898 increment_hk_counter( new_hk_lfr_le.timecode_invalid, old_hk_lfr_le.timecode_invalid, &counter );
948 899 // TIME
949 900 increment_hk_counter( new_hk_lfr_le.time_timecode_it, old_hk_lfr_le.time_timecode_it, &counter );
950 901 increment_hk_counter( new_hk_lfr_le.time_not_synchro, old_hk_lfr_le.time_not_synchro, &counter );
951 902 increment_hk_counter( new_hk_lfr_le.time_timecode_ctr, old_hk_lfr_le.time_timecode_ctr, &counter );
952 903 // AHB
953 904 increment_hk_counter( new_hk_lfr_le.ahb_correctable, old_hk_lfr_le.ahb_correctable, &counter );
954 905
955 906 // DPU
956 907 old_hk_lfr_le.dpu_spw_parity = new_hk_lfr_le.dpu_spw_parity;
957 908 old_hk_lfr_le.dpu_spw_disconnect= new_hk_lfr_le.dpu_spw_disconnect;
958 909 old_hk_lfr_le.dpu_spw_escape = new_hk_lfr_le.dpu_spw_escape;
959 910 old_hk_lfr_le.dpu_spw_credit = new_hk_lfr_le.dpu_spw_credit;
960 911 old_hk_lfr_le.dpu_spw_write_sync= new_hk_lfr_le.dpu_spw_write_sync;
961 912 // TIMECODE
962 913 old_hk_lfr_le.timecode_erroneous= new_hk_lfr_le.timecode_erroneous;
963 914 old_hk_lfr_le.timecode_missing = new_hk_lfr_le.timecode_missing;
964 915 old_hk_lfr_le.timecode_invalid = new_hk_lfr_le.timecode_invalid;
965 916 // TIME
966 917 old_hk_lfr_le.time_timecode_it = new_hk_lfr_le.time_timecode_it;
967 918 old_hk_lfr_le.time_not_synchro = new_hk_lfr_le.time_not_synchro;
968 919 old_hk_lfr_le.time_timecode_ctr = new_hk_lfr_le.time_timecode_ctr;
969 920 //AHB
970 921 old_hk_lfr_le.ahb_correctable = new_hk_lfr_le.ahb_correctable;
971 922 // housekeeping_packet.hk_lfr_dpu_spw_rx_ahb => not handled by the grspw driver
972 923 // housekeeping_packet.hk_lfr_dpu_spw_tx_ahb => not handled by the grspw driver
973 924
974 925 // update housekeeping packet counters, convert unsigned int numbers in 2 bytes numbers
975 926 // LE
976 927 housekeeping_packet.hk_lfr_le_cnt[0] = (unsigned char) ((counter & BYTE0_MASK) >> SHIFT_1_BYTE);
977 928 housekeeping_packet.hk_lfr_le_cnt[1] = (unsigned char) (counter & BYTE1_MASK);
978 929 }
979 930
980 931 void hk_lfr_me_update( void )
981 932 {
982 933 static hk_lfr_me_t old_hk_lfr_me = {0};
983 934 hk_lfr_me_t new_hk_lfr_me;
984 935 unsigned int counter;
985 936
986 937 counter = (((unsigned int) housekeeping_packet.hk_lfr_me_cnt[0]) * CONST_256) + housekeeping_packet.hk_lfr_me_cnt[1];
987 938
988 939 // get the current values
989 940 new_hk_lfr_me.dpu_spw_early_eop = housekeeping_packet.hk_lfr_dpu_spw_early_eop;
990 941 new_hk_lfr_me.dpu_spw_invalid_addr = housekeeping_packet.hk_lfr_dpu_spw_invalid_addr;
991 942 new_hk_lfr_me.dpu_spw_eep = housekeeping_packet.hk_lfr_dpu_spw_eep;
992 943 new_hk_lfr_me.dpu_spw_rx_too_big = housekeeping_packet.hk_lfr_dpu_spw_rx_too_big;
993 944
994 945 // update the me counter
995 946 increment_hk_counter( new_hk_lfr_me.dpu_spw_early_eop, old_hk_lfr_me.dpu_spw_early_eop, &counter );
996 947 increment_hk_counter( new_hk_lfr_me.dpu_spw_invalid_addr, old_hk_lfr_me.dpu_spw_invalid_addr, &counter );
997 948 increment_hk_counter( new_hk_lfr_me.dpu_spw_eep, old_hk_lfr_me.dpu_spw_eep, &counter );
998 949 increment_hk_counter( new_hk_lfr_me.dpu_spw_rx_too_big, old_hk_lfr_me.dpu_spw_rx_too_big, &counter );
999 950
1000 951 // store the counters for the next time
1001 952 old_hk_lfr_me.dpu_spw_early_eop = new_hk_lfr_me.dpu_spw_early_eop;
1002 953 old_hk_lfr_me.dpu_spw_invalid_addr = new_hk_lfr_me.dpu_spw_invalid_addr;
1003 954 old_hk_lfr_me.dpu_spw_eep = new_hk_lfr_me.dpu_spw_eep;
1004 955 old_hk_lfr_me.dpu_spw_rx_too_big = new_hk_lfr_me.dpu_spw_rx_too_big;
1005 956
1006 957 // update housekeeping packet counters, convert unsigned int numbers in 2 bytes numbers
1007 958 // ME
1008 959 housekeeping_packet.hk_lfr_me_cnt[0] = (unsigned char) ((counter & BYTE0_MASK) >> SHIFT_1_BYTE);
1009 960 housekeeping_packet.hk_lfr_me_cnt[1] = (unsigned char) (counter & BYTE1_MASK);
1010 961 }
1011 962
1012 963 void hk_lfr_le_me_he_update()
1013 964 {
1014 965
1015 966 unsigned int hk_lfr_he_cnt;
1016 967
1017 968 hk_lfr_he_cnt = (((unsigned int) housekeeping_packet.hk_lfr_he_cnt[0]) * 256) + housekeeping_packet.hk_lfr_he_cnt[1];
1018 969
1019 970 //update the low severity error counter
1020 971 hk_lfr_le_update( );
1021 972
1022 973 //update the medium severity error counter
1023 974 hk_lfr_me_update();
1024 975
1025 976 //update the high severity error counter
1026 977 hk_lfr_he_cnt = 0;
1027 978
1028 979 // update housekeeping packet counters, convert unsigned int numbers in 2 bytes numbers
1029 980 // HE
1030 981 housekeeping_packet.hk_lfr_he_cnt[0] = (unsigned char) ((hk_lfr_he_cnt & BYTE0_MASK) >> SHIFT_1_BYTE);
1031 982 housekeeping_packet.hk_lfr_he_cnt[1] = (unsigned char) (hk_lfr_he_cnt & BYTE1_MASK);
1032 983
1033 984 }
1034 985
1035 986 void set_hk_lfr_time_not_synchro()
1036 987 {
1037 988 static unsigned char synchroLost = 1;
1038 989 int synchronizationBit;
1039 990
1040 991 // get the synchronization bit
1041 992 synchronizationBit =
1042 993 (time_management_regs->coarse_time & VAL_LFR_SYNCHRONIZED) >> BIT_SYNCHRONIZATION; // 1000 0000 0000 0000
1043 994
1044 995 switch (synchronizationBit)
1045 996 {
1046 997 case 0:
1047 998 if (synchroLost == 1)
1048 999 {
1049 1000 synchroLost = 0;
1050 1001 }
1051 1002 break;
1052 1003 case 1:
1053 1004 if (synchroLost == 0 )
1054 1005 {
1055 1006 synchroLost = 1;
1056 1007 increase_unsigned_char_counter(&housekeeping_packet.hk_lfr_time_not_synchro);
1057 1008 update_hk_lfr_last_er_fields( RID_LE_LFR_TIME, CODE_NOT_SYNCHRO );
1058 1009 }
1059 1010 break;
1060 1011 default:
1061 1012 PRINTF1("in hk_lfr_time_not_synchro *** unexpected value for synchronizationBit = %d\n", synchronizationBit);
1062 1013 break;
1063 1014 }
1064 1015
1065 1016 }
1066 1017
1067 1018 void set_hk_lfr_ahb_correctable() // CRITICITY L
1068 1019 {
1069 1020 /** This function builds the error counter hk_lfr_ahb_correctable using the statistics provided
1070 1021 * by the Cache Control Register (ASI 2, offset 0) and in the Register Protection Control Register (ASR16) on the
1071 1022 * detected errors in the cache, in the integer unit and in the floating point unit.
1072 1023 *
1073 1024 * @param void
1074 1025 *
1075 1026 * @return void
1076 1027 *
1077 1028 * All errors are summed to set the value of the hk_lfr_ahb_correctable counter.
1078 1029 *
1079 1030 */
1080 1031
1081 1032 unsigned int ahb_correctable;
1082 1033 unsigned int instructionErrorCounter;
1083 1034 unsigned int dataErrorCounter;
1084 1035 unsigned int fprfErrorCounter;
1085 1036 unsigned int iurfErrorCounter;
1086 1037
1087 1038 instructionErrorCounter = 0;
1088 1039 dataErrorCounter = 0;
1089 1040 fprfErrorCounter = 0;
1090 1041 iurfErrorCounter = 0;
1091 1042
1092 1043 CCR_getInstructionAndDataErrorCounters( &instructionErrorCounter, &dataErrorCounter);
1093 1044 ASR16_get_FPRF_IURF_ErrorCounters( &fprfErrorCounter, &iurfErrorCounter);
1094 1045
1095 1046 ahb_correctable = instructionErrorCounter
1096 1047 + dataErrorCounter
1097 1048 + fprfErrorCounter
1098 1049 + iurfErrorCounter
1099 1050 + housekeeping_packet.hk_lfr_ahb_correctable;
1100 1051
1101 1052 housekeeping_packet.hk_lfr_ahb_correctable = (unsigned char) (ahb_correctable & INT8_ALL_F); // [1111 1111]
1102 1053
1103 1054 }
General Comments 0
You need to be logged in to leave comments. Login now