##// END OF EJS Templates
Bug 906 calibration signal
paul -
r332:86c97c298d6e R3_plus draft
parent child
Show More
@@ -1,111 +1,115
1 #ifndef TC_HANDLER_H_INCLUDED
1 #ifndef TC_HANDLER_H_INCLUDED
2 #define TC_HANDLER_H_INCLUDED
2 #define TC_HANDLER_H_INCLUDED
3
3
4 #include <rtems.h>
4 #include <rtems.h>
5 #include <leon.h>
5 #include <leon.h>
6
6
7 #include "tc_load_dump_parameters.h"
7 #include "tc_load_dump_parameters.h"
8 #include "tc_acceptance.h"
8 #include "tc_acceptance.h"
9 #include "tm_lfr_tc_exe.h"
9 #include "tm_lfr_tc_exe.h"
10 #include "wf_handler.h"
10 #include "wf_handler.h"
11 #include "fsw_processing.h"
11 #include "fsw_processing.h"
12
12
13 #include "lfr_cpu_usage_report.h"
13 #include "lfr_cpu_usage_report.h"
14
14
15 #define MAX_DELTA_COARSE_TIME 3
15 #define MAX_DELTA_COARSE_TIME 3
16 #define NB_SCIENCE_TASKS 10
16 #define NB_SCIENCE_TASKS 10
17 #define NB_ASM_TASKS 6
17 #define NB_ASM_TASKS 6
18 #define STATUS_0 0
18 #define STATUS_0 0
19 #define STATUS_1 1
19 #define STATUS_1 1
20 #define STATUS_2 2
20 #define STATUS_2 2
21 #define STATUS_3 3
21 #define STATUS_3 3
22 #define STATUS_4 4
22 #define STATUS_4 4
23 #define STATUS_5 5
23 #define STATUS_5 5
24 #define STATUS_6 6
24 #define STATUS_6 6
25 #define STATUS_7 7
25 #define STATUS_7 7
26 #define STATUS_8 8
26 #define STATUS_8 8
27 #define STATUS_9 9
27 #define STATUS_9 9
28
28
29 #define CAL_F0 625
29 #define CAL_F0 625.
30 #define CAL_F1 10000
30 #define CAL_F1 10000.
31 #define CAL_W0 (2. * pi * CAL_F0)
32 #define CAL_W1 (2. * pi * CAL_F1)
33 #define CAL_A0 1.
34 #define CAL_A1 2.
31 #define CAL_FS 160256.410
35 #define CAL_FS 160256.410
32 #define CAL_SCALE_FACTOR (0.250 / 0.000654) // 191, 500 mVpp, 2 sinus waves => 500 mVpp each, amplitude = 250 mV
36 #define CAL_SCALE_FACTOR (0.250 / 0.000654) // 191, 500 mVpp, 2 sinus waves => 500 mVpp each, amplitude = 250 mV
33 #define CAL_NB_PTS 256
37 #define CAL_NB_PTS 256
34 #define CAL_DATA_MASK 0xfff
38 #define CAL_DATA_MASK 0xfff
35 #define CAL_F_DIVISOR 38 // 25 MHz => 160 256 (39 - 1)
39 #define CAL_F_DIVISOR 38 // 25 MHz => 160 256 (39 - 1)
36 // INTERLEAVED MODE
40 // INTERLEAVED MODE
37 #define CAL_FS_INTER 240384.615
41 #define CAL_FS_INTER 240384.615
38 #define CAL_NB_PTS_INTER 384
42 #define CAL_NB_PTS_INTER 384
39 #define CAL_DATA_MASK_INTER 0x3f
43 #define CAL_DATA_MASK_INTER 0x3f
40 #define CAL_DATA_SHIFT_INTER 12
44 #define CAL_DATA_SHIFT_INTER 12
41 #define BYTES_FOR_2_SAMPLES 3 // one need 3 bytes = 24 bits to store 3 samples of 12 bits in interleaved mode
45 #define BYTES_FOR_2_SAMPLES 3 // one need 3 bytes = 24 bits to store 3 samples of 12 bits in interleaved mode
42 #define STEPS_FOR_STORAGE_INTER 128
46 #define STEPS_FOR_STORAGE_INTER 128
43 #define CAL_F_DIVISOR_INTER 26 // 25 MHz => 240 384
47 #define CAL_F_DIVISOR_INTER 26 // 25 MHz => 240 384
44
48
45 extern unsigned int lastValidEnterModeTime;
49 extern unsigned int lastValidEnterModeTime;
46 extern unsigned char oneTcLfrUpdateTimeReceived;
50 extern unsigned char oneTcLfrUpdateTimeReceived;
47
51
48 //****
52 //****
49 // ISR
53 // ISR
50 rtems_isr commutation_isr1( rtems_vector_number vector );
54 rtems_isr commutation_isr1( rtems_vector_number vector );
51 rtems_isr commutation_isr2( rtems_vector_number vector );
55 rtems_isr commutation_isr2( rtems_vector_number vector );
52
56
53 //***********
57 //***********
54 // RTEMS TASK
58 // RTEMS TASK
55 rtems_task actn_task( rtems_task_argument unused );
59 rtems_task actn_task( rtems_task_argument unused );
56
60
57 //***********
61 //***********
58 // TC ACTIONS
62 // TC ACTIONS
59 int action_reset( ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time );
63 int action_reset( ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time );
60 int action_enter_mode(ccsdsTelecommandPacket_t *TC, rtems_id queue_id);
64 int action_enter_mode(ccsdsTelecommandPacket_t *TC, rtems_id queue_id);
61 int action_update_info( ccsdsTelecommandPacket_t *TC, rtems_id queue_id );
65 int action_update_info( ccsdsTelecommandPacket_t *TC, rtems_id queue_id );
62 int action_enable_calibration( ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time );
66 int action_enable_calibration( ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time );
63 int action_disable_calibration( ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time );
67 int action_disable_calibration( ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time );
64 int action_update_time( ccsdsTelecommandPacket_t *TC);
68 int action_update_time( ccsdsTelecommandPacket_t *TC);
65
69
66 // mode transition
70 // mode transition
67 int check_mode_value( unsigned char requestedMode );
71 int check_mode_value( unsigned char requestedMode );
68 int check_mode_transition( unsigned char requestedMode );
72 int check_mode_transition( unsigned char requestedMode );
69 void update_last_valid_transition_date( unsigned int transitionCoarseTime );
73 void update_last_valid_transition_date( unsigned int transitionCoarseTime );
70 int check_transition_date( unsigned int transitionCoarseTime );
74 int check_transition_date( unsigned int transitionCoarseTime );
71 int stop_spectral_matrices( void );
75 int stop_spectral_matrices( void );
72 int stop_current_mode( void );
76 int stop_current_mode( void );
73 int enter_mode_standby(void );
77 int enter_mode_standby(void );
74 int enter_mode_normal( unsigned int transitionCoarseTime );
78 int enter_mode_normal( unsigned int transitionCoarseTime );
75 int enter_mode_burst( unsigned int transitionCoarseTime );
79 int enter_mode_burst( unsigned int transitionCoarseTime );
76 int enter_mode_sbm1( unsigned int transitionCoarseTime );
80 int enter_mode_sbm1( unsigned int transitionCoarseTime );
77 int enter_mode_sbm2( unsigned int transitionCoarseTime );
81 int enter_mode_sbm2( unsigned int transitionCoarseTime );
78 int restart_science_tasks( unsigned char lfrRequestedMode );
82 int restart_science_tasks( unsigned char lfrRequestedMode );
79 int restart_asm_tasks(unsigned char lfrRequestedMode );
83 int restart_asm_tasks(unsigned char lfrRequestedMode );
80 int suspend_science_tasks(void);
84 int suspend_science_tasks(void);
81 int suspend_asm_tasks( void );
85 int suspend_asm_tasks( void );
82 void launch_waveform_picker( unsigned char mode , unsigned int transitionCoarseTime );
86 void launch_waveform_picker( unsigned char mode , unsigned int transitionCoarseTime );
83 void launch_spectral_matrix( void );
87 void launch_spectral_matrix( void );
84 void set_sm_irq_onNewMatrix( unsigned char value );
88 void set_sm_irq_onNewMatrix( unsigned char value );
85 void set_sm_irq_onError( unsigned char value );
89 void set_sm_irq_onError( unsigned char value );
86
90
87 // other functions
91 // other functions
88 void updateLFRCurrentMode(unsigned char requestedMode);
92 void updateLFRCurrentMode(unsigned char requestedMode);
89 void set_lfr_soft_reset( unsigned char value );
93 void set_lfr_soft_reset( unsigned char value );
90 void reset_lfr( void );
94 void reset_lfr( void );
91 // CALIBRATION
95 // CALIBRATION
92 void setCalibrationPrescaler( unsigned int prescaler );
96 void setCalibrationPrescaler( unsigned int prescaler );
93 void setCalibrationDivisor( unsigned int divisionFactor );
97 void setCalibrationDivisor( unsigned int divisionFactor );
94 void setCalibrationData( void );
98 void setCalibrationData( void );
95 void setCalibrationReload( bool state);
99 void setCalibrationReload( bool state);
96 void setCalibrationEnable( bool state );
100 void setCalibrationEnable( bool state );
97 void setCalibrationInterleaved( bool state );
101 void setCalibrationInterleaved( bool state );
98 void setCalibration( bool state );
102 void setCalibration( bool state );
99 void configureCalibration( bool interleaved );
103 void configureCalibration( bool interleaved );
100 //
104 //
101 void update_last_TC_exe( ccsdsTelecommandPacket_t *TC , unsigned char *time );
105 void update_last_TC_exe( ccsdsTelecommandPacket_t *TC , unsigned char *time );
102 void update_last_TC_rej(ccsdsTelecommandPacket_t *TC , unsigned char *time );
106 void update_last_TC_rej(ccsdsTelecommandPacket_t *TC , unsigned char *time );
103 void close_action( ccsdsTelecommandPacket_t *TC, int result, rtems_id queue_id );
107 void close_action( ccsdsTelecommandPacket_t *TC, int result, rtems_id queue_id );
104
108
105 extern rtems_status_code get_message_queue_id_send( rtems_id *queue_id );
109 extern rtems_status_code get_message_queue_id_send( rtems_id *queue_id );
106 extern rtems_status_code get_message_queue_id_recv( rtems_id *queue_id );
110 extern rtems_status_code get_message_queue_id_recv( rtems_id *queue_id );
107
111
108 #endif // TC_HANDLER_H_INCLUDED
112 #endif // TC_HANDLER_H_INCLUDED
109
113
110
114
111
115
@@ -1,107 +1,107
1 cmake_minimum_required (VERSION 2.6)
1 cmake_minimum_required (VERSION 2.6)
2 project (fsw)
2 project (fsw)
3
3
4 include(sparc-rtems)
4 include(sparc-rtems)
5 include(cppcheck)
5 include(cppcheck)
6
6
7 include_directories("../header"
7 include_directories("../header"
8 "../header/lfr_common_headers"
8 "../header/lfr_common_headers"
9 "../header/processing"
9 "../header/processing"
10 "../LFR_basic-parameters"
10 "../LFR_basic-parameters"
11 "../src")
11 "../src")
12
12
13 set(SOURCES wf_handler.c
13 set(SOURCES wf_handler.c
14 tc_handler.c
14 tc_handler.c
15 fsw_misc.c
15 fsw_misc.c
16 fsw_init.c
16 fsw_init.c
17 fsw_globals.c
17 fsw_globals.c
18 fsw_spacewire.c
18 fsw_spacewire.c
19 tc_load_dump_parameters.c
19 tc_load_dump_parameters.c
20 tm_lfr_tc_exe.c
20 tm_lfr_tc_exe.c
21 tc_acceptance.c
21 tc_acceptance.c
22 processing/fsw_processing.c
22 processing/fsw_processing.c
23 processing/avf0_prc0.c
23 processing/avf0_prc0.c
24 processing/avf1_prc1.c
24 processing/avf1_prc1.c
25 processing/avf2_prc2.c
25 processing/avf2_prc2.c
26 lfr_cpu_usage_report.c
26 lfr_cpu_usage_report.c
27 ${LFR_BP_SRC}
27 ${LFR_BP_SRC}
28 ../header/wf_handler.h
28 ../header/wf_handler.h
29 ../header/tc_handler.h
29 ../header/tc_handler.h
30 ../header/grlib_regs.h
30 ../header/grlib_regs.h
31 ../header/fsw_misc.h
31 ../header/fsw_misc.h
32 ../header/fsw_init.h
32 ../header/fsw_init.h
33 ../header/fsw_spacewire.h
33 ../header/fsw_spacewire.h
34 ../header/tc_load_dump_parameters.h
34 ../header/tc_load_dump_parameters.h
35 ../header/tm_lfr_tc_exe.h
35 ../header/tm_lfr_tc_exe.h
36 ../header/tc_acceptance.h
36 ../header/tc_acceptance.h
37 ../header/processing/fsw_processing.h
37 ../header/processing/fsw_processing.h
38 ../header/processing/avf0_prc0.h
38 ../header/processing/avf0_prc0.h
39 ../header/processing/avf1_prc1.h
39 ../header/processing/avf1_prc1.h
40 ../header/processing/avf2_prc2.h
40 ../header/processing/avf2_prc2.h
41 ../header/fsw_params_wf_handler.h
41 ../header/fsw_params_wf_handler.h
42 ../header/lfr_cpu_usage_report.h
42 ../header/lfr_cpu_usage_report.h
43 ../header/lfr_common_headers/ccsds_types.h
43 ../header/lfr_common_headers/ccsds_types.h
44 ../header/lfr_common_headers/fsw_params.h
44 ../header/lfr_common_headers/fsw_params.h
45 ../header/lfr_common_headers/fsw_params_nb_bytes.h
45 ../header/lfr_common_headers/fsw_params_nb_bytes.h
46 ../header/lfr_common_headers/fsw_params_processing.h
46 ../header/lfr_common_headers/fsw_params_processing.h
47 ../header/lfr_common_headers/tm_byte_positions.h
47 ../header/lfr_common_headers/tm_byte_positions.h
48 ../LFR_basic-parameters/basic_parameters.h
48 ../LFR_basic-parameters/basic_parameters.h
49 ../LFR_basic-parameters/basic_parameters_params.h
49 ../LFR_basic-parameters/basic_parameters_params.h
50 ../header/GscMemoryLPP.hpp
50 ../header/GscMemoryLPP.hpp
51 )
51 )
52
52
53
53
54 option(FSW_verbose "Enable verbose LFR" OFF)
54 option(FSW_verbose "Enable verbose LFR" OFF)
55 option(FSW_boot_messages "Enable LFR boot messages" OFF)
55 option(FSW_boot_messages "Enable LFR boot messages" OFF)
56 option(FSW_debug_messages "Enable LFR debug messages" OFF)
56 option(FSW_debug_messages "Enable LFR debug messages" OFF)
57 option(FSW_cpu_usage_report "Enable LFR cpu usage report" OFF)
57 option(FSW_cpu_usage_report "Enable LFR cpu usage report" OFF)
58 option(FSW_stack_report "Enable LFR stack report" OFF)
58 option(FSW_stack_report "Enable LFR stack report" OFF)
59 option(FSW_vhdl_dev "?" OFF)
59 option(FSW_vhdl_dev "?" OFF)
60 option(FSW_lpp_dpu_destid "Set to debug at LPP" ON)
60 option(FSW_lpp_dpu_destid "Set to debug at LPP" ON)
61 option(FSW_debug_watchdog "Enable debug watchdog" OFF)
61 option(FSW_debug_watchdog "Enable debug watchdog" OFF)
62 option(FSW_debug_tch "?" OFF)
62 option(FSW_debug_tch "?" OFF)
63
63
64 set(SW_VERSION_N1 "3" CACHE STRING "Choose N1 FSW Version." FORCE)
64 set(SW_VERSION_N1 "3" CACHE STRING "Choose N1 FSW Version." FORCE)
65 set(SW_VERSION_N2 "1" CACHE STRING "Choose N2 FSW Version." FORCE)
65 set(SW_VERSION_N2 "1" CACHE STRING "Choose N2 FSW Version." FORCE)
66 set(SW_VERSION_N3 "0" CACHE STRING "Choose N3 FSW Version." FORCE)
66 set(SW_VERSION_N3 "0" CACHE STRING "Choose N3 FSW Version." FORCE)
67 set(SW_VERSION_N4 "5" CACHE STRING "Choose N4 FSW Version." FORCE)
67 set(SW_VERSION_N4 "6" CACHE STRING "Choose N4 FSW Version." FORCE)
68
68
69 if(FSW_verbose)
69 if(FSW_verbose)
70 add_definitions(-DPRINT_MESSAGES_ON_CONSOLE)
70 add_definitions(-DPRINT_MESSAGES_ON_CONSOLE)
71 endif()
71 endif()
72 if(FSW_boot_messages)
72 if(FSW_boot_messages)
73 add_definitions(-DBOOT_MESSAGES)
73 add_definitions(-DBOOT_MESSAGES)
74 endif()
74 endif()
75 if(FSW_debug_messages)
75 if(FSW_debug_messages)
76 add_definitions(-DDEBUG_MESSAGES)
76 add_definitions(-DDEBUG_MESSAGES)
77 endif()
77 endif()
78 if(FSW_cpu_usage_report)
78 if(FSW_cpu_usage_report)
79 add_definitions(-DPRINT_TASK_STATISTICS)
79 add_definitions(-DPRINT_TASK_STATISTICS)
80 endif()
80 endif()
81 if(FSW_stack_report)
81 if(FSW_stack_report)
82 add_definitions(-DPRINT_STACK_REPORT)
82 add_definitions(-DPRINT_STACK_REPORT)
83 endif()
83 endif()
84 if(FSW_vhdl_dev)
84 if(FSW_vhdl_dev)
85 add_definitions(-DVHDL_DEV)
85 add_definitions(-DVHDL_DEV)
86 endif()
86 endif()
87 if(FSW_lpp_dpu_destid)
87 if(FSW_lpp_dpu_destid)
88 add_definitions(-DLPP_DPU_DESTID)
88 add_definitions(-DLPP_DPU_DESTID)
89 endif()
89 endif()
90 if(FSW_debug_watchdog)
90 if(FSW_debug_watchdog)
91 add_definitions(-DDEBUG_WATCHDOG)
91 add_definitions(-DDEBUG_WATCHDOG)
92 endif()
92 endif()
93 if(FSW_debug_tch)
93 if(FSW_debug_tch)
94 add_definitions(-DDEBUG_TCH)
94 add_definitions(-DDEBUG_TCH)
95 endif()
95 endif()
96
96
97 add_definitions(-DMSB_FIRST_TCH)
97 add_definitions(-DMSB_FIRST_TCH)
98
98
99 add_definitions(-DSWVERSION=-1-0)
99 add_definitions(-DSWVERSION=-1-0)
100 add_definitions(-DSW_VERSION_N1=${SW_VERSION_N1})
100 add_definitions(-DSW_VERSION_N1=${SW_VERSION_N1})
101 add_definitions(-DSW_VERSION_N2=${SW_VERSION_N2})
101 add_definitions(-DSW_VERSION_N2=${SW_VERSION_N2})
102 add_definitions(-DSW_VERSION_N3=${SW_VERSION_N3})
102 add_definitions(-DSW_VERSION_N3=${SW_VERSION_N3})
103 add_definitions(-DSW_VERSION_N4=${SW_VERSION_N4})
103 add_definitions(-DSW_VERSION_N4=${SW_VERSION_N4})
104
104
105 add_executable(fsw ${SOURCES})
105 add_executable(fsw ${SOURCES})
106 add_test_cppcheck(fsw STYLE UNUSED_FUNCTIONS POSSIBLE_ERROR MISSING_INCLUDE)
106 add_test_cppcheck(fsw STYLE UNUSED_FUNCTIONS POSSIBLE_ERROR MISSING_INCLUDE)
107
107
@@ -1,1669 +1,1668
1 /** Functions and tasks related to TeleCommand handling.
1 /** Functions and tasks related to TeleCommand handling.
2 *
2 *
3 * @file
3 * @file
4 * @author P. LEROY
4 * @author P. LEROY
5 *
5 *
6 * A group of functions to handle TeleCommands:\n
6 * A group of functions to handle TeleCommands:\n
7 * action launching\n
7 * action launching\n
8 * TC parsing\n
8 * TC parsing\n
9 * ...
9 * ...
10 *
10 *
11 */
11 */
12
12
13 #include "tc_handler.h"
13 #include "tc_handler.h"
14 #include "math.h"
14 #include "math.h"
15
15
16 //***********
16 //***********
17 // RTEMS TASK
17 // RTEMS TASK
18
18
19 rtems_task actn_task( rtems_task_argument unused )
19 rtems_task actn_task( rtems_task_argument unused )
20 {
20 {
21 /** This RTEMS task is responsible for launching actions upton the reception of valid TeleCommands.
21 /** This RTEMS task is responsible for launching actions upton the reception of valid TeleCommands.
22 *
22 *
23 * @param unused is the starting argument of the RTEMS task
23 * @param unused is the starting argument of the RTEMS task
24 *
24 *
25 * The ACTN task waits for data coming from an RTEMS msesage queue. When data arrives, it launches specific actions depending
25 * The ACTN task waits for data coming from an RTEMS msesage queue. When data arrives, it launches specific actions depending
26 * on the incoming TeleCommand.
26 * on the incoming TeleCommand.
27 *
27 *
28 */
28 */
29
29
30 int result;
30 int result;
31 rtems_status_code status; // RTEMS status code
31 rtems_status_code status; // RTEMS status code
32 ccsdsTelecommandPacket_t __attribute__((aligned(4))) TC; // TC sent to the ACTN task
32 ccsdsTelecommandPacket_t __attribute__((aligned(4))) TC; // TC sent to the ACTN task
33 size_t size; // size of the incoming TC packet
33 size_t size; // size of the incoming TC packet
34 unsigned char subtype; // subtype of the current TC packet
34 unsigned char subtype; // subtype of the current TC packet
35 unsigned char time[BYTES_PER_TIME];
35 unsigned char time[BYTES_PER_TIME];
36 rtems_id queue_rcv_id;
36 rtems_id queue_rcv_id;
37 rtems_id queue_snd_id;
37 rtems_id queue_snd_id;
38
38
39 memset(&TC, 0, sizeof(ccsdsTelecommandPacket_t));
39 memset(&TC, 0, sizeof(ccsdsTelecommandPacket_t));
40 size = 0;
40 size = 0;
41 queue_rcv_id = RTEMS_ID_NONE;
41 queue_rcv_id = RTEMS_ID_NONE;
42 queue_snd_id = RTEMS_ID_NONE;
42 queue_snd_id = RTEMS_ID_NONE;
43
43
44 status = get_message_queue_id_recv( &queue_rcv_id );
44 status = get_message_queue_id_recv( &queue_rcv_id );
45 if (status != RTEMS_SUCCESSFUL)
45 if (status != RTEMS_SUCCESSFUL)
46 {
46 {
47 PRINTF1("in ACTN *** ERR get_message_queue_id_recv %d\n", status)
47 PRINTF1("in ACTN *** ERR get_message_queue_id_recv %d\n", status)
48 }
48 }
49
49
50 status = get_message_queue_id_send( &queue_snd_id );
50 status = get_message_queue_id_send( &queue_snd_id );
51 if (status != RTEMS_SUCCESSFUL)
51 if (status != RTEMS_SUCCESSFUL)
52 {
52 {
53 PRINTF1("in ACTN *** ERR get_message_queue_id_send %d\n", status)
53 PRINTF1("in ACTN *** ERR get_message_queue_id_send %d\n", status)
54 }
54 }
55
55
56 result = LFR_SUCCESSFUL;
56 result = LFR_SUCCESSFUL;
57 subtype = 0; // subtype of the current TC packet
57 subtype = 0; // subtype of the current TC packet
58
58
59 BOOT_PRINTF("in ACTN *** \n");
59 BOOT_PRINTF("in ACTN *** \n");
60
60
61 while(1)
61 while(1)
62 {
62 {
63 status = rtems_message_queue_receive( queue_rcv_id, (char*) &TC, &size,
63 status = rtems_message_queue_receive( queue_rcv_id, (char*) &TC, &size,
64 RTEMS_WAIT, RTEMS_NO_TIMEOUT);
64 RTEMS_WAIT, RTEMS_NO_TIMEOUT);
65 getTime( time ); // set time to the current time
65 getTime( time ); // set time to the current time
66 if (status!=RTEMS_SUCCESSFUL)
66 if (status!=RTEMS_SUCCESSFUL)
67 {
67 {
68 PRINTF1("ERR *** in task ACTN *** error receiving a message, code %d \n", status)
68 PRINTF1("ERR *** in task ACTN *** error receiving a message, code %d \n", status)
69 }
69 }
70 else
70 else
71 {
71 {
72 subtype = TC.serviceSubType;
72 subtype = TC.serviceSubType;
73 switch(subtype)
73 switch(subtype)
74 {
74 {
75 case TC_SUBTYPE_RESET:
75 case TC_SUBTYPE_RESET:
76 result = action_reset( &TC, queue_snd_id, time );
76 result = action_reset( &TC, queue_snd_id, time );
77 close_action( &TC, result, queue_snd_id );
77 close_action( &TC, result, queue_snd_id );
78 break;
78 break;
79 case TC_SUBTYPE_LOAD_COMM:
79 case TC_SUBTYPE_LOAD_COMM:
80 result = action_load_common_par( &TC );
80 result = action_load_common_par( &TC );
81 close_action( &TC, result, queue_snd_id );
81 close_action( &TC, result, queue_snd_id );
82 break;
82 break;
83 case TC_SUBTYPE_LOAD_NORM:
83 case TC_SUBTYPE_LOAD_NORM:
84 result = action_load_normal_par( &TC, queue_snd_id, time );
84 result = action_load_normal_par( &TC, queue_snd_id, time );
85 close_action( &TC, result, queue_snd_id );
85 close_action( &TC, result, queue_snd_id );
86 break;
86 break;
87 case TC_SUBTYPE_LOAD_BURST:
87 case TC_SUBTYPE_LOAD_BURST:
88 result = action_load_burst_par( &TC, queue_snd_id, time );
88 result = action_load_burst_par( &TC, queue_snd_id, time );
89 close_action( &TC, result, queue_snd_id );
89 close_action( &TC, result, queue_snd_id );
90 break;
90 break;
91 case TC_SUBTYPE_LOAD_SBM1:
91 case TC_SUBTYPE_LOAD_SBM1:
92 result = action_load_sbm1_par( &TC, queue_snd_id, time );
92 result = action_load_sbm1_par( &TC, queue_snd_id, time );
93 close_action( &TC, result, queue_snd_id );
93 close_action( &TC, result, queue_snd_id );
94 break;
94 break;
95 case TC_SUBTYPE_LOAD_SBM2:
95 case TC_SUBTYPE_LOAD_SBM2:
96 result = action_load_sbm2_par( &TC, queue_snd_id, time );
96 result = action_load_sbm2_par( &TC, queue_snd_id, time );
97 close_action( &TC, result, queue_snd_id );
97 close_action( &TC, result, queue_snd_id );
98 break;
98 break;
99 case TC_SUBTYPE_DUMP:
99 case TC_SUBTYPE_DUMP:
100 result = action_dump_par( &TC, queue_snd_id );
100 result = action_dump_par( &TC, queue_snd_id );
101 close_action( &TC, result, queue_snd_id );
101 close_action( &TC, result, queue_snd_id );
102 break;
102 break;
103 case TC_SUBTYPE_ENTER:
103 case TC_SUBTYPE_ENTER:
104 result = action_enter_mode( &TC, queue_snd_id );
104 result = action_enter_mode( &TC, queue_snd_id );
105 close_action( &TC, result, queue_snd_id );
105 close_action( &TC, result, queue_snd_id );
106 break;
106 break;
107 case TC_SUBTYPE_UPDT_INFO:
107 case TC_SUBTYPE_UPDT_INFO:
108 result = action_update_info( &TC, queue_snd_id );
108 result = action_update_info( &TC, queue_snd_id );
109 close_action( &TC, result, queue_snd_id );
109 close_action( &TC, result, queue_snd_id );
110 break;
110 break;
111 case TC_SUBTYPE_EN_CAL:
111 case TC_SUBTYPE_EN_CAL:
112 result = action_enable_calibration( &TC, queue_snd_id, time );
112 result = action_enable_calibration( &TC, queue_snd_id, time );
113 close_action( &TC, result, queue_snd_id );
113 close_action( &TC, result, queue_snd_id );
114 break;
114 break;
115 case TC_SUBTYPE_DIS_CAL:
115 case TC_SUBTYPE_DIS_CAL:
116 result = action_disable_calibration( &TC, queue_snd_id, time );
116 result = action_disable_calibration( &TC, queue_snd_id, time );
117 close_action( &TC, result, queue_snd_id );
117 close_action( &TC, result, queue_snd_id );
118 break;
118 break;
119 case TC_SUBTYPE_LOAD_K:
119 case TC_SUBTYPE_LOAD_K:
120 result = action_load_kcoefficients( &TC, queue_snd_id, time );
120 result = action_load_kcoefficients( &TC, queue_snd_id, time );
121 close_action( &TC, result, queue_snd_id );
121 close_action( &TC, result, queue_snd_id );
122 break;
122 break;
123 case TC_SUBTYPE_DUMP_K:
123 case TC_SUBTYPE_DUMP_K:
124 result = action_dump_kcoefficients( &TC, queue_snd_id, time );
124 result = action_dump_kcoefficients( &TC, queue_snd_id, time );
125 close_action( &TC, result, queue_snd_id );
125 close_action( &TC, result, queue_snd_id );
126 break;
126 break;
127 case TC_SUBTYPE_LOAD_FBINS:
127 case TC_SUBTYPE_LOAD_FBINS:
128 result = action_load_fbins_mask( &TC, queue_snd_id, time );
128 result = action_load_fbins_mask( &TC, queue_snd_id, time );
129 close_action( &TC, result, queue_snd_id );
129 close_action( &TC, result, queue_snd_id );
130 break;
130 break;
131 case TC_SUBTYPE_LOAD_FILTER_PAR:
131 case TC_SUBTYPE_LOAD_FILTER_PAR:
132 result = action_load_filter_par( &TC, queue_snd_id, time );
132 result = action_load_filter_par( &TC, queue_snd_id, time );
133 close_action( &TC, result, queue_snd_id );
133 close_action( &TC, result, queue_snd_id );
134 break;
134 break;
135 case TC_SUBTYPE_UPDT_TIME:
135 case TC_SUBTYPE_UPDT_TIME:
136 result = action_update_time( &TC );
136 result = action_update_time( &TC );
137 close_action( &TC, result, queue_snd_id );
137 close_action( &TC, result, queue_snd_id );
138 break;
138 break;
139 default:
139 default:
140 break;
140 break;
141 }
141 }
142 }
142 }
143 }
143 }
144 }
144 }
145
145
146 //***********
146 //***********
147 // TC ACTIONS
147 // TC ACTIONS
148
148
149 int action_reset(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
149 int action_reset(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
150 {
150 {
151 /** This function executes specific actions when a TC_LFR_RESET TeleCommand has been received.
151 /** This function executes specific actions when a TC_LFR_RESET TeleCommand has been received.
152 *
152 *
153 * @param TC points to the TeleCommand packet that is being processed
153 * @param TC points to the TeleCommand packet that is being processed
154 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
154 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
155 *
155 *
156 */
156 */
157
157
158 PRINTF("this is the end!!!\n");
158 PRINTF("this is the end!!!\n");
159 exit(0);
159 exit(0);
160
160
161 send_tm_lfr_tc_exe_not_implemented( TC, queue_id, time );
161 send_tm_lfr_tc_exe_not_implemented( TC, queue_id, time );
162
162
163 return LFR_DEFAULT;
163 return LFR_DEFAULT;
164 }
164 }
165
165
166 int action_enter_mode(ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
166 int action_enter_mode(ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
167 {
167 {
168 /** This function executes specific actions when a TC_LFR_ENTER_MODE TeleCommand has been received.
168 /** This function executes specific actions when a TC_LFR_ENTER_MODE TeleCommand has been received.
169 *
169 *
170 * @param TC points to the TeleCommand packet that is being processed
170 * @param TC points to the TeleCommand packet that is being processed
171 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
171 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
172 *
172 *
173 */
173 */
174
174
175 rtems_status_code status;
175 rtems_status_code status;
176 unsigned char requestedMode;
176 unsigned char requestedMode;
177 unsigned int *transitionCoarseTime_ptr;
178 unsigned int transitionCoarseTime;
177 unsigned int transitionCoarseTime;
179 unsigned char * bytePosPtr;
178 unsigned char * bytePosPtr;
180
179
181 printf("(0)\n");
180 printf("(0)\n");
182 bytePosPtr = (unsigned char *) &TC->packetID;
181 bytePosPtr = (unsigned char *) &TC->packetID;
183 printf("(1)\n");
182 printf("(1)\n");
184 requestedMode = bytePosPtr[ BYTE_POS_CP_MODE_LFR_SET ];
183 requestedMode = bytePosPtr[ BYTE_POS_CP_MODE_LFR_SET ];
185 printf("(2)\n");
184 printf("(2)\n");
186 copyInt32ByChar( &transitionCoarseTime, &bytePosPtr[ BYTE_POS_CP_LFR_ENTER_MODE_TIME ] );
185 copyInt32ByChar( (char*) &transitionCoarseTime, &bytePosPtr[ BYTE_POS_CP_LFR_ENTER_MODE_TIME ] );
187 printf("(3)\n");
186 printf("(3)\n");
188 transitionCoarseTime = transitionCoarseTime & COARSE_TIME_MASK;
187 transitionCoarseTime = transitionCoarseTime & COARSE_TIME_MASK;
189 printf("(4)\n");
188 printf("(4)\n");
190 status = check_mode_value( requestedMode );
189 status = check_mode_value( requestedMode );
191 printf("(5)\n");
190 printf("(5)\n");
192
191
193 if ( status != LFR_SUCCESSFUL ) // the mode value is inconsistent
192 if ( status != LFR_SUCCESSFUL ) // the mode value is inconsistent
194 {
193 {
195 send_tm_lfr_tc_exe_inconsistent( TC, queue_id, BYTE_POS_CP_MODE_LFR_SET, requestedMode );
194 send_tm_lfr_tc_exe_inconsistent( TC, queue_id, BYTE_POS_CP_MODE_LFR_SET, requestedMode );
196 }
195 }
197
196
198 else // the mode value is valid, check the transition
197 else // the mode value is valid, check the transition
199 {
198 {
200 status = check_mode_transition(requestedMode);
199 status = check_mode_transition(requestedMode);
201 if (status != LFR_SUCCESSFUL)
200 if (status != LFR_SUCCESSFUL)
202 {
201 {
203 PRINTF("ERR *** in action_enter_mode *** check_mode_transition\n")
202 PRINTF("ERR *** in action_enter_mode *** check_mode_transition\n")
204 send_tm_lfr_tc_exe_not_executable( TC, queue_id );
203 send_tm_lfr_tc_exe_not_executable( TC, queue_id );
205 }
204 }
206 }
205 }
207
206
208 if ( status == LFR_SUCCESSFUL ) // the transition is valid, check the date
207 if ( status == LFR_SUCCESSFUL ) // the transition is valid, check the date
209 {
208 {
210 status = check_transition_date( transitionCoarseTime );
209 status = check_transition_date( transitionCoarseTime );
211 if (status != LFR_SUCCESSFUL)
210 if (status != LFR_SUCCESSFUL)
212 {
211 {
213 PRINTF("ERR *** in action_enter_mode *** check_transition_date\n");
212 PRINTF("ERR *** in action_enter_mode *** check_transition_date\n");
214 send_tm_lfr_tc_exe_not_executable(TC, queue_id );
213 send_tm_lfr_tc_exe_not_executable(TC, queue_id );
215 }
214 }
216 }
215 }
217
216
218 if ( status == LFR_SUCCESSFUL ) // the date is valid, enter the mode
217 if ( status == LFR_SUCCESSFUL ) // the date is valid, enter the mode
219 {
218 {
220 PRINTF1("OK *** in action_enter_mode *** enter mode %d\n", requestedMode);
219 PRINTF1("OK *** in action_enter_mode *** enter mode %d\n", requestedMode);
221
220
222 switch(requestedMode)
221 switch(requestedMode)
223 {
222 {
224 case LFR_MODE_STANDBY:
223 case LFR_MODE_STANDBY:
225 status = enter_mode_standby();
224 status = enter_mode_standby();
226 break;
225 break;
227 case LFR_MODE_NORMAL:
226 case LFR_MODE_NORMAL:
228 status = enter_mode_normal( transitionCoarseTime );
227 status = enter_mode_normal( transitionCoarseTime );
229 break;
228 break;
230 case LFR_MODE_BURST:
229 case LFR_MODE_BURST:
231 status = enter_mode_burst( transitionCoarseTime );
230 status = enter_mode_burst( transitionCoarseTime );
232 break;
231 break;
233 case LFR_MODE_SBM1:
232 case LFR_MODE_SBM1:
234 status = enter_mode_sbm1( transitionCoarseTime );
233 status = enter_mode_sbm1( transitionCoarseTime );
235 break;
234 break;
236 case LFR_MODE_SBM2:
235 case LFR_MODE_SBM2:
237 status = enter_mode_sbm2( transitionCoarseTime );
236 status = enter_mode_sbm2( transitionCoarseTime );
238 break;
237 break;
239 default:
238 default:
240 break;
239 break;
241 }
240 }
242
241
243 if (status != RTEMS_SUCCESSFUL)
242 if (status != RTEMS_SUCCESSFUL)
244 {
243 {
245 status = LFR_EXE_ERROR;
244 status = LFR_EXE_ERROR;
246 }
245 }
247 }
246 }
248
247
249 return status;
248 return status;
250 }
249 }
251
250
252 int action_update_info(ccsdsTelecommandPacket_t *TC, rtems_id queue_id)
251 int action_update_info(ccsdsTelecommandPacket_t *TC, rtems_id queue_id)
253 {
252 {
254 /** This function executes specific actions when a TC_LFR_UPDATE_INFO TeleCommand has been received.
253 /** This function executes specific actions when a TC_LFR_UPDATE_INFO TeleCommand has been received.
255 *
254 *
256 * @param TC points to the TeleCommand packet that is being processed
255 * @param TC points to the TeleCommand packet that is being processed
257 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
256 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
258 *
257 *
259 * @return LFR directive status code:
258 * @return LFR directive status code:
260 * - LFR_DEFAULT
259 * - LFR_DEFAULT
261 * - LFR_SUCCESSFUL
260 * - LFR_SUCCESSFUL
262 *
261 *
263 */
262 */
264
263
265 unsigned int val;
264 unsigned int val;
266 int result;
265 int result;
267 unsigned int status;
266 unsigned int status;
268 unsigned char mode;
267 unsigned char mode;
269 unsigned char * bytePosPtr;
268 unsigned char * bytePosPtr;
270
269
271 bytePosPtr = (unsigned char *) &TC->packetID;
270 bytePosPtr = (unsigned char *) &TC->packetID;
272
271
273 // check LFR mode
272 // check LFR mode
274 mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET5 ] & BITS_LFR_MODE) >> SHIFT_LFR_MODE;
273 mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET5 ] & BITS_LFR_MODE) >> SHIFT_LFR_MODE;
275 status = check_update_info_hk_lfr_mode( mode );
274 status = check_update_info_hk_lfr_mode( mode );
276 if (status == LFR_SUCCESSFUL) // check TDS mode
275 if (status == LFR_SUCCESSFUL) // check TDS mode
277 {
276 {
278 mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET6 ] & BITS_TDS_MODE) >> SHIFT_TDS_MODE;
277 mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET6 ] & BITS_TDS_MODE) >> SHIFT_TDS_MODE;
279 status = check_update_info_hk_tds_mode( mode );
278 status = check_update_info_hk_tds_mode( mode );
280 }
279 }
281 if (status == LFR_SUCCESSFUL) // check THR mode
280 if (status == LFR_SUCCESSFUL) // check THR mode
282 {
281 {
283 mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET6 ] & BITS_THR_MODE);
282 mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET6 ] & BITS_THR_MODE);
284 status = check_update_info_hk_thr_mode( mode );
283 status = check_update_info_hk_thr_mode( mode );
285 }
284 }
286 if (status == LFR_SUCCESSFUL) // if the parameter check is successful
285 if (status == LFR_SUCCESSFUL) // if the parameter check is successful
287 {
286 {
288 val = (housekeeping_packet.hk_lfr_update_info_tc_cnt[0] * CONST_256)
287 val = (housekeeping_packet.hk_lfr_update_info_tc_cnt[0] * CONST_256)
289 + housekeeping_packet.hk_lfr_update_info_tc_cnt[1];
288 + housekeeping_packet.hk_lfr_update_info_tc_cnt[1];
290 val++;
289 val++;
291 housekeeping_packet.hk_lfr_update_info_tc_cnt[0] = (unsigned char) (val >> SHIFT_1_BYTE);
290 housekeeping_packet.hk_lfr_update_info_tc_cnt[0] = (unsigned char) (val >> SHIFT_1_BYTE);
292 housekeeping_packet.hk_lfr_update_info_tc_cnt[1] = (unsigned char) (val);
291 housekeeping_packet.hk_lfr_update_info_tc_cnt[1] = (unsigned char) (val);
293 }
292 }
294
293
295 // pa_bia_status_info
294 // pa_bia_status_info
296 // => pa_bia_mode_mux_set 3 bits
295 // => pa_bia_mode_mux_set 3 bits
297 // => pa_bia_mode_hv_enabled 1 bit
296 // => pa_bia_mode_hv_enabled 1 bit
298 // => pa_bia_mode_bias1_enabled 1 bit
297 // => pa_bia_mode_bias1_enabled 1 bit
299 // => pa_bia_mode_bias2_enabled 1 bit
298 // => pa_bia_mode_bias2_enabled 1 bit
300 // => pa_bia_mode_bias3_enabled 1 bit
299 // => pa_bia_mode_bias3_enabled 1 bit
301 // => pa_bia_on_off (cp_dpu_bias_on_off)
300 // => pa_bia_on_off (cp_dpu_bias_on_off)
302 pa_bia_status_info = bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET2 ] & BITS_BIA; // [1111 1110]
301 pa_bia_status_info = bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET2 ] & BITS_BIA; // [1111 1110]
303 pa_bia_status_info = pa_bia_status_info
302 pa_bia_status_info = pa_bia_status_info
304 | (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET1 ] & 1);
303 | (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET1 ] & 1);
305
304
306 // REACTION_WHEELS_FREQUENCY, copy the incoming parameters in the local variable (to be copied in HK packets)
305 // REACTION_WHEELS_FREQUENCY, copy the incoming parameters in the local variable (to be copied in HK packets)
307
306
308 cp_rpw_sc_rw_f_flags = bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW_F_FLAGS ];
307 cp_rpw_sc_rw_f_flags = bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW_F_FLAGS ];
309 getReactionWheelsFrequencies( TC );
308 getReactionWheelsFrequencies( TC );
310 build_sy_lfr_rw_masks();
309 build_sy_lfr_rw_masks();
311
310
312 // once the masks are built, they have to be merged with the fbins_mask
311 // once the masks are built, they have to be merged with the fbins_mask
313 merge_fbins_masks();
312 merge_fbins_masks();
314
313
315 result = status;
314 result = status;
316
315
317 return result;
316 return result;
318 }
317 }
319
318
320 int action_enable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
319 int action_enable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
321 {
320 {
322 /** This function executes specific actions when a TC_LFR_ENABLE_CALIBRATION TeleCommand has been received.
321 /** This function executes specific actions when a TC_LFR_ENABLE_CALIBRATION TeleCommand has been received.
323 *
322 *
324 * @param TC points to the TeleCommand packet that is being processed
323 * @param TC points to the TeleCommand packet that is being processed
325 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
324 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
326 *
325 *
327 */
326 */
328
327
329 int result;
328 int result;
330
329
331 result = LFR_DEFAULT;
330 result = LFR_DEFAULT;
332
331
333 setCalibration( true );
332 setCalibration( true );
334
333
335 result = LFR_SUCCESSFUL;
334 result = LFR_SUCCESSFUL;
336
335
337 return result;
336 return result;
338 }
337 }
339
338
340 int action_disable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
339 int action_disable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
341 {
340 {
342 /** This function executes specific actions when a TC_LFR_DISABLE_CALIBRATION TeleCommand has been received.
341 /** This function executes specific actions when a TC_LFR_DISABLE_CALIBRATION TeleCommand has been received.
343 *
342 *
344 * @param TC points to the TeleCommand packet that is being processed
343 * @param TC points to the TeleCommand packet that is being processed
345 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
344 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
346 *
345 *
347 */
346 */
348
347
349 int result;
348 int result;
350
349
351 result = LFR_DEFAULT;
350 result = LFR_DEFAULT;
352
351
353 setCalibration( false );
352 setCalibration( false );
354
353
355 result = LFR_SUCCESSFUL;
354 result = LFR_SUCCESSFUL;
356
355
357 return result;
356 return result;
358 }
357 }
359
358
360 int action_update_time(ccsdsTelecommandPacket_t *TC)
359 int action_update_time(ccsdsTelecommandPacket_t *TC)
361 {
360 {
362 /** This function executes specific actions when a TC_LFR_UPDATE_TIME TeleCommand has been received.
361 /** This function executes specific actions when a TC_LFR_UPDATE_TIME TeleCommand has been received.
363 *
362 *
364 * @param TC points to the TeleCommand packet that is being processed
363 * @param TC points to the TeleCommand packet that is being processed
365 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
364 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
366 *
365 *
367 * @return LFR_SUCCESSFUL
366 * @return LFR_SUCCESSFUL
368 *
367 *
369 */
368 */
370
369
371 unsigned int val;
370 unsigned int val;
372
371
373 time_management_regs->coarse_time_load = (TC->dataAndCRC[BYTE_0] << SHIFT_3_BYTES)
372 time_management_regs->coarse_time_load = (TC->dataAndCRC[BYTE_0] << SHIFT_3_BYTES)
374 + (TC->dataAndCRC[BYTE_1] << SHIFT_2_BYTES)
373 + (TC->dataAndCRC[BYTE_1] << SHIFT_2_BYTES)
375 + (TC->dataAndCRC[BYTE_2] << SHIFT_1_BYTE)
374 + (TC->dataAndCRC[BYTE_2] << SHIFT_1_BYTE)
376 + TC->dataAndCRC[BYTE_3];
375 + TC->dataAndCRC[BYTE_3];
377
376
378 val = (housekeeping_packet.hk_lfr_update_time_tc_cnt[0] * CONST_256)
377 val = (housekeeping_packet.hk_lfr_update_time_tc_cnt[0] * CONST_256)
379 + housekeeping_packet.hk_lfr_update_time_tc_cnt[1];
378 + housekeeping_packet.hk_lfr_update_time_tc_cnt[1];
380 val++;
379 val++;
381 housekeeping_packet.hk_lfr_update_time_tc_cnt[0] = (unsigned char) (val >> SHIFT_1_BYTE);
380 housekeeping_packet.hk_lfr_update_time_tc_cnt[0] = (unsigned char) (val >> SHIFT_1_BYTE);
382 housekeeping_packet.hk_lfr_update_time_tc_cnt[1] = (unsigned char) (val);
381 housekeeping_packet.hk_lfr_update_time_tc_cnt[1] = (unsigned char) (val);
383
382
384 oneTcLfrUpdateTimeReceived = 1;
383 oneTcLfrUpdateTimeReceived = 1;
385
384
386 return LFR_SUCCESSFUL;
385 return LFR_SUCCESSFUL;
387 }
386 }
388
387
389 //*******************
388 //*******************
390 // ENTERING THE MODES
389 // ENTERING THE MODES
391 int check_mode_value( unsigned char requestedMode )
390 int check_mode_value( unsigned char requestedMode )
392 {
391 {
393 int status;
392 int status;
394
393
395 status = LFR_DEFAULT;
394 status = LFR_DEFAULT;
396
395
397 if ( (requestedMode != LFR_MODE_STANDBY)
396 if ( (requestedMode