##// END OF EJS Templates
Forgot to remove dead code functions declarations
jeandet -
r405:f3243196bdc5 3.2.0.24 R3++ draft
parent child
Show More
@@ -1,156 +1,158
1 1 #ifndef FSW_MISC_H_INCLUDED
2 2 #define FSW_MISC_H_INCLUDED
3 3
4 4 #include <rtems.h>
5 5 #include <stdio.h>
6 6 #include <grspw.h>
7 7 #include <grlib_regs.h>
8 8
9 9 #include "fsw_params.h"
10 10 #include "fsw_spacewire.h"
11 11 #include "lfr_cpu_usage_report.h"
12 12
13 13 #define WATCHDOG_LOOP_PRINTF 10
14 14 #define WATCHDOG_LOOP_DEBUG 3
15 15
16 16 #define NB_RTEMS_EVENTS 32
17 17 #define EVENT_12 12
18 18 #define EVENT_13 13
19 19 #define EVENT_14 14
20 20 #define DUMB_MESSAGE_1 "in DUMB *** timecode_irq_handler"
21 21 #define DUMB_MESSAGE_12 "WATCHDOG timer"
22 22 #define DUMB_MESSAGE_13 "TIMECODE timer"
23 23
24 24 enum lfr_reset_cause_t{
25 25 UNKNOWN_CAUSE,
26 26 POWER_ON,
27 27 TC_RESET,
28 28 WATCHDOG,
29 29 ERROR_RESET,
30 30 UNEXP_RESET
31 31 };
32 32
33 33 typedef struct{
34 34 unsigned char dpu_spw_parity;
35 35 unsigned char dpu_spw_disconnect;
36 36 unsigned char dpu_spw_escape;
37 37 unsigned char dpu_spw_credit;
38 38 unsigned char dpu_spw_write_sync;
39 39 unsigned char timecode_erroneous;
40 40 unsigned char timecode_missing;
41 41 unsigned char timecode_invalid;
42 42 unsigned char time_timecode_it;
43 43 unsigned char time_not_synchro;
44 44 unsigned char time_timecode_ctr;
45 45 unsigned char ahb_correctable;
46 46 } hk_lfr_le_t;
47 47
48 48 typedef struct{
49 49 unsigned char dpu_spw_early_eop;
50 50 unsigned char dpu_spw_invalid_addr;
51 51 unsigned char dpu_spw_eep;
52 52 unsigned char dpu_spw_rx_too_big;
53 53 } hk_lfr_me_t;
54 54
55 55 #define B00 196
56 56 #define B01 196
57 57 #define B02 0
58 58 #define B10 131
59 59 #define B11 -244
60 60 #define B12 131
61 61 #define B20 161
62 62 #define B21 -314
63 63 #define B22 161
64 64
65 65 #define A00 1
66 66 #define A01 -925
67 67 #define A02 0
68 68 #define A10 1
69 69 #define A11 -947
70 70 #define A12 439
71 71 #define A20 1
72 72 #define A21 -993
73 73 #define A22 486
74 74
75 75 #define GAIN_B0 12
76 76 #define GAIN_B1 11
77 77 #define GAIN_B2 10
78 78
79 79 #define GAIN_A0 10
80 80 #define GAIN_A1 9
81 81 #define GAIN_A2 9
82 82
83 83 #define NB_COEFFS 3
84 84 #define COEFF0 0
85 85 #define COEFF1 1
86 86 #define COEFF2 2
87 87
88 88 typedef struct filter_ctx
89 89 {
90 90 int W[NB_COEFFS][NB_COEFFS];
91 91 }filter_ctx;
92 92
93 93 extern gptimer_regs_t *gptimer_regs;
94 94 extern void ASR16_get_FPRF_IURF_ErrorCounters( unsigned int*, unsigned int* );
95 95 extern void CCR_getInstructionAndDataErrorCounters( unsigned int*, unsigned int* );
96 96
97 97 extern rtems_name name_hk_rate_monotonic; // name of the HK rate monotonic
98 98 extern rtems_id HK_id;// id of the HK rate monotonic period
99 99 extern rtems_name name_avgv_rate_monotonic; // name of the AVGV rate monotonic
100 100 extern rtems_id AVGV_id;// id of the AVGV rate monotonic period
101 101
102 102 void timer_configure( unsigned char timer, unsigned int clock_divider,
103 103 unsigned char interrupt_level, rtems_isr (*timer_isr)() );
104 void timer_start( unsigned char timer );
104 #ifdef ENABLE_DEAD_CODE
105 void timer_start( unsigned char timer );
106 #endif
105 107 void timer_stop( unsigned char timer );
106 108 void timer_set_clock_divider(unsigned char timer, unsigned int clock_divider);
107 109
108 110 // WATCHDOG
109 111 rtems_isr watchdog_isr( rtems_vector_number vector );
110 112 void watchdog_configure(void);
111 113 void watchdog_stop(void);
112 114 void watchdog_reload(void);
113 115 void watchdog_start(void);
114 116
115 117 // SERIAL LINK
116 118 int send_console_outputs_on_apbuart_port( void );
117 119 int enable_apbuart_transmitter( void );
118 120 void set_apbuart_scaler_reload_register(unsigned int regs, unsigned int value);
119 121
120 122 // RTEMS TASKS
121 123 rtems_task load_task( rtems_task_argument argument );
122 124 rtems_task hous_task( rtems_task_argument argument );
123 125 rtems_task avgv_task( rtems_task_argument argument );
124 126 rtems_task dumb_task( rtems_task_argument unused );
125 127 rtems_task scrubbing_task( rtems_task_argument unused );
126 128 rtems_task calibration_sweep_task( rtems_task_argument unused );
127 129
128 130 void init_housekeeping_parameters( void );
129 131 void increment_seq_counter(unsigned short *packetSequenceControl);
130 132 void getTime( unsigned char *time);
131 133 unsigned long long int getTimeAsUnsignedLongLongInt( );
132 134 void get_temperatures( unsigned char *temperatures );
133 135 void get_v_e1_e2_f3( unsigned char *spacecraft_potential );
134 136 void get_cpu_load( unsigned char *resource_statistics );
135 137 void set_hk_lfr_sc_potential_flag( bool state );
136 138 void set_sy_lfr_pas_filter_enabled( bool state );
137 139 void set_sy_lfr_watchdog_enabled( bool state );
138 140 void set_hk_lfr_calib_enable( bool state );
139 141 void set_hk_lfr_reset_cause( enum lfr_reset_cause_t lfr_reset_cause );
140 142 void hk_lfr_le_me_he_update();
141 143 void set_hk_lfr_time_not_synchro();
142 144
143 145 extern int sched_yield( void );
144 146 extern void rtems_cpu_usage_reset();
145 147 extern ring_node *current_ring_node_f3;
146 148 extern ring_node *ring_node_to_send_cwf_f3;
147 149 extern ring_node waveform_ring_f3[];
148 150 extern unsigned short sequenceCounterHK;
149 151
150 152 extern unsigned char hk_lfr_q_sd_fifo_size_max;
151 153 extern unsigned char hk_lfr_q_rv_fifo_size_max;
152 154 extern unsigned char hk_lfr_q_p0_fifo_size_max;
153 155 extern unsigned char hk_lfr_q_p1_fifo_size_max;
154 156 extern unsigned char hk_lfr_q_p2_fifo_size_max;
155 157
156 158 #endif // FSW_MISC_H_INCLUDED
@@ -1,112 +1,114
1 1 #ifndef TC_HANDLER_H_INCLUDED
2 2 #define TC_HANDLER_H_INCLUDED
3 3
4 4 #include <rtems.h>
5 5 #include <leon.h>
6 6
7 7 #include "tc_load_dump_parameters.h"
8 8 #include "tc_acceptance.h"
9 9 #include "tm_lfr_tc_exe.h"
10 10 #include "wf_handler.h"
11 11 #include "fsw_processing.h"
12 12
13 13 #include "lfr_cpu_usage_report.h"
14 14
15 15 #define MAX_DELTA_COARSE_TIME 3
16 16 #define NB_SCIENCE_TASKS 10
17 17 #define NB_ASM_TASKS 6
18 18 #define STATUS_0 0
19 19 #define STATUS_1 1
20 20 #define STATUS_2 2
21 21 #define STATUS_3 3
22 22 #define STATUS_4 4
23 23 #define STATUS_5 5
24 24 #define STATUS_6 6
25 25 #define STATUS_7 7
26 26 #define STATUS_8 8
27 27 #define STATUS_9 9
28 28
29 29 #define CAL_F0 625.
30 30 #define CAL_F1 10000.
31 31 #define CAL_W0 (2. * pi * CAL_F0)
32 32 #define CAL_W1 (2. * pi * CAL_F1)
33 33 #define CAL_A0 1.
34 34 #define CAL_A1 2.
35 35 #define CAL_FS 160256.410
36 36 #define CAL_SCALE_FACTOR (0.250 / 0.000654) // 191, 500 mVpp, 2 sinus waves => 500 mVpp each, amplitude = 250 mV
37 37 #define CAL_NB_PTS 256
38 38 #define CAL_DATA_MASK 0xfff
39 39 #define CAL_F_DIVISOR 38 // 25 MHz => 160 256 (39 - 1)
40 40 #define CAL_F_DIVISOR_MIN 38
41 41 #define CAL_F_DIVISOR_MAX (38*2*2*2*2)
42 42 // INTERLEAVED MODE
43 43 #define CAL_FS_INTER 240384.615
44 44 #define CAL_NB_PTS_INTER 384
45 45 #define CAL_DATA_MASK_INTER 0x3f
46 46 #define CAL_DATA_SHIFT_INTER 12
47 47 #define BYTES_FOR_2_SAMPLES 3 // one need 3 bytes = 24 bits to store 3 samples of 12 bits in interleaved mode
48 48 #define STEPS_FOR_STORAGE_INTER 128
49 49 #define CAL_F_DIVISOR_INTER 26 // 25 MHz => 240 384
50 50
51 51 extern unsigned int lastValidEnterModeTime;
52 52 extern unsigned char oneTcLfrUpdateTimeReceived;
53 53
54 54 //***********
55 55 // RTEMS TASK
56 56 rtems_task actn_task( rtems_task_argument unused );
57 57
58 58 //***********
59 59 // TC ACTIONS
60 60 int action_reset( ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time );
61 61 int action_enter_mode(ccsdsTelecommandPacket_t *TC, rtems_id queue_id);
62 62 int action_update_info( ccsdsTelecommandPacket_t *TC, rtems_id queue_id );
63 63 int action_enable_calibration( ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time );
64 64 int action_disable_calibration( ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time );
65 65 int action_update_time( ccsdsTelecommandPacket_t *TC);
66 66
67 67 // mode transition
68 68 int check_mode_value( unsigned char requestedMode );
69 69 int check_mode_transition( unsigned char requestedMode );
70 70 void update_last_valid_transition_date( unsigned int transitionCoarseTime );
71 71 int check_transition_date( unsigned int transitionCoarseTime );
72 72 int stop_spectral_matrices( void );
73 73 int stop_current_mode( void );
74 74 int enter_mode_standby(void );
75 75 int enter_mode_normal( unsigned int transitionCoarseTime );
76 76 int enter_mode_burst( unsigned int transitionCoarseTime );
77 77 int enter_mode_sbm1( unsigned int transitionCoarseTime );
78 78 int enter_mode_sbm2( unsigned int transitionCoarseTime );
79 79 int restart_science_tasks( unsigned char lfrRequestedMode );
80 80 int restart_asm_tasks(unsigned char lfrRequestedMode );
81 81 int suspend_science_tasks(void);
82 82 int suspend_asm_tasks( void );
83 83 void launch_waveform_picker( unsigned char mode , unsigned int transitionCoarseTime );
84 84 void launch_spectral_matrix( void );
85 85 void set_sm_irq_onNewMatrix( unsigned char value );
86 86 void set_sm_irq_onError( unsigned char value );
87 87
88 88 // other functions
89 89 void updateLFRCurrentMode(unsigned char requestedMode);
90 90 void set_lfr_soft_reset( unsigned char value );
91 91 void reset_lfr( void );
92 92 // CALIBRATION
93 93 void setCalibrationPrescaler( unsigned int prescaler );
94 94 void setCalibrationDivisor( unsigned int divisionFactor );
95 95 void setCalibrationData( void );
96 96 void setCalibrationReload( bool state);
97 97 void setCalibrationEnable( bool state );
98 void setCalibrationInterleaved( bool state );
98 #ifdef ENABLE_DEAD_CODE
99 void setCalibrationInterleaved( bool state );
100 #endif
99 101 void setCalibration( bool state );
100 102 void configureCalibration( bool interleaved );
101 103 //
102 104 void update_last_TC_exe( ccsdsTelecommandPacket_t *TC , unsigned char *time );
103 105 void update_last_TC_rej(ccsdsTelecommandPacket_t *TC , unsigned char *time );
104 106 void close_action( ccsdsTelecommandPacket_t *TC, int result, rtems_id queue_id );
105 107
106 108 extern rtems_status_code get_message_queue_id_send( rtems_id *queue_id );
107 109 extern rtems_status_code get_message_queue_id_recv( rtems_id *queue_id );
108 110
109 111 #endif // TC_HANDLER_H_INCLUDED
110 112
111 113
112 114
@@ -1,27 +1,29
1 1 #ifndef TM_LFR_TC_EXE_H_INCLUDED
2 2 #define TM_LFR_TC_EXE_H_INCLUDED
3 3
4 4 #include <rtems.h>
5 5 #include <stdio.h>
6 6 #include <ccsds_types.h>
7 7
8 8 #include "fsw_params.h"
9 9 #include "fsw_spacewire.h"
10 10
11 11 extern unsigned short sequenceCounters_TC_EXE[];
12 12
13 13 int send_tm_lfr_tc_exe_success( ccsdsTelecommandPacket_t *TC, rtems_id queue_id );
14 14 int send_tm_lfr_tc_exe_inconsistent( ccsdsTelecommandPacket_t *TC, rtems_id queue_id,
15 15 unsigned char byte_position, unsigned char rcv_value );
16 16 int send_tm_lfr_tc_exe_not_executable( ccsdsTelecommandPacket_t *TC, rtems_id queue_id );
17 int send_tm_lfr_tc_exe_not_implemented( ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time );
17 #ifdef ENABLE_DEAD_CODE
18 int send_tm_lfr_tc_exe_not_implemented( ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time );
19 #endif
18 20 int send_tm_lfr_tc_exe_error(ccsdsTelecommandPacket_t *TC, rtems_id queue_id );
19 21 int send_tm_lfr_tc_exe_corrupted( ccsdsTelecommandPacket_t *TC, rtems_id queue_id,
20 22 unsigned char *computed_CRC, unsigned char *currentTC_LEN_RCV, unsigned char destinationID );
21 23
22 24 void increment_seq_counter_destination_id( unsigned char *packet_sequence_control, unsigned char destination_id );
23 25
24 26 #endif // TM_LFR_TC_EXE_H_INCLUDED
25 27
26 28
27 29
@@ -1,136 +1,136
1 1 cmake_minimum_required (VERSION 3.5)
2 2 project (fsw)
3 3
4 4 include(sparc-rtems)
5 5 include(cppcheck)
6 6
7 7 include_directories("../header"
8 8 "../header/lfr_common_headers"
9 9 "../header/processing"
10 10 "../LFR_basic-parameters"
11 11 "../src")
12 12
13 13 set(SOURCES wf_handler.c
14 14 tc_handler.c
15 15 fsw_misc.c
16 16 fsw_init.c
17 17 fsw_globals.c
18 18 fsw_spacewire.c
19 19 tc_load_dump_parameters.c
20 20 tm_lfr_tc_exe.c
21 21 tc_acceptance.c
22 22 processing/fsw_processing.c
23 23 processing/avf0_prc0.c
24 24 processing/avf1_prc1.c
25 25 processing/avf2_prc2.c
26 26 lfr_cpu_usage_report.c
27 27 ${LFR_BP_SRC}
28 28 ../header/wf_handler.h
29 29 ../header/tc_handler.h
30 30 ../header/grlib_regs.h
31 31 ../header/fsw_misc.h
32 32 ../header/fsw_init.h
33 33 ../header/fsw_spacewire.h
34 34 ../header/tc_load_dump_parameters.h
35 35 ../header/tm_lfr_tc_exe.h
36 36 ../header/tc_acceptance.h
37 37 ../header/processing/fsw_processing.h
38 38 ../header/processing/avf0_prc0.h
39 39 ../header/processing/avf1_prc1.h
40 40 ../header/processing/avf2_prc2.h
41 41 ../header/fsw_params_wf_handler.h
42 42 ../header/lfr_cpu_usage_report.h
43 43 ../header/lfr_common_headers/ccsds_types.h
44 44 ../header/lfr_common_headers/fsw_params.h
45 45 ../header/lfr_common_headers/fsw_params_nb_bytes.h
46 46 ../header/lfr_common_headers/fsw_params_processing.h
47 47 ../header/lfr_common_headers/tm_byte_positions.h
48 48 ../LFR_basic-parameters/basic_parameters.h
49 49 ../LFR_basic-parameters/basic_parameters_params.h
50 50 ../header/GscMemoryLPP.hpp
51 51 )
52 52
53 53
54 54 option(FSW_verbose "Enable verbose LFR" OFF)
55 55 option(FSW_boot_messages "Enable LFR boot messages" OFF)
56 56 option(FSW_debug_messages "Enable LFR debug messages" OFF)
57 57 option(FSW_cpu_usage_report "Enable LFR cpu usage report" OFF)
58 58 option(FSW_stack_report "Enable LFR stack report" OFF)
59 59 option(FSW_vhdl_dev "?" OFF)
60 60 option(FSW_lpp_dpu_destid "Set to debug at LPP" OFF)
61 61 option(FSW_debug_watchdog "Enable debug watchdog" OFF)
62 62 option(FSW_debug_tch "?" OFF)
63 63 option(FSW_Instrument_Scrubbing "Enable scrubbing counter" OFF)
64 64 option(FSW_Enable_Dead_Code "Enable dead code compilation, this is used to hide by default unused code." OFF)
65 65
66 66 set(SW_VERSION_N1 "3" CACHE STRING "Choose N1 FSW Version." FORCE)
67 67 set(SW_VERSION_N2 "2" CACHE STRING "Choose N2 FSW Version." FORCE)
68 68 set(SW_VERSION_N3 "0" CACHE STRING "Choose N3 FSW Version." FORCE)
69 set(SW_VERSION_N4 "23" CACHE STRING "Choose N4 FSW Version." FORCE)
69 set(SW_VERSION_N4 "24" CACHE STRING "Choose N4 FSW Version." FORCE)
70 70
71 71 if(FSW_verbose)
72 72 add_definitions(-DPRINT_MESSAGES_ON_CONSOLE)
73 73 endif()
74 74 if(FSW_boot_messages)
75 75 add_definitions(-DBOOT_MESSAGES)
76 76 endif()
77 77 if(FSW_debug_messages)
78 78 add_definitions(-DDEBUG_MESSAGES)
79 79 endif()
80 80 if(FSW_cpu_usage_report)
81 81 add_definitions(-DPRINT_TASK_STATISTICS)
82 82 endif()
83 83 if(FSW_stack_report)
84 84 add_definitions(-DPRINT_STACK_REPORT)
85 85 endif()
86 86 if(FSW_vhdl_dev)
87 87 add_definitions(-DVHDL_DEV)
88 88 endif()
89 89 if(FSW_lpp_dpu_destid)
90 90 add_definitions(-DLPP_DPU_DESTID)
91 91 endif()
92 92 if(FSW_debug_watchdog)
93 93 add_definitions(-DDEBUG_WATCHDOG)
94 94 endif()
95 95 if(FSW_debug_tch)
96 96 add_definitions(-DDEBUG_TCH)
97 97 endif()
98 98
99 99 if(FSW_Enable_Dead_Code)
100 100 add_definitions(-DENABLE_DEAD_CODE)
101 101 endif()
102 102
103 103
104 104
105 105
106 106 add_definitions(-DMSB_FIRST_TCH)
107 107
108 108 add_definitions(-DSWVERSION=-1-0)
109 109 add_definitions(-DSW_VERSION_N1=${SW_VERSION_N1})
110 110 add_definitions(-DSW_VERSION_N2=${SW_VERSION_N2})
111 111 add_definitions(-DSW_VERSION_N3=${SW_VERSION_N3})
112 112 add_definitions(-DSW_VERSION_N4=${SW_VERSION_N4})
113 113
114 114 add_executable(fsw ${SOURCES})
115 115
116 116 if(FSW_Instrument_Scrubbing)
117 117 add_definitions(-DENABLE_SCRUBBING_COUNTER)
118 118 endif()
119 119
120 120 if(Coverage)
121 121 target_link_libraries(fsw gcov)
122 122 SET_TARGET_PROPERTIES(fsw PROPERTIES COMPILE_FLAGS "-fprofile-arcs -ftest-coverage")
123 123 endif()
124 124
125 125
126 126 if(fix-b2bst)
127 127 check_b2bst(fsw ${CMAKE_CURRENT_BINARY_DIR})
128 128 endif()
129 129
130 130 if(NOT FSW_lpp_dpu_destid)
131 131 build_srec(fsw ${CMAKE_CURRENT_BINARY_DIR} "${SW_VERSION_N1}-${SW_VERSION_N2}-${SW_VERSION_N3}-${SW_VERSION_N4}")
132 132 endif()
133 133
134 134
135 135 #add_test_cppcheck(fsw STYLE UNUSED_FUNCTIONS POSSIBLE_ERROR MISSING_INCLUDE)
136 136
@@ -1,1692 +1,1694
1 1 /*------------------------------------------------------------------------------
2 2 -- Solar Orbiter's Low Frequency Receiver Flight Software (LFR FSW),
3 3 -- This file is a part of the LFR FSW
4 4 -- Copyright (C) 2012-2018, Plasma Physics Laboratory - CNRS
5 5 --
6 6 -- This program is free software; you can redistribute it and/or modify
7 7 -- it under the terms of the GNU General Public License as published by
8 8 -- the Free Software Foundation; either version 2 of the License, or
9 9 -- (at your option) any later version.
10 10 --
11 11 -- This program is distributed in the hope that it will be useful,
12 12 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
13 13 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 14 -- GNU General Public License for more details.
15 15 --
16 16 -- You should have received a copy of the GNU General Public License
17 17 -- along with this program; if not, write to the Free Software
18 18 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 19 -------------------------------------------------------------------------------*/
20 20 /*-- Author : Paul Leroy
21 21 -- Contact : Alexis Jeandet
22 22 -- Mail : alexis.jeandet@lpp.polytechnique.fr
23 23 ----------------------------------------------------------------------------*/
24 24 /** Functions and tasks related to TeleCommand handling.
25 25 *
26 26 * @file
27 27 * @author P. LEROY
28 28 *
29 29 * A group of functions to handle TeleCommands:\n
30 30 * action launching\n
31 31 * TC parsing\n
32 32 * ...
33 33 *
34 34 */
35 35
36 36 #include "tc_handler.h"
37 37 #include "math.h"
38 38
39 39 //***********
40 40 // RTEMS TASK
41 41
42 42 rtems_task actn_task( rtems_task_argument unused )
43 43 {
44 44 /** This RTEMS task is responsible for launching actions upton the reception of valid TeleCommands.
45 45 *
46 46 * @param unused is the starting argument of the RTEMS task
47 47 *
48 48 * The ACTN task waits for data coming from an RTEMS msesage queue. When data arrives, it launches specific actions depending
49 49 * on the incoming TeleCommand.
50 50 *
51 51 */
52 52
53 53 int result;
54 54 rtems_status_code status; // RTEMS status code
55 55 ccsdsTelecommandPacket_t __attribute__((aligned(4))) TC; // TC sent to the ACTN task
56 56 size_t size; // size of the incoming TC packet
57 57 unsigned char subtype; // subtype of the current TC packet
58 58 unsigned char time[BYTES_PER_TIME];
59 59 rtems_id queue_rcv_id;
60 60 rtems_id queue_snd_id;
61 61
62 62 memset(&TC, 0, sizeof(ccsdsTelecommandPacket_t));
63 63 size = 0;
64 64 queue_rcv_id = RTEMS_ID_NONE;
65 65 queue_snd_id = RTEMS_ID_NONE;
66 66
67 67 status = get_message_queue_id_recv( &queue_rcv_id );
68 68 if (status != RTEMS_SUCCESSFUL)
69 69 {
70 70 PRINTF1("in ACTN *** ERR get_message_queue_id_recv %d\n", status)
71 71 }
72 72
73 73 status = get_message_queue_id_send( &queue_snd_id );
74 74 if (status != RTEMS_SUCCESSFUL)
75 75 {
76 76 PRINTF1("in ACTN *** ERR get_message_queue_id_send %d\n", status)
77 77 }
78 78
79 79 result = LFR_SUCCESSFUL;
80 80 subtype = 0; // subtype of the current TC packet
81 81
82 82 BOOT_PRINTF("in ACTN *** \n");
83 83
84 84 while(1)
85 85 {
86 86 status = rtems_message_queue_receive( queue_rcv_id, (char*) &TC, &size,
87 87 RTEMS_WAIT, RTEMS_NO_TIMEOUT);
88 88 getTime( time ); // set time to the current time
89 89 if (status!=RTEMS_SUCCESSFUL)
90 90 {
91 91 PRINTF1("ERR *** in task ACTN *** error receiving a message, code %d \n", status)
92 92 }
93 93 else
94 94 {
95 95 subtype = TC.serviceSubType;
96 96 switch(subtype)
97 97 {
98 98 case TC_SUBTYPE_RESET:
99 99 result = action_reset( &TC, queue_snd_id, time );
100 100 close_action( &TC, result, queue_snd_id );
101 101 break;
102 102 case TC_SUBTYPE_LOAD_COMM:
103 103 result = action_load_common_par( &TC );
104 104 close_action( &TC, result, queue_snd_id );
105 105 break;
106 106 case TC_SUBTYPE_LOAD_NORM:
107 107 result = action_load_normal_par( &TC, queue_snd_id, time );
108 108 close_action( &TC, result, queue_snd_id );
109 109 break;
110 110 case TC_SUBTYPE_LOAD_BURST:
111 111 result = action_load_burst_par( &TC, queue_snd_id, time );
112 112 close_action( &TC, result, queue_snd_id );
113 113 break;
114 114 case TC_SUBTYPE_LOAD_SBM1:
115 115 result = action_load_sbm1_par( &TC, queue_snd_id, time );
116 116 close_action( &TC, result, queue_snd_id );
117 117 break;
118 118 case TC_SUBTYPE_LOAD_SBM2:
119 119 result = action_load_sbm2_par( &TC, queue_snd_id, time );
120 120 close_action( &TC, result, queue_snd_id );
121 121 break;
122 122 case TC_SUBTYPE_DUMP:
123 123 result = action_dump_par( &TC, queue_snd_id );
124 124 close_action( &TC, result, queue_snd_id );
125 125 break;
126 126 case TC_SUBTYPE_ENTER:
127 127 result = action_enter_mode( &TC, queue_snd_id );
128 128 close_action( &TC, result, queue_snd_id );
129 129 break;
130 130 case TC_SUBTYPE_UPDT_INFO:
131 131 result = action_update_info( &TC, queue_snd_id );
132 132 close_action( &TC, result, queue_snd_id );
133 133 break;
134 134 case TC_SUBTYPE_EN_CAL:
135 135 result = action_enable_calibration( &TC, queue_snd_id, time );
136 136 close_action( &TC, result, queue_snd_id );
137 137 break;
138 138 case TC_SUBTYPE_DIS_CAL:
139 139 result = action_disable_calibration( &TC, queue_snd_id, time );
140 140 close_action( &TC, result, queue_snd_id );
141 141 break;
142 142 case TC_SUBTYPE_LOAD_K:
143 143 result = action_load_kcoefficients( &TC, queue_snd_id, time );
144 144 close_action( &TC, result, queue_snd_id );
145 145 break;
146 146 case TC_SUBTYPE_DUMP_K:
147 147 result = action_dump_kcoefficients( &TC, queue_snd_id, time );
148 148 close_action( &TC, result, queue_snd_id );
149 149 break;
150 150 case TC_SUBTYPE_LOAD_FBINS:
151 151 result = action_load_fbins_mask( &TC, queue_snd_id, time );
152 152 close_action( &TC, result, queue_snd_id );
153 153 break;
154 154 case TC_SUBTYPE_LOAD_FILTER_PAR:
155 155 result = action_load_filter_par( &TC, queue_snd_id, time );
156 156 close_action( &TC, result, queue_snd_id );
157 157 break;
158 158 case TC_SUBTYPE_UPDT_TIME:
159 159 result = action_update_time( &TC );
160 160 close_action( &TC, result, queue_snd_id );
161 161 break;
162 162 default:
163 163 break;
164 164 }
165 165 }
166 166 }
167 167 }
168 168
169 169 //***********
170 170 // TC ACTIONS
171 171
172 172 int action_reset(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
173 173 {
174 174 /** This function executes specific actions when a TC_LFR_RESET TeleCommand has been received.
175 175 *
176 176 * @param TC points to the TeleCommand packet that is being processed
177 177 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
178 178 *
179 179 */
180 180
181 181 PRINTF("this is the end!!!\n");
182 182 #ifdef GCOV_ENABLED
183 183 #ifndef GCOV_USE_EXIT
184 184 extern void gcov_exit (void);
185 185 gcov_exit();
186 186 #endif
187 187 #endif
188 188 exit(0);
189 189
190 #ifdef ENABLE_DEAD_CODE
190 191 send_tm_lfr_tc_exe_not_implemented( TC, queue_id, time );
192 #endif
191 193
192 194 return LFR_DEFAULT;
193 195 }
194 196
195 197 int action_enter_mode(ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
196 198 {
197 199 /** This function executes specific actions when a TC_LFR_ENTER_MODE TeleCommand has been received.
198 200 *
199 201 * @param TC points to the TeleCommand packet that is being processed
200 202 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
201 203 *
202 204 */
203 205
204 206 rtems_status_code status;
205 207 unsigned char requestedMode;
206 208 unsigned int transitionCoarseTime;
207 209 unsigned char * bytePosPtr;
208 210
209 211 bytePosPtr = (unsigned char *) &TC->packetID;
210 212 requestedMode = bytePosPtr[ BYTE_POS_CP_MODE_LFR_SET ];
211 213 copyInt32ByChar( (char*) &transitionCoarseTime, &bytePosPtr[ BYTE_POS_CP_LFR_ENTER_MODE_TIME ] );
212 214 transitionCoarseTime = transitionCoarseTime & COARSE_TIME_MASK;
213 215 status = check_mode_value( requestedMode );
214 216
215 217 if ( status != LFR_SUCCESSFUL ) // the mode value is inconsistent
216 218 {
217 219 send_tm_lfr_tc_exe_inconsistent( TC, queue_id, BYTE_POS_CP_MODE_LFR_SET, requestedMode );
218 220 }
219 221
220 222 else // the mode value is valid, check the transition
221 223 {
222 224 status = check_mode_transition(requestedMode);
223 225 if (status != LFR_SUCCESSFUL)
224 226 {
225 227 PRINTF("ERR *** in action_enter_mode *** check_mode_transition\n")
226 228 send_tm_lfr_tc_exe_not_executable( TC, queue_id );
227 229 }
228 230 }
229 231
230 232 if ( status == LFR_SUCCESSFUL ) // the transition is valid, check the date
231 233 {
232 234 status = check_transition_date( transitionCoarseTime );
233 235 if (status != LFR_SUCCESSFUL)
234 236 {
235 237 PRINTF("ERR *** in action_enter_mode *** check_transition_date\n");
236 238 send_tm_lfr_tc_exe_not_executable(TC, queue_id );
237 239 }
238 240 }
239 241
240 242 if ( status == LFR_SUCCESSFUL ) // the date is valid, enter the mode
241 243 {
242 244 PRINTF1("OK *** in action_enter_mode *** enter mode %d\n", requestedMode);
243 245
244 246 switch(requestedMode)
245 247 {
246 248 case LFR_MODE_STANDBY:
247 249 status = enter_mode_standby();
248 250 break;
249 251 case LFR_MODE_NORMAL:
250 252 status = enter_mode_normal( transitionCoarseTime );
251 253 break;
252 254 case LFR_MODE_BURST:
253 255 status = enter_mode_burst( transitionCoarseTime );
254 256 break;
255 257 case LFR_MODE_SBM1:
256 258 status = enter_mode_sbm1( transitionCoarseTime );
257 259 break;
258 260 case LFR_MODE_SBM2:
259 261 status = enter_mode_sbm2( transitionCoarseTime );
260 262 break;
261 263 default:
262 264 break;
263 265 }
264 266
265 267 if (status != RTEMS_SUCCESSFUL)
266 268 {
267 269 status = LFR_EXE_ERROR;
268 270 }
269 271 }
270 272
271 273 return status;
272 274 }
273 275
274 276 int action_update_info(ccsdsTelecommandPacket_t *TC, rtems_id queue_id)
275 277 {
276 278 /** This function executes specific actions when a TC_LFR_UPDATE_INFO TeleCommand has been received.
277 279 *
278 280 * @param TC points to the TeleCommand packet that is being processed
279 281 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
280 282 *
281 283 * @return LFR directive status code:
282 284 * - LFR_DEFAULT
283 285 * - LFR_SUCCESSFUL
284 286 *
285 287 */
286 288
287 289 unsigned int val;
288 290 unsigned int status;
289 291 unsigned char mode;
290 292 unsigned char * bytePosPtr;
291 293 int pos;
292 294 float value;
293 295
294 296 pos = INIT_CHAR;
295 297 value = INIT_FLOAT;
296 298
297 299 status = LFR_DEFAULT;
298 300
299 301 bytePosPtr = (unsigned char *) &TC->packetID;
300 302
301 303 // check LFR mode
302 304 mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET5 ] & BITS_LFR_MODE) >> SHIFT_LFR_MODE;
303 305 status = check_update_info_hk_lfr_mode( mode );
304 306 if (status == LFR_SUCCESSFUL) // check TDS mode
305 307 {
306 308 mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET6 ] & BITS_TDS_MODE) >> SHIFT_TDS_MODE;
307 309 status = check_update_info_hk_tds_mode( mode );
308 310 }
309 311 if (status == LFR_SUCCESSFUL) // check THR mode
310 312 {
311 313 mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET6 ] & BITS_THR_MODE);
312 314 status = check_update_info_hk_thr_mode( mode );
313 315 }
314 316 if (status == LFR_SUCCESSFUL) // check reaction wheels frequencies
315 317 {
316 318 status = check_all_sy_lfr_rw_f(TC, &pos, &value);
317 319 }
318 320
319 321 // if the parameters checking succeeds, udpate all parameters
320 322 if (status == LFR_SUCCESSFUL)
321 323 {
322 324 // pa_bia_status_info
323 325 // => pa_bia_mode_mux_set 3 bits
324 326 // => pa_bia_mode_hv_enabled 1 bit
325 327 // => pa_bia_mode_bias1_enabled 1 bit
326 328 // => pa_bia_mode_bias2_enabled 1 bit
327 329 // => pa_bia_mode_bias3_enabled 1 bit
328 330 // => pa_bia_on_off (cp_dpu_bias_on_off)
329 331 pa_bia_status_info = bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET2 ] & BITS_BIA; // [1111 1110]
330 332 pa_bia_status_info = pa_bia_status_info
331 333 | (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET1 ] & 1);
332 334
333 335 // REACTION_WHEELS_FREQUENCY, copy the incoming parameters in the local variable (to be copied in HK packets)
334 336 getReactionWheelsFrequencies( TC );
335 337 set_hk_lfr_sc_rw_f_flags();
336 338 build_sy_lfr_rw_masks();
337 339
338 340 // once the masks are built, they have to be merged with the fbins_mask
339 341 merge_fbins_masks();
340 342
341 343 // increase the TC_LFR_UPDATE_INFO counter
342 344 if (status == LFR_SUCCESSFUL) // if the parameter check is successful
343 345 {
344 346 val = (housekeeping_packet.hk_lfr_update_info_tc_cnt[0] * CONST_256)
345 347 + housekeeping_packet.hk_lfr_update_info_tc_cnt[1];
346 348 val++;
347 349 housekeeping_packet.hk_lfr_update_info_tc_cnt[0] = (unsigned char) (val >> SHIFT_1_BYTE);
348 350 housekeeping_packet.hk_lfr_update_info_tc_cnt[1] = (unsigned char) (val);
349 351 }
350 352 }
351 353
352 354 return status;
353 355 }
354 356
355 357 int action_enable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
356 358 {
357 359 /** This function executes specific actions when a TC_LFR_ENABLE_CALIBRATION TeleCommand has been received.
358 360 *
359 361 * @param TC points to the TeleCommand packet that is being processed
360 362 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
361 363 *
362 364 */
363 365
364 366 int result;
365 367
366 368 result = LFR_DEFAULT;
367 369
368 370 setCalibration( true );
369 371
370 372 result = LFR_SUCCESSFUL;
371 373
372 374 return result;
373 375 }
374 376
375 377 int action_disable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
376 378 {
377 379 /** This function executes specific actions when a TC_LFR_DISABLE_CALIBRATION TeleCommand has been received.
378 380 *
379 381 * @param TC points to the TeleCommand packet that is being processed
380 382 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
381 383 *
382 384 */
383 385
384 386 int result;
385 387
386 388 result = LFR_DEFAULT;
387 389
388 390 setCalibration( false );
389 391
390 392 result = LFR_SUCCESSFUL;
391 393
392 394 return result;
393 395 }
394 396
395 397 int action_update_time(ccsdsTelecommandPacket_t *TC)
396 398 {
397 399 /** This function executes specific actions when a TC_LFR_UPDATE_TIME TeleCommand has been received.
398 400 *
399 401 * @param TC points to the TeleCommand packet that is being processed
400 402 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
401 403 *
402 404 * @return LFR_SUCCESSFUL
403 405 *
404 406 */
405 407
406 408 unsigned int val;
407 409
408 410 time_management_regs->coarse_time_load = (TC->dataAndCRC[BYTE_0] << SHIFT_3_BYTES)
409 411 + (TC->dataAndCRC[BYTE_1] << SHIFT_2_BYTES)
410 412 + (TC->dataAndCRC[BYTE_2] << SHIFT_1_BYTE)
411 413 + TC->dataAndCRC[BYTE_3];
412 414
413 415 val = (housekeeping_packet.hk_lfr_update_time_tc_cnt[0] * CONST_256)
414 416 + housekeeping_packet.hk_lfr_update_time_tc_cnt[1];
415 417 val++;
416 418 housekeeping_packet.hk_lfr_update_time_tc_cnt[0] = (unsigned char) (val >> SHIFT_1_BYTE);
417 419 housekeeping_packet.hk_lfr_update_time_tc_cnt[1] = (unsigned char) (val);
418 420
419 421 oneTcLfrUpdateTimeReceived = 1;
420 422
421 423 return LFR_SUCCESSFUL;
422 424 }
423 425
424 426 //*******************
425 427 // ENTERING THE MODES
426 428 int check_mode_value( unsigned char requestedMode )
427 429 {
428 430 int status;
429 431
430 432 status = LFR_DEFAULT;
431 433
432 434 if ( (requestedMode != LFR_MODE_STANDBY)
433 435 && (requestedMode != LFR_MODE_NORMAL) && (requestedMode != LFR_MODE_BURST)
434 436 && (requestedMode != LFR_MODE_SBM1) && (requestedMode != LFR_MODE_SBM2) )
435 437 {
436 438 status = LFR_DEFAULT;
437 439 }
438 440 else
439 441 {
440 442 status = LFR_SUCCESSFUL;
441 443 }
442 444
443 445 return status;
444 446 }
445 447
446 448 int check_mode_transition( unsigned char requestedMode )
447 449 {
448 450 /** This function checks the validity of the transition requested by the TC_LFR_ENTER_MODE.
449 451 *
450 452 * @param requestedMode is the mode requested by the TC_LFR_ENTER_MODE
451 453 *
452 454 * @return LFR directive status codes:
453 455 * - LFR_SUCCESSFUL - the transition is authorized
454 456 * - LFR_DEFAULT - the transition is not authorized
455 457 *
456 458 */
457 459
458 460 int status;
459 461
460 462 switch (requestedMode)
461 463 {
462 464 case LFR_MODE_STANDBY:
463 465 if ( lfrCurrentMode == LFR_MODE_STANDBY ) {
464 466 status = LFR_DEFAULT;
465 467 }
466 468 else
467 469 {
468 470 status = LFR_SUCCESSFUL;
469 471 }
470 472 break;
471 473 case LFR_MODE_NORMAL:
472 474 if ( lfrCurrentMode == LFR_MODE_NORMAL ) {
473 475 status = LFR_DEFAULT;
474 476 }
475 477 else {
476 478 status = LFR_SUCCESSFUL;
477 479 }
478 480 break;
479 481 case LFR_MODE_BURST:
480 482 if ( lfrCurrentMode == LFR_MODE_BURST ) {
481 483 status = LFR_DEFAULT;
482 484 }
483 485