##// 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 #ifdef ENABLE_DEAD_CODE
104 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 #ifdef ENABLE_DEAD_CODE
98 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 #ifdef ENABLE_DEAD_CODE
17 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 else {
484 486 status = LFR_SUCCESSFUL;
485 487 }
486 488 break;
487 489 case LFR_MODE_SBM1:
488 490 if ( lfrCurrentMode == LFR_MODE_SBM1 ) {
489 491 status = LFR_DEFAULT;
490 492 }
491 493 else {
492 494 status = LFR_SUCCESSFUL;
493 495 }
494 496 break;
495 497 case LFR_MODE_SBM2:
496 498 if ( lfrCurrentMode == LFR_MODE_SBM2 ) {
497 499 status = LFR_DEFAULT;
498 500 }
499 501 else {
500 502 status = LFR_SUCCESSFUL;
501 503 }
502 504 break;
503 505 default:
504 506 status = LFR_DEFAULT;
505 507 break;
506 508 }
507 509
508 510 return status;
509 511 }
510 512
511 513 void update_last_valid_transition_date( unsigned int transitionCoarseTime )
512 514 {
513 515 if (transitionCoarseTime == 0)
514 516 {
515 517 lastValidEnterModeTime = time_management_regs->coarse_time + 1;
516 518 PRINTF1("lastValidEnterModeTime = 0x%x (transitionCoarseTime = 0 => coarse_time+1)\n", lastValidEnterModeTime);
517 519 }
518 520 else
519 521 {
520 522 lastValidEnterModeTime = transitionCoarseTime;
521 523 PRINTF1("lastValidEnterModeTime = 0x%x\n", transitionCoarseTime);
522 524 }
523 525 }
524 526
525 527 int check_transition_date( unsigned int transitionCoarseTime )
526 528 {
527 529 int status;
528 530 unsigned int localCoarseTime;
529 531 unsigned int deltaCoarseTime;
530 532
531 533 status = LFR_SUCCESSFUL;
532 534
533 535 if (transitionCoarseTime == 0) // transition time = 0 means an instant transition
534 536 {
535 537 status = LFR_SUCCESSFUL;
536 538 }
537 539 else
538 540 {
539 541 localCoarseTime = time_management_regs->coarse_time & COARSE_TIME_MASK;
540 542
541 543 PRINTF2("localTime = %x, transitionTime = %x\n", localCoarseTime, transitionCoarseTime);
542 544
543 545 if ( transitionCoarseTime <= localCoarseTime ) // SSS-CP-EQS-322
544 546 {
545 547 status = LFR_DEFAULT;
546 548 PRINTF("ERR *** in check_transition_date *** transitionCoarseTime <= localCoarseTime\n");
547 549 }
548 550
549 551 if (status == LFR_SUCCESSFUL)
550 552 {
551 553 deltaCoarseTime = transitionCoarseTime - localCoarseTime;
552 554 if ( deltaCoarseTime > MAX_DELTA_COARSE_TIME ) // SSS-CP-EQS-323
553 555 {
554 556 status = LFR_DEFAULT;
555 557 PRINTF1("ERR *** in check_transition_date *** deltaCoarseTime = %x\n", deltaCoarseTime)
556 558 }
557 559 }
558 560 }
559 561
560 562 return status;
561 563 }
562 564
563 565 int restart_asm_activities( unsigned char lfrRequestedMode )
564 566 {
565 567 rtems_status_code status;
566 568
567 569 status = stop_spectral_matrices();
568 570
569 571 thisIsAnASMRestart = 1;
570 572
571 573 status = restart_asm_tasks( lfrRequestedMode );
572 574
573 575 launch_spectral_matrix();
574 576
575 577 return status;
576 578 }
577 579
578 580 int stop_spectral_matrices( void )
579 581 {
580 582 /** This function stops and restarts the current mode average spectral matrices activities.
581 583 *
582 584 * @return RTEMS directive status codes:
583 585 * - RTEMS_SUCCESSFUL - task restarted successfully
584 586 * - RTEMS_INVALID_ID - task id invalid
585 587 * - RTEMS_ALREADY_SUSPENDED - task already suspended
586 588 *
587 589 */
588 590
589 591 rtems_status_code status;
590 592
591 593 status = RTEMS_SUCCESSFUL;
592 594
593 595 // (1) mask interruptions
594 596 LEON_Mask_interrupt( IRQ_SPECTRAL_MATRIX ); // mask spectral matrix interrupt
595 597
596 598 // (2) reset spectral matrices registers
597 599 set_sm_irq_onNewMatrix( 0 ); // stop the spectral matrices
598 600 reset_sm_status();
599 601
600 602 // (3) clear interruptions
601 603 LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt
602 604
603 605 // suspend several tasks
604 606 if (lfrCurrentMode != LFR_MODE_STANDBY) {
605 607 status = suspend_asm_tasks();
606 608 }
607 609
608 610 if (status != RTEMS_SUCCESSFUL)
609 611 {
610 612 PRINTF1("in stop_current_mode *** in suspend_science_tasks *** ERR code: %d\n", status)
611 613 }
612 614
613 615 return status;
614 616 }
615 617
616 618 int stop_current_mode( void )
617 619 {
618 620 /** This function stops the current mode by masking interrupt lines and suspending science tasks.
619 621 *
620 622 * @return RTEMS directive status codes:
621 623 * - RTEMS_SUCCESSFUL - task restarted successfully
622 624 * - RTEMS_INVALID_ID - task id invalid
623 625 * - RTEMS_ALREADY_SUSPENDED - task already suspended
624 626 *
625 627 */
626 628
627 629 rtems_status_code status;
628 630
629 631 status = RTEMS_SUCCESSFUL;
630 632
631 633 // (1) mask interruptions
632 634 LEON_Mask_interrupt( IRQ_WAVEFORM_PICKER ); // mask waveform picker interrupt
633 635 LEON_Mask_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt
634 636
635 637 // (2) reset waveform picker registers
636 638 reset_wfp_burst_enable(); // reset burst and enable bits
637 639 reset_wfp_status(); // reset all the status bits
638 640
639 641 // (3) reset spectral matrices registers
640 642 set_sm_irq_onNewMatrix( 0 ); // stop the spectral matrices
641 643 reset_sm_status();
642 644
643 645 // reset lfr VHDL module
644 646 reset_lfr();
645 647
646 648 reset_extractSWF(); // reset the extractSWF flag to false
647 649
648 650 // (4) clear interruptions
649 651 LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER ); // clear waveform picker interrupt
650 652 LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt
651 653
652 654 // suspend several tasks
653 655 if (lfrCurrentMode != LFR_MODE_STANDBY) {
654 656 status = suspend_science_tasks();
655 657 }
656 658
657 659 if (status != RTEMS_SUCCESSFUL)
658 660 {
659 661 PRINTF1("in stop_current_mode *** in suspend_science_tasks *** ERR code: %d\n", status)
660 662 }
661 663
662 664 return status;
663 665 }
664 666
665 667 int enter_mode_standby( void )
666 668 {
667 669 /** This function is used to put LFR in the STANDBY mode.
668 670 *
669 671 * @param transitionCoarseTime is the requested transition time contained in the TC_LFR_ENTER_MODE
670 672 *
671 673 * @return RTEMS directive status codes:
672 674 * - RTEMS_SUCCESSFUL - task restarted successfully
673 675 * - RTEMS_INVALID_ID - task id invalid
674 676 * - RTEMS_INCORRECT_STATE - task never started
675 677 * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task
676 678 *
677 679 * The STANDBY mode does not depends on a specific transition date, the effect of the TC_LFR_ENTER_MODE
678 680 * is immediate.
679 681 *
680 682 */
681 683
682 684 int status;
683 685
684 686 status = stop_current_mode(); // STOP THE CURRENT MODE
685 687
686 688 #ifdef PRINT_TASK_STATISTICS
687 689 rtems_cpu_usage_report();
688 690 #endif
689 691
690 692 #ifdef PRINT_STACK_REPORT
691 693 PRINTF("stack report selected\n")
692 694 rtems_stack_checker_report_usage();
693 695 #endif
694 696
695 697 return status;
696 698 }
697 699
698 700 int enter_mode_normal( unsigned int transitionCoarseTime )
699 701 {
700 702 /** This function is used to start the NORMAL mode.
701 703 *
702 704 * @param transitionCoarseTime is the requested transition time contained in the TC_LFR_ENTER_MODE
703 705 *
704 706 * @return RTEMS directive status codes:
705 707 * - RTEMS_SUCCESSFUL - task restarted successfully
706 708 * - RTEMS_INVALID_ID - task id invalid
707 709 * - RTEMS_INCORRECT_STATE - task never started
708 710 * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task
709 711 *
710 712 * The way the NORMAL mode is started depends on the LFR current mode. If LFR is in SBM1 or SBM2,
711 713 * the snapshots are not restarted, only ASM, BP and CWF data generation are affected.
712 714 *
713 715 */
714 716
715 717 int status;
716 718
717 719 #ifdef PRINT_TASK_STATISTICS
718 720 rtems_cpu_usage_reset();
719 721 #endif
720 722
721 723 status = RTEMS_UNSATISFIED;
722 724
723 725 switch( lfrCurrentMode )
724 726 {
725 727 case LFR_MODE_STANDBY:
726 728 status = restart_science_tasks( LFR_MODE_NORMAL ); // restart science tasks
727 729 if (status == RTEMS_SUCCESSFUL) // relaunch spectral_matrix and waveform_picker modules
728 730 {
729 731 launch_spectral_matrix( );
730 732 launch_waveform_picker( LFR_MODE_NORMAL, transitionCoarseTime );
731 733 }
732 734 break;
733 735 case LFR_MODE_BURST:
734 736 status = stop_current_mode(); // stop the current mode
735 737 status = restart_science_tasks( LFR_MODE_NORMAL ); // restart the science tasks
736 738 if (status == RTEMS_SUCCESSFUL) // relaunch spectral_matrix and waveform_picker modules
737 739 {
738 740 launch_spectral_matrix( );
739 741 launch_waveform_picker( LFR_MODE_NORMAL, transitionCoarseTime );
740 742 }
741 743 break;
742 744 case LFR_MODE_SBM1:
743 745 status = restart_asm_activities( LFR_MODE_NORMAL ); // this is necessary to restart ASM tasks to update the parameters
744 746 status = LFR_SUCCESSFUL; // lfrCurrentMode will be updated after the execution of close_action
745 747 update_last_valid_transition_date( transitionCoarseTime );
746 748 break;
747 749 case LFR_MODE_SBM2:
748 750 status = restart_asm_activities( LFR_MODE_NORMAL ); // this is necessary to restart ASM tasks to update the parameters
749 751 status = LFR_SUCCESSFUL; // lfrCurrentMode will be updated after the execution of close_action
750 752 update_last_valid_transition_date( transitionCoarseTime );
751 753 break;
752 754 default:
753 755 break;
754 756 }
755 757
756 758 if (status != RTEMS_SUCCESSFUL)
757 759 {
758 760 PRINTF1("ERR *** in enter_mode_normal *** status = %d\n", status)
759 761 status = RTEMS_UNSATISFIED;
760 762 }
761 763
762 764 return status;
763 765 }
764 766
765 767 int enter_mode_burst( unsigned int transitionCoarseTime )
766 768 {
767 769 /** This function is used to start the BURST mode.
768 770 *
769 771 * @param transitionCoarseTime is the requested transition time contained in the TC_LFR_ENTER_MODE
770 772 *
771 773 * @return RTEMS directive status codes:
772 774 * - RTEMS_SUCCESSFUL - task restarted successfully
773 775 * - RTEMS_INVALID_ID - task id invalid
774 776 * - RTEMS_INCORRECT_STATE - task never started
775 777 * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task
776 778 *
777 779 * The way the BURST mode is started does not depend on the LFR current mode.
778 780 *
779 781 */
780 782
781 783
782 784 int status;
783 785
784 786 #ifdef PRINT_TASK_STATISTICS
785 787 rtems_cpu_usage_reset();
786 788 #endif
787 789
788 790 status = stop_current_mode(); // stop the current mode
789 791 status = restart_science_tasks( LFR_MODE_BURST ); // restart the science tasks
790 792 if (status == RTEMS_SUCCESSFUL) // relaunch spectral_matrix and waveform_picker modules
791 793 {
792 794 launch_spectral_matrix( );
793 795 launch_waveform_picker( LFR_MODE_BURST, transitionCoarseTime );
794 796 }
795 797
796 798 if (status != RTEMS_SUCCESSFUL)
797 799 {
798 800 PRINTF1("ERR *** in enter_mode_burst *** status = %d\n", status)
799 801 status = RTEMS_UNSATISFIED;
800 802 }
801 803
802 804 return status;
803 805 }
804 806
805 807 int enter_mode_sbm1( unsigned int transitionCoarseTime )
806 808 {
807 809 /** This function is used to start the SBM1 mode.
808 810 *
809 811 * @param transitionCoarseTime is the requested transition time contained in the TC_LFR_ENTER_MODE
810 812 *
811 813 * @return RTEMS directive status codes:
812 814 * - RTEMS_SUCCESSFUL - task restarted successfully
813 815 * - RTEMS_INVALID_ID - task id invalid
814 816 * - RTEMS_INCORRECT_STATE - task never started
815 817 * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task
816 818 *
817 819 * The way the SBM1 mode is started depends on the LFR current mode. If LFR is in NORMAL or SBM2,
818 820 * the snapshots are not restarted, only ASM, BP and CWF data generation are affected. In other
819 821 * cases, the acquisition is completely restarted.
820 822 *
821 823 */
822 824
823 825 int status;
824 826
825 827 #ifdef PRINT_TASK_STATISTICS
826 828 rtems_cpu_usage_reset();
827 829 #endif
828 830
829 831 status = RTEMS_UNSATISFIED;
830 832
831 833 switch( lfrCurrentMode )
832 834 {
833 835 case LFR_MODE_STANDBY:
834 836 status = restart_science_tasks( LFR_MODE_SBM1 ); // restart science tasks
835 837 if (status == RTEMS_SUCCESSFUL) // relaunch spectral_matrix and waveform_picker modules
836 838 {
837 839 launch_spectral_matrix( );
838 840 launch_waveform_picker( LFR_MODE_SBM1, transitionCoarseTime );
839 841 }
840 842 break;
841 843 case LFR_MODE_NORMAL: // lfrCurrentMode will be updated after the execution of close_action
842 844 status = restart_asm_activities( LFR_MODE_SBM1 );
843 845 status = LFR_SUCCESSFUL;
844 846 update_last_valid_transition_date( transitionCoarseTime );
845 847 break;
846 848 case LFR_MODE_BURST:
847 849 status = stop_current_mode(); // stop the current mode
848 850 status = restart_science_tasks( LFR_MODE_SBM1 ); // restart the science tasks
849 851 if (status == RTEMS_SUCCESSFUL) // relaunch spectral_matrix and waveform_picker modules
850 852 {
851 853 launch_spectral_matrix( );
852 854 launch_waveform_picker( LFR_MODE_SBM1, transitionCoarseTime );
853 855 }
854 856 break;
855 857 case LFR_MODE_SBM2:
856 858 status = restart_asm_activities( LFR_MODE_SBM1 );
857 859 status = LFR_SUCCESSFUL; // lfrCurrentMode will be updated after the execution of close_action
858 860 update_last_valid_transition_date( transitionCoarseTime );
859 861 break;
860 862 default:
861 863 break;
862 864 }
863 865
864 866 if (status != RTEMS_SUCCESSFUL)
865 867 {
866 868 PRINTF1("ERR *** in enter_mode_sbm1 *** status = %d\n", status);
867 869 status = RTEMS_UNSATISFIED;
868 870 }
869 871
870 872 return status;
871 873 }
872 874
873 875 int enter_mode_sbm2( unsigned int transitionCoarseTime )
874 876 {
875 877 /** This function is used to start the SBM2 mode.
876 878 *
877 879 * @param transitionCoarseTime is the requested transition time contained in the TC_LFR_ENTER_MODE
878 880 *
879 881 * @return RTEMS directive status codes:
880 882 * - RTEMS_SUCCESSFUL - task restarted successfully
881 883 * - RTEMS_INVALID_ID - task id invalid
882 884 * - RTEMS_INCORRECT_STATE - task never started
883 885 * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task
884 886 *
885 887 * The way the SBM2 mode is started depends on the LFR current mode. If LFR is in NORMAL or SBM1,
886 888 * the snapshots are not restarted, only ASM, BP and CWF data generation are affected. In other
887 889 * cases, the acquisition is completely restarted.
888 890 *
889 891 */
890 892
891 893 int status;
892 894
893 895 #ifdef PRINT_TASK_STATISTICS
894 896 rtems_cpu_usage_reset();
895 897 #endif
896 898
897 899 status = RTEMS_UNSATISFIED;
898 900
899 901 switch( lfrCurrentMode )
900 902 {
901 903 case LFR_MODE_STANDBY:
902 904 status = restart_science_tasks( LFR_MODE_SBM2 ); // restart science tasks
903 905 if (status == RTEMS_SUCCESSFUL) // relaunch spectral_matrix and waveform_picker modules
904 906 {
905 907 launch_spectral_matrix( );
906 908 launch_waveform_picker( LFR_MODE_SBM2, transitionCoarseTime );
907 909 }
908 910 break;
909 911 case LFR_MODE_NORMAL:
910 912 status = restart_asm_activities( LFR_MODE_SBM2 );
911 913 status = LFR_SUCCESSFUL; // lfrCurrentMode will be updated after the execution of close_action
912 914 update_last_valid_transition_date( transitionCoarseTime );
913 915 break;
914 916 case LFR_MODE_BURST:
915 917 status = stop_current_mode(); // stop the current mode
916 918 status = restart_science_tasks( LFR_MODE_SBM2 ); // restart the science tasks
917 919 if (status == RTEMS_SUCCESSFUL) // relaunch spectral_matrix and waveform_picker modules
918 920 {
919 921 launch_spectral_matrix( );
920 922 launch_waveform_picker( LFR_MODE_SBM2, transitionCoarseTime );
921 923 }
922 924 break;
923 925 case LFR_MODE_SBM1:
924 926 status = restart_asm_activities( LFR_MODE_SBM2 );
925 927 status = LFR_SUCCESSFUL; // lfrCurrentMode will be updated after the execution of close_action
926 928 update_last_valid_transition_date( transitionCoarseTime );
927 929 break;
928 930 default:
929 931 break;
930 932 }
931 933
932 934 if (status != RTEMS_SUCCESSFUL)
933 935 {
934 936 PRINTF1("ERR *** in enter_mode_sbm2 *** status = %d\n", status)
935 937 status = RTEMS_UNSATISFIED;
936 938 }
937 939
938 940 return status;
939 941 }
940 942
941 943 int restart_science_tasks( unsigned char lfrRequestedMode )
942 944 {
943 945 /** This function is used to restart all science tasks.
944 946 *
945 947 * @return RTEMS directive status codes:
946 948 * - RTEMS_SUCCESSFUL - task restarted successfully
947 949 * - RTEMS_INVALID_ID - task id invalid
948 950 * - RTEMS_INCORRECT_STATE - task never started
949 951 * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task
950 952 *
951 953 * Science tasks are AVF0, PRC0, WFRM, CWF3, CW2, CWF1
952 954 *
953 955 */
954 956
955 957 rtems_status_code status[NB_SCIENCE_TASKS];
956 958 rtems_status_code ret;
957 959
958 960 ret = RTEMS_SUCCESSFUL;
959 961
960 962 status[STATUS_0] = rtems_task_restart( Task_id[TASKID_AVF0], lfrRequestedMode );
961 963 if (status[STATUS_0] != RTEMS_SUCCESSFUL)
962 964 {
963 965 PRINTF1("in restart_science_task *** AVF0 ERR %d\n", status[STATUS_0])
964 966 }
965 967
966 968 status[STATUS_1] = rtems_task_restart( Task_id[TASKID_PRC0], lfrRequestedMode );
967 969 if (status[STATUS_1] != RTEMS_SUCCESSFUL)
968 970 {
969 971 PRINTF1("in restart_science_task *** PRC0 ERR %d\n", status[STATUS_1])
970 972 }
971 973
972 974 status[STATUS_2] = rtems_task_restart( Task_id[TASKID_WFRM],1 );
973 975 if (status[STATUS_2] != RTEMS_SUCCESSFUL)
974 976 {
975 977 PRINTF1("in restart_science_task *** WFRM ERR %d\n", status[STATUS_2])
976 978 }
977 979
978 980 status[STATUS_3] = rtems_task_restart( Task_id[TASKID_CWF3],1 );
979 981 if (status[STATUS_3] != RTEMS_SUCCESSFUL)
980 982 {
981 983 PRINTF1("in restart_science_task *** CWF3 ERR %d\n", status[STATUS_3])
982 984 }
983 985
984 986 status[STATUS_4] = rtems_task_restart( Task_id[TASKID_CWF2],1 );
985 987 if (status[STATUS_4] != RTEMS_SUCCESSFUL)
986 988 {
987 989 PRINTF1("in restart_science_task *** CWF2 ERR %d\n", status[STATUS_4])
988 990 }
989 991
990 992 status[STATUS_5] = rtems_task_restart( Task_id[TASKID_CWF1],1 );
991 993 if (status[STATUS_5] != RTEMS_SUCCESSFUL)
992 994 {
993 995 PRINTF1("in restart_science_task *** CWF1 ERR %d\n", status[STATUS_5])
994 996 }
995 997
996 998 status[STATUS_6] = rtems_task_restart( Task_id[TASKID_AVF1], lfrRequestedMode );
997 999 if (status[STATUS_6] != RTEMS_SUCCESSFUL)
998 1000 {
999 1001 PRINTF1("in restart_science_task *** AVF1 ERR %d\n", status[STATUS_6])
1000 1002 }
1001 1003
1002 1004 status[STATUS_7] = rtems_task_restart( Task_id[TASKID_PRC1],lfrRequestedMode );
1003 1005 if (status[STATUS_7] != RTEMS_SUCCESSFUL)
1004 1006 {
1005 1007 PRINTF1("in restart_science_task *** PRC1 ERR %d\n", status[STATUS_7])
1006 1008 }
1007 1009
1008 1010 status[STATUS_8] = rtems_task_restart( Task_id[TASKID_AVF2], 1 );
1009 1011 if (status[STATUS_8] != RTEMS_SUCCESSFUL)
1010 1012 {
1011 1013 PRINTF1("in restart_science_task *** AVF2 ERR %d\n", status[STATUS_8])
1012 1014 }
1013 1015
1014 1016 status[STATUS_9] = rtems_task_restart( Task_id[TASKID_PRC2], 1 );
1015 1017 if (status[STATUS_9] != RTEMS_SUCCESSFUL)
1016 1018 {
1017 1019 PRINTF1("in restart_science_task *** PRC2 ERR %d\n", status[STATUS_9])
1018 1020 }
1019 1021
1020 1022 if ( (status[STATUS_0] != RTEMS_SUCCESSFUL) || (status[STATUS_1] != RTEMS_SUCCESSFUL) ||
1021 1023 (status[STATUS_2] != RTEMS_SUCCESSFUL) || (status[STATUS_3] != RTEMS_SUCCESSFUL) ||
1022 1024 (status[STATUS_4] != RTEMS_SUCCESSFUL) || (status[STATUS_5] != RTEMS_SUCCESSFUL) ||
1023 1025 (status[STATUS_6] != RTEMS_SUCCESSFUL) || (status[STATUS_7] != RTEMS_SUCCESSFUL) ||
1024 1026 (status[STATUS_8] != RTEMS_SUCCESSFUL) || (status[STATUS_9] != RTEMS_SUCCESSFUL) )
1025 1027 {
1026 1028 ret = RTEMS_UNSATISFIED;
1027 1029 }
1028 1030
1029 1031 return ret;
1030 1032 }
1031 1033
1032 1034 int restart_asm_tasks( unsigned char lfrRequestedMode )
1033 1035 {
1034 1036 /** This function is used to restart average spectral matrices tasks.
1035 1037 *
1036 1038 * @return RTEMS directive status codes:
1037 1039 * - RTEMS_SUCCESSFUL - task restarted successfully
1038 1040 * - RTEMS_INVALID_ID - task id invalid
1039 1041 * - RTEMS_INCORRECT_STATE - task never started
1040 1042 * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task
1041 1043 *
1042 1044 * ASM tasks are AVF0, PRC0, AVF1, PRC1, AVF2 and PRC2
1043 1045 *
1044 1046 */
1045 1047
1046 1048 rtems_status_code status[NB_ASM_TASKS];
1047 1049 rtems_status_code ret;
1048 1050
1049 1051 ret = RTEMS_SUCCESSFUL;
1050 1052
1051 1053 status[STATUS_0] = rtems_task_restart( Task_id[TASKID_AVF0], lfrRequestedMode );
1052 1054 if (status[STATUS_0] != RTEMS_SUCCESSFUL)
1053 1055 {
1054 1056 PRINTF1("in restart_science_task *** AVF0 ERR %d\n", status[STATUS_0])
1055 1057 }
1056 1058
1057 1059 status[STATUS_1] = rtems_task_restart( Task_id[TASKID_PRC0], lfrRequestedMode );
1058 1060 if (status[STATUS_1] != RTEMS_SUCCESSFUL)
1059 1061 {
1060 1062 PRINTF1("in restart_science_task *** PRC0 ERR %d\n", status[STATUS_1])
1061 1063 }
1062 1064
1063 1065 status[STATUS_2] = rtems_task_restart( Task_id[TASKID_AVF1], lfrRequestedMode );
1064 1066 if (status[STATUS_2] != RTEMS_SUCCESSFUL)
1065 1067 {
1066 1068 PRINTF1("in restart_science_task *** AVF1 ERR %d\n", status[STATUS_2])
1067 1069 }
1068 1070
1069 1071 status[STATUS_3] = rtems_task_restart( Task_id[TASKID_PRC1],lfrRequestedMode );
1070 1072 if (status[STATUS_3] != RTEMS_SUCCESSFUL)
1071 1073 {
1072 1074 PRINTF1("in restart_science_task *** PRC1 ERR %d\n", status[STATUS_3])
1073 1075 }
1074 1076
1075 1077 status[STATUS_4] = rtems_task_restart( Task_id[TASKID_AVF2], 1 );
1076 1078 if (status[STATUS_4] != RTEMS_SUCCESSFUL)
1077 1079 {
1078 1080 PRINTF1("in restart_science_task *** AVF2 ERR %d\n", status[STATUS_4])
1079 1081 }
1080 1082
1081 1083 status[STATUS_5] = rtems_task_restart( Task_id[TASKID_PRC2], 1 );
1082 1084 if (status[STATUS_5] != RTEMS_SUCCESSFUL)
1083 1085 {
1084 1086 PRINTF1("in restart_science_task *** PRC2 ERR %d\n", status[STATUS_5])
1085 1087 }
1086 1088
1087 1089 if ( (status[STATUS_0] != RTEMS_SUCCESSFUL) || (status[STATUS_1] != RTEMS_SUCCESSFUL) ||
1088 1090 (status[STATUS_2] != RTEMS_SUCCESSFUL) || (status[STATUS_3] != RTEMS_SUCCESSFUL) ||
1089 1091 (status[STATUS_4] != RTEMS_SUCCESSFUL) || (status[STATUS_5] != RTEMS_SUCCESSFUL) )
1090 1092 {
1091 1093 ret = RTEMS_UNSATISFIED;
1092 1094 }
1093 1095
1094 1096 return ret;
1095 1097 }
1096 1098
1097 1099 int suspend_science_tasks( void )
1098 1100 {
1099 1101 /** This function suspends the science tasks.
1100 1102 *
1101 1103 * @return RTEMS directive status codes:
1102 1104 * - RTEMS_SUCCESSFUL - task restarted successfully
1103 1105 * - RTEMS_INVALID_ID - task id invalid
1104 1106 * - RTEMS_ALREADY_SUSPENDED - task already suspended
1105 1107 *
1106 1108 */
1107 1109
1108 1110 rtems_status_code status;
1109 1111
1110 1112 PRINTF("in suspend_science_tasks\n")
1111 1113
1112 1114 status = rtems_task_suspend( Task_id[TASKID_AVF0] ); // suspend AVF0
1113 1115 if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED))
1114 1116 {
1115 1117 PRINTF1("in suspend_science_task *** AVF0 ERR %d\n", status)
1116 1118 }
1117 1119 else
1118 1120 {
1119 1121 status = RTEMS_SUCCESSFUL;
1120 1122 }
1121 1123 if (status == RTEMS_SUCCESSFUL) // suspend PRC0
1122 1124 {
1123 1125 status = rtems_task_suspend( Task_id[TASKID_PRC0] );
1124 1126 if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED))
1125 1127 {
1126 1128 PRINTF1("in suspend_science_task *** PRC0 ERR %d\n", status)
1127 1129 }
1128 1130 else
1129 1131 {
1130 1132 status = RTEMS_SUCCESSFUL;
1131 1133 }
1132 1134 }
1133 1135 if (status == RTEMS_SUCCESSFUL) // suspend AVF1
1134 1136 {
1135 1137 status = rtems_task_suspend( Task_id[TASKID_AVF1] );
1136 1138 if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED))
1137 1139 {
1138 1140 PRINTF1("in suspend_science_task *** AVF1 ERR %d\n", status)
1139 1141 }
1140 1142 else
1141 1143 {
1142 1144 status = RTEMS_SUCCESSFUL;
1143 1145 }
1144 1146 }
1145 1147 if (status == RTEMS_SUCCESSFUL) // suspend PRC1
1146 1148 {
1147 1149 status = rtems_task_suspend( Task_id[TASKID_PRC1] );
1148 1150 if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED))
1149 1151 {
1150 1152 PRINTF1("in suspend_science_task *** PRC1 ERR %d\n", status)
1151 1153 }
1152 1154 else
1153 1155 {
1154 1156 status = RTEMS_SUCCESSFUL;
1155 1157 }
1156 1158 }
1157 1159 if (status == RTEMS_SUCCESSFUL) // suspend AVF2
1158 1160 {
1159 1161 status = rtems_task_suspend( Task_id[TASKID_AVF2] );
1160 1162 if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED))
1161 1163 {
1162 1164 PRINTF1("in suspend_science_task *** AVF2 ERR %d\n", status)
1163 1165 }
1164 1166 else
1165 1167 {
1166 1168 status = RTEMS_SUCCESSFUL;
1167 1169 }
1168 1170 }
1169 1171 if (status == RTEMS_SUCCESSFUL) // suspend PRC2
1170 1172 {
1171 1173 status = rtems_task_suspend( Task_id[TASKID_PRC2] );
1172 1174 if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED))
1173 1175 {
1174 1176 PRINTF1("in suspend_science_task *** PRC2 ERR %d\n", status)
1175 1177 }
1176 1178 else
1177 1179 {
1178 1180 status = RTEMS_SUCCESSFUL;
1179 1181 }
1180 1182 }
1181 1183 if (status == RTEMS_SUCCESSFUL) // suspend WFRM
1182 1184 {
1183 1185 status = rtems_task_suspend( Task_id[TASKID_WFRM] );
1184 1186 if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED))
1185 1187 {
1186 1188 PRINTF1("in suspend_science_task *** WFRM ERR %d\n", status)
1187 1189 }
1188 1190 else
1189 1191 {
1190 1192 status = RTEMS_SUCCESSFUL;
1191 1193 }
1192 1194 }
1193 1195 if (status == RTEMS_SUCCESSFUL) // suspend CWF3
1194 1196 {
1195 1197 status = rtems_task_suspend( Task_id[TASKID_CWF3] );
1196 1198 if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED))
1197 1199 {
1198 1200 PRINTF1("in suspend_science_task *** CWF3 ERR %d\n", status)
1199 1201 }
1200 1202 else
1201 1203 {
1202 1204 status = RTEMS_SUCCESSFUL;
1203 1205 }
1204 1206 }
1205 1207 if (status == RTEMS_SUCCESSFUL) // suspend CWF2
1206 1208 {
1207 1209 status = rtems_task_suspend( Task_id[TASKID_CWF2] );
1208 1210 if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED))
1209 1211 {
1210 1212 PRINTF1("in suspend_science_task *** CWF2 ERR %d\n", status)
1211 1213 }
1212 1214 else
1213 1215 {
1214 1216 status = RTEMS_SUCCESSFUL;
1215 1217 }
1216 1218 }
1217 1219 if (status == RTEMS_SUCCESSFUL) // suspend CWF1
1218 1220 {
1219 1221 status = rtems_task_suspend( Task_id[TASKID_CWF1] );
1220 1222 if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED))
1221 1223 {
1222 1224 PRINTF1("in suspend_science_task *** CWF1 ERR %d\n", status)
1223 1225 }
1224 1226 else
1225 1227 {
1226 1228 status = RTEMS_SUCCESSFUL;
1227 1229 }
1228 1230 }
1229 1231
1230 1232 return status;
1231 1233 }
1232 1234
1233 1235 int suspend_asm_tasks( void )
1234 1236 {
1235 1237 /** This function suspends the science tasks.
1236 1238 *
1237 1239 * @return RTEMS directive status codes:
1238 1240 * - RTEMS_SUCCESSFUL - task restarted successfully
1239 1241 * - RTEMS_INVALID_ID - task id invalid
1240 1242 * - RTEMS_ALREADY_SUSPENDED - task already suspended
1241 1243 *
1242 1244 */
1243 1245
1244 1246 rtems_status_code status;
1245 1247
1246 1248 PRINTF("in suspend_science_tasks\n")
1247 1249
1248 1250 status = rtems_task_suspend( Task_id[TASKID_AVF0] ); // suspend AVF0
1249 1251 if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED))
1250 1252 {
1251 1253 PRINTF1("in suspend_science_task *** AVF0 ERR %d\n", status)
1252 1254 }
1253 1255 else
1254 1256 {
1255 1257 status = RTEMS_SUCCESSFUL;
1256 1258 }
1257 1259
1258 1260 if (status == RTEMS_SUCCESSFUL) // suspend PRC0
1259 1261 {
1260 1262 status = rtems_task_suspend( Task_id[TASKID_PRC0] );
1261 1263 if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED))
1262 1264 {
1263 1265 PRINTF1("in suspend_science_task *** PRC0 ERR %d\n", status)
1264 1266 }
1265 1267 else
1266 1268 {
1267 1269 status = RTEMS_SUCCESSFUL;
1268 1270 }
1269 1271 }
1270 1272
1271 1273 if (status == RTEMS_SUCCESSFUL) // suspend AVF1
1272 1274 {
1273 1275 status = rtems_task_suspend( Task_id[TASKID_AVF1] );
1274 1276 if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED))
1275 1277 {
1276 1278 PRINTF1("in suspend_science_task *** AVF1 ERR %d\n", status)
1277 1279 }
1278 1280 else
1279 1281 {
1280 1282 status = RTEMS_SUCCESSFUL;
1281 1283 }
1282 1284 }
1283 1285
1284 1286 if (status == RTEMS_SUCCESSFUL) // suspend PRC1
1285 1287 {
1286 1288 status = rtems_task_suspend( Task_id[TASKID_PRC1] );
1287 1289 if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED))
1288 1290 {
1289 1291 PRINTF1("in suspend_science_task *** PRC1 ERR %d\n", status)
1290 1292 }
1291 1293 else
1292 1294 {
1293 1295 status = RTEMS_SUCCESSFUL;
1294 1296 }
1295 1297 }
1296 1298
1297 1299 if (status == RTEMS_SUCCESSFUL) // suspend AVF2
1298 1300 {
1299 1301 status = rtems_task_suspend( Task_id[TASKID_AVF2] );
1300 1302 if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED))
1301 1303 {
1302 1304 PRINTF1("in suspend_science_task *** AVF2 ERR %d\n", status)
1303 1305 }
1304 1306 else
1305 1307 {
1306 1308 status = RTEMS_SUCCESSFUL;
1307 1309 }
1308 1310 }
1309 1311
1310 1312 if (status == RTEMS_SUCCESSFUL) // suspend PRC2
1311 1313 {
1312 1314 status = rtems_task_suspend( Task_id[TASKID_PRC2] );
1313 1315 if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED))
1314 1316 {
1315 1317 PRINTF1("in suspend_science_task *** PRC2 ERR %d\n", status)
1316 1318 }
1317 1319 else
1318 1320 {
1319 1321 status = RTEMS_SUCCESSFUL;
1320 1322 }
1321 1323 }
1322 1324
1323 1325 return status;
1324 1326 }
1325 1327
1326 1328 void launch_waveform_picker( unsigned char mode, unsigned int transitionCoarseTime )
1327 1329 {
1328 1330
1329 1331 WFP_reset_current_ring_nodes();
1330 1332
1331 1333 reset_waveform_picker_regs();
1332 1334
1333 1335 set_wfp_burst_enable_register( mode );
1334 1336
1335 1337 LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER );
1336 1338 LEON_Unmask_interrupt( IRQ_WAVEFORM_PICKER );
1337 1339
1338 1340 if (transitionCoarseTime == 0)
1339 1341 {
1340 1342 // instant transition means transition on the next valid date
1341 1343 // this is mandatory to have a good snapshot period and a good correction of the snapshot period
1342 1344 waveform_picker_regs->start_date = time_management_regs->coarse_time + 1;
1343 1345 }
1344 1346 else
1345 1347 {
1346 1348 waveform_picker_regs->start_date = transitionCoarseTime;
1347 1349 }
1348 1350
1349 1351 update_last_valid_transition_date(waveform_picker_regs->start_date);
1350 1352
1351 1353 }
1352 1354
1353 1355 void launch_spectral_matrix( void )
1354 1356 {
1355 1357 SM_reset_current_ring_nodes();
1356 1358
1357 1359 reset_spectral_matrix_regs();
1358 1360
1359 1361 reset_nb_sm();
1360 1362
1361 1363 set_sm_irq_onNewMatrix( 1 );
1362 1364
1363 1365 LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX );
1364 1366 LEON_Unmask_interrupt( IRQ_SPECTRAL_MATRIX );
1365 1367
1366 1368 }
1367 1369
1368 1370 void set_sm_irq_onNewMatrix( unsigned char value )
1369 1371 {
1370 1372 if (value == 1)
1371 1373 {
1372 1374 spectral_matrix_regs->config = spectral_matrix_regs->config | BIT_IRQ_ON_NEW_MATRIX;
1373 1375 }
1374 1376 else
1375 1377 {
1376 1378 spectral_matrix_regs->config = spectral_matrix_regs->config & MASK_IRQ_ON_NEW_MATRIX; // 1110
1377 1379 }
1378 1380 }
1379 1381
1380 1382 void set_sm_irq_onError( unsigned char value )
1381 1383 {
1382 1384 if (value == 1)
1383 1385 {
1384 1386 spectral_matrix_regs->config = spectral_matrix_regs->config | BIT_IRQ_ON_ERROR;
1385 1387 }
1386 1388 else
1387 1389 {
1388 1390 spectral_matrix_regs->config = spectral_matrix_regs->config & MASK_IRQ_ON_ERROR; // 1101
1389 1391 }
1390 1392 }
1391 1393
1392 1394 //*****************************
1393 1395 // CONFIGURE CALIBRATION SIGNAL
1394 1396 void setCalibrationPrescaler( unsigned int prescaler )
1395 1397 {
1396 1398 // prescaling of the master clock (25 MHz)
1397 1399 // master clock is divided by 2^prescaler
1398 1400 time_management_regs->calPrescaler = prescaler;
1399 1401 }
1400 1402
1401 1403 void setCalibrationDivisor( unsigned int divisionFactor )
1402 1404 {
1403 1405 // division of the prescaled clock by the division factor
1404 1406 time_management_regs->calDivisor = divisionFactor;
1405 1407 }
1406 1408
1407 1409 void setCalibrationData( void )
1408 1410 {
1409 1411 /** This function is used to store the values used to drive the DAC in order to generate the SCM calibration signal
1410 1412 *
1411 1413 * @param void
1412 1414 *
1413 1415 * @return void
1414 1416 *
1415 1417 */
1416 1418
1417 1419 unsigned int k;
1418 1420 unsigned short data;
1419 1421 float val;
1420 1422 float Ts;
1421 1423
1422 1424 time_management_regs->calDataPtr = INIT_CHAR;
1423 1425
1424 1426 Ts = 1 / CAL_FS;
1425 1427
1426 1428 // build the signal for the SCM calibration
1427 1429 for (k = 0; k < CAL_NB_PTS; k++)
1428 1430 {
1429 1431 val = CAL_A0 * sin( CAL_W0 * k * Ts )
1430 1432 + CAL_A1 * sin( CAL_W1 * k * Ts );
1431 1433 data = (unsigned short) ((val * CAL_SCALE_FACTOR) + CONST_2048);
1432 1434 time_management_regs->calData = data & CAL_DATA_MASK;
1433 1435 }
1434 1436 }
1435 1437
1436 1438 #ifdef ENABLE_DEAD_CODE
1437 1439 void setCalibrationDataInterleaved( void )
1438 1440 {
1439 1441 /** This function is used to store the values used to drive the DAC in order to generate the SCM calibration signal
1440 1442 *
1441 1443 * @param void
1442 1444 *
1443 1445 * @return void
1444 1446 *
1445 1447 * In interleaved mode, one can store more values than in normal mode.
1446 1448 * The data are stored in bunch of 18 bits, 12 bits from one sample and 6 bits from another sample.
1447 1449 * T store 3 values, one need two write operations.
1448 1450 * s1 [ b11 b10 b9 b8 b7 b6 ] s0 [ b11 b10 b9 b8 b7 b6 b5 b3 b2 b1 b0 ]
1449 1451 * s1 [ b5 b4 b3 b2 b1 b0 ] s2 [ b11 b10 b9 b8 b7 b6 b5 b3 b2 b1 b0 ]
1450 1452 *
1451 1453 */
1452 1454
1453 1455 unsigned int k;
1454 1456 float val;
1455 1457 float Ts;
1456 1458 unsigned short data[CAL_NB_PTS_INTER];
1457 1459 unsigned char *dataPtr;
1458 1460
1459 1461 Ts = 1 / CAL_FS_INTER;
1460 1462
1461 1463 time_management_regs->calDataPtr = INIT_CHAR;
1462 1464
1463 1465 // build the signal for the SCM calibration
1464 1466 for (k=0; k<CAL_NB_PTS_INTER; k++)
1465 1467 {
1466 1468 val = sin( 2 * pi * CAL_F0 * k * Ts )
1467 1469 + sin( 2 * pi * CAL_F1 * k * Ts );
1468 1470 data[k] = (unsigned short) ((val * CONST_512) + CONST_2048);
1469 1471 }
1470 1472
1471 1473 // write the signal in interleaved mode
1472 1474 for (k=0; k < STEPS_FOR_STORAGE_INTER; k++)
1473 1475 {
1474 1476 dataPtr = (unsigned char*) &data[ (k * BYTES_FOR_2_SAMPLES) + 2 ];
1475 1477 time_management_regs->calData = ( data[ k * BYTES_FOR_2_SAMPLES ] & CAL_DATA_MASK )
1476 1478 + ( (dataPtr[0] & CAL_DATA_MASK_INTER) << CAL_DATA_SHIFT_INTER);
1477 1479 time_management_regs->calData = ( data[(k * BYTES_FOR_2_SAMPLES) + 1] & CAL_DATA_MASK )
1478 1480 + ( (dataPtr[1] & CAL_DATA_MASK_INTER) << CAL_DATA_SHIFT_INTER);
1479 1481 }
1480 1482 }
1481 1483 #endif
1482 1484
1483 1485 void setCalibrationReload( bool state)
1484 1486 {
1485 1487 if (state == true)
1486 1488 {
1487 1489 time_management_regs->calDACCtrl = time_management_regs->calDACCtrl | BIT_CAL_RELOAD; // [0001 0000]
1488 1490 }
1489 1491 else
1490 1492 {
1491 1493 time_management_regs->calDACCtrl = time_management_regs->calDACCtrl & MASK_CAL_RELOAD; // [1110 1111]
1492 1494 }
1493 1495 }
1494 1496
1495 1497 void setCalibrationEnable( bool state )
1496 1498 {
1497 1499 // this bit drives the multiplexer
1498 1500 if (state == true)
1499 1501 {
1500 1502 time_management_regs->calDACCtrl = time_management_regs->calDACCtrl | BIT_CAL_ENABLE; // [0100 0000]
1501 1503 }
1502 1504 else
1503 1505 {
1504 1506 time_management_regs->calDACCtrl = time_management_regs->calDACCtrl & MASK_CAL_ENABLE; // [1011 1111]
1505 1507 }
1506 1508 }
1507 1509
1508 1510 #ifdef ENABLE_DEAD_CODE
1509 1511 void setCalibrationInterleaved( bool state )
1510 1512 {
1511 1513 // this bit drives the multiplexer
1512 1514 if (state == true)
1513 1515 {
1514 1516 time_management_regs->calDACCtrl = time_management_regs->calDACCtrl | BIT_SET_INTERLEAVED; // [0010 0000]
1515 1517 }
1516 1518 else
1517 1519 {
1518 1520 time_management_regs->calDACCtrl = time_management_regs->calDACCtrl & MASK_SET_INTERLEAVED; // [1101 1111]
1519 1521 }
1520 1522 }
1521 1523 #endif
1522 1524
1523 1525 void setCalibration( bool state )
1524 1526 {
1525 1527 if (state == true)
1526 1528 {
1527 1529 setCalibrationEnable( true );
1528 1530 setCalibrationReload( false );
1529 1531 set_hk_lfr_calib_enable( true );
1530 1532 }
1531 1533 else
1532 1534 {
1533 1535 setCalibrationEnable( false );
1534 1536 setCalibrationReload( true );
1535 1537 set_hk_lfr_calib_enable( false );
1536 1538 }
1537 1539 }
1538 1540
1539 1541 void configureCalibration( bool interleaved )
1540 1542 {
1541 1543 setCalibration( false );
1542 1544 #ifdef ENABLE_DEAD_CODE
1543 1545 if ( interleaved == true )
1544 1546 {
1545 1547 setCalibrationInterleaved( true );
1546 1548 setCalibrationPrescaler( 0 ); // 25 MHz => 25 000 000
1547 1549 setCalibrationDivisor( CAL_F_DIVISOR_INTER ); // => 240 384
1548 1550 setCalibrationDataInterleaved();
1549 1551 }
1550 1552 else
1551 1553 #endif
1552 1554 {
1553 1555 setCalibrationPrescaler( 0 ); // 25 MHz => 25 000 000
1554 1556 setCalibrationDivisor( CAL_F_DIVISOR ); // => 160 256 (39 - 1)
1555 1557 setCalibrationData();
1556 1558 }
1557 1559 }
1558 1560
1559 1561 //****************
1560 1562 // CLOSING ACTIONS
1561 1563 void update_last_TC_exe( ccsdsTelecommandPacket_t *TC, unsigned char * time )
1562 1564 {
1563 1565 /** This function is used to update the HK packets statistics after a successful TC execution.
1564 1566 *
1565 1567 * @param TC points to the TC being processed
1566 1568 * @param time is the time used to date the TC execution
1567 1569 *
1568 1570 */
1569 1571
1570 1572 unsigned int val;
1571 1573
1572 1574 housekeeping_packet.hk_lfr_last_exe_tc_id[0] = TC->packetID[0];
1573 1575 housekeeping_packet.hk_lfr_last_exe_tc_id[1] = TC->packetID[1];
1574 1576 housekeeping_packet.hk_lfr_last_exe_tc_type[0] = INIT_CHAR;
1575 1577 housekeeping_packet.hk_lfr_last_exe_tc_type[1] = TC->serviceType;
1576 1578 housekeeping_packet.hk_lfr_last_exe_tc_subtype[0] = INIT_CHAR;
1577 1579 housekeeping_packet.hk_lfr_last_exe_tc_subtype[1] = TC->serviceSubType;
1578 1580 housekeeping_packet.hk_lfr_last_exe_tc_time[BYTE_0] = time[BYTE_0];
1579 1581 housekeeping_packet.hk_lfr_last_exe_tc_time[BYTE_1] = time[BYTE_1];
1580 1582 housekeeping_packet.hk_lfr_last_exe_tc_time[BYTE_2] = time[BYTE_2];
1581 1583 housekeeping_packet.hk_lfr_last_exe_tc_time[BYTE_3] = time[BYTE_3];
1582 1584 housekeeping_packet.hk_lfr_last_exe_tc_time[BYTE_4] = time[BYTE_4];
1583 1585 housekeeping_packet.hk_lfr_last_exe_tc_time[BYTE_5] = time[BYTE_5];
1584 1586
1585 1587 val = (housekeeping_packet.hk_lfr_exe_tc_cnt[0] * CONST_256) + housekeeping_packet.hk_lfr_exe_tc_cnt[1];
1586 1588 val++;
1587 1589 housekeeping_packet.hk_lfr_exe_tc_cnt[0] = (unsigned char) (val >> SHIFT_1_BYTE);
1588 1590 housekeeping_packet.hk_lfr_exe_tc_cnt[1] = (unsigned char) (val);
1589 1591 }
1590 1592
1591 1593 void update_last_TC_rej(ccsdsTelecommandPacket_t *TC, unsigned char * time )
1592 1594 {
1593 1595 /** This function is used to update the HK packets statistics after a TC rejection.
1594 1596 *
1595 1597 * @param TC points to the TC being processed
1596 1598 * @param time is the time used to date the TC rejection
1597 1599 *
1598 1600 */
1599 1601
1600 1602 unsigned int val;
1601 1603
1602 1604 housekeeping_packet.hk_lfr_last_rej_tc_id[0] = TC->packetID[0];
1603 1605 housekeeping_packet.hk_lfr_last_rej_tc_id[1] = TC->packetID[1];
1604 1606 housekeeping_packet.hk_lfr_last_rej_tc_type[0] = INIT_CHAR;
1605 1607 housekeeping_packet.hk_lfr_last_rej_tc_type[1] = TC->serviceType;
1606 1608 housekeeping_packet.hk_lfr_last_rej_tc_subtype[0] = INIT_CHAR;
1607 1609 housekeeping_packet.hk_lfr_last_rej_tc_subtype[1] = TC->serviceSubType;
1608 1610 housekeeping_packet.hk_lfr_last_rej_tc_time[BYTE_0] = time[BYTE_0];
1609 1611 housekeeping_packet.hk_lfr_last_rej_tc_time[BYTE_1] = time[BYTE_1];
1610 1612 housekeeping_packet.hk_lfr_last_rej_tc_time[BYTE_2] = time[BYTE_2];
1611 1613 housekeeping_packet.hk_lfr_last_rej_tc_time[BYTE_3] = time[BYTE_3];
1612 1614 housekeeping_packet.hk_lfr_last_rej_tc_time[BYTE_4] = time[BYTE_4];
1613 1615 housekeeping_packet.hk_lfr_last_rej_tc_time[BYTE_5] = time[BYTE_5];
1614 1616
1615 1617 val = (housekeeping_packet.hk_lfr_rej_tc_cnt[0] * CONST_256) + housekeeping_packet.hk_lfr_rej_tc_cnt[1];
1616 1618 val++;
1617 1619 housekeeping_packet.hk_lfr_rej_tc_cnt[0] = (unsigned char) (val >> SHIFT_1_BYTE);
1618 1620 housekeeping_packet.hk_lfr_rej_tc_cnt[1] = (unsigned char) (val);
1619 1621 }
1620 1622
1621 1623 void close_action(ccsdsTelecommandPacket_t *TC, int result, rtems_id queue_id )
1622 1624 {
1623 1625 /** This function is the last step of the TC execution workflow.
1624 1626 *
1625 1627 * @param TC points to the TC being processed
1626 1628 * @param result is the result of the TC execution (LFR_SUCCESSFUL / LFR_DEFAULT)
1627 1629 * @param queue_id is the id of the RTEMS message queue used to send TM packets
1628 1630 * @param time is the time used to date the TC execution
1629 1631 *
1630 1632 */
1631 1633
1632 1634 unsigned char requestedMode;
1633 1635
1634 1636 if (result == LFR_SUCCESSFUL)
1635 1637 {
1636 1638 if ( !( (TC->serviceType==TC_TYPE_TIME) & (TC->serviceSubType==TC_SUBTYPE_UPDT_TIME) )
1637 1639 &
1638 1640 !( (TC->serviceType==TC_TYPE_GEN) & (TC->serviceSubType==TC_SUBTYPE_UPDT_INFO))
1639 1641 )
1640 1642 {
1641 1643 send_tm_lfr_tc_exe_success( TC, queue_id );
1642 1644 }
1643 1645 if ( (TC->serviceType == TC_TYPE_GEN) & (TC->serviceSubType == TC_SUBTYPE_ENTER) )
1644 1646 {
1645 1647 //**********************************
1646 1648 // UPDATE THE LFRMODE LOCAL VARIABLE
1647 1649 requestedMode = TC->dataAndCRC[1];
1648 1650 updateLFRCurrentMode( requestedMode );
1649 1651 }
1650 1652 }
1651 1653 else if (result == LFR_EXE_ERROR)
1652 1654 {
1653 1655 send_tm_lfr_tc_exe_error( TC, queue_id );
1654 1656 }
1655 1657 }
1656 1658
1657 1659 //****************
1658 1660 // OTHER FUNCTIONS
1659 1661 void updateLFRCurrentMode( unsigned char requestedMode )
1660 1662 {
1661 1663 /** This function updates the value of the global variable lfrCurrentMode.
1662 1664 *
1663 1665 * lfrCurrentMode is a parameter used by several functions to know in which mode LFR is running.
1664 1666 *
1665 1667 */
1666 1668
1667 1669 // update the local value of lfrCurrentMode with the value contained in the housekeeping_packet structure
1668 1670 housekeeping_packet.lfr_status_word[0] = (housekeeping_packet.lfr_status_word[0] & STATUS_WORD_LFR_MODE_MASK)
1669 1671 + (unsigned char) ( requestedMode << STATUS_WORD_LFR_MODE_SHIFT );
1670 1672 lfrCurrentMode = requestedMode;
1671 1673 }
1672 1674
1673 1675 void set_lfr_soft_reset( unsigned char value )
1674 1676 {
1675 1677 if (value == 1)
1676 1678 {
1677 1679 time_management_regs->ctrl = time_management_regs->ctrl | BIT_SOFT_RESET; // [0100]
1678 1680 }
1679 1681 else
1680 1682 {
1681 1683 time_management_regs->ctrl = time_management_regs->ctrl & MASK_SOFT_RESET; // [1011]
1682 1684 }
1683 1685 }
1684 1686
1685 1687 void reset_lfr( void )
1686 1688 {
1687 1689 set_lfr_soft_reset( 1 );
1688 1690
1689 1691 set_lfr_soft_reset( 0 );
1690 1692
1691 1693 set_hk_lfr_sc_potential_flag( true );
1692 1694 }
General Comments 0
You need to be logged in to leave comments. Login now