@@ -1,107 +1,107 | |||||
1 | cmake_minimum_required (VERSION 2.6) |
|
1 | cmake_minimum_required (VERSION 2.6) | |
2 | project (fsw) |
|
2 | project (fsw) | |
3 |
|
3 | |||
4 | include(sparc-rtems) |
|
4 | include(sparc-rtems) | |
5 | include(cppcheck) |
|
5 | include(cppcheck) | |
6 |
|
6 | |||
7 | include_directories("../header" |
|
7 | include_directories("../header" | |
8 | "../header/lfr_common_headers" |
|
8 | "../header/lfr_common_headers" | |
9 | "../header/processing" |
|
9 | "../header/processing" | |
10 | "../LFR_basic-parameters" |
|
10 | "../LFR_basic-parameters" | |
11 | "../src") |
|
11 | "../src") | |
12 |
|
12 | |||
13 | set(SOURCES wf_handler.c |
|
13 | set(SOURCES wf_handler.c | |
14 | tc_handler.c |
|
14 | tc_handler.c | |
15 | fsw_misc.c |
|
15 | fsw_misc.c | |
16 | fsw_init.c |
|
16 | fsw_init.c | |
17 | fsw_globals.c |
|
17 | fsw_globals.c | |
18 | fsw_spacewire.c |
|
18 | fsw_spacewire.c | |
19 | tc_load_dump_parameters.c |
|
19 | tc_load_dump_parameters.c | |
20 | tm_lfr_tc_exe.c |
|
20 | tm_lfr_tc_exe.c | |
21 | tc_acceptance.c |
|
21 | tc_acceptance.c | |
22 | processing/fsw_processing.c |
|
22 | processing/fsw_processing.c | |
23 | processing/avf0_prc0.c |
|
23 | processing/avf0_prc0.c | |
24 | processing/avf1_prc1.c |
|
24 | processing/avf1_prc1.c | |
25 | processing/avf2_prc2.c |
|
25 | processing/avf2_prc2.c | |
26 | lfr_cpu_usage_report.c |
|
26 | lfr_cpu_usage_report.c | |
27 | ${LFR_BP_SRC} |
|
27 | ${LFR_BP_SRC} | |
28 | ../header/wf_handler.h |
|
28 | ../header/wf_handler.h | |
29 | ../header/tc_handler.h |
|
29 | ../header/tc_handler.h | |
30 | ../header/grlib_regs.h |
|
30 | ../header/grlib_regs.h | |
31 | ../header/fsw_misc.h |
|
31 | ../header/fsw_misc.h | |
32 | ../header/fsw_init.h |
|
32 | ../header/fsw_init.h | |
33 | ../header/fsw_spacewire.h |
|
33 | ../header/fsw_spacewire.h | |
34 | ../header/tc_load_dump_parameters.h |
|
34 | ../header/tc_load_dump_parameters.h | |
35 | ../header/tm_lfr_tc_exe.h |
|
35 | ../header/tm_lfr_tc_exe.h | |
36 | ../header/tc_acceptance.h |
|
36 | ../header/tc_acceptance.h | |
37 | ../header/processing/fsw_processing.h |
|
37 | ../header/processing/fsw_processing.h | |
38 | ../header/processing/avf0_prc0.h |
|
38 | ../header/processing/avf0_prc0.h | |
39 | ../header/processing/avf1_prc1.h |
|
39 | ../header/processing/avf1_prc1.h | |
40 | ../header/processing/avf2_prc2.h |
|
40 | ../header/processing/avf2_prc2.h | |
41 | ../header/fsw_params_wf_handler.h |
|
41 | ../header/fsw_params_wf_handler.h | |
42 | ../header/lfr_cpu_usage_report.h |
|
42 | ../header/lfr_cpu_usage_report.h | |
43 | ../header/lfr_common_headers/ccsds_types.h |
|
43 | ../header/lfr_common_headers/ccsds_types.h | |
44 | ../header/lfr_common_headers/fsw_params.h |
|
44 | ../header/lfr_common_headers/fsw_params.h | |
45 | ../header/lfr_common_headers/fsw_params_nb_bytes.h |
|
45 | ../header/lfr_common_headers/fsw_params_nb_bytes.h | |
46 | ../header/lfr_common_headers/fsw_params_processing.h |
|
46 | ../header/lfr_common_headers/fsw_params_processing.h | |
47 | ../header/lfr_common_headers/tm_byte_positions.h |
|
47 | ../header/lfr_common_headers/tm_byte_positions.h | |
48 | ../LFR_basic-parameters/basic_parameters.h |
|
48 | ../LFR_basic-parameters/basic_parameters.h | |
49 | ../LFR_basic-parameters/basic_parameters_params.h |
|
49 | ../LFR_basic-parameters/basic_parameters_params.h | |
50 | ../header/GscMemoryLPP.hpp |
|
50 | ../header/GscMemoryLPP.hpp | |
51 | ) |
|
51 | ) | |
52 |
|
52 | |||
53 |
|
53 | |||
54 | option(FSW_verbose "Enable verbose LFR" OFF) |
|
54 | option(FSW_verbose "Enable verbose LFR" OFF) | |
55 | option(FSW_boot_messages "Enable LFR boot messages" OFF) |
|
55 | option(FSW_boot_messages "Enable LFR boot messages" OFF) | |
56 | option(FSW_debug_messages "Enable LFR debug messages" OFF) |
|
56 | option(FSW_debug_messages "Enable LFR debug messages" OFF) | |
57 | option(FSW_cpu_usage_report "Enable LFR cpu usage report" OFF) |
|
57 | option(FSW_cpu_usage_report "Enable LFR cpu usage report" OFF) | |
58 | option(FSW_stack_report "Enable LFR stack report" OFF) |
|
58 | option(FSW_stack_report "Enable LFR stack report" OFF) | |
59 | option(FSW_vhdl_dev "?" OFF) |
|
59 | option(FSW_vhdl_dev "?" OFF) | |
60 | option(FSW_lpp_dpu_destid "Set to debug at LPP" ON) |
|
60 | option(FSW_lpp_dpu_destid "Set to debug at LPP" ON) | |
61 | option(FSW_debug_watchdog "Enable debug watchdog" OFF) |
|
61 | option(FSW_debug_watchdog "Enable debug watchdog" OFF) | |
62 | option(FSW_debug_tch "?" OFF) |
|
62 | option(FSW_debug_tch "?" OFF) | |
63 |
|
63 | |||
64 | set(SW_VERSION_N1 "3" CACHE STRING "Choose N1 FSW Version." FORCE) |
|
64 | set(SW_VERSION_N1 "3" CACHE STRING "Choose N1 FSW Version." FORCE) | |
65 | set(SW_VERSION_N2 "2" CACHE STRING "Choose N2 FSW Version." FORCE) |
|
65 | set(SW_VERSION_N2 "2" CACHE STRING "Choose N2 FSW Version." FORCE) | |
66 | set(SW_VERSION_N3 "0" CACHE STRING "Choose N3 FSW Version." FORCE) |
|
66 | set(SW_VERSION_N3 "0" CACHE STRING "Choose N3 FSW Version." FORCE) | |
67 |
set(SW_VERSION_N4 " |
|
67 | set(SW_VERSION_N4 "7" CACHE STRING "Choose N4 FSW Version." FORCE) | |
68 |
|
68 | |||
69 | if(FSW_verbose) |
|
69 | if(FSW_verbose) | |
70 | add_definitions(-DPRINT_MESSAGES_ON_CONSOLE) |
|
70 | add_definitions(-DPRINT_MESSAGES_ON_CONSOLE) | |
71 | endif() |
|
71 | endif() | |
72 | if(FSW_boot_messages) |
|
72 | if(FSW_boot_messages) | |
73 | add_definitions(-DBOOT_MESSAGES) |
|
73 | add_definitions(-DBOOT_MESSAGES) | |
74 | endif() |
|
74 | endif() | |
75 | if(FSW_debug_messages) |
|
75 | if(FSW_debug_messages) | |
76 | add_definitions(-DDEBUG_MESSAGES) |
|
76 | add_definitions(-DDEBUG_MESSAGES) | |
77 | endif() |
|
77 | endif() | |
78 | if(FSW_cpu_usage_report) |
|
78 | if(FSW_cpu_usage_report) | |
79 | add_definitions(-DPRINT_TASK_STATISTICS) |
|
79 | add_definitions(-DPRINT_TASK_STATISTICS) | |
80 | endif() |
|
80 | endif() | |
81 | if(FSW_stack_report) |
|
81 | if(FSW_stack_report) | |
82 | add_definitions(-DPRINT_STACK_REPORT) |
|
82 | add_definitions(-DPRINT_STACK_REPORT) | |
83 | endif() |
|
83 | endif() | |
84 | if(FSW_vhdl_dev) |
|
84 | if(FSW_vhdl_dev) | |
85 | add_definitions(-DVHDL_DEV) |
|
85 | add_definitions(-DVHDL_DEV) | |
86 | endif() |
|
86 | endif() | |
87 | if(FSW_lpp_dpu_destid) |
|
87 | if(FSW_lpp_dpu_destid) | |
88 | add_definitions(-DLPP_DPU_DESTID) |
|
88 | add_definitions(-DLPP_DPU_DESTID) | |
89 | endif() |
|
89 | endif() | |
90 | if(FSW_debug_watchdog) |
|
90 | if(FSW_debug_watchdog) | |
91 | add_definitions(-DDEBUG_WATCHDOG) |
|
91 | add_definitions(-DDEBUG_WATCHDOG) | |
92 | endif() |
|
92 | endif() | |
93 | if(FSW_debug_tch) |
|
93 | if(FSW_debug_tch) | |
94 | add_definitions(-DDEBUG_TCH) |
|
94 | add_definitions(-DDEBUG_TCH) | |
95 | endif() |
|
95 | endif() | |
96 |
|
96 | |||
97 | add_definitions(-DMSB_FIRST_TCH) |
|
97 | add_definitions(-DMSB_FIRST_TCH) | |
98 |
|
98 | |||
99 | add_definitions(-DSWVERSION=-1-0) |
|
99 | add_definitions(-DSWVERSION=-1-0) | |
100 | add_definitions(-DSW_VERSION_N1=${SW_VERSION_N1}) |
|
100 | add_definitions(-DSW_VERSION_N1=${SW_VERSION_N1}) | |
101 | add_definitions(-DSW_VERSION_N2=${SW_VERSION_N2}) |
|
101 | add_definitions(-DSW_VERSION_N2=${SW_VERSION_N2}) | |
102 | add_definitions(-DSW_VERSION_N3=${SW_VERSION_N3}) |
|
102 | add_definitions(-DSW_VERSION_N3=${SW_VERSION_N3}) | |
103 | add_definitions(-DSW_VERSION_N4=${SW_VERSION_N4}) |
|
103 | add_definitions(-DSW_VERSION_N4=${SW_VERSION_N4}) | |
104 |
|
104 | |||
105 | add_executable(fsw ${SOURCES}) |
|
105 | add_executable(fsw ${SOURCES}) | |
106 | add_test_cppcheck(fsw STYLE UNUSED_FUNCTIONS POSSIBLE_ERROR MISSING_INCLUDE) |
|
106 | add_test_cppcheck(fsw STYLE UNUSED_FUNCTIONS POSSIBLE_ERROR MISSING_INCLUDE) | |
107 |
|
107 |
@@ -1,1019 +1,1040 | |||||
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 | // SEND PACKET |
|
334 | // SEND PACKET | |
335 | status = rtems_message_queue_send( queue_id, &housekeeping_packet, |
|
335 | status = rtems_message_queue_send( queue_id, &housekeeping_packet, | |
336 | PACKET_LENGTH_HK + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES); |
|
336 | PACKET_LENGTH_HK + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES); | |
337 | if (status != RTEMS_SUCCESSFUL) { |
|
337 | if (status != RTEMS_SUCCESSFUL) { | |
338 | PRINTF1("in HOUS *** ERR send: %d\n", status) |
|
338 | PRINTF1("in HOUS *** ERR send: %d\n", status) | |
339 | } |
|
339 | } | |
340 | } |
|
340 | } | |
341 | } |
|
341 | } | |
342 |
|
342 | |||
343 | PRINTF("in HOUS *** deleting task\n") |
|
343 | PRINTF("in HOUS *** deleting task\n") | |
344 |
|
344 | |||
345 | status = rtems_task_delete( RTEMS_SELF ); // should not return |
|
345 | status = rtems_task_delete( RTEMS_SELF ); // should not return | |
346 |
|
346 | |||
347 | return; |
|
347 | return; | |
348 | } |
|
348 | } | |
349 |
|
349 | |||
350 | int32_t getIntFromShort( int reg ) |
|
350 | int32_t getIntFromShort( int reg ) | |
351 | { |
|
351 | { | |
352 | int16_t ret_as_int16; |
|
352 | int16_t ret_as_int16; | |
353 | int32_t ret_as_int32; |
|
353 | int32_t ret_as_int32; | |
354 | char *regPtr; |
|
354 | char *regPtr; | |
355 | char *ret_as_int16_ptr; |
|
355 | char *ret_as_int16_ptr; | |
356 |
|
356 | |||
357 | regPtr = (char*) ® |
|
357 | regPtr = (char*) ® | |
358 | ret_as_int16_ptr = (char*) &ret_as_int16; |
|
358 | ret_as_int16_ptr = (char*) &ret_as_int16; | |
359 |
|
359 | |||
360 | ret_as_int16_ptr[BYTE_0] = regPtr[BYTE_3]; |
|
360 | ret_as_int16_ptr[BYTE_0] = regPtr[BYTE_3]; | |
361 | ret_as_int16_ptr[BYTE_1] = regPtr[BYTE_4]; |
|
361 | ret_as_int16_ptr[BYTE_1] = regPtr[BYTE_4]; | |
362 |
|
362 | |||
363 | ret_as_int32 = (int32_t) ret_as_int16; |
|
363 | ret_as_int32 = (int32_t) ret_as_int16; | |
364 |
|
364 | |||
365 | return ret_as_int32; |
|
365 | return ret_as_int32; | |
366 | } |
|
366 | } | |
367 |
|
367 | |||
368 | rtems_task avgv_task(rtems_task_argument argument) |
|
368 | rtems_task avgv_task(rtems_task_argument argument) | |
369 | { |
|
369 | { | |
370 | #define MOVING_AVERAGE 16 |
|
370 | #define MOVING_AVERAGE 16 | |
371 | rtems_status_code status; |
|
371 | rtems_status_code status; | |
372 | static int32_t v[MOVING_AVERAGE] = {0}; |
|
372 | static int32_t v[MOVING_AVERAGE] = {0}; | |
373 | static int32_t e1[MOVING_AVERAGE] = {0}; |
|
373 | static int32_t e1[MOVING_AVERAGE] = {0}; | |
374 | static int32_t e2[MOVING_AVERAGE] = {0}; |
|
374 | static int32_t e2[MOVING_AVERAGE] = {0}; | |
|
375 | static int old_v = 0; | |||
|
376 | static int old_e1 = 0; | |||
|
377 | static int old_e2 = 0; | |||
|
378 | int current_v; | |||
|
379 | int current_e1; | |||
|
380 | int current_e2; | |||
375 | int32_t average_v; |
|
381 | int32_t average_v; | |
376 | int32_t average_e1; |
|
382 | int32_t average_e1; | |
377 | int32_t average_e2; |
|
383 | int32_t average_e2; | |
378 | int32_t newValue_v; |
|
384 | int32_t newValue_v; | |
379 | int32_t newValue_e1; |
|
385 | int32_t newValue_e1; | |
380 | int32_t newValue_e2; |
|
386 | int32_t newValue_e2; | |
381 | unsigned char k; |
|
387 | unsigned char k; | |
382 | unsigned char indexOfOldValue; |
|
388 | unsigned char indexOfOldValue; | |
383 |
|
389 | |||
384 | BOOT_PRINTF("in AVGV ***\n"); |
|
390 | BOOT_PRINTF("in AVGV ***\n"); | |
385 |
|
391 | |||
386 | if (rtems_rate_monotonic_ident( name_avgv_rate_monotonic, &AVGV_id) != RTEMS_SUCCESSFUL) { |
|
392 | if (rtems_rate_monotonic_ident( name_avgv_rate_monotonic, &AVGV_id) != RTEMS_SUCCESSFUL) { | |
387 | status = rtems_rate_monotonic_create( name_avgv_rate_monotonic, &AVGV_id ); |
|
393 | status = rtems_rate_monotonic_create( name_avgv_rate_monotonic, &AVGV_id ); | |
388 | if( status != RTEMS_SUCCESSFUL ) { |
|
394 | if( status != RTEMS_SUCCESSFUL ) { | |
389 | PRINTF1( "rtems_rate_monotonic_create failed with status of %d\n", status ); |
|
395 | PRINTF1( "rtems_rate_monotonic_create failed with status of %d\n", status ); | |
390 | } |
|
396 | } | |
391 | } |
|
397 | } | |
392 |
|
398 | |||
393 | status = rtems_rate_monotonic_cancel(AVGV_id); |
|
399 | status = rtems_rate_monotonic_cancel(AVGV_id); | |
394 | if( status != RTEMS_SUCCESSFUL ) { |
|
400 | if( status != RTEMS_SUCCESSFUL ) { | |
395 | PRINTF1( "ERR *** in AVGV *** rtems_rate_monotonic_cancel(AVGV_id) ***code: %d\n", status ); |
|
401 | PRINTF1( "ERR *** in AVGV *** rtems_rate_monotonic_cancel(AVGV_id) ***code: %d\n", status ); | |
396 | } |
|
402 | } | |
397 | else { |
|
403 | else { | |
398 | DEBUG_PRINTF("OK *** in AVGV *** rtems_rate_monotonic_cancel(AVGV_id)\n"); |
|
404 | DEBUG_PRINTF("OK *** in AVGV *** rtems_rate_monotonic_cancel(AVGV_id)\n"); | |
399 | } |
|
405 | } | |
400 |
|
406 | |||
401 | // initialize values |
|
407 | // initialize values | |
402 | indexOfOldValue = MOVING_AVERAGE - 1; |
|
408 | indexOfOldValue = MOVING_AVERAGE - 1; | |
|
409 | current_v = 0; | |||
|
410 | current_e1 = 0; | |||
|
411 | current_e2 = 0; | |||
403 | average_v = 0; |
|
412 | average_v = 0; | |
404 | average_e1 = 0; |
|
413 | average_e1 = 0; | |
405 | average_e2 = 0; |
|
414 | average_e2 = 0; | |
406 | newValue_v = 0; |
|
415 | newValue_v = 0; | |
407 | newValue_e1 = 0; |
|
416 | newValue_e1 = 0; | |
408 | newValue_e2 = 0; |
|
417 | newValue_e2 = 0; | |
409 |
|
418 | |||
410 | k = INIT_CHAR; |
|
419 | k = INIT_CHAR; | |
411 |
|
420 | |||
412 | while(1) |
|
421 | while(1) | |
413 | { // launch the rate monotonic task |
|
422 | { // launch the rate monotonic task | |
414 | status = rtems_rate_monotonic_period( AVGV_id, AVGV_PERIOD ); |
|
423 | status = rtems_rate_monotonic_period( AVGV_id, AVGV_PERIOD ); | |
415 | if ( status != RTEMS_SUCCESSFUL ) |
|
424 | if ( status != RTEMS_SUCCESSFUL ) | |
416 | { |
|
425 | { | |
417 | PRINTF1( "in AVGV *** ERR period: %d\n", status); |
|
426 | PRINTF1( "in AVGV *** ERR period: %d\n", status); | |
418 | } |
|
427 | } | |
419 | else |
|
428 | else | |
420 | { |
|
429 | { | |
421 | // get new values |
|
430 | current_v = waveform_picker_regs->v; | |
422 |
|
|
431 | current_e1 = waveform_picker_regs->e1; | |
423 |
|
|
432 | current_e2 = waveform_picker_regs->e2; | |
424 | newValue_e2 = getIntFromShort( waveform_picker_regs->e2 ); |
|
433 | if ( (current_v != old_v) | |
|
434 | && (current_e1 != old_e1) | |||
|
435 | && (current_e2 != old_e2)) | |||
|
436 | { | |||
|
437 | // get new values | |||
|
438 | newValue_v = getIntFromShort( current_v ); | |||
|
439 | newValue_e1 = getIntFromShort( current_e1 ); | |||
|
440 | newValue_e2 = getIntFromShort( current_e2 ); | |||
425 |
|
441 | |||
426 | // compute the moving average |
|
442 | // compute the moving average | |
427 | average_v = average_v + newValue_v - v[k]; |
|
443 | average_v = average_v + newValue_v - v[k]; | |
428 | average_e1 = average_e1 + newValue_e1 - e1[k]; |
|
444 | average_e1 = average_e1 + newValue_e1 - e1[k]; | |
429 | average_e2 = average_e2 + newValue_e2 - e2[k]; |
|
445 | average_e2 = average_e2 + newValue_e2 - e2[k]; | |
430 |
|
446 | |||
431 | // store new values in buffers |
|
447 | // store new values in buffers | |
432 | v[k] = newValue_v; |
|
448 | v[k] = newValue_v; | |
433 | e1[k] = newValue_e1; |
|
449 | e1[k] = newValue_e1; | |
434 | e2[k] = newValue_e2; |
|
450 | e2[k] = newValue_e2; | |
435 | } |
|
451 | ||
436 | if (k == (MOVING_AVERAGE-1)) |
|
452 | if (k == (MOVING_AVERAGE-1)) | |
437 | { |
|
453 | { | |
438 | k = 0; |
|
454 | k = 0; | |
|
455 | } | |||
|
456 | else | |||
|
457 | { | |||
|
458 | k++; | |||
|
459 | } | |||
|
460 | //update int16 values | |||
|
461 | hk_lfr_sc_v_f3_as_int16 = (int16_t) (average_v / MOVING_AVERAGE ); | |||
|
462 | hk_lfr_sc_e1_f3_as_int16 = (int16_t) (average_e1 / MOVING_AVERAGE ); | |||
|
463 | hk_lfr_sc_e2_f3_as_int16 = (int16_t) (average_e2 / MOVING_AVERAGE ); | |||
|
464 | } | |||
|
465 | old_v = current_v; | |||
|
466 | old_e1 = current_e1; | |||
|
467 | old_e2 = current_e2; | |||
439 | } |
|
468 | } | |
440 | else |
|
|||
441 | { |
|
|||
442 | k++; |
|
|||
443 | } |
|
|||
444 | //update int16 values |
|
|||
445 | hk_lfr_sc_v_f3_as_int16 = (int16_t) (average_v / MOVING_AVERAGE ); |
|
|||
446 | hk_lfr_sc_e1_f3_as_int16 = (int16_t) (average_e1 / MOVING_AVERAGE ); |
|
|||
447 | hk_lfr_sc_e2_f3_as_int16 = (int16_t) (average_e2 / MOVING_AVERAGE ); |
|
|||
448 | } |
|
469 | } | |
449 |
|
470 | |||
450 | PRINTF("in AVGV *** deleting task\n"); |
|
471 | PRINTF("in AVGV *** deleting task\n"); | |
451 |
|
472 | |||
452 | status = rtems_task_delete( RTEMS_SELF ); // should not return |
|
473 | status = rtems_task_delete( RTEMS_SELF ); // should not return | |
453 |
|
474 | |||
454 | return; |
|
475 | return; | |
455 | } |
|
476 | } | |
456 |
|
477 | |||
457 | rtems_task dumb_task( rtems_task_argument unused ) |
|
478 | rtems_task dumb_task( rtems_task_argument unused ) | |
458 | { |
|
479 | { | |
459 | /** This RTEMS taks is used to print messages without affecting the general behaviour of the software. |
|
480 | /** This RTEMS taks is used to print messages without affecting the general behaviour of the software. | |
460 | * |
|
481 | * | |
461 | * @param unused is the starting argument of the RTEMS task |
|
482 | * @param unused is the starting argument of the RTEMS task | |
462 | * |
|
483 | * | |
463 | * The DUMB taks waits for RTEMS events and print messages depending on the incoming events. |
|
484 | * The DUMB taks waits for RTEMS events and print messages depending on the incoming events. | |
464 | * |
|
485 | * | |
465 | */ |
|
486 | */ | |
466 |
|
487 | |||
467 | unsigned int i; |
|
488 | unsigned int i; | |
468 | unsigned int intEventOut; |
|
489 | unsigned int intEventOut; | |
469 | unsigned int coarse_time = 0; |
|
490 | unsigned int coarse_time = 0; | |
470 | unsigned int fine_time = 0; |
|
491 | unsigned int fine_time = 0; | |
471 | rtems_event_set event_out; |
|
492 | rtems_event_set event_out; | |
472 |
|
493 | |||
473 | event_out = EVENT_SETS_NONE_PENDING; |
|
494 | event_out = EVENT_SETS_NONE_PENDING; | |
474 |
|
495 | |||
475 | BOOT_PRINTF("in DUMB *** \n") |
|
496 | BOOT_PRINTF("in DUMB *** \n") | |
476 |
|
497 | |||
477 | while(1){ |
|
498 | while(1){ | |
478 | rtems_event_receive(RTEMS_EVENT_0 | RTEMS_EVENT_1 | RTEMS_EVENT_2 | RTEMS_EVENT_3 |
|
499 | rtems_event_receive(RTEMS_EVENT_0 | RTEMS_EVENT_1 | RTEMS_EVENT_2 | RTEMS_EVENT_3 | |
479 | | RTEMS_EVENT_4 | RTEMS_EVENT_5 | RTEMS_EVENT_6 | RTEMS_EVENT_7 |
|
500 | | RTEMS_EVENT_4 | RTEMS_EVENT_5 | RTEMS_EVENT_6 | RTEMS_EVENT_7 | |
480 | | RTEMS_EVENT_8 | RTEMS_EVENT_9 | RTEMS_EVENT_12 | RTEMS_EVENT_13 |
|
501 | | RTEMS_EVENT_8 | RTEMS_EVENT_9 | RTEMS_EVENT_12 | RTEMS_EVENT_13 | |
481 | | RTEMS_EVENT_14, |
|
502 | | RTEMS_EVENT_14, | |
482 | RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT |
|
503 | RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT | |
483 | intEventOut = (unsigned int) event_out; |
|
504 | intEventOut = (unsigned int) event_out; | |
484 | for ( i=0; i<NB_RTEMS_EVENTS; i++) |
|
505 | for ( i=0; i<NB_RTEMS_EVENTS; i++) | |
485 | { |
|
506 | { | |
486 | if ( ((intEventOut >> i) & 1) != 0) |
|
507 | if ( ((intEventOut >> i) & 1) != 0) | |
487 | { |
|
508 | { | |
488 | coarse_time = time_management_regs->coarse_time; |
|
509 | coarse_time = time_management_regs->coarse_time; | |
489 | fine_time = time_management_regs->fine_time; |
|
510 | fine_time = time_management_regs->fine_time; | |
490 | if (i==EVENT_12) |
|
511 | if (i==EVENT_12) | |
491 | { |
|
512 | { | |
492 | PRINTF1("%s\n", DUMB_MESSAGE_12) |
|
513 | PRINTF1("%s\n", DUMB_MESSAGE_12) | |
493 | } |
|
514 | } | |
494 | if (i==EVENT_13) |
|
515 | if (i==EVENT_13) | |
495 | { |
|
516 | { | |
496 | PRINTF1("%s\n", DUMB_MESSAGE_13) |
|
517 | PRINTF1("%s\n", DUMB_MESSAGE_13) | |
497 | } |
|
518 | } | |
498 | if (i==EVENT_14) |
|
519 | if (i==EVENT_14) | |
499 | { |
|
520 | { | |
500 | PRINTF1("%s\n", DUMB_MESSAGE_1) |
|
521 | PRINTF1("%s\n", DUMB_MESSAGE_1) | |
501 | } |
|
522 | } | |
502 | } |
|
523 | } | |
503 | } |
|
524 | } | |
504 | } |
|
525 | } | |
505 | } |
|
526 | } | |
506 |
|
527 | |||
507 | //***************************** |
|
528 | //***************************** | |
508 | // init housekeeping parameters |
|
529 | // init housekeeping parameters | |
509 |
|
530 | |||
510 | void init_housekeeping_parameters( void ) |
|
531 | void init_housekeeping_parameters( void ) | |
511 | { |
|
532 | { | |
512 | /** This function initialize the housekeeping_packet global variable with default values. |
|
533 | /** This function initialize the housekeeping_packet global variable with default values. | |
513 | * |
|
534 | * | |
514 | */ |
|
535 | */ | |
515 |
|
536 | |||
516 | unsigned int i = 0; |
|
537 | unsigned int i = 0; | |
517 | unsigned char *parameters; |
|
538 | unsigned char *parameters; | |
518 | unsigned char sizeOfHK; |
|
539 | unsigned char sizeOfHK; | |
519 |
|
540 | |||
520 | sizeOfHK = sizeof( Packet_TM_LFR_HK_t ); |
|
541 | sizeOfHK = sizeof( Packet_TM_LFR_HK_t ); | |
521 |
|
542 | |||
522 | parameters = (unsigned char*) &housekeeping_packet; |
|
543 | parameters = (unsigned char*) &housekeeping_packet; | |
523 |
|
544 | |||
524 | for(i = 0; i< sizeOfHK; i++) |
|
545 | for(i = 0; i< sizeOfHK; i++) | |
525 | { |
|
546 | { | |
526 | parameters[i] = INIT_CHAR; |
|
547 | parameters[i] = INIT_CHAR; | |
527 | } |
|
548 | } | |
528 |
|
549 | |||
529 | housekeeping_packet.targetLogicalAddress = CCSDS_DESTINATION_ID; |
|
550 | housekeeping_packet.targetLogicalAddress = CCSDS_DESTINATION_ID; | |
530 | housekeeping_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID; |
|
551 | housekeeping_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID; | |
531 | housekeeping_packet.reserved = DEFAULT_RESERVED; |
|
552 | housekeeping_packet.reserved = DEFAULT_RESERVED; | |
532 | housekeeping_packet.userApplication = CCSDS_USER_APP; |
|
553 | housekeeping_packet.userApplication = CCSDS_USER_APP; | |
533 | housekeeping_packet.packetID[0] = (unsigned char) (APID_TM_HK >> SHIFT_1_BYTE); |
|
554 | housekeeping_packet.packetID[0] = (unsigned char) (APID_TM_HK >> SHIFT_1_BYTE); | |
534 | housekeeping_packet.packetID[1] = (unsigned char) (APID_TM_HK); |
|
555 | housekeeping_packet.packetID[1] = (unsigned char) (APID_TM_HK); | |
535 | housekeeping_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; |
|
556 | housekeeping_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; | |
536 | housekeeping_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT; |
|
557 | housekeeping_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT; | |
537 | housekeeping_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_HK >> SHIFT_1_BYTE); |
|
558 | housekeeping_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_HK >> SHIFT_1_BYTE); | |
538 | housekeeping_packet.packetLength[1] = (unsigned char) (PACKET_LENGTH_HK ); |
|
559 | housekeeping_packet.packetLength[1] = (unsigned char) (PACKET_LENGTH_HK ); | |
539 | housekeeping_packet.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2; |
|
560 | housekeeping_packet.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2; | |
540 | housekeeping_packet.serviceType = TM_TYPE_HK; |
|
561 | housekeeping_packet.serviceType = TM_TYPE_HK; | |
541 | housekeeping_packet.serviceSubType = TM_SUBTYPE_HK; |
|
562 | housekeeping_packet.serviceSubType = TM_SUBTYPE_HK; | |
542 | housekeeping_packet.destinationID = TM_DESTINATION_ID_GROUND; |
|
563 | housekeeping_packet.destinationID = TM_DESTINATION_ID_GROUND; | |
543 | housekeeping_packet.sid = SID_HK; |
|
564 | housekeeping_packet.sid = SID_HK; | |
544 |
|
565 | |||
545 | // init status word |
|
566 | // init status word | |
546 | housekeeping_packet.lfr_status_word[0] = DEFAULT_STATUS_WORD_BYTE0; |
|
567 | housekeeping_packet.lfr_status_word[0] = DEFAULT_STATUS_WORD_BYTE0; | |
547 | housekeeping_packet.lfr_status_word[1] = DEFAULT_STATUS_WORD_BYTE1; |
|
568 | housekeeping_packet.lfr_status_word[1] = DEFAULT_STATUS_WORD_BYTE1; | |
548 | // init software version |
|
569 | // init software version | |
549 | housekeeping_packet.lfr_sw_version[0] = SW_VERSION_N1; |
|
570 | housekeeping_packet.lfr_sw_version[0] = SW_VERSION_N1; | |
550 | housekeeping_packet.lfr_sw_version[1] = SW_VERSION_N2; |
|
571 | housekeeping_packet.lfr_sw_version[1] = SW_VERSION_N2; | |
551 | housekeeping_packet.lfr_sw_version[BYTE_2] = SW_VERSION_N3; |
|
572 | housekeeping_packet.lfr_sw_version[BYTE_2] = SW_VERSION_N3; | |
552 | housekeeping_packet.lfr_sw_version[BYTE_3] = SW_VERSION_N4; |
|
573 | housekeeping_packet.lfr_sw_version[BYTE_3] = SW_VERSION_N4; | |
553 | // init fpga version |
|
574 | // init fpga version | |
554 | parameters = (unsigned char *) (REGS_ADDR_VHDL_VERSION); |
|
575 | parameters = (unsigned char *) (REGS_ADDR_VHDL_VERSION); | |
555 | housekeeping_packet.lfr_fpga_version[BYTE_0] = parameters[BYTE_1]; // n1 |
|
576 | housekeeping_packet.lfr_fpga_version[BYTE_0] = parameters[BYTE_1]; // n1 | |
556 | housekeeping_packet.lfr_fpga_version[BYTE_1] = parameters[BYTE_2]; // n2 |
|
577 | housekeeping_packet.lfr_fpga_version[BYTE_1] = parameters[BYTE_2]; // n2 | |
557 | housekeeping_packet.lfr_fpga_version[BYTE_2] = parameters[BYTE_3]; // n3 |
|
578 | housekeeping_packet.lfr_fpga_version[BYTE_2] = parameters[BYTE_3]; // n3 | |
558 |
|
579 | |||
559 | housekeeping_packet.hk_lfr_q_sd_fifo_size = MSG_QUEUE_COUNT_SEND; |
|
580 | housekeeping_packet.hk_lfr_q_sd_fifo_size = MSG_QUEUE_COUNT_SEND; | |
560 | housekeeping_packet.hk_lfr_q_rv_fifo_size = MSG_QUEUE_COUNT_RECV; |
|
581 | housekeeping_packet.hk_lfr_q_rv_fifo_size = MSG_QUEUE_COUNT_RECV; | |
561 | housekeeping_packet.hk_lfr_q_p0_fifo_size = MSG_QUEUE_COUNT_PRC0; |
|
582 | housekeeping_packet.hk_lfr_q_p0_fifo_size = MSG_QUEUE_COUNT_PRC0; | |
562 | housekeeping_packet.hk_lfr_q_p1_fifo_size = MSG_QUEUE_COUNT_PRC1; |
|
583 | housekeeping_packet.hk_lfr_q_p1_fifo_size = MSG_QUEUE_COUNT_PRC1; | |
563 | housekeeping_packet.hk_lfr_q_p2_fifo_size = MSG_QUEUE_COUNT_PRC2; |
|
584 | housekeeping_packet.hk_lfr_q_p2_fifo_size = MSG_QUEUE_COUNT_PRC2; | |
564 | } |
|
585 | } | |
565 |
|
586 | |||
566 | void increment_seq_counter( unsigned short *packetSequenceControl ) |
|
587 | void increment_seq_counter( unsigned short *packetSequenceControl ) | |
567 | { |
|
588 | { | |
568 | /** This function increment the sequence counter passes in argument. |
|
589 | /** This function increment the sequence counter passes in argument. | |
569 | * |
|
590 | * | |
570 | * The increment does not affect the grouping flag. In case of an overflow, the counter is reset to 0. |
|
591 | * The increment does not affect the grouping flag. In case of an overflow, the counter is reset to 0. | |
571 | * |
|
592 | * | |
572 | */ |
|
593 | */ | |
573 |
|
594 | |||
574 | unsigned short segmentation_grouping_flag; |
|
595 | unsigned short segmentation_grouping_flag; | |
575 | unsigned short sequence_cnt; |
|
596 | unsigned short sequence_cnt; | |
576 |
|
597 | |||
577 | segmentation_grouping_flag = TM_PACKET_SEQ_CTRL_STANDALONE << SHIFT_1_BYTE; // keep bits 7 downto 6 |
|
598 | segmentation_grouping_flag = TM_PACKET_SEQ_CTRL_STANDALONE << SHIFT_1_BYTE; // keep bits 7 downto 6 | |
578 | sequence_cnt = (*packetSequenceControl) & SEQ_CNT_MASK; // [0011 1111 1111 1111] |
|
599 | sequence_cnt = (*packetSequenceControl) & SEQ_CNT_MASK; // [0011 1111 1111 1111] | |
579 |
|
600 | |||
580 | if ( sequence_cnt < SEQ_CNT_MAX) |
|
601 | if ( sequence_cnt < SEQ_CNT_MAX) | |
581 | { |
|
602 | { | |
582 | sequence_cnt = sequence_cnt + 1; |
|
603 | sequence_cnt = sequence_cnt + 1; | |
583 | } |
|
604 | } | |
584 | else |
|
605 | else | |
585 | { |
|
606 | { | |
586 | sequence_cnt = 0; |
|
607 | sequence_cnt = 0; | |
587 | } |
|
608 | } | |
588 |
|
609 | |||
589 | *packetSequenceControl = segmentation_grouping_flag | sequence_cnt ; |
|
610 | *packetSequenceControl = segmentation_grouping_flag | sequence_cnt ; | |
590 | } |
|
611 | } | |
591 |
|
612 | |||
592 | void getTime( unsigned char *time) |
|
613 | void getTime( unsigned char *time) | |
593 | { |
|
614 | { | |
594 | /** This function write the current local time in the time buffer passed in argument. |
|
615 | /** This function write the current local time in the time buffer passed in argument. | |
595 | * |
|
616 | * | |
596 | */ |
|
617 | */ | |
597 |
|
618 | |||
598 | time[0] = (unsigned char) (time_management_regs->coarse_time>>SHIFT_3_BYTES); |
|
619 | time[0] = (unsigned char) (time_management_regs->coarse_time>>SHIFT_3_BYTES); | |
599 | time[1] = (unsigned char) (time_management_regs->coarse_time>>SHIFT_2_BYTES); |
|
620 | time[1] = (unsigned char) (time_management_regs->coarse_time>>SHIFT_2_BYTES); | |
600 | time[2] = (unsigned char) (time_management_regs->coarse_time>>SHIFT_1_BYTE); |
|
621 | time[2] = (unsigned char) (time_management_regs->coarse_time>>SHIFT_1_BYTE); | |
601 | time[3] = (unsigned char) (time_management_regs->coarse_time); |
|
622 | time[3] = (unsigned char) (time_management_regs->coarse_time); | |
602 | time[4] = (unsigned char) (time_management_regs->fine_time>>SHIFT_1_BYTE); |
|
623 | time[4] = (unsigned char) (time_management_regs->fine_time>>SHIFT_1_BYTE); | |
603 | time[5] = (unsigned char) (time_management_regs->fine_time); |
|
624 | time[5] = (unsigned char) (time_management_regs->fine_time); | |
604 | } |
|
625 | } | |
605 |
|
626 | |||
606 | unsigned long long int getTimeAsUnsignedLongLongInt( ) |
|
627 | unsigned long long int getTimeAsUnsignedLongLongInt( ) | |
607 | { |
|
628 | { | |
608 | /** This function write the current local time in the time buffer passed in argument. |
|
629 | /** This function write the current local time in the time buffer passed in argument. | |
609 | * |
|
630 | * | |
610 | */ |
|
631 | */ | |
611 | unsigned long long int time; |
|
632 | unsigned long long int time; | |
612 |
|
633 | |||
613 | time = ( (unsigned long long int) (time_management_regs->coarse_time & COARSE_TIME_MASK) << SHIFT_2_BYTES ) |
|
634 | time = ( (unsigned long long int) (time_management_regs->coarse_time & COARSE_TIME_MASK) << SHIFT_2_BYTES ) | |
614 | + time_management_regs->fine_time; |
|
635 | + time_management_regs->fine_time; | |
615 |
|
636 | |||
616 | return time; |
|
637 | return time; | |
617 | } |
|
638 | } | |
618 |
|
639 | |||
619 | void send_dumb_hk( void ) |
|
640 | void send_dumb_hk( void ) | |
620 | { |
|
641 | { | |
621 | Packet_TM_LFR_HK_t dummy_hk_packet; |
|
642 | Packet_TM_LFR_HK_t dummy_hk_packet; | |
622 | unsigned char *parameters; |
|
643 | unsigned char *parameters; | |
623 | unsigned int i; |
|
644 | unsigned int i; | |
624 | rtems_id queue_id; |
|
645 | rtems_id queue_id; | |
625 |
|
646 | |||
626 | queue_id = RTEMS_ID_NONE; |
|
647 | queue_id = RTEMS_ID_NONE; | |
627 |
|
648 | |||
628 | dummy_hk_packet.targetLogicalAddress = CCSDS_DESTINATION_ID; |
|
649 | dummy_hk_packet.targetLogicalAddress = CCSDS_DESTINATION_ID; | |
629 | dummy_hk_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID; |
|
650 | dummy_hk_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID; | |
630 | dummy_hk_packet.reserved = DEFAULT_RESERVED; |
|
651 | dummy_hk_packet.reserved = DEFAULT_RESERVED; | |
631 | dummy_hk_packet.userApplication = CCSDS_USER_APP; |
|
652 | dummy_hk_packet.userApplication = CCSDS_USER_APP; | |
632 | dummy_hk_packet.packetID[0] = (unsigned char) (APID_TM_HK >> SHIFT_1_BYTE); |
|
653 | dummy_hk_packet.packetID[0] = (unsigned char) (APID_TM_HK >> SHIFT_1_BYTE); | |
633 | dummy_hk_packet.packetID[1] = (unsigned char) (APID_TM_HK); |
|
654 | dummy_hk_packet.packetID[1] = (unsigned char) (APID_TM_HK); | |
634 | dummy_hk_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; |
|
655 | dummy_hk_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; | |
635 | dummy_hk_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT; |
|
656 | dummy_hk_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT; | |
636 | dummy_hk_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_HK >> SHIFT_1_BYTE); |
|
657 | dummy_hk_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_HK >> SHIFT_1_BYTE); | |
637 | dummy_hk_packet.packetLength[1] = (unsigned char) (PACKET_LENGTH_HK ); |
|
658 | dummy_hk_packet.packetLength[1] = (unsigned char) (PACKET_LENGTH_HK ); | |
638 | dummy_hk_packet.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2; |
|
659 | dummy_hk_packet.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2; | |
639 | dummy_hk_packet.serviceType = TM_TYPE_HK; |
|
660 | dummy_hk_packet.serviceType = TM_TYPE_HK; | |
640 | dummy_hk_packet.serviceSubType = TM_SUBTYPE_HK; |
|
661 | dummy_hk_packet.serviceSubType = TM_SUBTYPE_HK; | |
641 | dummy_hk_packet.destinationID = TM_DESTINATION_ID_GROUND; |
|
662 | dummy_hk_packet.destinationID = TM_DESTINATION_ID_GROUND; | |
642 | dummy_hk_packet.time[0] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_3_BYTES); |
|
663 | dummy_hk_packet.time[0] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_3_BYTES); | |
643 | dummy_hk_packet.time[1] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_2_BYTES); |
|
664 | dummy_hk_packet.time[1] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_2_BYTES); | |
644 | dummy_hk_packet.time[BYTE_2] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_1_BYTE); |
|
665 | dummy_hk_packet.time[BYTE_2] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_1_BYTE); | |
645 | dummy_hk_packet.time[BYTE_3] = (unsigned char) (time_management_regs->coarse_time); |
|
666 | dummy_hk_packet.time[BYTE_3] = (unsigned char) (time_management_regs->coarse_time); | |
646 | dummy_hk_packet.time[BYTE_4] = (unsigned char) (time_management_regs->fine_time >> SHIFT_1_BYTE); |
|
667 | dummy_hk_packet.time[BYTE_4] = (unsigned char) (time_management_regs->fine_time >> SHIFT_1_BYTE); | |
647 | dummy_hk_packet.time[BYTE_5] = (unsigned char) (time_management_regs->fine_time); |
|
668 | dummy_hk_packet.time[BYTE_5] = (unsigned char) (time_management_regs->fine_time); | |
648 | dummy_hk_packet.sid = SID_HK; |
|
669 | dummy_hk_packet.sid = SID_HK; | |
649 |
|
670 | |||
650 | // init status word |
|
671 | // init status word | |
651 | dummy_hk_packet.lfr_status_word[0] = INT8_ALL_F; |
|
672 | dummy_hk_packet.lfr_status_word[0] = INT8_ALL_F; | |
652 | dummy_hk_packet.lfr_status_word[1] = INT8_ALL_F; |
|
673 | dummy_hk_packet.lfr_status_word[1] = INT8_ALL_F; | |
653 | // init software version |
|
674 | // init software version | |
654 | dummy_hk_packet.lfr_sw_version[0] = SW_VERSION_N1; |
|
675 | dummy_hk_packet.lfr_sw_version[0] = SW_VERSION_N1; | |
655 | dummy_hk_packet.lfr_sw_version[1] = SW_VERSION_N2; |
|
676 | dummy_hk_packet.lfr_sw_version[1] = SW_VERSION_N2; | |
656 | dummy_hk_packet.lfr_sw_version[BYTE_2] = SW_VERSION_N3; |
|
677 | dummy_hk_packet.lfr_sw_version[BYTE_2] = SW_VERSION_N3; | |
657 | dummy_hk_packet.lfr_sw_version[BYTE_3] = SW_VERSION_N4; |
|
678 | dummy_hk_packet.lfr_sw_version[BYTE_3] = SW_VERSION_N4; | |
658 | // init fpga version |
|
679 | // init fpga version | |
659 | parameters = (unsigned char *) (REGS_ADDR_WAVEFORM_PICKER + APB_OFFSET_VHDL_REV); |
|
680 | parameters = (unsigned char *) (REGS_ADDR_WAVEFORM_PICKER + APB_OFFSET_VHDL_REV); | |
660 | dummy_hk_packet.lfr_fpga_version[BYTE_0] = parameters[BYTE_1]; // n1 |
|
681 | dummy_hk_packet.lfr_fpga_version[BYTE_0] = parameters[BYTE_1]; // n1 | |
661 | dummy_hk_packet.lfr_fpga_version[BYTE_1] = parameters[BYTE_2]; // n2 |
|
682 | dummy_hk_packet.lfr_fpga_version[BYTE_1] = parameters[BYTE_2]; // n2 | |
662 | dummy_hk_packet.lfr_fpga_version[BYTE_2] = parameters[BYTE_3]; // n3 |
|
683 | dummy_hk_packet.lfr_fpga_version[BYTE_2] = parameters[BYTE_3]; // n3 | |
663 |
|
684 | |||
664 | parameters = (unsigned char *) &dummy_hk_packet.hk_lfr_cpu_load; |
|
685 | parameters = (unsigned char *) &dummy_hk_packet.hk_lfr_cpu_load; | |
665 |
|
686 | |||
666 | for (i=0; i<(BYTE_POS_HK_REACTION_WHEELS_FREQUENCY - BYTE_POS_HK_LFR_CPU_LOAD); i++) |
|
687 | for (i=0; i<(BYTE_POS_HK_REACTION_WHEELS_FREQUENCY - BYTE_POS_HK_LFR_CPU_LOAD); i++) | |
667 | { |
|
688 | { | |
668 | parameters[i] = INT8_ALL_F; |
|
689 | parameters[i] = INT8_ALL_F; | |
669 | } |
|
690 | } | |
670 |
|
691 | |||
671 | get_message_queue_id_send( &queue_id ); |
|
692 | get_message_queue_id_send( &queue_id ); | |
672 |
|
693 | |||
673 | rtems_message_queue_send( queue_id, &dummy_hk_packet, |
|
694 | rtems_message_queue_send( queue_id, &dummy_hk_packet, | |
674 | PACKET_LENGTH_HK + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES); |
|
695 | PACKET_LENGTH_HK + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES); | |
675 | } |
|
696 | } | |
676 |
|
697 | |||
677 | void get_temperatures( unsigned char *temperatures ) |
|
698 | void get_temperatures( unsigned char *temperatures ) | |
678 | { |
|
699 | { | |
679 | unsigned char* temp_scm_ptr; |
|
700 | unsigned char* temp_scm_ptr; | |
680 | unsigned char* temp_pcb_ptr; |
|
701 | unsigned char* temp_pcb_ptr; | |
681 | unsigned char* temp_fpga_ptr; |
|
702 | unsigned char* temp_fpga_ptr; | |
682 |
|
703 | |||
683 | // SEL1 SEL0 |
|
704 | // SEL1 SEL0 | |
684 | // 0 0 => PCB |
|
705 | // 0 0 => PCB | |
685 | // 0 1 => FPGA |
|
706 | // 0 1 => FPGA | |
686 | // 1 0 => SCM |
|
707 | // 1 0 => SCM | |
687 |
|
708 | |||
688 | temp_scm_ptr = (unsigned char *) &time_management_regs->temp_scm; |
|
709 | temp_scm_ptr = (unsigned char *) &time_management_regs->temp_scm; | |
689 | temp_pcb_ptr = (unsigned char *) &time_management_regs->temp_pcb; |
|
710 | temp_pcb_ptr = (unsigned char *) &time_management_regs->temp_pcb; | |
690 | temp_fpga_ptr = (unsigned char *) &time_management_regs->temp_fpga; |
|
711 | temp_fpga_ptr = (unsigned char *) &time_management_regs->temp_fpga; | |
691 |
|
712 | |||
692 | temperatures[ BYTE_0 ] = temp_scm_ptr[ BYTE_2 ]; |
|
713 | temperatures[ BYTE_0 ] = temp_scm_ptr[ BYTE_2 ]; | |
693 | temperatures[ BYTE_1 ] = temp_scm_ptr[ BYTE_3 ]; |
|
714 | temperatures[ BYTE_1 ] = temp_scm_ptr[ BYTE_3 ]; | |
694 | temperatures[ BYTE_2 ] = temp_pcb_ptr[ BYTE_2 ]; |
|
715 | temperatures[ BYTE_2 ] = temp_pcb_ptr[ BYTE_2 ]; | |
695 | temperatures[ BYTE_3 ] = temp_pcb_ptr[ BYTE_3 ]; |
|
716 | temperatures[ BYTE_3 ] = temp_pcb_ptr[ BYTE_3 ]; | |
696 | temperatures[ BYTE_4 ] = temp_fpga_ptr[ BYTE_2 ]; |
|
717 | temperatures[ BYTE_4 ] = temp_fpga_ptr[ BYTE_2 ]; | |
697 | temperatures[ BYTE_5 ] = temp_fpga_ptr[ BYTE_3 ]; |
|
718 | temperatures[ BYTE_5 ] = temp_fpga_ptr[ BYTE_3 ]; | |
698 | } |
|
719 | } | |
699 |
|
720 | |||
700 | void get_v_e1_e2_f3( unsigned char *spacecraft_potential ) |
|
721 | void get_v_e1_e2_f3( unsigned char *spacecraft_potential ) | |
701 | { |
|
722 | { | |
702 | unsigned char* v_ptr; |
|
723 | unsigned char* v_ptr; | |
703 | unsigned char* e1_ptr; |
|
724 | unsigned char* e1_ptr; | |
704 | unsigned char* e2_ptr; |
|
725 | unsigned char* e2_ptr; | |
705 |
|
726 | |||
706 | v_ptr = (unsigned char *) &hk_lfr_sc_v_f3_as_int16; |
|
727 | v_ptr = (unsigned char *) &hk_lfr_sc_v_f3_as_int16; | |
707 | e1_ptr = (unsigned char *) &hk_lfr_sc_e1_f3_as_int16; |
|
728 | e1_ptr = (unsigned char *) &hk_lfr_sc_e1_f3_as_int16; | |
708 | e2_ptr = (unsigned char *) &hk_lfr_sc_e2_f3_as_int16; |
|
729 | e2_ptr = (unsigned char *) &hk_lfr_sc_e2_f3_as_int16; | |
709 |
|
730 | |||
710 | spacecraft_potential[BYTE_0] = v_ptr[0]; |
|
731 | spacecraft_potential[BYTE_0] = v_ptr[0]; | |
711 | spacecraft_potential[BYTE_1] = v_ptr[1]; |
|
732 | spacecraft_potential[BYTE_1] = v_ptr[1]; | |
712 | spacecraft_potential[BYTE_2] = e1_ptr[0]; |
|
733 | spacecraft_potential[BYTE_2] = e1_ptr[0]; | |
713 | spacecraft_potential[BYTE_3] = e1_ptr[1]; |
|
734 | spacecraft_potential[BYTE_3] = e1_ptr[1]; | |
714 | spacecraft_potential[BYTE_4] = e2_ptr[0]; |
|
735 | spacecraft_potential[BYTE_4] = e2_ptr[0]; | |
715 | spacecraft_potential[BYTE_5] = e2_ptr[1]; |
|
736 | spacecraft_potential[BYTE_5] = e2_ptr[1]; | |
716 | } |
|
737 | } | |
717 |
|
738 | |||
718 | void get_cpu_load( unsigned char *resource_statistics ) |
|
739 | void get_cpu_load( unsigned char *resource_statistics ) | |
719 | { |
|
740 | { | |
720 | unsigned char cpu_load; |
|
741 | unsigned char cpu_load; | |
721 |
|
742 | |||
722 | cpu_load = lfr_rtems_cpu_usage_report(); |
|
743 | cpu_load = lfr_rtems_cpu_usage_report(); | |
723 |
|
744 | |||
724 | // HK_LFR_CPU_LOAD |
|
745 | // HK_LFR_CPU_LOAD | |
725 | resource_statistics[0] = cpu_load; |
|
746 | resource_statistics[0] = cpu_load; | |
726 |
|
747 | |||
727 | // HK_LFR_CPU_LOAD_MAX |
|
748 | // HK_LFR_CPU_LOAD_MAX | |
728 | if (cpu_load > resource_statistics[1]) |
|
749 | if (cpu_load > resource_statistics[1]) | |
729 | { |
|
750 | { | |
730 | resource_statistics[1] = cpu_load; |
|
751 | resource_statistics[1] = cpu_load; | |
731 | } |
|
752 | } | |
732 |
|
753 | |||
733 | // CPU_LOAD_AVE |
|
754 | // CPU_LOAD_AVE | |
734 | resource_statistics[BYTE_2] = 0; |
|
755 | resource_statistics[BYTE_2] = 0; | |
735 |
|
756 | |||
736 | #ifndef PRINT_TASK_STATISTICS |
|
757 | #ifndef PRINT_TASK_STATISTICS | |
737 | rtems_cpu_usage_reset(); |
|
758 | rtems_cpu_usage_reset(); | |
738 | #endif |
|
759 | #endif | |
739 |
|
760 | |||
740 | } |
|
761 | } | |
741 |
|
762 | |||
742 | void set_hk_lfr_sc_potential_flag( bool state ) |
|
763 | void set_hk_lfr_sc_potential_flag( bool state ) | |
743 | { |
|
764 | { | |
744 | if (state == true) |
|
765 | if (state == true) | |
745 | { |
|
766 | { | |
746 | housekeeping_packet.lfr_status_word[1] = |
|
767 | housekeeping_packet.lfr_status_word[1] = | |
747 | housekeeping_packet.lfr_status_word[1] | STATUS_WORD_SC_POTENTIAL_FLAG_BIT; // [0100 0000] |
|
768 | housekeeping_packet.lfr_status_word[1] | STATUS_WORD_SC_POTENTIAL_FLAG_BIT; // [0100 0000] | |
748 | } |
|
769 | } | |
749 | else |
|
770 | else | |
750 | { |
|
771 | { | |
751 | housekeeping_packet.lfr_status_word[1] = |
|
772 | housekeeping_packet.lfr_status_word[1] = | |
752 | housekeeping_packet.lfr_status_word[1] & STATUS_WORD_SC_POTENTIAL_FLAG_MASK; // [1011 1111] |
|
773 | housekeeping_packet.lfr_status_word[1] & STATUS_WORD_SC_POTENTIAL_FLAG_MASK; // [1011 1111] | |
753 | } |
|
774 | } | |
754 | } |
|
775 | } | |
755 |
|
776 | |||
756 | void set_sy_lfr_pas_filter_enabled( bool state ) |
|
777 | void set_sy_lfr_pas_filter_enabled( bool state ) | |
757 | { |
|
778 | { | |
758 | if (state == true) |
|
779 | if (state == true) | |
759 | { |
|
780 | { | |
760 | housekeeping_packet.lfr_status_word[1] = |
|
781 | housekeeping_packet.lfr_status_word[1] = | |
761 | housekeeping_packet.lfr_status_word[1] | STATUS_WORD_PAS_FILTER_ENABLED_BIT; // [0010 0000] |
|
782 | housekeeping_packet.lfr_status_word[1] | STATUS_WORD_PAS_FILTER_ENABLED_BIT; // [0010 0000] | |
762 | } |
|
783 | } | |
763 | else |
|
784 | else | |
764 | { |
|
785 | { | |
765 | housekeeping_packet.lfr_status_word[1] = |
|
786 | housekeeping_packet.lfr_status_word[1] = | |
766 | housekeeping_packet.lfr_status_word[1] & STATUS_WORD_PAS_FILTER_ENABLED_MASK; // [1101 1111] |
|
787 | housekeeping_packet.lfr_status_word[1] & STATUS_WORD_PAS_FILTER_ENABLED_MASK; // [1101 1111] | |
767 | } |
|
788 | } | |
768 | } |
|
789 | } | |
769 |
|
790 | |||
770 | void set_sy_lfr_watchdog_enabled( bool state ) |
|
791 | void set_sy_lfr_watchdog_enabled( bool state ) | |
771 | { |
|
792 | { | |
772 | if (state == true) |
|
793 | if (state == true) | |
773 | { |
|
794 | { | |
774 | housekeeping_packet.lfr_status_word[1] = |
|
795 | housekeeping_packet.lfr_status_word[1] = | |
775 | housekeeping_packet.lfr_status_word[1] | STATUS_WORD_WATCHDOG_BIT; // [0001 0000] |
|
796 | housekeeping_packet.lfr_status_word[1] | STATUS_WORD_WATCHDOG_BIT; // [0001 0000] | |
776 | } |
|
797 | } | |
777 | else |
|
798 | else | |
778 | { |
|
799 | { | |
779 | housekeeping_packet.lfr_status_word[1] = |
|
800 | housekeeping_packet.lfr_status_word[1] = | |
780 | housekeeping_packet.lfr_status_word[1] & STATUS_WORD_WATCHDOG_MASK; // [1110 1111] |
|
801 | housekeeping_packet.lfr_status_word[1] & STATUS_WORD_WATCHDOG_MASK; // [1110 1111] | |
781 | } |
|
802 | } | |
782 | } |
|
803 | } | |
783 |
|
804 | |||
784 | void set_hk_lfr_calib_enable( bool state ) |
|
805 | void set_hk_lfr_calib_enable( bool state ) | |
785 | { |
|
806 | { | |
786 | if (state == true) |
|
807 | if (state == true) | |
787 | { |
|
808 | { | |
788 | housekeeping_packet.lfr_status_word[1] = |
|
809 | housekeeping_packet.lfr_status_word[1] = | |
789 | housekeeping_packet.lfr_status_word[1] | STATUS_WORD_CALIB_BIT; // [0000 1000] |
|
810 | housekeeping_packet.lfr_status_word[1] | STATUS_WORD_CALIB_BIT; // [0000 1000] | |
790 | } |
|
811 | } | |
791 | else |
|
812 | else | |
792 | { |
|
813 | { | |
793 | housekeeping_packet.lfr_status_word[1] = |
|
814 | housekeeping_packet.lfr_status_word[1] = | |
794 | housekeeping_packet.lfr_status_word[1] & STATUS_WORD_CALIB_MASK; // [1111 0111] |
|
815 | housekeeping_packet.lfr_status_word[1] & STATUS_WORD_CALIB_MASK; // [1111 0111] | |
795 | } |
|
816 | } | |
796 | } |
|
817 | } | |
797 |
|
818 | |||
798 | void set_hk_lfr_reset_cause( enum lfr_reset_cause_t lfr_reset_cause ) |
|
819 | void set_hk_lfr_reset_cause( enum lfr_reset_cause_t lfr_reset_cause ) | |
799 | { |
|
820 | { | |
800 | housekeeping_packet.lfr_status_word[1] = |
|
821 | housekeeping_packet.lfr_status_word[1] = | |
801 | housekeeping_packet.lfr_status_word[1] & STATUS_WORD_RESET_CAUSE_MASK; // [1111 1000] |
|
822 | housekeeping_packet.lfr_status_word[1] & STATUS_WORD_RESET_CAUSE_MASK; // [1111 1000] | |
802 |
|
823 | |||
803 | housekeeping_packet.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1] |
|
824 | housekeeping_packet.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1] | |
804 | | (lfr_reset_cause & STATUS_WORD_RESET_CAUSE_BITS ); // [0000 0111] |
|
825 | | (lfr_reset_cause & STATUS_WORD_RESET_CAUSE_BITS ); // [0000 0111] | |
805 |
|
826 | |||
806 | } |
|
827 | } | |
807 |
|
828 | |||
808 | void increment_hk_counter( unsigned char newValue, unsigned char oldValue, unsigned int *counter ) |
|
829 | void increment_hk_counter( unsigned char newValue, unsigned char oldValue, unsigned int *counter ) | |
809 | { |
|
830 | { | |
810 | int delta; |
|
831 | int delta; | |
811 |
|
832 | |||
812 | delta = 0; |
|
833 | delta = 0; | |
813 |
|
834 | |||
814 | if (newValue >= oldValue) |
|
835 | if (newValue >= oldValue) | |
815 | { |
|
836 | { | |
816 | delta = newValue - oldValue; |
|
837 | delta = newValue - oldValue; | |
817 | } |
|
838 | } | |
818 | else |
|
839 | else | |
819 | { |
|
840 | { | |
820 | delta = (CONST_256 - oldValue) + newValue; |
|
841 | delta = (CONST_256 - oldValue) + newValue; | |
821 | } |
|
842 | } | |
822 |
|
843 | |||
823 | *counter = *counter + delta; |
|
844 | *counter = *counter + delta; | |
824 | } |
|
845 | } | |
825 |
|
846 | |||
826 | void hk_lfr_le_update( void ) |
|
847 | void hk_lfr_le_update( void ) | |
827 | { |
|
848 | { | |
828 | static hk_lfr_le_t old_hk_lfr_le = {0}; |
|
849 | static hk_lfr_le_t old_hk_lfr_le = {0}; | |
829 | hk_lfr_le_t new_hk_lfr_le; |
|
850 | hk_lfr_le_t new_hk_lfr_le; | |
830 | unsigned int counter; |
|
851 | unsigned int counter; | |
831 |
|
852 | |||
832 | counter = (((unsigned int) housekeeping_packet.hk_lfr_le_cnt[0]) * CONST_256) + housekeeping_packet.hk_lfr_le_cnt[1]; |
|
853 | counter = (((unsigned int) housekeeping_packet.hk_lfr_le_cnt[0]) * CONST_256) + housekeeping_packet.hk_lfr_le_cnt[1]; | |
833 |
|
854 | |||
834 | // DPU |
|
855 | // DPU | |
835 | new_hk_lfr_le.dpu_spw_parity = housekeeping_packet.hk_lfr_dpu_spw_parity; |
|
856 | new_hk_lfr_le.dpu_spw_parity = housekeeping_packet.hk_lfr_dpu_spw_parity; | |
836 | new_hk_lfr_le.dpu_spw_disconnect= housekeeping_packet.hk_lfr_dpu_spw_disconnect; |
|
857 | new_hk_lfr_le.dpu_spw_disconnect= housekeeping_packet.hk_lfr_dpu_spw_disconnect; | |
837 | new_hk_lfr_le.dpu_spw_escape = housekeeping_packet.hk_lfr_dpu_spw_escape; |
|
858 | new_hk_lfr_le.dpu_spw_escape = housekeeping_packet.hk_lfr_dpu_spw_escape; | |
838 | new_hk_lfr_le.dpu_spw_credit = housekeeping_packet.hk_lfr_dpu_spw_credit; |
|
859 | new_hk_lfr_le.dpu_spw_credit = housekeeping_packet.hk_lfr_dpu_spw_credit; | |
839 | new_hk_lfr_le.dpu_spw_write_sync= housekeeping_packet.hk_lfr_dpu_spw_write_sync; |
|
860 | new_hk_lfr_le.dpu_spw_write_sync= housekeeping_packet.hk_lfr_dpu_spw_write_sync; | |
840 | // TIMECODE |
|
861 | // TIMECODE | |
841 | new_hk_lfr_le.timecode_erroneous= housekeeping_packet.hk_lfr_timecode_erroneous; |
|
862 | new_hk_lfr_le.timecode_erroneous= housekeeping_packet.hk_lfr_timecode_erroneous; | |
842 | new_hk_lfr_le.timecode_missing = housekeeping_packet.hk_lfr_timecode_missing; |
|
863 | new_hk_lfr_le.timecode_missing = housekeeping_packet.hk_lfr_timecode_missing; | |
843 | new_hk_lfr_le.timecode_invalid = housekeeping_packet.hk_lfr_timecode_invalid; |
|
864 | new_hk_lfr_le.timecode_invalid = housekeeping_packet.hk_lfr_timecode_invalid; | |
844 | // TIME |
|
865 | // TIME | |
845 | new_hk_lfr_le.time_timecode_it = housekeeping_packet.hk_lfr_time_timecode_it; |
|
866 | new_hk_lfr_le.time_timecode_it = housekeeping_packet.hk_lfr_time_timecode_it; | |
846 | new_hk_lfr_le.time_not_synchro = housekeeping_packet.hk_lfr_time_not_synchro; |
|
867 | new_hk_lfr_le.time_not_synchro = housekeeping_packet.hk_lfr_time_not_synchro; | |
847 | new_hk_lfr_le.time_timecode_ctr = housekeeping_packet.hk_lfr_time_timecode_ctr; |
|
868 | new_hk_lfr_le.time_timecode_ctr = housekeeping_packet.hk_lfr_time_timecode_ctr; | |
848 | //AHB |
|
869 | //AHB | |
849 | new_hk_lfr_le.ahb_correctable = housekeeping_packet.hk_lfr_ahb_correctable; |
|
870 | new_hk_lfr_le.ahb_correctable = housekeeping_packet.hk_lfr_ahb_correctable; | |
850 | // housekeeping_packet.hk_lfr_dpu_spw_rx_ahb => not handled by the grspw driver |
|
871 | // housekeeping_packet.hk_lfr_dpu_spw_rx_ahb => not handled by the grspw driver | |
851 | // housekeeping_packet.hk_lfr_dpu_spw_tx_ahb => not handled by the grspw driver |
|
872 | // housekeeping_packet.hk_lfr_dpu_spw_tx_ahb => not handled by the grspw driver | |
852 |
|
873 | |||
853 | // update the le counter |
|
874 | // update the le counter | |
854 | // DPU |
|
875 | // DPU | |
855 | increment_hk_counter( new_hk_lfr_le.dpu_spw_parity, old_hk_lfr_le.dpu_spw_parity, &counter ); |
|
876 | increment_hk_counter( new_hk_lfr_le.dpu_spw_parity, old_hk_lfr_le.dpu_spw_parity, &counter ); | |
856 | increment_hk_counter( new_hk_lfr_le.dpu_spw_disconnect,old_hk_lfr_le.dpu_spw_disconnect, &counter ); |
|
877 | increment_hk_counter( new_hk_lfr_le.dpu_spw_disconnect,old_hk_lfr_le.dpu_spw_disconnect, &counter ); | |
857 | increment_hk_counter( new_hk_lfr_le.dpu_spw_escape, old_hk_lfr_le.dpu_spw_escape, &counter ); |
|
878 | increment_hk_counter( new_hk_lfr_le.dpu_spw_escape, old_hk_lfr_le.dpu_spw_escape, &counter ); | |
858 | increment_hk_counter( new_hk_lfr_le.dpu_spw_credit, old_hk_lfr_le.dpu_spw_credit, &counter ); |
|
879 | increment_hk_counter( new_hk_lfr_le.dpu_spw_credit, old_hk_lfr_le.dpu_spw_credit, &counter ); | |
859 | increment_hk_counter( new_hk_lfr_le.dpu_spw_write_sync,old_hk_lfr_le.dpu_spw_write_sync, &counter ); |
|
880 | increment_hk_counter( new_hk_lfr_le.dpu_spw_write_sync,old_hk_lfr_le.dpu_spw_write_sync, &counter ); | |
860 | // TIMECODE |
|
881 | // TIMECODE | |
861 | increment_hk_counter( new_hk_lfr_le.timecode_erroneous,old_hk_lfr_le.timecode_erroneous, &counter ); |
|
882 | increment_hk_counter( new_hk_lfr_le.timecode_erroneous,old_hk_lfr_le.timecode_erroneous, &counter ); | |
862 | increment_hk_counter( new_hk_lfr_le.timecode_missing, old_hk_lfr_le.timecode_missing, &counter ); |
|
883 | increment_hk_counter( new_hk_lfr_le.timecode_missing, old_hk_lfr_le.timecode_missing, &counter ); | |
863 | increment_hk_counter( new_hk_lfr_le.timecode_invalid, old_hk_lfr_le.timecode_invalid, &counter ); |
|
884 | increment_hk_counter( new_hk_lfr_le.timecode_invalid, old_hk_lfr_le.timecode_invalid, &counter ); | |
864 | // TIME |
|
885 | // TIME | |
865 | increment_hk_counter( new_hk_lfr_le.time_timecode_it, old_hk_lfr_le.time_timecode_it, &counter ); |
|
886 | increment_hk_counter( new_hk_lfr_le.time_timecode_it, old_hk_lfr_le.time_timecode_it, &counter ); | |
866 | increment_hk_counter( new_hk_lfr_le.time_not_synchro, old_hk_lfr_le.time_not_synchro, &counter ); |
|
887 | increment_hk_counter( new_hk_lfr_le.time_not_synchro, old_hk_lfr_le.time_not_synchro, &counter ); | |
867 | increment_hk_counter( new_hk_lfr_le.time_timecode_ctr, old_hk_lfr_le.time_timecode_ctr, &counter ); |
|
888 | increment_hk_counter( new_hk_lfr_le.time_timecode_ctr, old_hk_lfr_le.time_timecode_ctr, &counter ); | |
868 | // AHB |
|
889 | // AHB | |
869 | increment_hk_counter( new_hk_lfr_le.ahb_correctable, old_hk_lfr_le.ahb_correctable, &counter ); |
|
890 | increment_hk_counter( new_hk_lfr_le.ahb_correctable, old_hk_lfr_le.ahb_correctable, &counter ); | |
870 |
|
891 | |||
871 | // DPU |
|
892 | // DPU | |
872 | old_hk_lfr_le.dpu_spw_parity = new_hk_lfr_le.dpu_spw_parity; |
|
893 | old_hk_lfr_le.dpu_spw_parity = new_hk_lfr_le.dpu_spw_parity; | |
873 | old_hk_lfr_le.dpu_spw_disconnect= new_hk_lfr_le.dpu_spw_disconnect; |
|
894 | old_hk_lfr_le.dpu_spw_disconnect= new_hk_lfr_le.dpu_spw_disconnect; | |
874 | old_hk_lfr_le.dpu_spw_escape = new_hk_lfr_le.dpu_spw_escape; |
|
895 | old_hk_lfr_le.dpu_spw_escape = new_hk_lfr_le.dpu_spw_escape; | |
875 | old_hk_lfr_le.dpu_spw_credit = new_hk_lfr_le.dpu_spw_credit; |
|
896 | old_hk_lfr_le.dpu_spw_credit = new_hk_lfr_le.dpu_spw_credit; | |
876 | old_hk_lfr_le.dpu_spw_write_sync= new_hk_lfr_le.dpu_spw_write_sync; |
|
897 | old_hk_lfr_le.dpu_spw_write_sync= new_hk_lfr_le.dpu_spw_write_sync; | |
877 | // TIMECODE |
|
898 | // TIMECODE | |
878 | old_hk_lfr_le.timecode_erroneous= new_hk_lfr_le.timecode_erroneous; |
|
899 | old_hk_lfr_le.timecode_erroneous= new_hk_lfr_le.timecode_erroneous; | |
879 | old_hk_lfr_le.timecode_missing = new_hk_lfr_le.timecode_missing; |
|
900 | old_hk_lfr_le.timecode_missing = new_hk_lfr_le.timecode_missing; | |
880 | old_hk_lfr_le.timecode_invalid = new_hk_lfr_le.timecode_invalid; |
|
901 | old_hk_lfr_le.timecode_invalid = new_hk_lfr_le.timecode_invalid; | |
881 | // TIME |
|
902 | // TIME | |
882 | old_hk_lfr_le.time_timecode_it = new_hk_lfr_le.time_timecode_it; |
|
903 | old_hk_lfr_le.time_timecode_it = new_hk_lfr_le.time_timecode_it; | |
883 | old_hk_lfr_le.time_not_synchro = new_hk_lfr_le.time_not_synchro; |
|
904 | old_hk_lfr_le.time_not_synchro = new_hk_lfr_le.time_not_synchro; | |
884 | old_hk_lfr_le.time_timecode_ctr = new_hk_lfr_le.time_timecode_ctr; |
|
905 | old_hk_lfr_le.time_timecode_ctr = new_hk_lfr_le.time_timecode_ctr; | |
885 | //AHB |
|
906 | //AHB | |
886 | old_hk_lfr_le.ahb_correctable = new_hk_lfr_le.ahb_correctable; |
|
907 | old_hk_lfr_le.ahb_correctable = new_hk_lfr_le.ahb_correctable; | |
887 | // housekeeping_packet.hk_lfr_dpu_spw_rx_ahb => not handled by the grspw driver |
|
908 | // housekeeping_packet.hk_lfr_dpu_spw_rx_ahb => not handled by the grspw driver | |
888 | // housekeeping_packet.hk_lfr_dpu_spw_tx_ahb => not handled by the grspw driver |
|
909 | // housekeeping_packet.hk_lfr_dpu_spw_tx_ahb => not handled by the grspw driver | |
889 |
|
910 | |||
890 | // update housekeeping packet counters, convert unsigned int numbers in 2 bytes numbers |
|
911 | // update housekeeping packet counters, convert unsigned int numbers in 2 bytes numbers | |
891 | // LE |
|
912 | // LE | |
892 | housekeeping_packet.hk_lfr_le_cnt[0] = (unsigned char) ((counter & BYTE0_MASK) >> SHIFT_1_BYTE); |
|
913 | housekeeping_packet.hk_lfr_le_cnt[0] = (unsigned char) ((counter & BYTE0_MASK) >> SHIFT_1_BYTE); | |
893 | housekeeping_packet.hk_lfr_le_cnt[1] = (unsigned char) (counter & BYTE1_MASK); |
|
914 | housekeeping_packet.hk_lfr_le_cnt[1] = (unsigned char) (counter & BYTE1_MASK); | |
894 | } |
|
915 | } | |
895 |
|
916 | |||
896 | void hk_lfr_me_update( void ) |
|
917 | void hk_lfr_me_update( void ) | |
897 | { |
|
918 | { | |
898 | static hk_lfr_me_t old_hk_lfr_me = {0}; |
|
919 | static hk_lfr_me_t old_hk_lfr_me = {0}; | |
899 | hk_lfr_me_t new_hk_lfr_me; |
|
920 | hk_lfr_me_t new_hk_lfr_me; | |
900 | unsigned int counter; |
|
921 | unsigned int counter; | |
901 |
|
922 | |||
902 | counter = (((unsigned int) housekeeping_packet.hk_lfr_me_cnt[0]) * CONST_256) + housekeeping_packet.hk_lfr_me_cnt[1]; |
|
923 | counter = (((unsigned int) housekeeping_packet.hk_lfr_me_cnt[0]) * CONST_256) + housekeeping_packet.hk_lfr_me_cnt[1]; | |
903 |
|
924 | |||
904 | // get the current values |
|
925 | // get the current values | |
905 | new_hk_lfr_me.dpu_spw_early_eop = housekeeping_packet.hk_lfr_dpu_spw_early_eop; |
|
926 | new_hk_lfr_me.dpu_spw_early_eop = housekeeping_packet.hk_lfr_dpu_spw_early_eop; | |
906 | new_hk_lfr_me.dpu_spw_invalid_addr = housekeeping_packet.hk_lfr_dpu_spw_invalid_addr; |
|
927 | new_hk_lfr_me.dpu_spw_invalid_addr = housekeeping_packet.hk_lfr_dpu_spw_invalid_addr; | |
907 | new_hk_lfr_me.dpu_spw_eep = housekeeping_packet.hk_lfr_dpu_spw_eep; |
|
928 | new_hk_lfr_me.dpu_spw_eep = housekeeping_packet.hk_lfr_dpu_spw_eep; | |
908 | new_hk_lfr_me.dpu_spw_rx_too_big = housekeeping_packet.hk_lfr_dpu_spw_rx_too_big; |
|
929 | new_hk_lfr_me.dpu_spw_rx_too_big = housekeeping_packet.hk_lfr_dpu_spw_rx_too_big; | |
909 |
|
930 | |||
910 | // update the me counter |
|
931 | // update the me counter | |
911 | increment_hk_counter( new_hk_lfr_me.dpu_spw_early_eop, old_hk_lfr_me.dpu_spw_early_eop, &counter ); |
|
932 | increment_hk_counter( new_hk_lfr_me.dpu_spw_early_eop, old_hk_lfr_me.dpu_spw_early_eop, &counter ); | |
912 | increment_hk_counter( new_hk_lfr_me.dpu_spw_invalid_addr, old_hk_lfr_me.dpu_spw_invalid_addr, &counter ); |
|
933 | increment_hk_counter( new_hk_lfr_me.dpu_spw_invalid_addr, old_hk_lfr_me.dpu_spw_invalid_addr, &counter ); | |
913 | increment_hk_counter( new_hk_lfr_me.dpu_spw_eep, old_hk_lfr_me.dpu_spw_eep, &counter ); |
|
934 | increment_hk_counter( new_hk_lfr_me.dpu_spw_eep, old_hk_lfr_me.dpu_spw_eep, &counter ); | |
914 | increment_hk_counter( new_hk_lfr_me.dpu_spw_rx_too_big, old_hk_lfr_me.dpu_spw_rx_too_big, &counter ); |
|
935 | increment_hk_counter( new_hk_lfr_me.dpu_spw_rx_too_big, old_hk_lfr_me.dpu_spw_rx_too_big, &counter ); | |
915 |
|
936 | |||
916 | // store the counters for the next time |
|
937 | // store the counters for the next time | |
917 | old_hk_lfr_me.dpu_spw_early_eop = new_hk_lfr_me.dpu_spw_early_eop; |
|
938 | old_hk_lfr_me.dpu_spw_early_eop = new_hk_lfr_me.dpu_spw_early_eop; | |
918 | old_hk_lfr_me.dpu_spw_invalid_addr = new_hk_lfr_me.dpu_spw_invalid_addr; |
|
939 | old_hk_lfr_me.dpu_spw_invalid_addr = new_hk_lfr_me.dpu_spw_invalid_addr; | |
919 | old_hk_lfr_me.dpu_spw_eep = new_hk_lfr_me.dpu_spw_eep; |
|
940 | old_hk_lfr_me.dpu_spw_eep = new_hk_lfr_me.dpu_spw_eep; | |
920 | old_hk_lfr_me.dpu_spw_rx_too_big = new_hk_lfr_me.dpu_spw_rx_too_big; |
|
941 | old_hk_lfr_me.dpu_spw_rx_too_big = new_hk_lfr_me.dpu_spw_rx_too_big; | |
921 |
|
942 | |||
922 | // update housekeeping packet counters, convert unsigned int numbers in 2 bytes numbers |
|
943 | // update housekeeping packet counters, convert unsigned int numbers in 2 bytes numbers | |
923 | // ME |
|
944 | // ME | |
924 | housekeeping_packet.hk_lfr_me_cnt[0] = (unsigned char) ((counter & BYTE0_MASK) >> SHIFT_1_BYTE); |
|
945 | housekeeping_packet.hk_lfr_me_cnt[0] = (unsigned char) ((counter & BYTE0_MASK) >> SHIFT_1_BYTE); | |
925 | housekeeping_packet.hk_lfr_me_cnt[1] = (unsigned char) (counter & BYTE1_MASK); |
|
946 | housekeeping_packet.hk_lfr_me_cnt[1] = (unsigned char) (counter & BYTE1_MASK); | |
926 | } |
|
947 | } | |
927 |
|
948 | |||
928 | void hk_lfr_le_me_he_update() |
|
949 | void hk_lfr_le_me_he_update() | |
929 | { |
|
950 | { | |
930 |
|
951 | |||
931 | unsigned int hk_lfr_he_cnt; |
|
952 | unsigned int hk_lfr_he_cnt; | |
932 |
|
953 | |||
933 | hk_lfr_he_cnt = (((unsigned int) housekeeping_packet.hk_lfr_he_cnt[0]) * 256) + housekeeping_packet.hk_lfr_he_cnt[1]; |
|
954 | hk_lfr_he_cnt = (((unsigned int) housekeeping_packet.hk_lfr_he_cnt[0]) * 256) + housekeeping_packet.hk_lfr_he_cnt[1]; | |
934 |
|
955 | |||
935 | //update the low severity error counter |
|
956 | //update the low severity error counter | |
936 | hk_lfr_le_update( ); |
|
957 | hk_lfr_le_update( ); | |
937 |
|
958 | |||
938 | //update the medium severity error counter |
|
959 | //update the medium severity error counter | |
939 | hk_lfr_me_update(); |
|
960 | hk_lfr_me_update(); | |
940 |
|
961 | |||
941 | //update the high severity error counter |
|
962 | //update the high severity error counter | |
942 | hk_lfr_he_cnt = 0; |
|
963 | hk_lfr_he_cnt = 0; | |
943 |
|
964 | |||
944 | // update housekeeping packet counters, convert unsigned int numbers in 2 bytes numbers |
|
965 | // update housekeeping packet counters, convert unsigned int numbers in 2 bytes numbers | |
945 | // HE |
|
966 | // HE | |
946 | housekeeping_packet.hk_lfr_he_cnt[0] = (unsigned char) ((hk_lfr_he_cnt & BYTE0_MASK) >> SHIFT_1_BYTE); |
|
967 | housekeeping_packet.hk_lfr_he_cnt[0] = (unsigned char) ((hk_lfr_he_cnt & BYTE0_MASK) >> SHIFT_1_BYTE); | |
947 | housekeeping_packet.hk_lfr_he_cnt[1] = (unsigned char) (hk_lfr_he_cnt & BYTE1_MASK); |
|
968 | housekeeping_packet.hk_lfr_he_cnt[1] = (unsigned char) (hk_lfr_he_cnt & BYTE1_MASK); | |
948 |
|
969 | |||
949 | } |
|
970 | } | |
950 |
|
971 | |||
951 | void set_hk_lfr_time_not_synchro() |
|
972 | void set_hk_lfr_time_not_synchro() | |
952 | { |
|
973 | { | |
953 | static unsigned char synchroLost = 1; |
|
974 | static unsigned char synchroLost = 1; | |
954 | int synchronizationBit; |
|
975 | int synchronizationBit; | |
955 |
|
976 | |||
956 | // get the synchronization bit |
|
977 | // get the synchronization bit | |
957 | synchronizationBit = |
|
978 | synchronizationBit = | |
958 | (time_management_regs->coarse_time & VAL_LFR_SYNCHRONIZED) >> BIT_SYNCHRONIZATION; // 1000 0000 0000 0000 |
|
979 | (time_management_regs->coarse_time & VAL_LFR_SYNCHRONIZED) >> BIT_SYNCHRONIZATION; // 1000 0000 0000 0000 | |
959 |
|
980 | |||
960 | switch (synchronizationBit) |
|
981 | switch (synchronizationBit) | |
961 | { |
|
982 | { | |
962 | case 0: |
|
983 | case 0: | |
963 | if (synchroLost == 1) |
|
984 | if (synchroLost == 1) | |
964 | { |
|
985 | { | |
965 | synchroLost = 0; |
|
986 | synchroLost = 0; | |
966 | } |
|
987 | } | |
967 | break; |
|
988 | break; | |
968 | case 1: |
|
989 | case 1: | |
969 | if (synchroLost == 0 ) |
|
990 | if (synchroLost == 0 ) | |
970 | { |
|
991 | { | |
971 | synchroLost = 1; |
|
992 | synchroLost = 1; | |
972 | increase_unsigned_char_counter(&housekeeping_packet.hk_lfr_time_not_synchro); |
|
993 | increase_unsigned_char_counter(&housekeeping_packet.hk_lfr_time_not_synchro); | |
973 | update_hk_lfr_last_er_fields( RID_LE_LFR_TIME, CODE_NOT_SYNCHRO ); |
|
994 | update_hk_lfr_last_er_fields( RID_LE_LFR_TIME, CODE_NOT_SYNCHRO ); | |
974 | } |
|
995 | } | |
975 | break; |
|
996 | break; | |
976 | default: |
|
997 | default: | |
977 | PRINTF1("in hk_lfr_time_not_synchro *** unexpected value for synchronizationBit = %d\n", synchronizationBit); |
|
998 | PRINTF1("in hk_lfr_time_not_synchro *** unexpected value for synchronizationBit = %d\n", synchronizationBit); | |
978 | break; |
|
999 | break; | |
979 | } |
|
1000 | } | |
980 |
|
1001 | |||
981 | } |
|
1002 | } | |
982 |
|
1003 | |||
983 | void set_hk_lfr_ahb_correctable() // CRITICITY L |
|
1004 | void set_hk_lfr_ahb_correctable() // CRITICITY L | |
984 | { |
|
1005 | { | |
985 | /** This function builds the error counter hk_lfr_ahb_correctable using the statistics provided |
|
1006 | /** This function builds the error counter hk_lfr_ahb_correctable using the statistics provided | |
986 | * by the Cache Control Register (ASI 2, offset 0) and in the Register Protection Control Register (ASR16) on the |
|
1007 | * by the Cache Control Register (ASI 2, offset 0) and in the Register Protection Control Register (ASR16) on the | |
987 | * detected errors in the cache, in the integer unit and in the floating point unit. |
|
1008 | * detected errors in the cache, in the integer unit and in the floating point unit. | |
988 | * |
|
1009 | * | |
989 | * @param void |
|
1010 | * @param void | |
990 | * |
|
1011 | * | |
991 | * @return void |
|
1012 | * @return void | |
992 | * |
|
1013 | * | |
993 | * All errors are summed to set the value of the hk_lfr_ahb_correctable counter. |
|
1014 | * All errors are summed to set the value of the hk_lfr_ahb_correctable counter. | |
994 | * |
|
1015 | * | |
995 | */ |
|
1016 | */ | |
996 |
|
1017 | |||
997 | unsigned int ahb_correctable; |
|
1018 | unsigned int ahb_correctable; | |
998 | unsigned int instructionErrorCounter; |
|
1019 | unsigned int instructionErrorCounter; | |
999 | unsigned int dataErrorCounter; |
|
1020 | unsigned int dataErrorCounter; | |
1000 | unsigned int fprfErrorCounter; |
|
1021 | unsigned int fprfErrorCounter; | |
1001 | unsigned int iurfErrorCounter; |
|
1022 | unsigned int iurfErrorCounter; | |
1002 |
|
1023 | |||
1003 | instructionErrorCounter = 0; |
|
1024 | instructionErrorCounter = 0; | |
1004 | dataErrorCounter = 0; |
|
1025 | dataErrorCounter = 0; | |
1005 | fprfErrorCounter = 0; |
|
1026 | fprfErrorCounter = 0; | |
1006 | iurfErrorCounter = 0; |
|
1027 | iurfErrorCounter = 0; | |
1007 |
|
1028 | |||
1008 | CCR_getInstructionAndDataErrorCounters( &instructionErrorCounter, &dataErrorCounter); |
|
1029 | CCR_getInstructionAndDataErrorCounters( &instructionErrorCounter, &dataErrorCounter); | |
1009 | ASR16_get_FPRF_IURF_ErrorCounters( &fprfErrorCounter, &iurfErrorCounter); |
|
1030 | ASR16_get_FPRF_IURF_ErrorCounters( &fprfErrorCounter, &iurfErrorCounter); | |
1010 |
|
1031 | |||
1011 | ahb_correctable = instructionErrorCounter |
|
1032 | ahb_correctable = instructionErrorCounter | |
1012 | + dataErrorCounter |
|
1033 | + dataErrorCounter | |
1013 | + fprfErrorCounter |
|
1034 | + fprfErrorCounter | |
1014 | + iurfErrorCounter |
|
1035 | + iurfErrorCounter | |
1015 | + housekeeping_packet.hk_lfr_ahb_correctable; |
|
1036 | + housekeeping_packet.hk_lfr_ahb_correctable; | |
1016 |
|
1037 | |||
1017 | housekeeping_packet.hk_lfr_ahb_correctable = (unsigned char) (ahb_correctable & INT8_ALL_F); // [1111 1111] |
|
1038 | housekeeping_packet.hk_lfr_ahb_correctable = (unsigned char) (ahb_correctable & INT8_ALL_F); // [1111 1111] | |
1018 |
|
1039 | |||
1019 | } |
|
1040 | } |
General Comments 0
You need to be logged in to leave comments.
Login now