##// END OF EJS Templates
Modification of the launch of NORMAL, SBM1 and SBM2 modes
paul -
r238:3412b0dcc87a R3
parent child
Show More
@@ -1,2 +1,2
1 3081d1f9bb20b2b64a192585337a292a9804e0c5 LFR_basic-parameters
1 3081d1f9bb20b2b64a192585337a292a9804e0c5 LFR_basic-parameters
2 07e22c5c44daa84954a10db557a74b8c8dd2d014 header/lfr_common_headers
2 e1bf35e31e3c8c1d1448d2e485c71f5f1259615c header/lfr_common_headers
@@ -1,112 +1,112
1 TEMPLATE = app
1 TEMPLATE = app
2 # CONFIG += console v8 sim
2 # CONFIG += console v8 sim
3 # CONFIG options = verbose *** boot_messages *** debug_messages *** cpu_usage_report *** stack_report *** vhdl_dev *** debug_tch
3 # CONFIG options = verbose *** boot_messages *** debug_messages *** cpu_usage_report *** stack_report *** vhdl_dev *** debug_tch
4 # lpp_dpu_destid
4 # lpp_dpu_destid
5 CONFIG += console verbose lpp_dpu_destid cpu_usage_report stack_report
5 CONFIG += console verbose lpp_dpu_destid cpu_usage_report stack_report
6 CONFIG -= qt
6 CONFIG -= qt
7
7
8 include(./sparc.pri)
8 include(./sparc.pri)
9
9
10 # flight software version
10 # flight software version
11 SWVERSION=-1-0
11 SWVERSION=-1-0
12 DEFINES += SW_VERSION_N1=3 # major
12 DEFINES += SW_VERSION_N1=3 # major
13 DEFINES += SW_VERSION_N2=0 # minor
13 DEFINES += SW_VERSION_N2=0 # minor
14 DEFINES += SW_VERSION_N3=0 # patch
14 DEFINES += SW_VERSION_N3=0 # patch
15 DEFINES += SW_VERSION_N4=12 # internal
15 DEFINES += SW_VERSION_N4=13 # internal
16
16
17 # <GCOV>
17 # <GCOV>
18 #QMAKE_CFLAGS_RELEASE += -fprofile-arcs -ftest-coverage
18 #QMAKE_CFLAGS_RELEASE += -fprofile-arcs -ftest-coverage
19 #LIBS += -lgcov /opt/GCOV/01A/lib/overload.o -lc
19 #LIBS += -lgcov /opt/GCOV/01A/lib/overload.o -lc
20 # </GCOV>
20 # </GCOV>
21
21
22 # <CHANGE BEFORE FLIGHT>
22 # <CHANGE BEFORE FLIGHT>
23 contains( CONFIG, lpp_dpu_destid ) {
23 contains( CONFIG, lpp_dpu_destid ) {
24 DEFINES += LPP_DPU_DESTID
24 DEFINES += LPP_DPU_DESTID
25 }
25 }
26 # </CHANGE BEFORE FLIGHT>
26 # </CHANGE BEFORE FLIGHT>
27
27
28 contains( CONFIG, debug_tch ) {
28 contains( CONFIG, debug_tch ) {
29 DEFINES += DEBUG_TCH
29 DEFINES += DEBUG_TCH
30 }
30 }
31 DEFINES += MSB_FIRST_TCH
31 DEFINES += MSB_FIRST_TCH
32
32
33 contains( CONFIG, vhdl_dev ) {
33 contains( CONFIG, vhdl_dev ) {
34 DEFINES += VHDL_DEV
34 DEFINES += VHDL_DEV
35 }
35 }
36
36
37 contains( CONFIG, verbose ) {
37 contains( CONFIG, verbose ) {
38 DEFINES += PRINT_MESSAGES_ON_CONSOLE
38 DEFINES += PRINT_MESSAGES_ON_CONSOLE
39 }
39 }
40
40
41 contains( CONFIG, debug_messages ) {
41 contains( CONFIG, debug_messages ) {
42 DEFINES += DEBUG_MESSAGES
42 DEFINES += DEBUG_MESSAGES
43 }
43 }
44
44
45 contains( CONFIG, cpu_usage_report ) {
45 contains( CONFIG, cpu_usage_report ) {
46 DEFINES += PRINT_TASK_STATISTICS
46 DEFINES += PRINT_TASK_STATISTICS
47 }
47 }
48
48
49 contains( CONFIG, stack_report ) {
49 contains( CONFIG, stack_report ) {
50 DEFINES += PRINT_STACK_REPORT
50 DEFINES += PRINT_STACK_REPORT
51 }
51 }
52
52
53 contains( CONFIG, boot_messages ) {
53 contains( CONFIG, boot_messages ) {
54 DEFINES += BOOT_MESSAGES
54 DEFINES += BOOT_MESSAGES
55 }
55 }
56
56
57 #doxygen.target = doxygen
57 #doxygen.target = doxygen
58 #doxygen.commands = doxygen ../doc/Doxyfile
58 #doxygen.commands = doxygen ../doc/Doxyfile
59 #QMAKE_EXTRA_TARGETS += doxygen
59 #QMAKE_EXTRA_TARGETS += doxygen
60
60
61 TARGET = fsw
61 TARGET = fsw
62
62
63 INCLUDEPATH += \
63 INCLUDEPATH += \
64 $${PWD}/../src \
64 $${PWD}/../src \
65 $${PWD}/../header \
65 $${PWD}/../header \
66 $${PWD}/../header/lfr_common_headers \
66 $${PWD}/../header/lfr_common_headers \
67 $${PWD}/../header/processing \
67 $${PWD}/../header/processing \
68 $${PWD}/../LFR_basic-parameters
68 $${PWD}/../LFR_basic-parameters
69
69
70 SOURCES += \
70 SOURCES += \
71 ../src/wf_handler.c \
71 ../src/wf_handler.c \
72 ../src/tc_handler.c \
72 ../src/tc_handler.c \
73 ../src/fsw_misc.c \
73 ../src/fsw_misc.c \
74 ../src/fsw_init.c \
74 ../src/fsw_init.c \
75 ../src/fsw_globals.c \
75 ../src/fsw_globals.c \
76 ../src/fsw_spacewire.c \
76 ../src/fsw_spacewire.c \
77 ../src/tc_load_dump_parameters.c \
77 ../src/tc_load_dump_parameters.c \
78 ../src/tm_lfr_tc_exe.c \
78 ../src/tm_lfr_tc_exe.c \
79 ../src/tc_acceptance.c \
79 ../src/tc_acceptance.c \
80 ../src/processing/fsw_processing.c \
80 ../src/processing/fsw_processing.c \
81 ../src/processing/avf0_prc0.c \
81 ../src/processing/avf0_prc0.c \
82 ../src/processing/avf1_prc1.c \
82 ../src/processing/avf1_prc1.c \
83 ../src/processing/avf2_prc2.c \
83 ../src/processing/avf2_prc2.c \
84 ../src/lfr_cpu_usage_report.c \
84 ../src/lfr_cpu_usage_report.c \
85 ../LFR_basic-parameters/basic_parameters.c
85 ../LFR_basic-parameters/basic_parameters.c
86
86
87 HEADERS += \
87 HEADERS += \
88 ../header/wf_handler.h \
88 ../header/wf_handler.h \
89 ../header/tc_handler.h \
89 ../header/tc_handler.h \
90 ../header/grlib_regs.h \
90 ../header/grlib_regs.h \
91 ../header/fsw_misc.h \
91 ../header/fsw_misc.h \
92 ../header/fsw_init.h \
92 ../header/fsw_init.h \
93 ../header/fsw_spacewire.h \
93 ../header/fsw_spacewire.h \
94 ../header/tc_load_dump_parameters.h \
94 ../header/tc_load_dump_parameters.h \
95 ../header/tm_lfr_tc_exe.h \
95 ../header/tm_lfr_tc_exe.h \
96 ../header/tc_acceptance.h \
96 ../header/tc_acceptance.h \
97 ../header/processing/fsw_processing.h \
97 ../header/processing/fsw_processing.h \
98 ../header/processing/avf0_prc0.h \
98 ../header/processing/avf0_prc0.h \
99 ../header/processing/avf1_prc1.h \
99 ../header/processing/avf1_prc1.h \
100 ../header/processing/avf2_prc2.h \
100 ../header/processing/avf2_prc2.h \
101 ../header/fsw_params_wf_handler.h \
101 ../header/fsw_params_wf_handler.h \
102 ../header/lfr_cpu_usage_report.h \
102 ../header/lfr_cpu_usage_report.h \
103 ../header/lfr_common_headers/ccsds_types.h \
103 ../header/lfr_common_headers/ccsds_types.h \
104 ../header/lfr_common_headers/fsw_params.h \
104 ../header/lfr_common_headers/fsw_params.h \
105 ../header/lfr_common_headers/fsw_params_nb_bytes.h \
105 ../header/lfr_common_headers/fsw_params_nb_bytes.h \
106 ../header/lfr_common_headers/fsw_params_processing.h \
106 ../header/lfr_common_headers/fsw_params_processing.h \
107 ../header/lfr_common_headers/TC_types.h \
107 ../header/lfr_common_headers/TC_types.h \
108 ../header/lfr_common_headers/tm_byte_positions.h \
108 ../header/lfr_common_headers/tm_byte_positions.h \
109 ../LFR_basic-parameters/basic_parameters.h \
109 ../LFR_basic-parameters/basic_parameters.h \
110 ../LFR_basic-parameters/basic_parameters_params.h \
110 ../LFR_basic-parameters/basic_parameters_params.h \
111 ../header/GscMemoryLPP.hpp
111 ../header/GscMemoryLPP.hpp
112
112
@@ -1,75 +1,77
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 //****
15 //****
16 // ISR
16 // ISR
17 rtems_isr commutation_isr1( rtems_vector_number vector );
17 rtems_isr commutation_isr1( rtems_vector_number vector );
18 rtems_isr commutation_isr2( rtems_vector_number vector );
18 rtems_isr commutation_isr2( rtems_vector_number vector );
19
19
20 //***********
20 //***********
21 // RTEMS TASK
21 // RTEMS TASK
22 rtems_task actn_task( rtems_task_argument unused );
22 rtems_task actn_task( rtems_task_argument unused );
23
23
24 //***********
24 //***********
25 // TC ACTIONS
25 // TC ACTIONS
26 int action_reset( ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time );
26 int action_reset( ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time );
27 int action_enter_mode(ccsdsTelecommandPacket_t *TC, rtems_id queue_id);
27 int action_enter_mode(ccsdsTelecommandPacket_t *TC, rtems_id queue_id);
28 int action_update_info( ccsdsTelecommandPacket_t *TC, rtems_id queue_id );
28 int action_update_info( ccsdsTelecommandPacket_t *TC, rtems_id queue_id );
29 int action_enable_calibration( ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time );
29 int action_enable_calibration( ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time );
30 int action_disable_calibration( ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time );
30 int action_disable_calibration( ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time );
31 int action_update_time( ccsdsTelecommandPacket_t *TC);
31 int action_update_time( ccsdsTelecommandPacket_t *TC);
32
32
33 // mode transition
33 // mode transition
34 int check_mode_value( unsigned char requestedMode );
34 int check_mode_value( unsigned char requestedMode );
35 int check_mode_transition( unsigned char requestedMode );
35 int check_mode_transition( unsigned char requestedMode );
36 int check_transition_date( unsigned int transitionCoarseTime );
36 int check_transition_date( unsigned int transitionCoarseTime );
37 int stop_spectral_matrices( void );
37 int stop_current_mode( void );
38 int stop_current_mode( void );
38 int enter_mode_standby( void );
39 int enter_mode_standby( void );
39 int enter_mode_normal( unsigned int transitionCoarseTime );
40 int enter_mode_normal( unsigned int transitionCoarseTime );
40 int enter_mode_burst( unsigned int transitionCoarseTime );
41 int enter_mode_burst( unsigned int transitionCoarseTime );
41 int enter_mode_sbm1( unsigned int transitionCoarseTime );
42 int enter_mode_sbm1( unsigned int transitionCoarseTime );
42 int enter_mode_sbm2( unsigned int transitionCoarseTime );
43 int enter_mode_sbm2( unsigned int transitionCoarseTime );
43 int restart_science_tasks( unsigned char lfrRequestedMode );
44 int restart_science_tasks( unsigned char lfrRequestedMode );
44 int suspend_science_tasks();
45 int restart_asm_tasks(unsigned char lfrRequestedMode );
46 int suspend_science_tasks(void);
47 int suspend_asm_tasks( void );
45 void launch_waveform_picker( unsigned char mode , unsigned int transitionCoarseTime );
48 void launch_waveform_picker( unsigned char mode , unsigned int transitionCoarseTime );
46 void launch_spectral_matrix( void );
49 void launch_spectral_matrix( void );
47 void launch_spectral_matrix_simu( void );
48 void set_sm_irq_onNewMatrix( unsigned char value );
50 void set_sm_irq_onNewMatrix( unsigned char value );
49 void set_sm_irq_onError( unsigned char value );
51 void set_sm_irq_onError( unsigned char value );
50
52
51 // other functions
53 // other functions
52 void updateLFRCurrentMode();
54 void updateLFRCurrentMode();
53 void set_lfr_soft_reset( unsigned char value );
55 void set_lfr_soft_reset( unsigned char value );
54 void reset_lfr( void );
56 void reset_lfr( void );
55 // CALIBRATION
57 // CALIBRATION
56 void setCalibrationPrescaler( unsigned int prescaler );
58 void setCalibrationPrescaler( unsigned int prescaler );
57 void setCalibrationDivisor( unsigned int divisionFactor );
59 void setCalibrationDivisor( unsigned int divisionFactor );
58 void setCalibrationData( void );
60 void setCalibrationData( void );
59 void setCalibrationReload( bool state);
61 void setCalibrationReload( bool state);
60 void setCalibrationEnable( bool state );
62 void setCalibrationEnable( bool state );
61 void setCalibrationInterleaved( bool state );
63 void setCalibrationInterleaved( bool state );
62 void setCalibration( bool state );
64 void setCalibration( bool state );
63 void configureCalibration( bool interleaved );
65 void configureCalibration( bool interleaved );
64 //
66 //
65 void update_last_TC_exe( ccsdsTelecommandPacket_t *TC , unsigned char *time );
67 void update_last_TC_exe( ccsdsTelecommandPacket_t *TC , unsigned char *time );
66 void update_last_TC_rej(ccsdsTelecommandPacket_t *TC , unsigned char *time );
68 void update_last_TC_rej(ccsdsTelecommandPacket_t *TC , unsigned char *time );
67 void close_action( ccsdsTelecommandPacket_t *TC, int result, rtems_id queue_id );
69 void close_action( ccsdsTelecommandPacket_t *TC, int result, rtems_id queue_id );
68
70
69 extern rtems_status_code get_message_queue_id_send( rtems_id *queue_id );
71 extern rtems_status_code get_message_queue_id_send( rtems_id *queue_id );
70 extern rtems_status_code get_message_queue_id_recv( rtems_id *queue_id );
72 extern rtems_status_code get_message_queue_id_recv( rtems_id *queue_id );
71
73
72 #endif // TC_HANDLER_H_INCLUDED
74 #endif // TC_HANDLER_H_INCLUDED
73
75
74
76
75
77
@@ -1,86 +1,87
1 #ifndef WF_HANDLER_H_INCLUDED
1 #ifndef WF_HANDLER_H_INCLUDED
2 #define WF_HANDLER_H_INCLUDED
2 #define WF_HANDLER_H_INCLUDED
3
3
4 #include <rtems.h>
4 #include <rtems.h>
5 #include <grspw.h>
5 #include <grspw.h>
6 #include <stdio.h>
6 #include <stdio.h>
7 #include <math.h>
7 #include <math.h>
8 #include <fsw_params.h>
8 #include <fsw_params.h>
9
9
10 #include "fsw_init.h"
10 #include "fsw_init.h"
11 #include "fsw_params_wf_handler.h"
11 #include "fsw_params_wf_handler.h"
12
12
13 #define pi 3.14159265359
13 #define pi 3.14159265359
14
14
15 extern int fdSPW;
15 extern int fdSPW;
16
16
17 //*****************
17 //*****************
18 // waveform buffers
18 // waveform buffers
19 extern volatile int wf_buffer_f0[ ];
19 extern volatile int wf_buffer_f0[ ];
20 extern volatile int wf_buffer_f1[ ];
20 extern volatile int wf_buffer_f1[ ];
21 extern volatile int wf_buffer_f2[ ];
21 extern volatile int wf_buffer_f2[ ];
22 extern volatile int wf_buffer_f3[ ];
22 extern volatile int wf_buffer_f3[ ];
23
23
24 extern waveform_picker_regs_0_1_18_t *waveform_picker_regs;
24 extern waveform_picker_regs_0_1_18_t *waveform_picker_regs;
25 extern time_management_regs_t *time_management_regs;
25 extern time_management_regs_t *time_management_regs;
26 extern Packet_TM_LFR_HK_t housekeeping_packet;
26 extern Packet_TM_LFR_HK_t housekeeping_packet;
27 extern Packet_TM_LFR_PARAMETER_DUMP_t parameter_dump_packet;
27 extern Packet_TM_LFR_PARAMETER_DUMP_t parameter_dump_packet;
28 extern struct param_local_str param_local;
28 extern struct param_local_str param_local;
29
29
30 extern unsigned short sequenceCounters_SCIENCE_NORMAL_BURST;
30 extern unsigned short sequenceCounters_SCIENCE_NORMAL_BURST;
31 extern unsigned short sequenceCounters_SCIENCE_SBM1_SBM2;
31 extern unsigned short sequenceCounters_SCIENCE_SBM1_SBM2;
32
32
33 extern rtems_id Task_id[20]; /* array of task ids */
33 extern rtems_id Task_id[20]; /* array of task ids */
34
34
35 extern unsigned char lfrCurrentMode;
35 extern unsigned char lfrCurrentMode;
36
36
37 //**********
37 //**********
38 // RTEMS_ISR
38 // RTEMS_ISR
39 void reset_extractSWF( void );
39 void reset_extractSWF( void );
40 rtems_isr waveforms_isr( rtems_vector_number vector );
40 rtems_isr waveforms_isr( rtems_vector_number vector );
41
41
42 //***********
42 //***********
43 // RTEMS_TASK
43 // RTEMS_TASK
44 rtems_task wfrm_task( rtems_task_argument argument );
44 rtems_task wfrm_task( rtems_task_argument argument );
45 rtems_task cwf3_task( rtems_task_argument argument );
45 rtems_task cwf3_task( rtems_task_argument argument );
46 rtems_task cwf2_task( rtems_task_argument argument );
46 rtems_task cwf2_task( rtems_task_argument argument );
47 rtems_task cwf1_task( rtems_task_argument argument );
47 rtems_task cwf1_task( rtems_task_argument argument );
48 rtems_task swbd_task( rtems_task_argument argument );
48 rtems_task swbd_task( rtems_task_argument argument );
49
49
50 //******************
50 //******************
51 // general functions
51 // general functions
52 void WFP_init_rings( void );
52 void WFP_init_rings( void );
53 void init_ring( ring_node ring[], unsigned char nbNodes, volatile int buffer[] , unsigned int bufferSize );
53 void init_ring( ring_node ring[], unsigned char nbNodes, volatile int buffer[] , unsigned int bufferSize );
54 void WFP_reset_current_ring_nodes( void );
54 void WFP_reset_current_ring_nodes( void );
55 //
55 //
56 int init_header_continuous_cwf3_light_table( Header_TM_LFR_SCIENCE_CWF_t *headerCWF );
56 int init_header_continuous_cwf3_light_table( Header_TM_LFR_SCIENCE_CWF_t *headerCWF );
57 //
57 //
58 int send_waveform_CWF3_light(ring_node *ring_node_to_send, ring_node *ring_node_cwf3_light, rtems_id queue_id );
58 int send_waveform_CWF3_light(ring_node *ring_node_to_send, ring_node *ring_node_cwf3_light, rtems_id queue_id );
59 //
59 //
60 void compute_acquisition_time(unsigned int coarseTime, unsigned int fineTime,
60 void compute_acquisition_time(unsigned int coarseTime, unsigned int fineTime,
61 unsigned int sid, unsigned char pa_lfr_pkt_nr, unsigned char *acquisitionTime );
61 unsigned int sid, unsigned char pa_lfr_pkt_nr, unsigned char *acquisitionTime );
62 void build_snapshot_from_ring(ring_node *ring_node_to_send, unsigned char frequencyChannel , unsigned long long acquisitionTimeF0_asLong);
62 void build_snapshot_from_ring(ring_node *ring_node_to_send, unsigned char frequencyChannel ,
63 unsigned long long acquisitionTimeF0_asLong, ring_node *ring_node_swf_extracted, int *swf_extracted);
63 void snapshot_resynchronization( unsigned char *timePtr );
64 void snapshot_resynchronization( unsigned char *timePtr );
64 //
65 //
65 rtems_id get_pkts_queue_id( void );
66 rtems_id get_pkts_queue_id( void );
66
67
67 //**************
68 //**************
68 // wfp registers
69 // wfp registers
69 // RESET
70 // RESET
70 void reset_wfp_burst_enable( void );
71 void reset_wfp_burst_enable( void );
71 void reset_wfp_status( void );
72 void reset_wfp_status( void );
72 void reset_wfp_buffer_addresses( void );
73 void reset_wfp_buffer_addresses( void );
73 void reset_waveform_picker_regs( void );
74 void reset_waveform_picker_regs( void );
74 // SET
75 // SET
75 void set_wfp_data_shaping(void);
76 void set_wfp_data_shaping(void);
76 void set_wfp_burst_enable_register( unsigned char mode );
77 void set_wfp_burst_enable_register( unsigned char mode );
77 void set_wfp_delta_snapshot( void );
78 void set_wfp_delta_snapshot( void );
78 void set_wfp_delta_f0_f0_2( void );
79 void set_wfp_delta_f0_f0_2( void );
79 void set_wfp_delta_f1( void );
80 void set_wfp_delta_f1( void );
80 void set_wfp_delta_f2( void );
81 void set_wfp_delta_f2( void );
81
82
82 //*****************
83 //*****************
83 // local parameters
84 // local parameters
84 void increment_seq_counter_source_id( unsigned char *packet_sequence_control, unsigned int sid );
85 void increment_seq_counter_source_id( unsigned char *packet_sequence_control, unsigned int sid );
85
86
86 #endif // WF_HANDLER_H_INCLUDED
87 #endif // WF_HANDLER_H_INCLUDED
@@ -1,872 +1,872
1 /** This is the RTEMS initialization module.
1 /** This is the RTEMS initialization module.
2 *
2 *
3 * @file
3 * @file
4 * @author P. LEROY
4 * @author P. LEROY
5 *
5 *
6 * This module contains two very different information:
6 * This module contains two very different information:
7 * - specific instructions to configure the compilation of the RTEMS executive
7 * - specific instructions to configure the compilation of the RTEMS executive
8 * - functions related to the fligth softwre initialization, especially the INIT RTEMS task
8 * - functions related to the fligth softwre initialization, especially the INIT RTEMS task
9 *
9 *
10 */
10 */
11
11
12 //*************************
12 //*************************
13 // GPL reminder to be added
13 // GPL reminder to be added
14 //*************************
14 //*************************
15
15
16 #include <rtems.h>
16 #include <rtems.h>
17
17
18 /* configuration information */
18 /* configuration information */
19
19
20 #define CONFIGURE_INIT
20 #define CONFIGURE_INIT
21
21
22 #include <bsp.h> /* for device driver prototypes */
22 #include <bsp.h> /* for device driver prototypes */
23
23
24 /* configuration information */
24 /* configuration information */
25
25
26 #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
26 #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
27 #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
27 #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
28
28
29 #define CONFIGURE_MAXIMUM_TASKS 20
29 #define CONFIGURE_MAXIMUM_TASKS 20
30 #define CONFIGURE_RTEMS_INIT_TASKS_TABLE
30 #define CONFIGURE_RTEMS_INIT_TASKS_TABLE
31 #define CONFIGURE_EXTRA_TASK_STACKS (3 * RTEMS_MINIMUM_STACK_SIZE)
31 #define CONFIGURE_EXTRA_TASK_STACKS (3 * RTEMS_MINIMUM_STACK_SIZE)
32 #define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 32
32 #define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 32
33 #define CONFIGURE_INIT_TASK_PRIORITY 1 // instead of 100
33 #define CONFIGURE_INIT_TASK_PRIORITY 1 // instead of 100
34 #define CONFIGURE_INIT_TASK_MODE (RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT)
34 #define CONFIGURE_INIT_TASK_MODE (RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT)
35 #define CONFIGURE_INIT_TASK_ATTRIBUTES (RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT)
35 #define CONFIGURE_INIT_TASK_ATTRIBUTES (RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT)
36 #define CONFIGURE_MAXIMUM_DRIVERS 16
36 #define CONFIGURE_MAXIMUM_DRIVERS 16
37 #define CONFIGURE_MAXIMUM_PERIODS 5
37 #define CONFIGURE_MAXIMUM_PERIODS 5
38 #define CONFIGURE_MAXIMUM_TIMERS 5 // STAT (1s), send SWF (0.3s), send CWF3 (1s)
38 #define CONFIGURE_MAXIMUM_TIMERS 5 // STAT (1s), send SWF (0.3s), send CWF3 (1s)
39 #define CONFIGURE_MAXIMUM_MESSAGE_QUEUES 5
39 #define CONFIGURE_MAXIMUM_MESSAGE_QUEUES 5
40 #ifdef PRINT_STACK_REPORT
40 #ifdef PRINT_STACK_REPORT
41 #define CONFIGURE_STACK_CHECKER_ENABLED
41 #define CONFIGURE_STACK_CHECKER_ENABLED
42 #endif
42 #endif
43
43
44 #include <rtems/confdefs.h>
44 #include <rtems/confdefs.h>
45
45
46 /* If --drvmgr was enabled during the configuration of the RTEMS kernel */
46 /* If --drvmgr was enabled during the configuration of the RTEMS kernel */
47 #ifdef RTEMS_DRVMGR_STARTUP
47 #ifdef RTEMS_DRVMGR_STARTUP
48 #ifdef LEON3
48 #ifdef LEON3
49 /* Add Timer and UART Driver */
49 /* Add Timer and UART Driver */
50 #ifdef CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
50 #ifdef CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
51 #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GPTIMER
51 #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GPTIMER
52 #endif
52 #endif
53 #ifdef CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
53 #ifdef CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
54 #define CONFIGURE_DRIVER_AMBAPP_GAISLER_APBUART
54 #define CONFIGURE_DRIVER_AMBAPP_GAISLER_APBUART
55 #endif
55 #endif
56 #endif
56 #endif
57 #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GRSPW /* GRSPW Driver */
57 #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GRSPW /* GRSPW Driver */
58 #include <drvmgr/drvmgr_confdefs.h>
58 #include <drvmgr/drvmgr_confdefs.h>
59 #endif
59 #endif
60
60
61 #include "fsw_init.h"
61 #include "fsw_init.h"
62 #include "fsw_config.c"
62 #include "fsw_config.c"
63 #include "GscMemoryLPP.hpp"
63 #include "GscMemoryLPP.hpp"
64
64
65 void initCache()
65 void initCache()
66 {
66 {
67 unsigned int cacheControlRegister;
67 unsigned int cacheControlRegister;
68
68
69 cacheControlRegister = getCacheControlRegister();
69 cacheControlRegister = getCacheControlRegister();
70 PRINTF1("(0) cacheControlRegister = %x\n", cacheControlRegister)
70 PRINTF1("(0) cacheControlRegister = %x\n", cacheControlRegister)
71
71
72 resetCacheControlRegister();
72 resetCacheControlRegister();
73
73
74 enableInstructionCache();
74 enableInstructionCache();
75 enableDataCache();
75 enableDataCache();
76 enableInstructionBurstFetch();
76 enableInstructionBurstFetch();
77
77
78 cacheControlRegister = getCacheControlRegister();
78 cacheControlRegister = getCacheControlRegister();
79 PRINTF1("(1) cacheControlRegister = %x\n", cacheControlRegister)
79 PRINTF1("(1) cacheControlRegister = %x\n", cacheControlRegister)
80 }
80 }
81
81
82 rtems_task Init( rtems_task_argument ignored )
82 rtems_task Init( rtems_task_argument ignored )
83 {
83 {
84 /** This is the RTEMS INIT taks, it is the first task launched by the system.
84 /** This is the RTEMS INIT taks, it is the first task launched by the system.
85 *
85 *
86 * @param unused is the starting argument of the RTEMS task
86 * @param unused is the starting argument of the RTEMS task
87 *
87 *
88 * The INIT task create and run all other RTEMS tasks.
88 * The INIT task create and run all other RTEMS tasks.
89 *
89 *
90 */
90 */
91
91
92 //***********
92 //***********
93 // INIT CACHE
93 // INIT CACHE
94
94
95 unsigned char *vhdlVersion;
95 unsigned char *vhdlVersion;
96
96
97 reset_lfr();
97 reset_lfr();
98
98
99 reset_local_time();
99 reset_local_time();
100
100
101 rtems_cpu_usage_reset();
101 rtems_cpu_usage_reset();
102
102
103 rtems_status_code status;
103 rtems_status_code status;
104 rtems_status_code status_spw;
104 rtems_status_code status_spw;
105 rtems_isr_entry old_isr_handler;
105 rtems_isr_entry old_isr_handler;
106
106
107 // UART settings
107 // UART settings
108 send_console_outputs_on_apbuart_port();
108 send_console_outputs_on_apbuart_port();
109 set_apbuart_scaler_reload_register(REGS_ADDR_APBUART, APBUART_SCALER_RELOAD_VALUE);
109 set_apbuart_scaler_reload_register(REGS_ADDR_APBUART, APBUART_SCALER_RELOAD_VALUE);
110 enable_apbuart_transmitter();
110 enable_apbuart_transmitter();
111
111
112 DEBUG_PRINTF("\n\n\n\n\nIn INIT *** Now the console is on port COM1\n")
112 DEBUG_PRINTF("\n\n\n\n\nIn INIT *** Now the console is on port COM1\n")
113
113
114
114
115 PRINTF("\n\n\n\n\n")
115 PRINTF("\n\n\n\n\n")
116
116
117 initCache();
117 initCache();
118
118
119 PRINTF("*************************\n")
119 PRINTF("*************************\n")
120 PRINTF("** LFR Flight Software **\n")
120 PRINTF("** LFR Flight Software **\n")
121 PRINTF1("** %d.", SW_VERSION_N1)
121 PRINTF1("** %d.", SW_VERSION_N1)
122 PRINTF1("%d." , SW_VERSION_N2)
122 PRINTF1("%d." , SW_VERSION_N2)
123 PRINTF1("%d." , SW_VERSION_N3)
123 PRINTF1("%d." , SW_VERSION_N3)
124 PRINTF1("%d **\n", SW_VERSION_N4)
124 PRINTF1("%d **\n", SW_VERSION_N4)
125
125
126 vhdlVersion = (unsigned char *) (REGS_ADDR_VHDL_VERSION);
126 vhdlVersion = (unsigned char *) (REGS_ADDR_VHDL_VERSION);
127 PRINTF("** VHDL **\n")
127 PRINTF("** VHDL **\n")
128 PRINTF1("** %d.", vhdlVersion[1])
128 PRINTF1("** %d.", vhdlVersion[1])
129 PRINTF1("%d." , vhdlVersion[2])
129 PRINTF1("%d." , vhdlVersion[2])
130 PRINTF1("%d **\n", vhdlVersion[3])
130 PRINTF1("%d **\n", vhdlVersion[3])
131 PRINTF("*************************\n")
131 PRINTF("*************************\n")
132 PRINTF("\n\n")
132 PRINTF("\n\n")
133
133
134 init_parameter_dump();
134 init_parameter_dump();
135 init_kcoefficients_dump();
135 init_kcoefficients_dump();
136 init_local_mode_parameters();
136 init_local_mode_parameters();
137 init_housekeeping_parameters();
137 init_housekeeping_parameters();
138 init_k_coefficients_prc0();
138 init_k_coefficients_prc0();
139 init_k_coefficients_prc1();
139 init_k_coefficients_prc1();
140 init_k_coefficients_prc2();
140 init_k_coefficients_prc2();
141 pa_bia_status_info = 0x00;
141 pa_bia_status_info = 0x00;
142
142
143 // waveform picker initialization
143 // waveform picker initialization
144 WFP_init_rings(); // initialize the waveform rings
144 WFP_init_rings(); // initialize the waveform rings
145 WFP_reset_current_ring_nodes();
145 WFP_reset_current_ring_nodes();
146 reset_waveform_picker_regs();
146 reset_waveform_picker_regs();
147
147
148 // spectral matrices initialization
148 // spectral matrices initialization
149 SM_init_rings(); // initialize spectral matrices rings
149 SM_init_rings(); // initialize spectral matrices rings
150 SM_reset_current_ring_nodes();
150 SM_reset_current_ring_nodes();
151 reset_spectral_matrix_regs();
151 reset_spectral_matrix_regs();
152
152
153 // configure calibration
153 // configure calibration
154 configureCalibration( false ); // true means interleaved mode, false is for normal mode
154 configureCalibration( false ); // true means interleaved mode, false is for normal mode
155
155
156 updateLFRCurrentMode();
156 updateLFRCurrentMode();
157
157
158 BOOT_PRINTF1("in INIT *** lfrCurrentMode is %d\n", lfrCurrentMode)
158 BOOT_PRINTF1("in INIT *** lfrCurrentMode is %d\n", lfrCurrentMode)
159
159
160 create_names(); // create all names
160 create_names(); // create all names
161
161
162 status = create_message_queues(); // create message queues
162 status = create_message_queues(); // create message queues
163 if (status != RTEMS_SUCCESSFUL)
163 if (status != RTEMS_SUCCESSFUL)
164 {
164 {
165 PRINTF1("in INIT *** ERR in create_message_queues, code %d", status)
165 PRINTF1("in INIT *** ERR in create_message_queues, code %d", status)
166 }
166 }
167
167
168 status = create_all_tasks(); // create all tasks
168 status = create_all_tasks(); // create all tasks
169 if (status != RTEMS_SUCCESSFUL)
169 if (status != RTEMS_SUCCESSFUL)
170 {
170 {
171 PRINTF1("in INIT *** ERR in create_all_tasks, code %d\n", status)
171 PRINTF1("in INIT *** ERR in create_all_tasks, code %d\n", status)
172 }
172 }
173
173
174 // **************************
174 // **************************
175 // <SPACEWIRE INITIALIZATION>
175 // <SPACEWIRE INITIALIZATION>
176 grspw_timecode_callback = &timecode_irq_handler;
176 grspw_timecode_callback = &timecode_irq_handler;
177
177
178 status_spw = spacewire_open_link(); // (1) open the link
178 status_spw = spacewire_open_link(); // (1) open the link
179 if ( status_spw != RTEMS_SUCCESSFUL )
179 if ( status_spw != RTEMS_SUCCESSFUL )
180 {
180 {
181 PRINTF1("in INIT *** ERR spacewire_open_link code %d\n", status_spw )
181 PRINTF1("in INIT *** ERR spacewire_open_link code %d\n", status_spw )
182 }
182 }
183
183
184 if ( status_spw == RTEMS_SUCCESSFUL ) // (2) configure the link
184 if ( status_spw == RTEMS_SUCCESSFUL ) // (2) configure the link
185 {
185 {
186 status_spw = spacewire_configure_link( fdSPW );
186 status_spw = spacewire_configure_link( fdSPW );
187 if ( status_spw != RTEMS_SUCCESSFUL )
187 if ( status_spw != RTEMS_SUCCESSFUL )
188 {
188 {
189 PRINTF1("in INIT *** ERR spacewire_configure_link code %d\n", status_spw )
189 PRINTF1("in INIT *** ERR spacewire_configure_link code %d\n", status_spw )
190 }
190 }
191 }
191 }
192
192
193 if ( status_spw == RTEMS_SUCCESSFUL) // (3) start the link
193 if ( status_spw == RTEMS_SUCCESSFUL) // (3) start the link
194 {
194 {
195 status_spw = spacewire_start_link( fdSPW );
195 status_spw = spacewire_start_link( fdSPW );
196 if ( status_spw != RTEMS_SUCCESSFUL )
196 if ( status_spw != RTEMS_SUCCESSFUL )
197 {
197 {
198 PRINTF1("in INIT *** ERR spacewire_start_link code %d\n", status_spw )
198 PRINTF1("in INIT *** ERR spacewire_start_link code %d\n", status_spw )
199 }
199 }
200 }
200 }
201 // </SPACEWIRE INITIALIZATION>
201 // </SPACEWIRE INITIALIZATION>
202 // ***************************
202 // ***************************
203
203
204 status = start_all_tasks(); // start all tasks
204 status = start_all_tasks(); // start all tasks
205 if (status != RTEMS_SUCCESSFUL)
205 if (status != RTEMS_SUCCESSFUL)
206 {
206 {
207 PRINTF1("in INIT *** ERR in start_all_tasks, code %d", status)
207 PRINTF1("in INIT *** ERR in start_all_tasks, code %d", status)
208 }
208 }
209
209
210 // start RECV and SEND *AFTER* SpaceWire Initialization, due to the timeout of the start call during the initialization
210 // start RECV and SEND *AFTER* SpaceWire Initialization, due to the timeout of the start call during the initialization
211 status = start_recv_send_tasks();
211 status = start_recv_send_tasks();
212 if ( status != RTEMS_SUCCESSFUL )
212 if ( status != RTEMS_SUCCESSFUL )
213 {
213 {
214 PRINTF1("in INIT *** ERR start_recv_send_tasks code %d\n", status )
214 PRINTF1("in INIT *** ERR start_recv_send_tasks code %d\n", status )
215 }
215 }
216
216
217 // suspend science tasks, they will be restarted later depending on the mode
217 // suspend science tasks, they will be restarted later depending on the mode
218 status = suspend_science_tasks(); // suspend science tasks (not done in stop_current_mode if current mode = STANDBY)
218 status = suspend_science_tasks(); // suspend science tasks (not done in stop_current_mode if current mode = STANDBY)
219 if (status != RTEMS_SUCCESSFUL)
219 if (status != RTEMS_SUCCESSFUL)
220 {
220 {
221 PRINTF1("in INIT *** in suspend_science_tasks *** ERR code: %d\n", status)
221 PRINTF1("in INIT *** in suspend_science_tasks *** ERR code: %d\n", status)
222 }
222 }
223
223
224 //******************************
224 //******************************
225 // <SPECTRAL MATRICES SIMULATOR>
225 // <SPECTRAL MATRICES SIMULATOR>
226 LEON_Mask_interrupt( IRQ_SM_SIMULATOR );
226 LEON_Mask_interrupt( IRQ_SM_SIMULATOR );
227 configure_timer((gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR, CLKDIV_SM_SIMULATOR,
227 configure_timer((gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR, CLKDIV_SM_SIMULATOR,
228 IRQ_SPARC_SM_SIMULATOR, spectral_matrices_isr_simu );
228 IRQ_SPARC_SM_SIMULATOR, spectral_matrices_isr_simu );
229 // </SPECTRAL MATRICES SIMULATOR>
229 // </SPECTRAL MATRICES SIMULATOR>
230 //*******************************
230 //*******************************
231
231
232 // configure IRQ handling for the waveform picker unit
232 // configure IRQ handling for the waveform picker unit
233 status = rtems_interrupt_catch( waveforms_isr,
233 status = rtems_interrupt_catch( waveforms_isr,
234 IRQ_SPARC_WAVEFORM_PICKER,
234 IRQ_SPARC_WAVEFORM_PICKER,
235 &old_isr_handler) ;
235 &old_isr_handler) ;
236 // configure IRQ handling for the spectral matrices unit
236 // configure IRQ handling for the spectral matrices unit
237 status = rtems_interrupt_catch( spectral_matrices_isr,
237 status = rtems_interrupt_catch( spectral_matrices_isr,
238 IRQ_SPARC_SPECTRAL_MATRIX,
238 IRQ_SPARC_SPECTRAL_MATRIX,
239 &old_isr_handler) ;
239 &old_isr_handler) ;
240
240
241 // if the spacewire link is not up then send an event to the SPIQ task for link recovery
241 // if the spacewire link is not up then send an event to the SPIQ task for link recovery
242 if ( status_spw != RTEMS_SUCCESSFUL )
242 if ( status_spw != RTEMS_SUCCESSFUL )
243 {
243 {
244 status = rtems_event_send( Task_id[TASKID_SPIQ], SPW_LINKERR_EVENT );
244 status = rtems_event_send( Task_id[TASKID_SPIQ], SPW_LINKERR_EVENT );
245 if ( status != RTEMS_SUCCESSFUL ) {
245 if ( status != RTEMS_SUCCESSFUL ) {
246 PRINTF1("in INIT *** ERR rtems_event_send to SPIQ code %d\n", status )
246 PRINTF1("in INIT *** ERR rtems_event_send to SPIQ code %d\n", status )
247 }
247 }
248 }
248 }
249
249
250 BOOT_PRINTF("delete INIT\n")
250 BOOT_PRINTF("delete INIT\n")
251
251
252 set_hk_lfr_sc_potential_flag( true );
252 set_hk_lfr_sc_potential_flag( true );
253
253
254 status = rtems_task_delete(RTEMS_SELF);
254 status = rtems_task_delete(RTEMS_SELF);
255
255
256 }
256 }
257
257
258 void init_local_mode_parameters( void )
258 void init_local_mode_parameters( void )
259 {
259 {
260 /** This function initialize the param_local global variable with default values.
260 /** This function initialize the param_local global variable with default values.
261 *
261 *
262 */
262 */
263
263
264 unsigned int i;
264 unsigned int i;
265
265
266 // LOCAL PARAMETERS
266 // LOCAL PARAMETERS
267
267
268 BOOT_PRINTF1("local_sbm1_nb_cwf_max %d \n", param_local.local_sbm1_nb_cwf_max)
268 BOOT_PRINTF1("local_sbm1_nb_cwf_max %d \n", param_local.local_sbm1_nb_cwf_max)
269 BOOT_PRINTF1("local_sbm2_nb_cwf_max %d \n", param_local.local_sbm2_nb_cwf_max)
269 BOOT_PRINTF1("local_sbm2_nb_cwf_max %d \n", param_local.local_sbm2_nb_cwf_max)
270 BOOT_PRINTF1("nb_interrupt_f0_MAX = %d\n", param_local.local_nb_interrupt_f0_MAX)
270 BOOT_PRINTF1("nb_interrupt_f0_MAX = %d\n", param_local.local_nb_interrupt_f0_MAX)
271
271
272 // init sequence counters
272 // init sequence counters
273
273
274 for(i = 0; i<SEQ_CNT_NB_DEST_ID; i++)
274 for(i = 0; i<SEQ_CNT_NB_DEST_ID; i++)
275 {
275 {
276 sequenceCounters_TC_EXE[i] = 0x00;
276 sequenceCounters_TC_EXE[i] = 0x00;
277 sequenceCounters_TM_DUMP[i] = 0x00;
277 sequenceCounters_TM_DUMP[i] = 0x00;
278 }
278 }
279 sequenceCounters_SCIENCE_NORMAL_BURST = 0x00;
279 sequenceCounters_SCIENCE_NORMAL_BURST = 0x00;
280 sequenceCounters_SCIENCE_SBM1_SBM2 = 0x00;
280 sequenceCounters_SCIENCE_SBM1_SBM2 = 0x00;
281 sequenceCounterHK = TM_PACKET_SEQ_CTRL_STANDALONE << 8;
281 sequenceCounterHK = TM_PACKET_SEQ_CTRL_STANDALONE << 8;
282 }
282 }
283
283
284 void reset_local_time( void )
284 void reset_local_time( void )
285 {
285 {
286 time_management_regs->ctrl = time_management_regs->ctrl | 0x02; // [0010] software reset, coarse time = 0x80000000
286 time_management_regs->ctrl = time_management_regs->ctrl | 0x02; // [0010] software reset, coarse time = 0x80000000
287 }
287 }
288
288
289 void create_names( void ) // create all names for tasks and queues
289 void create_names( void ) // create all names for tasks and queues
290 {
290 {
291 /** This function creates all RTEMS names used in the software for tasks and queues.
291 /** This function creates all RTEMS names used in the software for tasks and queues.
292 *
292 *
293 * @return RTEMS directive status codes:
293 * @return RTEMS directive status codes:
294 * - RTEMS_SUCCESSFUL - successful completion
294 * - RTEMS_SUCCESSFUL - successful completion
295 *
295 *
296 */
296 */
297
297
298 // task names
298 // task names
299 Task_name[TASKID_RECV] = rtems_build_name( 'R', 'E', 'C', 'V' );
299 Task_name[TASKID_RECV] = rtems_build_name( 'R', 'E', 'C', 'V' );
300 Task_name[TASKID_ACTN] = rtems_build_name( 'A', 'C', 'T', 'N' );
300 Task_name[TASKID_ACTN] = rtems_build_name( 'A', 'C', 'T', 'N' );
301 Task_name[TASKID_SPIQ] = rtems_build_name( 'S', 'P', 'I', 'Q' );
301 Task_name[TASKID_SPIQ] = rtems_build_name( 'S', 'P', 'I', 'Q' );
302 Task_name[TASKID_STAT] = rtems_build_name( 'S', 'T', 'A', 'T' );
302 Task_name[TASKID_STAT] = rtems_build_name( 'S', 'T', 'A', 'T' );
303 Task_name[TASKID_AVF0] = rtems_build_name( 'A', 'V', 'F', '0' );
303 Task_name[TASKID_AVF0] = rtems_build_name( 'A', 'V', 'F', '0' );
304 Task_name[TASKID_SWBD] = rtems_build_name( 'S', 'W', 'B', 'D' );
304 Task_name[TASKID_SWBD] = rtems_build_name( 'S', 'W', 'B', 'D' );
305 Task_name[TASKID_WFRM] = rtems_build_name( 'W', 'F', 'R', 'M' );
305 Task_name[TASKID_WFRM] = rtems_build_name( 'W', 'F', 'R', 'M' );
306 Task_name[TASKID_DUMB] = rtems_build_name( 'D', 'U', 'M', 'B' );
306 Task_name[TASKID_DUMB] = rtems_build_name( 'D', 'U', 'M', 'B' );
307 Task_name[TASKID_HOUS] = rtems_build_name( 'H', 'O', 'U', 'S' );
307 Task_name[TASKID_HOUS] = rtems_build_name( 'H', 'O', 'U', 'S' );
308 Task_name[TASKID_PRC0] = rtems_build_name( 'P', 'R', 'C', '0' );
308 Task_name[TASKID_PRC0] = rtems_build_name( 'P', 'R', 'C', '0' );
309 Task_name[TASKID_CWF3] = rtems_build_name( 'C', 'W', 'F', '3' );
309 Task_name[TASKID_CWF3] = rtems_build_name( 'C', 'W', 'F', '3' );
310 Task_name[TASKID_CWF2] = rtems_build_name( 'C', 'W', 'F', '2' );
310 Task_name[TASKID_CWF2] = rtems_build_name( 'C', 'W', 'F', '2' );
311 Task_name[TASKID_CWF1] = rtems_build_name( 'C', 'W', 'F', '1' );
311 Task_name[TASKID_CWF1] = rtems_build_name( 'C', 'W', 'F', '1' );
312 Task_name[TASKID_SEND] = rtems_build_name( 'S', 'E', 'N', 'D' );
312 Task_name[TASKID_SEND] = rtems_build_name( 'S', 'E', 'N', 'D' );
313 Task_name[TASKID_WTDG] = rtems_build_name( 'W', 'T', 'D', 'G' );
313 Task_name[TASKID_WTDG] = rtems_build_name( 'W', 'T', 'D', 'G' );
314 Task_name[TASKID_AVF1] = rtems_build_name( 'A', 'V', 'F', '1' );
314 Task_name[TASKID_AVF1] = rtems_build_name( 'A', 'V', 'F', '1' );
315 Task_name[TASKID_PRC1] = rtems_build_name( 'P', 'R', 'C', '1' );
315 Task_name[TASKID_PRC1] = rtems_build_name( 'P', 'R', 'C', '1' );
316 Task_name[TASKID_AVF2] = rtems_build_name( 'A', 'V', 'F', '2' );
316 Task_name[TASKID_AVF2] = rtems_build_name( 'A', 'V', 'F', '2' );
317 Task_name[TASKID_PRC2] = rtems_build_name( 'P', 'R', 'C', '2' );
317 Task_name[TASKID_PRC2] = rtems_build_name( 'P', 'R', 'C', '2' );
318
318
319 // rate monotonic period names
319 // rate monotonic period names
320 name_hk_rate_monotonic = rtems_build_name( 'H', 'O', 'U', 'S' );
320 name_hk_rate_monotonic = rtems_build_name( 'H', 'O', 'U', 'S' );
321
321
322 misc_name[QUEUE_RECV] = rtems_build_name( 'Q', '_', 'R', 'V' );
322 misc_name[QUEUE_RECV] = rtems_build_name( 'Q', '_', 'R', 'V' );
323 misc_name[QUEUE_SEND] = rtems_build_name( 'Q', '_', 'S', 'D' );
323 misc_name[QUEUE_SEND] = rtems_build_name( 'Q', '_', 'S', 'D' );
324 misc_name[QUEUE_PRC0] = rtems_build_name( 'Q', '_', 'P', '0' );
324 misc_name[QUEUE_PRC0] = rtems_build_name( 'Q', '_', 'P', '0' );
325 misc_name[QUEUE_PRC1] = rtems_build_name( 'Q', '_', 'P', '1' );
325 misc_name[QUEUE_PRC1] = rtems_build_name( 'Q', '_', 'P', '1' );
326 misc_name[QUEUE_PRC2] = rtems_build_name( 'Q', '_', 'P', '2' );
326 misc_name[QUEUE_PRC2] = rtems_build_name( 'Q', '_', 'P', '2' );
327 }
327 }
328
328
329 int create_all_tasks( void ) // create all tasks which run in the software
329 int create_all_tasks( void ) // create all tasks which run in the software
330 {
330 {
331 /** This function creates all RTEMS tasks used in the software.
331 /** This function creates all RTEMS tasks used in the software.
332 *
332 *
333 * @return RTEMS directive status codes:
333 * @return RTEMS directive status codes:
334 * - RTEMS_SUCCESSFUL - task created successfully
334 * - RTEMS_SUCCESSFUL - task created successfully
335 * - RTEMS_INVALID_ADDRESS - id is NULL
335 * - RTEMS_INVALID_ADDRESS - id is NULL
336 * - RTEMS_INVALID_NAME - invalid task name
336 * - RTEMS_INVALID_NAME - invalid task name
337 * - RTEMS_INVALID_PRIORITY - invalid task priority
337 * - RTEMS_INVALID_PRIORITY - invalid task priority
338 * - RTEMS_MP_NOT_CONFIGURED - multiprocessing not configured
338 * - RTEMS_MP_NOT_CONFIGURED - multiprocessing not configured
339 * - RTEMS_TOO_MANY - too many tasks created
339 * - RTEMS_TOO_MANY - too many tasks created
340 * - RTEMS_UNSATISFIED - not enough memory for stack/FP context
340 * - RTEMS_UNSATISFIED - not enough memory for stack/FP context
341 * - RTEMS_TOO_MANY - too many global objects
341 * - RTEMS_TOO_MANY - too many global objects
342 *
342 *
343 */
343 */
344
344
345 rtems_status_code status;
345 rtems_status_code status;
346
346
347 //**********
347 //**********
348 // SPACEWIRE
348 // SPACEWIRE
349 // RECV
349 // RECV
350 status = rtems_task_create(
350 status = rtems_task_create(
351 Task_name[TASKID_RECV], TASK_PRIORITY_RECV, RTEMS_MINIMUM_STACK_SIZE,
351 Task_name[TASKID_RECV], TASK_PRIORITY_RECV, RTEMS_MINIMUM_STACK_SIZE,
352 RTEMS_DEFAULT_MODES,
352 RTEMS_DEFAULT_MODES,
353 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_RECV]
353 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_RECV]
354 );
354 );
355 if (status == RTEMS_SUCCESSFUL) // SEND
355 if (status == RTEMS_SUCCESSFUL) // SEND
356 {
356 {
357 status = rtems_task_create(
357 status = rtems_task_create(
358 Task_name[TASKID_SEND], TASK_PRIORITY_SEND, RTEMS_MINIMUM_STACK_SIZE * 2,
358 Task_name[TASKID_SEND], TASK_PRIORITY_SEND, RTEMS_MINIMUM_STACK_SIZE * 2,
359 RTEMS_DEFAULT_MODES,
359 RTEMS_DEFAULT_MODES,
360 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_SEND]
360 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_SEND]
361 );
361 );
362 }
362 }
363 if (status == RTEMS_SUCCESSFUL) // WTDG
363 if (status == RTEMS_SUCCESSFUL) // WTDG
364 {
364 {
365 status = rtems_task_create(
365 status = rtems_task_create(
366 Task_name[TASKID_WTDG], TASK_PRIORITY_WTDG, RTEMS_MINIMUM_STACK_SIZE,
366 Task_name[TASKID_WTDG], TASK_PRIORITY_WTDG, RTEMS_MINIMUM_STACK_SIZE,
367 RTEMS_DEFAULT_MODES,
367 RTEMS_DEFAULT_MODES,
368 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_WTDG]
368 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_WTDG]
369 );
369 );
370 }
370 }
371 if (status == RTEMS_SUCCESSFUL) // ACTN
371 if (status == RTEMS_SUCCESSFUL) // ACTN
372 {
372 {
373 status = rtems_task_create(
373 status = rtems_task_create(
374 Task_name[TASKID_ACTN], TASK_PRIORITY_ACTN, RTEMS_MINIMUM_STACK_SIZE,
374 Task_name[TASKID_ACTN], TASK_PRIORITY_ACTN, RTEMS_MINIMUM_STACK_SIZE,
375 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
375 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
376 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_ACTN]
376 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_ACTN]
377 );
377 );
378 }
378 }
379 if (status == RTEMS_SUCCESSFUL) // SPIQ
379 if (status == RTEMS_SUCCESSFUL) // SPIQ
380 {
380 {
381 status = rtems_task_create(
381 status = rtems_task_create(
382 Task_name[TASKID_SPIQ], TASK_PRIORITY_SPIQ, RTEMS_MINIMUM_STACK_SIZE,
382 Task_name[TASKID_SPIQ], TASK_PRIORITY_SPIQ, RTEMS_MINIMUM_STACK_SIZE,
383 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
383 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
384 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SPIQ]
384 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SPIQ]
385 );
385 );
386 }
386 }
387
387
388 //******************
388 //******************
389 // SPECTRAL MATRICES
389 // SPECTRAL MATRICES
390 if (status == RTEMS_SUCCESSFUL) // AVF0
390 if (status == RTEMS_SUCCESSFUL) // AVF0
391 {
391 {
392 status = rtems_task_create(
392 status = rtems_task_create(
393 Task_name[TASKID_AVF0], TASK_PRIORITY_AVF0, RTEMS_MINIMUM_STACK_SIZE,
393 Task_name[TASKID_AVF0], TASK_PRIORITY_AVF0, RTEMS_MINIMUM_STACK_SIZE,
394 RTEMS_DEFAULT_MODES,
394 RTEMS_DEFAULT_MODES,
395 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF0]
395 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF0]
396 );
396 );
397 }
397 }
398 if (status == RTEMS_SUCCESSFUL) // PRC0
398 if (status == RTEMS_SUCCESSFUL) // PRC0
399 {
399 {
400 status = rtems_task_create(
400 status = rtems_task_create(
401 Task_name[TASKID_PRC0], TASK_PRIORITY_PRC0, RTEMS_MINIMUM_STACK_SIZE * 2,
401 Task_name[TASKID_PRC0], TASK_PRIORITY_PRC0, RTEMS_MINIMUM_STACK_SIZE * 2,
402 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
402 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
403 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_PRC0]
403 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_PRC0]
404 );
404 );
405 }
405 }
406 if (status == RTEMS_SUCCESSFUL) // AVF1
406 if (status == RTEMS_SUCCESSFUL) // AVF1
407 {
407 {
408 status = rtems_task_create(
408 status = rtems_task_create(
409 Task_name[TASKID_AVF1], TASK_PRIORITY_AVF1, RTEMS_MINIMUM_STACK_SIZE,
409 Task_name[TASKID_AVF1], TASK_PRIORITY_AVF1, RTEMS_MINIMUM_STACK_SIZE,
410 RTEMS_DEFAULT_MODES,
410 RTEMS_DEFAULT_MODES,
411 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF1]
411 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF1]
412 );
412 );
413 }
413 }
414 if (status == RTEMS_SUCCESSFUL) // PRC1
414 if (status == RTEMS_SUCCESSFUL) // PRC1
415 {
415 {
416 status = rtems_task_create(
416 status = rtems_task_create(
417 Task_name[TASKID_PRC1], TASK_PRIORITY_PRC1, RTEMS_MINIMUM_STACK_SIZE * 2,
417 Task_name[TASKID_PRC1], TASK_PRIORITY_PRC1, RTEMS_MINIMUM_STACK_SIZE * 2,
418 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
418 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
419 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_PRC1]
419 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_PRC1]
420 );
420 );
421 }
421 }
422 if (status == RTEMS_SUCCESSFUL) // AVF2
422 if (status == RTEMS_SUCCESSFUL) // AVF2
423 {
423 {
424 status = rtems_task_create(
424 status = rtems_task_create(
425 Task_name[TASKID_AVF2], TASK_PRIORITY_AVF2, RTEMS_MINIMUM_STACK_SIZE,
425 Task_name[TASKID_AVF2], TASK_PRIORITY_AVF2, RTEMS_MINIMUM_STACK_SIZE,
426 RTEMS_DEFAULT_MODES,
426 RTEMS_DEFAULT_MODES,
427 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF2]
427 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF2]
428 );
428 );
429 }
429 }
430 if (status == RTEMS_SUCCESSFUL) // PRC2
430 if (status == RTEMS_SUCCESSFUL) // PRC2
431 {
431 {
432 status = rtems_task_create(
432 status = rtems_task_create(
433 Task_name[TASKID_PRC2], TASK_PRIORITY_PRC2, RTEMS_MINIMUM_STACK_SIZE * 2,
433 Task_name[TASKID_PRC2], TASK_PRIORITY_PRC2, RTEMS_MINIMUM_STACK_SIZE * 2,
434 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
434 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
435 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_PRC2]
435 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_PRC2]
436 );
436 );
437 }
437 }
438
438
439 //****************
439 //****************
440 // WAVEFORM PICKER
440 // WAVEFORM PICKER
441 if (status == RTEMS_SUCCESSFUL) // WFRM
441 if (status == RTEMS_SUCCESSFUL) // WFRM
442 {
442 {
443 status = rtems_task_create(
443 status = rtems_task_create(
444 Task_name[TASKID_WFRM], TASK_PRIORITY_WFRM, RTEMS_MINIMUM_STACK_SIZE,
444 Task_name[TASKID_WFRM], TASK_PRIORITY_WFRM, RTEMS_MINIMUM_STACK_SIZE,
445 RTEMS_DEFAULT_MODES,
445 RTEMS_DEFAULT_MODES,
446 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_WFRM]
446 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_WFRM]
447 );
447 );
448 }
448 }
449 if (status == RTEMS_SUCCESSFUL) // CWF3
449 if (status == RTEMS_SUCCESSFUL) // CWF3
450 {
450 {
451 status = rtems_task_create(
451 status = rtems_task_create(
452 Task_name[TASKID_CWF3], TASK_PRIORITY_CWF3, RTEMS_MINIMUM_STACK_SIZE,
452 Task_name[TASKID_CWF3], TASK_PRIORITY_CWF3, RTEMS_MINIMUM_STACK_SIZE,
453 RTEMS_DEFAULT_MODES,
453 RTEMS_DEFAULT_MODES,
454 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_CWF3]
454 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_CWF3]
455 );
455 );
456 }
456 }
457 if (status == RTEMS_SUCCESSFUL) // CWF2
457 if (status == RTEMS_SUCCESSFUL) // CWF2
458 {
458 {
459 status = rtems_task_create(
459 status = rtems_task_create(
460 Task_name[TASKID_CWF2], TASK_PRIORITY_CWF2, RTEMS_MINIMUM_STACK_SIZE,
460 Task_name[TASKID_CWF2], TASK_PRIORITY_CWF2, RTEMS_MINIMUM_STACK_SIZE,
461 RTEMS_DEFAULT_MODES,
461 RTEMS_DEFAULT_MODES,
462 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_CWF2]
462 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_CWF2]
463 );
463 );
464 }
464 }
465 if (status == RTEMS_SUCCESSFUL) // CWF1
465 if (status == RTEMS_SUCCESSFUL) // CWF1
466 {
466 {
467 status = rtems_task_create(
467 status = rtems_task_create(
468 Task_name[TASKID_CWF1], TASK_PRIORITY_CWF1, RTEMS_MINIMUM_STACK_SIZE,
468 Task_name[TASKID_CWF1], TASK_PRIORITY_CWF1, RTEMS_MINIMUM_STACK_SIZE,
469 RTEMS_DEFAULT_MODES,
469 RTEMS_DEFAULT_MODES,
470 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_CWF1]
470 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_CWF1]
471 );
471 );
472 }
472 }
473 if (status == RTEMS_SUCCESSFUL) // SWBD
473 if (status == RTEMS_SUCCESSFUL) // SWBD
474 {
474 {
475 status = rtems_task_create(
475 status = rtems_task_create(
476 Task_name[TASKID_SWBD], TASK_PRIORITY_SWBD, RTEMS_MINIMUM_STACK_SIZE,
476 Task_name[TASKID_SWBD], TASK_PRIORITY_SWBD, RTEMS_MINIMUM_STACK_SIZE,
477 RTEMS_DEFAULT_MODES,
477 RTEMS_DEFAULT_MODES,
478 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_SWBD]
478 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_SWBD]
479 );
479 );
480 }
480 }
481
481
482 //*****
482 //*****
483 // MISC
483 // MISC
484 if (status == RTEMS_SUCCESSFUL) // STAT
484 if (status == RTEMS_SUCCESSFUL) // STAT
485 {
485 {
486 status = rtems_task_create(
486 status = rtems_task_create(
487 Task_name[TASKID_STAT], TASK_PRIORITY_STAT, RTEMS_MINIMUM_STACK_SIZE,
487 Task_name[TASKID_STAT], TASK_PRIORITY_STAT, RTEMS_MINIMUM_STACK_SIZE,
488 RTEMS_DEFAULT_MODES,
488 RTEMS_DEFAULT_MODES,
489 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_STAT]
489 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_STAT]
490 );
490 );
491 }
491 }
492 if (status == RTEMS_SUCCESSFUL) // DUMB
492 if (status == RTEMS_SUCCESSFUL) // DUMB
493 {
493 {
494 status = rtems_task_create(
494 status = rtems_task_create(
495 Task_name[TASKID_DUMB], TASK_PRIORITY_DUMB, RTEMS_MINIMUM_STACK_SIZE,
495 Task_name[TASKID_DUMB], TASK_PRIORITY_DUMB, RTEMS_MINIMUM_STACK_SIZE,
496 RTEMS_DEFAULT_MODES,
496 RTEMS_DEFAULT_MODES,
497 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_DUMB]
497 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_DUMB]
498 );
498 );
499 }
499 }
500 if (status == RTEMS_SUCCESSFUL) // HOUS
500 if (status == RTEMS_SUCCESSFUL) // HOUS
501 {
501 {
502 status = rtems_task_create(
502 status = rtems_task_create(
503 Task_name[TASKID_HOUS], TASK_PRIORITY_HOUS, RTEMS_MINIMUM_STACK_SIZE,
503 Task_name[TASKID_HOUS], TASK_PRIORITY_HOUS, RTEMS_MINIMUM_STACK_SIZE,
504 RTEMS_DEFAULT_MODES,
504 RTEMS_DEFAULT_MODES,
505 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_HOUS]
505 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_HOUS]
506 );
506 );
507 }
507 }
508
508
509 return status;
509 return status;
510 }
510 }
511
511
512 int start_recv_send_tasks( void )
512 int start_recv_send_tasks( void )
513 {
513 {
514 rtems_status_code status;
514 rtems_status_code status;
515
515
516 status = rtems_task_start( Task_id[TASKID_RECV], recv_task, 1 );
516 status = rtems_task_start( Task_id[TASKID_RECV], recv_task, 1 );
517 if (status!=RTEMS_SUCCESSFUL) {
517 if (status!=RTEMS_SUCCESSFUL) {
518 BOOT_PRINTF("in INIT *** Error starting TASK_RECV\n")
518 BOOT_PRINTF("in INIT *** Error starting TASK_RECV\n")
519 }
519 }
520
520
521 if (status == RTEMS_SUCCESSFUL) // SEND
521 if (status == RTEMS_SUCCESSFUL) // SEND
522 {
522 {
523 status = rtems_task_start( Task_id[TASKID_SEND], send_task, 1 );
523 status = rtems_task_start( Task_id[TASKID_SEND], send_task, 1 );
524 if (status!=RTEMS_SUCCESSFUL) {
524 if (status!=RTEMS_SUCCESSFUL) {
525 BOOT_PRINTF("in INIT *** Error starting TASK_SEND\n")
525 BOOT_PRINTF("in INIT *** Error starting TASK_SEND\n")
526 }
526 }
527 }
527 }
528
528
529 return status;
529 return status;
530 }
530 }
531
531
532 int start_all_tasks( void ) // start all tasks except SEND RECV and HOUS
532 int start_all_tasks( void ) // start all tasks except SEND RECV and HOUS
533 {
533 {
534 /** This function starts all RTEMS tasks used in the software.
534 /** This function starts all RTEMS tasks used in the software.
535 *
535 *
536 * @return RTEMS directive status codes:
536 * @return RTEMS directive status codes:
537 * - RTEMS_SUCCESSFUL - ask started successfully
537 * - RTEMS_SUCCESSFUL - ask started successfully
538 * - RTEMS_INVALID_ADDRESS - invalid task entry point
538 * - RTEMS_INVALID_ADDRESS - invalid task entry point
539 * - RTEMS_INVALID_ID - invalid task id
539 * - RTEMS_INVALID_ID - invalid task id
540 * - RTEMS_INCORRECT_STATE - task not in the dormant state
540 * - RTEMS_INCORRECT_STATE - task not in the dormant state
541 * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot start remote task
541 * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot start remote task
542 *
542 *
543 */
543 */
544 // starts all the tasks fot eh flight software
544 // starts all the tasks fot eh flight software
545
545
546 rtems_status_code status;
546 rtems_status_code status;
547
547
548 //**********
548 //**********
549 // SPACEWIRE
549 // SPACEWIRE
550 status = rtems_task_start( Task_id[TASKID_SPIQ], spiq_task, 1 );
550 status = rtems_task_start( Task_id[TASKID_SPIQ], spiq_task, 1 );
551 if (status!=RTEMS_SUCCESSFUL) {
551 if (status!=RTEMS_SUCCESSFUL) {
552 BOOT_PRINTF("in INIT *** Error starting TASK_SPIQ\n")
552 BOOT_PRINTF("in INIT *** Error starting TASK_SPIQ\n")
553 }
553 }
554
554
555 if (status == RTEMS_SUCCESSFUL) // WTDG
555 if (status == RTEMS_SUCCESSFUL) // WTDG
556 {
556 {
557 status = rtems_task_start( Task_id[TASKID_WTDG], wtdg_task, 1 );
557 status = rtems_task_start( Task_id[TASKID_WTDG], wtdg_task, 1 );
558 if (status!=RTEMS_SUCCESSFUL) {
558 if (status!=RTEMS_SUCCESSFUL) {
559 BOOT_PRINTF("in INIT *** Error starting TASK_WTDG\n")
559 BOOT_PRINTF("in INIT *** Error starting TASK_WTDG\n")
560 }
560 }
561 }
561 }
562
562
563 if (status == RTEMS_SUCCESSFUL) // ACTN
563 if (status == RTEMS_SUCCESSFUL) // ACTN
564 {
564 {
565 status = rtems_task_start( Task_id[TASKID_ACTN], actn_task, 1 );
565 status = rtems_task_start( Task_id[TASKID_ACTN], actn_task, 1 );
566 if (status!=RTEMS_SUCCESSFUL) {
566 if (status!=RTEMS_SUCCESSFUL) {
567 BOOT_PRINTF("in INIT *** Error starting TASK_ACTN\n")
567 BOOT_PRINTF("in INIT *** Error starting TASK_ACTN\n")
568 }
568 }
569 }
569 }
570
570
571 //******************
571 //******************
572 // SPECTRAL MATRICES
572 // SPECTRAL MATRICES
573 if (status == RTEMS_SUCCESSFUL) // AVF0
573 if (status == RTEMS_SUCCESSFUL) // AVF0
574 {
574 {
575 status = rtems_task_start( Task_id[TASKID_AVF0], avf0_task, LFR_MODE_STANDBY );
575 status = rtems_task_start( Task_id[TASKID_AVF0], avf0_task, LFR_MODE_STANDBY );
576 if (status!=RTEMS_SUCCESSFUL) {
576 if (status!=RTEMS_SUCCESSFUL) {
577 BOOT_PRINTF("in INIT *** Error starting TASK_AVF0\n")
577 BOOT_PRINTF("in INIT *** Error starting TASK_AVF0\n")
578 }
578 }
579 }
579 }
580 if (status == RTEMS_SUCCESSFUL) // PRC0
580 if (status == RTEMS_SUCCESSFUL) // PRC0
581 {
581 {
582 status = rtems_task_start( Task_id[TASKID_PRC0], prc0_task, LFR_MODE_STANDBY );
582 status = rtems_task_start( Task_id[TASKID_PRC0], prc0_task, LFR_MODE_STANDBY );
583 if (status!=RTEMS_SUCCESSFUL) {
583 if (status!=RTEMS_SUCCESSFUL) {
584 BOOT_PRINTF("in INIT *** Error starting TASK_PRC0\n")
584 BOOT_PRINTF("in INIT *** Error starting TASK_PRC0\n")
585 }
585 }
586 }
586 }
587 if (status == RTEMS_SUCCESSFUL) // AVF1
587 if (status == RTEMS_SUCCESSFUL) // AVF1
588 {
588 {
589 status = rtems_task_start( Task_id[TASKID_AVF1], avf1_task, LFR_MODE_STANDBY );
589 status = rtems_task_start( Task_id[TASKID_AVF1], avf1_task, LFR_MODE_STANDBY );
590 if (status!=RTEMS_SUCCESSFUL) {
590 if (status!=RTEMS_SUCCESSFUL) {
591 BOOT_PRINTF("in INIT *** Error starting TASK_AVF1\n")
591 BOOT_PRINTF("in INIT *** Error starting TASK_AVF1\n")
592 }
592 }
593 }
593 }
594 if (status == RTEMS_SUCCESSFUL) // PRC1
594 if (status == RTEMS_SUCCESSFUL) // PRC1
595 {
595 {
596 status = rtems_task_start( Task_id[TASKID_PRC1], prc1_task, LFR_MODE_STANDBY );
596 status = rtems_task_start( Task_id[TASKID_PRC1], prc1_task, LFR_MODE_STANDBY );
597 if (status!=RTEMS_SUCCESSFUL) {
597 if (status!=RTEMS_SUCCESSFUL) {
598 BOOT_PRINTF("in INIT *** Error starting TASK_PRC1\n")
598 BOOT_PRINTF("in INIT *** Error starting TASK_PRC1\n")
599 }
599 }
600 }
600 }
601 if (status == RTEMS_SUCCESSFUL) // AVF2
601 if (status == RTEMS_SUCCESSFUL) // AVF2
602 {
602 {
603 status = rtems_task_start( Task_id[TASKID_AVF2], avf2_task, 1 );
603 status = rtems_task_start( Task_id[TASKID_AVF2], avf2_task, 1 );
604 if (status!=RTEMS_SUCCESSFUL) {
604 if (status!=RTEMS_SUCCESSFUL) {
605 BOOT_PRINTF("in INIT *** Error starting TASK_AVF2\n")
605 BOOT_PRINTF("in INIT *** Error starting TASK_AVF2\n")
606 }
606 }
607 }
607 }
608 if (status == RTEMS_SUCCESSFUL) // PRC2
608 if (status == RTEMS_SUCCESSFUL) // PRC2
609 {
609 {
610 status = rtems_task_start( Task_id[TASKID_PRC2], prc2_task, 1 );
610 status = rtems_task_start( Task_id[TASKID_PRC2], prc2_task, 1 );
611 if (status!=RTEMS_SUCCESSFUL) {
611 if (status!=RTEMS_SUCCESSFUL) {
612 BOOT_PRINTF("in INIT *** Error starting TASK_PRC2\n")
612 BOOT_PRINTF("in INIT *** Error starting TASK_PRC2\n")
613 }
613 }
614 }
614 }
615
615
616 //****************
616 //****************
617 // WAVEFORM PICKER
617 // WAVEFORM PICKER
618 if (status == RTEMS_SUCCESSFUL) // WFRM
618 if (status == RTEMS_SUCCESSFUL) // WFRM
619 {
619 {
620 status = rtems_task_start( Task_id[TASKID_WFRM], wfrm_task, 1 );
620 status = rtems_task_start( Task_id[TASKID_WFRM], wfrm_task, 1 );
621 if (status!=RTEMS_SUCCESSFUL) {
621 if (status!=RTEMS_SUCCESSFUL) {
622 BOOT_PRINTF("in INIT *** Error starting TASK_WFRM\n")
622 BOOT_PRINTF("in INIT *** Error starting TASK_WFRM\n")
623 }
623 }
624 }
624 }
625 if (status == RTEMS_SUCCESSFUL) // CWF3
625 if (status == RTEMS_SUCCESSFUL) // CWF3
626 {
626 {
627 status = rtems_task_start( Task_id[TASKID_CWF3], cwf3_task, 1 );
627 status = rtems_task_start( Task_id[TASKID_CWF3], cwf3_task, 1 );
628 if (status!=RTEMS_SUCCESSFUL) {
628 if (status!=RTEMS_SUCCESSFUL) {
629 BOOT_PRINTF("in INIT *** Error starting TASK_CWF3\n")
629 BOOT_PRINTF("in INIT *** Error starting TASK_CWF3\n")
630 }
630 }
631 }
631 }
632 if (status == RTEMS_SUCCESSFUL) // CWF2
632 if (status == RTEMS_SUCCESSFUL) // CWF2
633 {
633 {
634 status = rtems_task_start( Task_id[TASKID_CWF2], cwf2_task, 1 );
634 status = rtems_task_start( Task_id[TASKID_CWF2], cwf2_task, 1 );
635 if (status!=RTEMS_SUCCESSFUL) {
635 if (status!=RTEMS_SUCCESSFUL) {
636 BOOT_PRINTF("in INIT *** Error starting TASK_CWF2\n")
636 BOOT_PRINTF("in INIT *** Error starting TASK_CWF2\n")
637 }
637 }
638 }
638 }
639 if (status == RTEMS_SUCCESSFUL) // CWF1
639 if (status == RTEMS_SUCCESSFUL) // CWF1
640 {
640 {
641 status = rtems_task_start( Task_id[TASKID_CWF1], cwf1_task, 1 );
641 status = rtems_task_start( Task_id[TASKID_CWF1], cwf1_task, 1 );
642 if (status!=RTEMS_SUCCESSFUL) {
642 if (status!=RTEMS_SUCCESSFUL) {
643 BOOT_PRINTF("in INIT *** Error starting TASK_CWF1\n")
643 BOOT_PRINTF("in INIT *** Error starting TASK_CWF1\n")
644 }
644 }
645 }
645 }
646 if (status == RTEMS_SUCCESSFUL) // SWBD
646 if (status == RTEMS_SUCCESSFUL) // SWBD
647 {
647 {
648 status = rtems_task_start( Task_id[TASKID_SWBD], swbd_task, 1 );
648 status = rtems_task_start( Task_id[TASKID_SWBD], swbd_task, 1 );
649 if (status!=RTEMS_SUCCESSFUL) {
649 if (status!=RTEMS_SUCCESSFUL) {
650 BOOT_PRINTF("in INIT *** Error starting TASK_SWBD\n")
650 BOOT_PRINTF("in INIT *** Error starting TASK_SWBD\n")
651 }
651 }
652 }
652 }
653
653
654 //*****
654 //*****
655 // MISC
655 // MISC
656 if (status == RTEMS_SUCCESSFUL) // HOUS
656 if (status == RTEMS_SUCCESSFUL) // HOUS
657 {
657 {
658 status = rtems_task_start( Task_id[TASKID_HOUS], hous_task, 1 );
658 status = rtems_task_start( Task_id[TASKID_HOUS], hous_task, 1 );
659 if (status!=RTEMS_SUCCESSFUL) {
659 if (status!=RTEMS_SUCCESSFUL) {
660 BOOT_PRINTF("in INIT *** Error starting TASK_HOUS\n")
660 BOOT_PRINTF("in INIT *** Error starting TASK_HOUS\n")
661 }
661 }
662 }
662 }
663 if (status == RTEMS_SUCCESSFUL) // DUMB
663 if (status == RTEMS_SUCCESSFUL) // DUMB
664 {
664 {
665 status = rtems_task_start( Task_id[TASKID_DUMB], dumb_task, 1 );
665 status = rtems_task_start( Task_id[TASKID_DUMB], dumb_task, 1 );
666 if (status!=RTEMS_SUCCESSFUL) {
666 if (status!=RTEMS_SUCCESSFUL) {
667 BOOT_PRINTF("in INIT *** Error starting TASK_DUMB\n")
667 BOOT_PRINTF("in INIT *** Error starting TASK_DUMB\n")
668 }
668 }
669 }
669 }
670 if (status == RTEMS_SUCCESSFUL) // STAT
670 if (status == RTEMS_SUCCESSFUL) // STAT
671 {
671 {
672 status = rtems_task_start( Task_id[TASKID_STAT], stat_task, 1 );
672 status = rtems_task_start( Task_id[TASKID_STAT], stat_task, 1 );
673 if (status!=RTEMS_SUCCESSFUL) {
673 if (status!=RTEMS_SUCCESSFUL) {
674 BOOT_PRINTF("in INIT *** Error starting TASK_STAT\n")
674 BOOT_PRINTF("in INIT *** Error starting TASK_STAT\n")
675 }
675 }
676 }
676 }
677
677
678 return status;
678 return status;
679 }
679 }
680
680
681 rtems_status_code create_message_queues( void ) // create the two message queues used in the software
681 rtems_status_code create_message_queues( void ) // create the two message queues used in the software
682 {
682 {
683 rtems_status_code status_recv;
683 rtems_status_code status_recv;
684 rtems_status_code status_send;
684 rtems_status_code status_send;
685 rtems_status_code status_q_p0;
685 rtems_status_code status_q_p0;
686 rtems_status_code status_q_p1;
686 rtems_status_code status_q_p1;
687 rtems_status_code status_q_p2;
687 rtems_status_code status_q_p2;
688 rtems_status_code ret;
688 rtems_status_code ret;
689 rtems_id queue_id;
689 rtems_id queue_id;
690
690
691 //****************************************
691 //****************************************
692 // create the queue for handling valid TCs
692 // create the queue for handling valid TCs
693 status_recv = rtems_message_queue_create( misc_name[QUEUE_RECV],
693 status_recv = rtems_message_queue_create( misc_name[QUEUE_RECV],
694 MSG_QUEUE_COUNT_RECV, CCSDS_TC_PKT_MAX_SIZE,
694 MSG_QUEUE_COUNT_RECV, CCSDS_TC_PKT_MAX_SIZE,
695 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
695 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
696 if ( status_recv != RTEMS_SUCCESSFUL ) {
696 if ( status_recv != RTEMS_SUCCESSFUL ) {
697 PRINTF1("in create_message_queues *** ERR creating QUEU queue, %d\n", status_recv)
697 PRINTF1("in create_message_queues *** ERR creating QUEU queue, %d\n", status_recv)
698 }
698 }
699
699
700 //************************************************
700 //************************************************
701 // create the queue for handling TM packet sending
701 // create the queue for handling TM packet sending
702 status_send = rtems_message_queue_create( misc_name[QUEUE_SEND],
702 status_send = rtems_message_queue_create( misc_name[QUEUE_SEND],
703 MSG_QUEUE_COUNT_SEND, MSG_QUEUE_SIZE_SEND,
703 MSG_QUEUE_COUNT_SEND, MSG_QUEUE_SIZE_SEND,
704 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
704 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
705 if ( status_send != RTEMS_SUCCESSFUL ) {
705 if ( status_send != RTEMS_SUCCESSFUL ) {
706 PRINTF1("in create_message_queues *** ERR creating PKTS queue, %d\n", status_send)
706 PRINTF1("in create_message_queues *** ERR creating PKTS queue, %d\n", status_send)
707 }
707 }
708
708
709 //*****************************************************************************
709 //*****************************************************************************
710 // create the queue for handling averaged spectral matrices for processing @ f0
710 // create the queue for handling averaged spectral matrices for processing @ f0
711 status_q_p0 = rtems_message_queue_create( misc_name[QUEUE_PRC0],
711 status_q_p0 = rtems_message_queue_create( misc_name[QUEUE_PRC0],
712 MSG_QUEUE_COUNT_PRC0, MSG_QUEUE_SIZE_PRC0,
712 MSG_QUEUE_COUNT_PRC0, MSG_QUEUE_SIZE_PRC0,
713 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
713 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
714 if ( status_q_p0 != RTEMS_SUCCESSFUL ) {
714 if ( status_q_p0 != RTEMS_SUCCESSFUL ) {
715 PRINTF1("in create_message_queues *** ERR creating Q_P0 queue, %d\n", status_q_p0)
715 PRINTF1("in create_message_queues *** ERR creating Q_P0 queue, %d\n", status_q_p0)
716 }
716 }
717
717
718 //*****************************************************************************
718 //*****************************************************************************
719 // create the queue for handling averaged spectral matrices for processing @ f1
719 // create the queue for handling averaged spectral matrices for processing @ f1
720 status_q_p1 = rtems_message_queue_create( misc_name[QUEUE_PRC1],
720 status_q_p1 = rtems_message_queue_create( misc_name[QUEUE_PRC1],
721 MSG_QUEUE_COUNT_PRC1, MSG_QUEUE_SIZE_PRC1,
721 MSG_QUEUE_COUNT_PRC1, MSG_QUEUE_SIZE_PRC1,
722 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
722 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
723 if ( status_q_p1 != RTEMS_SUCCESSFUL ) {
723 if ( status_q_p1 != RTEMS_SUCCESSFUL ) {
724 PRINTF1("in create_message_queues *** ERR creating Q_P1 queue, %d\n", status_q_p1)
724 PRINTF1("in create_message_queues *** ERR creating Q_P1 queue, %d\n", status_q_p1)
725 }
725 }
726
726
727 //*****************************************************************************
727 //*****************************************************************************
728 // create the queue for handling averaged spectral matrices for processing @ f2
728 // create the queue for handling averaged spectral matrices for processing @ f2
729 status_q_p2 = rtems_message_queue_create( misc_name[QUEUE_PRC2],
729 status_q_p2 = rtems_message_queue_create( misc_name[QUEUE_PRC2],
730 MSG_QUEUE_COUNT_PRC2, MSG_QUEUE_SIZE_PRC2,
730 MSG_QUEUE_COUNT_PRC2, MSG_QUEUE_SIZE_PRC2,
731 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
731 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
732 if ( status_q_p2 != RTEMS_SUCCESSFUL ) {
732 if ( status_q_p2 != RTEMS_SUCCESSFUL ) {
733 PRINTF1("in create_message_queues *** ERR creating Q_P2 queue, %d\n", status_q_p2)
733 PRINTF1("in create_message_queues *** ERR creating Q_P2 queue, %d\n", status_q_p2)
734 }
734 }
735
735
736 if ( status_recv != RTEMS_SUCCESSFUL )
736 if ( status_recv != RTEMS_SUCCESSFUL )
737 {
737 {
738 ret = status_recv;
738 ret = status_recv;
739 }
739 }
740 else if( status_send != RTEMS_SUCCESSFUL )
740 else if( status_send != RTEMS_SUCCESSFUL )
741 {
741 {
742 ret = status_send;
742 ret = status_send;
743 }
743 }
744 else if( status_q_p0 != RTEMS_SUCCESSFUL )
744 else if( status_q_p0 != RTEMS_SUCCESSFUL )
745 {
745 {
746 ret = status_q_p0;
746 ret = status_q_p0;
747 }
747 }
748 else if( status_q_p1 != RTEMS_SUCCESSFUL )
748 else if( status_q_p1 != RTEMS_SUCCESSFUL )
749 {
749 {
750 ret = status_q_p1;
750 ret = status_q_p1;
751 }
751 }
752 else
752 else
753 {
753 {
754 ret = status_q_p2;
754 ret = status_q_p2;
755 }
755 }
756
756
757 return ret;
757 return ret;
758 }
758 }
759
759
760 rtems_status_code get_message_queue_id_send( rtems_id *queue_id )
760 rtems_status_code get_message_queue_id_send( rtems_id *queue_id )
761 {
761 {
762 rtems_status_code status;
762 rtems_status_code status;
763 rtems_name queue_name;
763 rtems_name queue_name;
764
764
765 queue_name = rtems_build_name( 'Q', '_', 'S', 'D' );
765 queue_name = rtems_build_name( 'Q', '_', 'S', 'D' );
766
766
767 status = rtems_message_queue_ident( queue_name, 0, queue_id );
767 status = rtems_message_queue_ident( queue_name, 0, queue_id );
768
768
769 return status;
769 return status;
770 }
770 }
771
771
772 rtems_status_code get_message_queue_id_recv( rtems_id *queue_id )
772 rtems_status_code get_message_queue_id_recv( rtems_id *queue_id )
773 {
773 {
774 rtems_status_code status;
774 rtems_status_code status;
775 rtems_name queue_name;
775 rtems_name queue_name;
776
776
777 queue_name = rtems_build_name( 'Q', '_', 'R', 'V' );
777 queue_name = rtems_build_name( 'Q', '_', 'R', 'V' );
778
778
779 status = rtems_message_queue_ident( queue_name, 0, queue_id );
779 status = rtems_message_queue_ident( queue_name, 0, queue_id );
780
780
781 return status;
781 return status;
782 }
782 }
783
783
784 rtems_status_code get_message_queue_id_prc0( rtems_id *queue_id )
784 rtems_status_code get_message_queue_id_prc0( rtems_id *queue_id )
785 {
785 {
786 rtems_status_code status;
786 rtems_status_code status;
787 rtems_name queue_name;
787 rtems_name queue_name;
788
788
789 queue_name = rtems_build_name( 'Q', '_', 'P', '0' );
789 queue_name = rtems_build_name( 'Q', '_', 'P', '0' );
790
790
791 status = rtems_message_queue_ident( queue_name, 0, queue_id );
791 status = rtems_message_queue_ident( queue_name, 0, queue_id );
792
792
793 return status;
793 return status;
794 }
794 }
795
795
796 rtems_status_code get_message_queue_id_prc1( rtems_id *queue_id )
796 rtems_status_code get_message_queue_id_prc1( rtems_id *queue_id )
797 {
797 {
798 rtems_status_code status;
798 rtems_status_code status;
799 rtems_name queue_name;
799 rtems_name queue_name;
800
800
801 queue_name = rtems_build_name( 'Q', '_', 'P', '1' );
801 queue_name = rtems_build_name( 'Q', '_', 'P', '1' );
802
802
803 status = rtems_message_queue_ident( queue_name, 0, queue_id );
803 status = rtems_message_queue_ident( queue_name, 0, queue_id );
804
804
805 return status;
805 return status;
806 }
806 }
807
807
808 rtems_status_code get_message_queue_id_prc2( rtems_id *queue_id )
808 rtems_status_code get_message_queue_id_prc2( rtems_id *queue_id )
809 {
809 {
810 rtems_status_code status;
810 rtems_status_code status;
811 rtems_name queue_name;
811 rtems_name queue_name;
812
812
813 queue_name = rtems_build_name( 'Q', '_', 'P', '2' );
813 queue_name = rtems_build_name( 'Q', '_', 'P', '2' );
814
814
815 status = rtems_message_queue_ident( queue_name, 0, queue_id );
815 status = rtems_message_queue_ident( queue_name, 0, queue_id );
816
816
817 return status;
817 return status;
818 }
818 }
819
819
820 void update_queue_max_count( rtems_id queue_id, unsigned char*fifo_size_max )
820 void update_queue_max_count( rtems_id queue_id, unsigned char*fifo_size_max )
821 {
821 {
822 u_int32_t count;
822 u_int32_t count;
823 rtems_status_code status;
823 rtems_status_code status;
824
824
825 status = rtems_message_queue_get_number_pending( queue_id, &count );
825 status = rtems_message_queue_get_number_pending( queue_id, &count );
826
826
827 count = count + 1;
827 count = count + 1;
828
828
829 if (status != RTEMS_SUCCESSFUL)
829 if (status != RTEMS_SUCCESSFUL)
830 {
830 {
831 PRINTF1("in update_queue_max_count *** ERR = %d\n", status)
831 PRINTF1("in update_queue_max_count *** ERR = %d\n", status)
832 }
832 }
833 else
833 else
834 {
834 {
835 if (count > *fifo_size_max)
835 if (count > *fifo_size_max)
836 {
836 {
837 *fifo_size_max = count;
837 *fifo_size_max = count;
838 }
838 }
839 }
839 }
840 }
840 }
841
841
842 void init_ring(ring_node ring[], unsigned char nbNodes, volatile int buffer[], unsigned int bufferSize )
842 void init_ring(ring_node ring[], unsigned char nbNodes, volatile int buffer[], unsigned int bufferSize )
843 {
843 {
844 unsigned char i;
844 unsigned char i;
845
845
846 //***************
846 //***************
847 // BUFFER ADDRESS
847 // BUFFER ADDRESS
848 for(i=0; i<nbNodes; i++)
848 for(i=0; i<nbNodes; i++)
849 {
849 {
850 ring[i].coarseTime = 0xffffffff;
850 ring[i].coarseTime = 0xffffffff;
851 ring[i].fineTime = 0xffffffff;
851 ring[i].fineTime = 0xffffffff;
852 ring[i].sid = 0x00;
852 ring[i].sid = 0x00;
853 ring[i].status = 0x00;
853 ring[i].status = 0x00;
854 ring[i].buffer_address = (int) &buffer[ i * bufferSize ];
854 ring[i].buffer_address = (int) &buffer[ i * bufferSize ];
855 }
855 }
856
856
857 //*****
857 //*****
858 // NEXT
858 // NEXT
859 ring[ nbNodes - 1 ].next = (ring_node*) &ring[ 0 ];
859 ring[ nbNodes - 1 ].next = (ring_node*) &ring[ 0 ];
860 for(i=0; i<nbNodes-1; i++)
860 for(i=0; i<nbNodes-1; i++)
861 {
861 {
862 ring[i].next = (ring_node*) &ring[ i + 1 ];
862 ring[i].next = (ring_node*) &ring[ i + 1 ];
863 }
863 }
864
864
865 //*********
865 //*********
866 // PREVIOUS
866 // PREVIOUS
867 ring[ 0 ].previous = (ring_node*) &ring[ nbNodes - 1 ];
867 ring[ 0 ].previous = (ring_node*) &ring[ nbNodes - 1 ];
868 for(i=1; i<nbNodes; i++)
868 for(i=1; i<nbNodes; i++)
869 {
869 {
870 ring[i].previous = (ring_node*) &ring[ i - 1 ];
870 ring[i].previous = (ring_node*) &ring[ i - 1 ];
871 }
871 }
872 }
872 }
@@ -1,1322 +1,1525
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 TC; // TC sent to the ACTN task
32 ccsdsTelecommandPacket_t 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[6];
35 unsigned char time[6];
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 status = get_message_queue_id_recv( &queue_rcv_id );
39 status = get_message_queue_id_recv( &queue_rcv_id );
40 if (status != RTEMS_SUCCESSFUL)
40 if (status != RTEMS_SUCCESSFUL)
41 {
41 {
42 PRINTF1("in ACTN *** ERR get_message_queue_id_recv %d\n", status)
42 PRINTF1("in ACTN *** ERR get_message_queue_id_recv %d\n", status)
43 }
43 }
44
44
45 status = get_message_queue_id_send( &queue_snd_id );
45 status = get_message_queue_id_send( &queue_snd_id );
46 if (status != RTEMS_SUCCESSFUL)
46 if (status != RTEMS_SUCCESSFUL)
47 {
47 {
48 PRINTF1("in ACTN *** ERR get_message_queue_id_send %d\n", status)
48 PRINTF1("in ACTN *** ERR get_message_queue_id_send %d\n", status)
49 }
49 }
50
50
51 result = LFR_SUCCESSFUL;
51 result = LFR_SUCCESSFUL;
52 subtype = 0; // subtype of the current TC packet
52 subtype = 0; // subtype of the current TC packet
53
53
54 BOOT_PRINTF("in ACTN *** \n")
54 BOOT_PRINTF("in ACTN *** \n")
55
55
56 while(1)
56 while(1)
57 {
57 {
58 status = rtems_message_queue_receive( queue_rcv_id, (char*) &TC, &size,
58 status = rtems_message_queue_receive( queue_rcv_id, (char*) &TC, &size,
59 RTEMS_WAIT, RTEMS_NO_TIMEOUT);
59 RTEMS_WAIT, RTEMS_NO_TIMEOUT);
60 getTime( time ); // set time to the current time
60 getTime( time ); // set time to the current time
61 if (status!=RTEMS_SUCCESSFUL)
61 if (status!=RTEMS_SUCCESSFUL)
62 {
62 {
63 PRINTF1("ERR *** in task ACTN *** error receiving a message, code %d \n", status)
63 PRINTF1("ERR *** in task ACTN *** error receiving a message, code %d \n", status)
64 }
64 }
65 else
65 else
66 {
66 {
67 subtype = TC.serviceSubType;
67 subtype = TC.serviceSubType;
68 switch(subtype)
68 switch(subtype)
69 {
69 {
70 case TC_SUBTYPE_RESET:
70 case TC_SUBTYPE_RESET:
71 result = action_reset( &TC, queue_snd_id, time );
71 result = action_reset( &TC, queue_snd_id, time );
72 close_action( &TC, result, queue_snd_id );
72 close_action( &TC, result, queue_snd_id );
73 break;
73 break;
74 case TC_SUBTYPE_LOAD_COMM:
74 case TC_SUBTYPE_LOAD_COMM:
75 result = action_load_common_par( &TC );
75 result = action_load_common_par( &TC );
76 close_action( &TC, result, queue_snd_id );
76 close_action( &TC, result, queue_snd_id );
77 break;
77 break;
78 case TC_SUBTYPE_LOAD_NORM:
78 case TC_SUBTYPE_LOAD_NORM:
79 result = action_load_normal_par( &TC, queue_snd_id, time );
79 result = action_load_normal_par( &TC, queue_snd_id, time );
80 close_action( &TC, result, queue_snd_id );
80 close_action( &TC, result, queue_snd_id );
81 break;
81 break;
82 case TC_SUBTYPE_LOAD_BURST:
82 case TC_SUBTYPE_LOAD_BURST:
83 result = action_load_burst_par( &TC, queue_snd_id, time );
83 result = action_load_burst_par( &TC, queue_snd_id, time );
84 close_action( &TC, result, queue_snd_id );
84 close_action( &TC, result, queue_snd_id );
85 break;
85 break;
86 case TC_SUBTYPE_LOAD_SBM1:
86 case TC_SUBTYPE_LOAD_SBM1:
87 result = action_load_sbm1_par( &TC, queue_snd_id, time );
87 result = action_load_sbm1_par( &TC, queue_snd_id, time );
88 close_action( &TC, result, queue_snd_id );
88 close_action( &TC, result, queue_snd_id );
89 break;
89 break;
90 case TC_SUBTYPE_LOAD_SBM2:
90 case TC_SUBTYPE_LOAD_SBM2:
91 result = action_load_sbm2_par( &TC, queue_snd_id, time );
91 result = action_load_sbm2_par( &TC, queue_snd_id, time );
92 close_action( &TC, result, queue_snd_id );
92 close_action( &TC, result, queue_snd_id );
93 break;
93 break;
94 case TC_SUBTYPE_DUMP:
94 case TC_SUBTYPE_DUMP:
95 result = action_dump_par( &TC, queue_snd_id );
95 result = action_dump_par( &TC, queue_snd_id );
96 close_action( &TC, result, queue_snd_id );
96 close_action( &TC, result, queue_snd_id );
97 break;
97 break;
98 case TC_SUBTYPE_ENTER:
98 case TC_SUBTYPE_ENTER:
99 result = action_enter_mode( &TC, queue_snd_id );
99 result = action_enter_mode( &TC, queue_snd_id );
100 close_action( &TC, result, queue_snd_id );
100 close_action( &TC, result, queue_snd_id );
101 break;
101 break;
102 case TC_SUBTYPE_UPDT_INFO:
102 case TC_SUBTYPE_UPDT_INFO:
103 result = action_update_info( &TC, queue_snd_id );
103 result = action_update_info( &TC, queue_snd_id );
104 close_action( &TC, result, queue_snd_id );
104 close_action( &TC, result, queue_snd_id );
105 break;
105 break;
106 case TC_SUBTYPE_EN_CAL:
106 case TC_SUBTYPE_EN_CAL:
107 result = action_enable_calibration( &TC, queue_snd_id, time );
107 result = action_enable_calibration( &TC, queue_snd_id, time );
108 close_action( &TC, result, queue_snd_id );
108 close_action( &TC, result, queue_snd_id );
109 break;
109 break;
110 case TC_SUBTYPE_DIS_CAL:
110 case TC_SUBTYPE_DIS_CAL:
111 result = action_disable_calibration( &TC, queue_snd_id, time );
111 result = action_disable_calibration( &TC, queue_snd_id, time );
112 close_action( &TC, result, queue_snd_id );
112 close_action( &TC, result, queue_snd_id );
113 break;
113 break;
114 case TC_SUBTYPE_LOAD_K:
114 case TC_SUBTYPE_LOAD_K:
115 result = action_load_kcoefficients( &TC, queue_snd_id, time );
115 result = action_load_kcoefficients( &TC, queue_snd_id, time );
116 close_action( &TC, result, queue_snd_id );
116 close_action( &TC, result, queue_snd_id );
117 break;
117 break;
118 case TC_SUBTYPE_DUMP_K:
118 case TC_SUBTYPE_DUMP_K:
119 result = action_dump_kcoefficients( &TC, queue_snd_id, time );
119 result = action_dump_kcoefficients( &TC, queue_snd_id, time );
120 close_action( &TC, result, queue_snd_id );
120 close_action( &TC, result, queue_snd_id );
121 break;
121 break;
122 case TC_SUBTYPE_LOAD_FBINS:
122 case TC_SUBTYPE_LOAD_FBINS:
123 result = action_load_fbins_mask( &TC, queue_snd_id, time );
123 result = action_load_fbins_mask( &TC, queue_snd_id, time );
124 close_action( &TC, result, queue_snd_id );
124 close_action( &TC, result, queue_snd_id );
125 break;
125 break;
126 case TC_SUBTYPE_UPDT_TIME:
126 case TC_SUBTYPE_UPDT_TIME:
127 result = action_update_time( &TC );
127 result = action_update_time( &TC );
128 close_action( &TC, result, queue_snd_id );
128 close_action( &TC, result, queue_snd_id );
129 break;
129 break;
130 default:
130 default:
131 break;
131 break;
132 }
132 }
133 }
133 }
134 }
134 }
135 }
135 }
136
136
137 //***********
137 //***********
138 // TC ACTIONS
138 // TC ACTIONS
139
139
140 int action_reset(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
140 int action_reset(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
141 {
141 {
142 /** This function executes specific actions when a TC_LFR_RESET TeleCommand has been received.
142 /** This function executes specific actions when a TC_LFR_RESET TeleCommand has been received.
143 *
143 *
144 * @param TC points to the TeleCommand packet that is being processed
144 * @param TC points to the TeleCommand packet that is being processed
145 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
145 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
146 *
146 *
147 */
147 */
148
148
149 PRINTF("this is the end!!!\n")
149 PRINTF("this is the end!!!\n")
150 exit(0);
150 exit(0);
151 send_tm_lfr_tc_exe_not_implemented( TC, queue_id, time );
151 send_tm_lfr_tc_exe_not_implemented( TC, queue_id, time );
152 return LFR_DEFAULT;
152 return LFR_DEFAULT;
153 }
153 }
154
154
155 int action_enter_mode(ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
155 int action_enter_mode(ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
156 {
156 {
157 /** This function executes specific actions when a TC_LFR_ENTER_MODE TeleCommand has been received.
157 /** This function executes specific actions when a TC_LFR_ENTER_MODE TeleCommand has been received.
158 *
158 *
159 * @param TC points to the TeleCommand packet that is being processed
159 * @param TC points to the TeleCommand packet that is being processed
160 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
160 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
161 *
161 *
162 */
162 */
163
163
164 rtems_status_code status;
164 rtems_status_code status;
165 unsigned char requestedMode;
165 unsigned char requestedMode;
166 unsigned int *transitionCoarseTime_ptr;
166 unsigned int *transitionCoarseTime_ptr;
167 unsigned int transitionCoarseTime;
167 unsigned int transitionCoarseTime;
168 unsigned char * bytePosPtr;
168 unsigned char * bytePosPtr;
169
169
170 bytePosPtr = (unsigned char *) &TC->packetID;
170 bytePosPtr = (unsigned char *) &TC->packetID;
171
171
172 requestedMode = bytePosPtr[ BYTE_POS_CP_MODE_LFR_SET ];
172 requestedMode = bytePosPtr[ BYTE_POS_CP_MODE_LFR_SET ];
173 transitionCoarseTime_ptr = (unsigned int *) ( &bytePosPtr[ BYTE_POS_CP_LFR_ENTER_MODE_TIME ] );
173 transitionCoarseTime_ptr = (unsigned int *) ( &bytePosPtr[ BYTE_POS_CP_LFR_ENTER_MODE_TIME ] );
174 transitionCoarseTime = (*transitionCoarseTime_ptr) & 0x7fffffff;
174 transitionCoarseTime = (*transitionCoarseTime_ptr) & 0x7fffffff;
175
175
176 status = check_mode_value( requestedMode );
176 status = check_mode_value( requestedMode );
177
177
178 if ( status != LFR_SUCCESSFUL ) // the mode value is inconsistent
178 if ( status != LFR_SUCCESSFUL ) // the mode value is inconsistent
179 {
179 {
180 send_tm_lfr_tc_exe_inconsistent( TC, queue_id, BYTE_POS_CP_MODE_LFR_SET, requestedMode );
180 send_tm_lfr_tc_exe_inconsistent( TC, queue_id, BYTE_POS_CP_MODE_LFR_SET, requestedMode );
181 }
181 }
182 else // the mode value is valid, check the transition
182 else // the mode value is valid, check the transition
183 {
183 {
184 status = check_mode_transition(requestedMode);
184 status = check_mode_transition(requestedMode);
185 if (status != LFR_SUCCESSFUL)
185 if (status != LFR_SUCCESSFUL)
186 {
186 {
187 PRINTF("ERR *** in action_enter_mode *** check_mode_transition\n")
187 PRINTF("ERR *** in action_enter_mode *** check_mode_transition\n")
188 send_tm_lfr_tc_exe_not_executable( TC, queue_id );
188 send_tm_lfr_tc_exe_not_executable( TC, queue_id );
189 }
189 }
190 }
190 }
191
191
192 if ( status == LFR_SUCCESSFUL ) // the transition is valid, check the date
192 if ( status == LFR_SUCCESSFUL ) // the transition is valid, check the date
193 {
193 {
194 status = check_transition_date( transitionCoarseTime );
194 status = check_transition_date( transitionCoarseTime );
195 if (status != LFR_SUCCESSFUL)
195 if (status != LFR_SUCCESSFUL)
196 {
196 {
197 PRINTF("ERR *** in action_enter_mode *** check_transition_date\n")
197 PRINTF("ERR *** in action_enter_mode *** check_transition_date\n")
198 send_tm_lfr_tc_exe_inconsistent( TC, queue_id,
198 send_tm_lfr_tc_exe_inconsistent( TC, queue_id,
199 BYTE_POS_CP_LFR_ENTER_MODE_TIME,
199 BYTE_POS_CP_LFR_ENTER_MODE_TIME,
200 bytePosPtr[ BYTE_POS_CP_LFR_ENTER_MODE_TIME + 3 ] );
200 bytePosPtr[ BYTE_POS_CP_LFR_ENTER_MODE_TIME + 3 ] );
201 }
201 }
202 }
202 }
203
203
204 if ( status == LFR_SUCCESSFUL ) // the date is valid, enter the mode
204 if ( status == LFR_SUCCESSFUL ) // the date is valid, enter the mode
205 {
205 {
206 PRINTF1("OK *** in action_enter_mode *** enter mode %d\n", requestedMode);
206 PRINTF1("OK *** in action_enter_mode *** enter mode %d\n", requestedMode);
207
207
208 switch(requestedMode)
208 switch(requestedMode)
209 {
209 {
210 case LFR_MODE_STANDBY:
210 case LFR_MODE_STANDBY:
211 status = enter_mode_standby();
211 status = enter_mode_standby();
212 break;
212 break;
213 case LFR_MODE_NORMAL:
213 case LFR_MODE_NORMAL:
214 status = enter_mode_normal( transitionCoarseTime );
214 status = enter_mode_normal( transitionCoarseTime );
215 break;
215 break;
216 case LFR_MODE_BURST:
216 case LFR_MODE_BURST:
217 status = enter_mode_burst( transitionCoarseTime );
217 status = enter_mode_burst( transitionCoarseTime );
218 break;
218 break;
219 case LFR_MODE_SBM1:
219 case LFR_MODE_SBM1:
220 status = enter_mode_sbm1( transitionCoarseTime );
220 status = enter_mode_sbm1( transitionCoarseTime );
221 break;
221 break;
222 case LFR_MODE_SBM2:
222 case LFR_MODE_SBM2:
223 status = enter_mode_sbm2( transitionCoarseTime );
223 status = enter_mode_sbm2( transitionCoarseTime );
224 break;
224 break;
225 default:
225 default:
226 break;
226 break;
227 }
227 }
228 }
228 }
229
229
230 return status;
230 return status;
231 }
231 }
232
232
233 int action_update_info(ccsdsTelecommandPacket_t *TC, rtems_id queue_id)
233 int action_update_info(ccsdsTelecommandPacket_t *TC, rtems_id queue_id)
234 {
234 {
235 /** This function executes specific actions when a TC_LFR_UPDATE_INFO TeleCommand has been received.
235 /** This function executes specific actions when a TC_LFR_UPDATE_INFO TeleCommand has been received.
236 *
236 *
237 * @param TC points to the TeleCommand packet that is being processed
237 * @param TC points to the TeleCommand packet that is being processed
238 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
238 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
239 *
239 *
240 * @return LFR directive status code:
240 * @return LFR directive status code:
241 * - LFR_DEFAULT
241 * - LFR_DEFAULT
242 * - LFR_SUCCESSFUL
242 * - LFR_SUCCESSFUL
243 *
243 *
244 */
244 */
245
245
246 unsigned int val;
246 unsigned int val;
247 int result;
247 int result;
248 unsigned int status;
248 unsigned int status;
249 unsigned char mode;
249 unsigned char mode;
250 unsigned char * bytePosPtr;
250 unsigned char * bytePosPtr;
251
251
252 bytePosPtr = (unsigned char *) &TC->packetID;
252 bytePosPtr = (unsigned char *) &TC->packetID;
253
253
254 // check LFR mode
254 // check LFR mode
255 mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET5 ] & 0x1e) >> 1;
255 mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET5 ] & 0x1e) >> 1;
256 status = check_update_info_hk_lfr_mode( mode );
256 status = check_update_info_hk_lfr_mode( mode );
257 if (status == LFR_SUCCESSFUL) // check TDS mode
257 if (status == LFR_SUCCESSFUL) // check TDS mode
258 {
258 {
259 mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET6 ] & 0xf0) >> 4;
259 mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET6 ] & 0xf0) >> 4;
260 status = check_update_info_hk_tds_mode( mode );
260 status = check_update_info_hk_tds_mode( mode );
261 }
261 }
262 if (status == LFR_SUCCESSFUL) // check THR mode
262 if (status == LFR_SUCCESSFUL) // check THR mode
263 {
263 {
264 mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET6 ] & 0x0f);
264 mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET6 ] & 0x0f);
265 status = check_update_info_hk_thr_mode( mode );
265 status = check_update_info_hk_thr_mode( mode );
266 }
266 }
267 if (status == LFR_SUCCESSFUL) // if the parameter check is successful
267 if (status == LFR_SUCCESSFUL) // if the parameter check is successful
268 {
268 {
269 val = housekeeping_packet.hk_lfr_update_info_tc_cnt[0] * 256
269 val = housekeeping_packet.hk_lfr_update_info_tc_cnt[0] * 256
270 + housekeeping_packet.hk_lfr_update_info_tc_cnt[1];
270 + housekeeping_packet.hk_lfr_update_info_tc_cnt[1];
271 val++;
271 val++;
272 housekeeping_packet.hk_lfr_update_info_tc_cnt[0] = (unsigned char) (val >> 8);
272 housekeeping_packet.hk_lfr_update_info_tc_cnt[0] = (unsigned char) (val >> 8);
273 housekeeping_packet.hk_lfr_update_info_tc_cnt[1] = (unsigned char) (val);
273 housekeeping_packet.hk_lfr_update_info_tc_cnt[1] = (unsigned char) (val);
274 }
274 }
275
275
276 // pa_bia_status_info
276 // pa_bia_status_info
277 // => pa_bia_mode_mux_set 3 bits
277 // => pa_bia_mode_mux_set 3 bits
278 // => pa_bia_mode_hv_enabled 1 bit
278 // => pa_bia_mode_hv_enabled 1 bit
279 // => pa_bia_mode_bias1_enabled 1 bit
279 // => pa_bia_mode_bias1_enabled 1 bit
280 // => pa_bia_mode_bias2_enabled 1 bit
280 // => pa_bia_mode_bias2_enabled 1 bit
281 // => pa_bia_mode_bias3_enabled 1 bit
281 // => pa_bia_mode_bias3_enabled 1 bit
282 // => pa_bia_on_off (cp_dpu_bias_on_off)
282 // => pa_bia_on_off (cp_dpu_bias_on_off)
283 pa_bia_status_info = bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET2 ] & 0xfe; // [1111 1110]
283 pa_bia_status_info = bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET2 ] & 0xfe; // [1111 1110]
284 pa_bia_status_info = pa_bia_status_info
284 pa_bia_status_info = pa_bia_status_info
285 | (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET1 ] & 0x1);
285 | (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET1 ] & 0x1);
286
286
287 result = status;
287 result = status;
288
288
289 return result;
289 return result;
290 }
290 }
291
291
292 int action_enable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
292 int action_enable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
293 {
293 {
294 /** This function executes specific actions when a TC_LFR_ENABLE_CALIBRATION TeleCommand has been received.
294 /** This function executes specific actions when a TC_LFR_ENABLE_CALIBRATION TeleCommand has been received.
295 *
295 *
296 * @param TC points to the TeleCommand packet that is being processed
296 * @param TC points to the TeleCommand packet that is being processed
297 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
297 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
298 *
298 *
299 */
299 */
300
300
301 int result;
301 int result;
302
302
303 result = LFR_DEFAULT;
303 result = LFR_DEFAULT;
304
304
305 setCalibration( true );
305 setCalibration( true );
306
306
307 result = LFR_SUCCESSFUL;
307 result = LFR_SUCCESSFUL;
308
308
309 return result;
309 return result;
310 }
310 }
311
311
312 int action_disable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
312 int action_disable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
313 {
313 {
314 /** This function executes specific actions when a TC_LFR_DISABLE_CALIBRATION TeleCommand has been received.
314 /** This function executes specific actions when a TC_LFR_DISABLE_CALIBRATION TeleCommand has been received.
315 *
315 *
316 * @param TC points to the TeleCommand packet that is being processed
316 * @param TC points to the TeleCommand packet that is being processed
317 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
317 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
318 *
318 *
319 */
319 */
320
320
321 int result;
321 int result;
322
322
323 result = LFR_DEFAULT;
323 result = LFR_DEFAULT;
324
324
325 setCalibration( false );
325 setCalibration( false );
326
326
327 result = LFR_SUCCESSFUL;
327 result = LFR_SUCCESSFUL;
328
328
329 return result;
329 return result;
330 }
330 }
331
331
332 int action_update_time(ccsdsTelecommandPacket_t *TC)
332 int action_update_time(ccsdsTelecommandPacket_t *TC)
333 {
333 {
334 /** This function executes specific actions when a TC_LFR_UPDATE_TIME TeleCommand has been received.
334 /** This function executes specific actions when a TC_LFR_UPDATE_TIME TeleCommand has been received.
335 *
335 *
336 * @param TC points to the TeleCommand packet that is being processed
336 * @param TC points to the TeleCommand packet that is being processed
337 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
337 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
338 *
338 *
339 * @return LFR_SUCCESSFUL
339 * @return LFR_SUCCESSFUL
340 *
340 *
341 */
341 */
342
342
343 unsigned int val;
343 unsigned int val;
344
344
345 time_management_regs->coarse_time_load = (TC->dataAndCRC[0] << 24)
345 time_management_regs->coarse_time_load = (TC->dataAndCRC[0] << 24)
346 + (TC->dataAndCRC[1] << 16)
346 + (TC->dataAndCRC[1] << 16)
347 + (TC->dataAndCRC[2] << 8)
347 + (TC->dataAndCRC[2] << 8)
348 + TC->dataAndCRC[3];
348 + TC->dataAndCRC[3];
349
349
350 val = housekeeping_packet.hk_lfr_update_time_tc_cnt[0] * 256
350 val = housekeeping_packet.hk_lfr_update_time_tc_cnt[0] * 256
351 + housekeeping_packet.hk_lfr_update_time_tc_cnt[1];
351 + housekeeping_packet.hk_lfr_update_time_tc_cnt[1];
352 val++;
352 val++;
353 housekeeping_packet.hk_lfr_update_time_tc_cnt[0] = (unsigned char) (val >> 8);
353 housekeeping_packet.hk_lfr_update_time_tc_cnt[0] = (unsigned char) (val >> 8);
354 housekeeping_packet.hk_lfr_update_time_tc_cnt[1] = (unsigned char) (val);
354 housekeeping_packet.hk_lfr_update_time_tc_cnt[1] = (unsigned char) (val);
355
355
356 return LFR_SUCCESSFUL;
356 return LFR_SUCCESSFUL;
357 }
357 }
358
358
359 //*******************
359 //*******************
360 // ENTERING THE MODES
360 // ENTERING THE MODES
361 int check_mode_value( unsigned char requestedMode )
361 int check_mode_value( unsigned char requestedMode )
362 {
362 {
363 int status;
363 int status;
364
364
365 if ( (requestedMode != LFR_MODE_STANDBY)
365 if ( (requestedMode != LFR_MODE_STANDBY)
366 && (requestedMode != LFR_MODE_NORMAL) && (requestedMode != LFR_MODE_BURST)
366 && (requestedMode != LFR_MODE_NORMAL) && (requestedMode != LFR_MODE_BURST)
367 && (requestedMode != LFR_MODE_SBM1) && (requestedMode != LFR_MODE_SBM2) )
367 && (requestedMode != LFR_MODE_SBM1) && (requestedMode != LFR_MODE_SBM2) )
368 {
368 {
369 status = LFR_DEFAULT;
369 status = LFR_DEFAULT;
370 }
370 }
371 else
371 else
372 {
372 {
373 status = LFR_SUCCESSFUL;
373 status = LFR_SUCCESSFUL;
374 }
374 }
375
375
376 return status;
376 return status;
377 }
377 }
378
378
379 int check_mode_transition( unsigned char requestedMode )
379 int check_mode_transition( unsigned char requestedMode )
380 {
380 {
381 /** This function checks the validity of the transition requested by the TC_LFR_ENTER_MODE.
381 /** This function checks the validity of the transition requested by the TC_LFR_ENTER_MODE.
382 *
382 *
383 * @param requestedMode is the mode requested by the TC_LFR_ENTER_MODE
383 * @param requestedMode is the mode requested by the TC_LFR_ENTER_MODE
384 *
384 *
385 * @return LFR directive status codes:
385 * @return LFR directive status codes:
386 * - LFR_SUCCESSFUL - the transition is authorized
386 * - LFR_SUCCESSFUL - the transition is authorized
387 * - LFR_DEFAULT - the transition is not authorized
387 * - LFR_DEFAULT - the transition is not authorized
388 *
388 *
389 */
389 */
390
390
391 int status;
391 int status;
392
392
393 switch (requestedMode)
393 switch (requestedMode)
394 {
394 {
395 case LFR_MODE_STANDBY:
395 case LFR_MODE_STANDBY:
396 if ( lfrCurrentMode == LFR_MODE_STANDBY ) {
396 if ( lfrCurrentMode == LFR_MODE_STANDBY ) {
397 status = LFR_DEFAULT;
397 status = LFR_DEFAULT;
398 }
398 }
399 else
399 else
400 {
400 {
401 status = LFR_SUCCESSFUL;
401 status = LFR_SUCCESSFUL;
402 }
402 }
403 break;
403 break;
404 case LFR_MODE_NORMAL:
404 case LFR_MODE_NORMAL:
405 if ( lfrCurrentMode == LFR_MODE_NORMAL ) {
405 if ( lfrCurrentMode == LFR_MODE_NORMAL ) {
406 status = LFR_DEFAULT;
406 status = LFR_DEFAULT;
407 }
407 }
408 else {
408 else {
409 status = LFR_SUCCESSFUL;
409 status = LFR_SUCCESSFUL;
410 }
410 }
411 break;
411 break;
412 case LFR_MODE_BURST:
412 case LFR_MODE_BURST:
413 if ( lfrCurrentMode == LFR_MODE_BURST ) {
413 if ( lfrCurrentMode == LFR_MODE_BURST ) {
414 status = LFR_DEFAULT;
414 status = LFR_DEFAULT;
415 }
415 }
416 else {
416 else {
417 status = LFR_SUCCESSFUL;
417 status = LFR_SUCCESSFUL;
418 }
418 }
419 break;
419 break;
420 case LFR_MODE_SBM1:
420 case LFR_MODE_SBM1:
421 if ( lfrCurrentMode == LFR_MODE_SBM1 ) {
421 if ( lfrCurrentMode == LFR_MODE_SBM1 ) {
422 status = LFR_DEFAULT;
422 status = LFR_DEFAULT;
423 }
423 }
424 else {
424 else {
425 status = LFR_SUCCESSFUL;
425 status = LFR_SUCCESSFUL;
426 }
426 }
427 break;
427 break;
428 case LFR_MODE_SBM2:
428 case LFR_MODE_SBM2:
429 if ( lfrCurrentMode == LFR_MODE_SBM2 ) {
429 if ( lfrCurrentMode == LFR_MODE_SBM2 ) {
430 status = LFR_DEFAULT;
430 status = LFR_DEFAULT;
431 }
431 }
432 else {
432 else {
433 status = LFR_SUCCESSFUL;
433 status = LFR_SUCCESSFUL;
434 }
434 }
435 break;
435 break;
436 default:
436 default:
437 status = LFR_DEFAULT;
437 status = LFR_DEFAULT;
438 break;
438 break;
439 }
439 }
440
440
441 return status;
441 return status;
442 }
442 }
443
443
444 int check_transition_date( unsigned int transitionCoarseTime )
444 int check_transition_date( unsigned int transitionCoarseTime )
445 {
445 {
446 int status;
446 int status;
447 unsigned int localCoarseTime;
447 unsigned int localCoarseTime;
448 unsigned int deltaCoarseTime;
448 unsigned int deltaCoarseTime;
449
449
450 status = LFR_SUCCESSFUL;
450 status = LFR_SUCCESSFUL;
451
451
452 if (transitionCoarseTime == 0) // transition time = 0 means an instant transition
452 if (transitionCoarseTime == 0) // transition time = 0 means an instant transition
453 {
453 {
454 status = LFR_SUCCESSFUL;
454 status = LFR_SUCCESSFUL;
455 }
455 }
456 else
456 else
457 {
457 {
458 localCoarseTime = time_management_regs->coarse_time & 0x7fffffff;
458 localCoarseTime = time_management_regs->coarse_time & 0x7fffffff;
459
459
460 PRINTF2("localTime = %x, transitionTime = %x\n", localCoarseTime, transitionCoarseTime)
460 PRINTF2("localTime = %x, transitionTime = %x\n", localCoarseTime, transitionCoarseTime)
461
461
462 if ( transitionCoarseTime <= localCoarseTime ) // SSS-CP-EQS-322
462 if ( transitionCoarseTime <= localCoarseTime ) // SSS-CP-EQS-322
463 {
463 {
464 status = LFR_DEFAULT;
464 status = LFR_DEFAULT;
465 PRINTF("ERR *** in check_transition_date *** transitionCoarseTime <= localCoarseTime\n")
465 PRINTF("ERR *** in check_transition_date *** transitionCoarseTime <= localCoarseTime\n")
466 }
466 }
467
467
468 if (status == LFR_SUCCESSFUL)
468 if (status == LFR_SUCCESSFUL)
469 {
469 {
470 deltaCoarseTime = transitionCoarseTime - localCoarseTime;
470 deltaCoarseTime = transitionCoarseTime - localCoarseTime;
471 if ( deltaCoarseTime > 3 ) // SSS-CP-EQS-323
471 if ( deltaCoarseTime > 3 ) // SSS-CP-EQS-323
472 {
472 {
473 status = LFR_DEFAULT;
473 status = LFR_DEFAULT;
474 PRINTF1("ERR *** in check_transition_date *** deltaCoarseTime = %x\n", deltaCoarseTime)
474 PRINTF1("ERR *** in check_transition_date *** deltaCoarseTime = %x\n", deltaCoarseTime)
475 }
475 }
476 }
476 }
477 }
477 }
478
478
479 return status;
479 return status;
480 }
480 }
481
481
482 int restart_asm_activities( unsigned char lfrRequestedMode )
483 {
484 rtems_status_code status;
485
486 status = stop_spectral_matrices();
487
488 status = restart_asm_tasks( lfrRequestedMode );
489
490 launch_spectral_matrix();
491
492 return status;
493 }
494
495 int stop_spectral_matrices( void )
496 {
497 /** This function stops and restarts the current mode average spectral matrices activities.
498 *
499 * @return RTEMS directive status codes:
500 * - RTEMS_SUCCESSFUL - task restarted successfully
501 * - RTEMS_INVALID_ID - task id invalid
502 * - RTEMS_ALREADY_SUSPENDED - task already suspended
503 *
504 */
505
506 rtems_status_code status;
507
508 status = RTEMS_SUCCESSFUL;
509
510 // (1) mask interruptions
511 LEON_Mask_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt
512
513 // (2) reset spectral matrices registers
514 set_sm_irq_onNewMatrix( 0 ); // stop the spectral matrices
515 reset_sm_status();
516
517 // (3) clear interruptions
518 LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt
519
520 // suspend several tasks
521 if (lfrCurrentMode != LFR_MODE_STANDBY) {
522 status = suspend_asm_tasks();
523 }
524
525 if (status != RTEMS_SUCCESSFUL)
526 {
527 PRINTF1("in stop_current_mode *** in suspend_science_tasks *** ERR code: %d\n", status)
528 }
529
530 return status;
531 }
532
482 int stop_current_mode( void )
533 int stop_current_mode( void )
483 {
534 {
484 /** This function stops the current mode by masking interrupt lines and suspending science tasks.
535 /** This function stops the current mode by masking interrupt lines and suspending science tasks.
485 *
536 *
486 * @return RTEMS directive status codes:
537 * @return RTEMS directive status codes:
487 * - RTEMS_SUCCESSFUL - task restarted successfully
538 * - RTEMS_SUCCESSFUL - task restarted successfully
488 * - RTEMS_INVALID_ID - task id invalid
539 * - RTEMS_INVALID_ID - task id invalid
489 * - RTEMS_ALREADY_SUSPENDED - task already suspended
540 * - RTEMS_ALREADY_SUSPENDED - task already suspended
490 *
541 *
491 */
542 */
492
543
493 rtems_status_code status;
544 rtems_status_code status;
494
545
495 status = RTEMS_SUCCESSFUL;
546 status = RTEMS_SUCCESSFUL;
496
547
497 // (1) mask interruptions
548 // (1) mask interruptions
498 LEON_Mask_interrupt( IRQ_WAVEFORM_PICKER ); // mask waveform picker interrupt
549 LEON_Mask_interrupt( IRQ_WAVEFORM_PICKER ); // mask waveform picker interrupt
499 LEON_Mask_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt
550 LEON_Mask_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt
500
551
501 // (2) reset waveform picker registers
552 // (2) reset waveform picker registers
502 reset_wfp_burst_enable(); // reset burst and enable bits
553 reset_wfp_burst_enable(); // reset burst and enable bits
503 reset_wfp_status(); // reset all the status bits
554 reset_wfp_status(); // reset all the status bits
504
555
505 // (3) reset spectral matrices registers
556 // (3) reset spectral matrices registers
506 set_sm_irq_onNewMatrix( 0 ); // stop the spectral matrices
557 set_sm_irq_onNewMatrix( 0 ); // stop the spectral matrices
507 reset_sm_status();
558 reset_sm_status();
508
559
509 // reset lfr VHDL module
560 // reset lfr VHDL module
510 reset_lfr();
561 reset_lfr();
511
562
512 reset_extractSWF(); // reset the extractSWF flag to false
563 reset_extractSWF(); // reset the extractSWF flag to false
513
564
514 // (4) clear interruptions
565 // (4) clear interruptions
515 LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER ); // clear waveform picker interrupt
566 LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER ); // clear waveform picker interrupt
516 LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt
567 LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt
517
568
518 // <Spectral Matrices simulator>
569 // <Spectral Matrices simulator>
519 LEON_Mask_interrupt( IRQ_SM_SIMULATOR ); // mask spectral matrix interrupt simulator
570 LEON_Mask_interrupt( IRQ_SM_SIMULATOR ); // mask spectral matrix interrupt simulator
520 timer_stop( (gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR );
571 timer_stop( (gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR );
521 LEON_Clear_interrupt( IRQ_SM_SIMULATOR ); // clear spectral matrix interrupt simulator
572 LEON_Clear_interrupt( IRQ_SM_SIMULATOR ); // clear spectral matrix interrupt simulator
522 // </Spectral Matrices simulator>
573 // </Spectral Matrices simulator>
523
574
524 // suspend several tasks
575 // suspend several tasks
525 if (lfrCurrentMode != LFR_MODE_STANDBY) {
576 if (lfrCurrentMode != LFR_MODE_STANDBY) {
526 status = suspend_science_tasks();
577 status = suspend_science_tasks();
527 }
578 }
528
579
529 if (status != RTEMS_SUCCESSFUL)
580 if (status != RTEMS_SUCCESSFUL)
530 {
581 {
531 PRINTF1("in stop_current_mode *** in suspend_science_tasks *** ERR code: %d\n", status)
582 PRINTF1("in stop_current_mode *** in suspend_science_tasks *** ERR code: %d\n", status)
532 }
583 }
533
584
534 return status;
585 return status;
535 }
586 }
536
587
537 int enter_mode_standby()
588 int enter_mode_standby()
538 {
589 {
539 int status;
590 int status;
540
591
541 status = stop_current_mode(); // STOP THE CURRENT MODE
592 status = stop_current_mode(); // STOP THE CURRENT MODE
542
593
543 #ifdef PRINT_TASK_STATISTICS
594 #ifdef PRINT_TASK_STATISTICS
544 rtems_cpu_usage_report();
595 rtems_cpu_usage_report();
545 #endif
596 #endif
546
597
547 #ifdef PRINT_STACK_REPORT
598 #ifdef PRINT_STACK_REPORT
548 PRINTF("stack report selected\n")
599 PRINTF("stack report selected\n")
549 rtems_stack_checker_report_usage();
600 rtems_stack_checker_report_usage();
550 #endif
601 #endif
551
602
552 return status;
603 return status;
553 }
604 }
554
605
555 int enter_mode_normal( unsigned int transitionCoarseTime )
606 int enter_mode_normal( unsigned int transitionCoarseTime )
556 {
607 {
557 int status;
608 int status;
558
609
559 #ifdef PRINT_TASK_STATISTICS
610 #ifdef PRINT_TASK_STATISTICS
560 rtems_cpu_usage_reset();
611 rtems_cpu_usage_reset();
561 #endif
612 #endif
562
613
563 status = RTEMS_UNSATISFIED;
614 status = RTEMS_UNSATISFIED;
564
615
565 switch( lfrCurrentMode )
616 switch( lfrCurrentMode )
566 {
617 {
567 case LFR_MODE_STANDBY:
618 case LFR_MODE_STANDBY:
568 status = restart_science_tasks( LFR_MODE_NORMAL ); // restart science tasks
619 status = restart_science_tasks( LFR_MODE_NORMAL ); // restart science tasks
569 if (status == RTEMS_SUCCESSFUL) // relaunch spectral_matrix and waveform_picker modules
620 if (status == RTEMS_SUCCESSFUL) // relaunch spectral_matrix and waveform_picker modules
570 {
621 {
571 launch_spectral_matrix( );
622 launch_spectral_matrix( );
572 launch_waveform_picker( LFR_MODE_NORMAL, transitionCoarseTime );
623 launch_waveform_picker( LFR_MODE_NORMAL, transitionCoarseTime );
573 }
624 }
574 break;
625 break;
575 case LFR_MODE_BURST:
626 case LFR_MODE_BURST:
576 status = stop_current_mode(); // stop the current mode
627 status = stop_current_mode(); // stop the current mode
577 status = restart_science_tasks( LFR_MODE_NORMAL ); // restart the science tasks
628 status = restart_science_tasks( LFR_MODE_NORMAL ); // restart the science tasks
578 if (status == RTEMS_SUCCESSFUL) // relaunch spectral_matrix and waveform_picker modules
629 if (status == RTEMS_SUCCESSFUL) // relaunch spectral_matrix and waveform_picker modules
579 {
630 {
580 launch_spectral_matrix( );
631 launch_spectral_matrix( );
581 launch_waveform_picker( LFR_MODE_NORMAL, transitionCoarseTime );
632 launch_waveform_picker( LFR_MODE_NORMAL, transitionCoarseTime );
582 }
633 }
583 break;
634 break;
584 case LFR_MODE_SBM1:
635 case LFR_MODE_SBM1:
636 restart_asm_activities( LFR_MODE_NORMAL );
585 status = LFR_SUCCESSFUL; // lfrCurrentMode will be updated after the execution of close_action
637 status = LFR_SUCCESSFUL; // lfrCurrentMode will be updated after the execution of close_action
586 break;
638 break;
587 case LFR_MODE_SBM2:
639 case LFR_MODE_SBM2:
640 restart_asm_activities( LFR_MODE_NORMAL );
588 status = LFR_SUCCESSFUL; // lfrCurrentMode will be updated after the execution of close_action
641 status = LFR_SUCCESSFUL; // lfrCurrentMode will be updated after the execution of close_action
589 break;
642 break;
590 default:
643 default:
591 break;
644 break;
592 }
645 }
593
646
594 if (status != RTEMS_SUCCESSFUL)
647 if (status != RTEMS_SUCCESSFUL)
595 {
648 {
596 PRINTF1("ERR *** in enter_mode_normal *** status = %d\n", status)
649 PRINTF1("ERR *** in enter_mode_normal *** status = %d\n", status)
597 status = RTEMS_UNSATISFIED;
650 status = RTEMS_UNSATISFIED;
598 }
651 }
599
652
600 return status;
653 return status;
601 }
654 }
602
655
603 int enter_mode_burst( unsigned int transitionCoarseTime )
656 int enter_mode_burst( unsigned int transitionCoarseTime )
604 {
657 {
605 int status;
658 int status;
606
659
607 #ifdef PRINT_TASK_STATISTICS
660 #ifdef PRINT_TASK_STATISTICS
608 rtems_cpu_usage_reset();
661 rtems_cpu_usage_reset();
609 #endif
662 #endif
610
663
611 status = stop_current_mode(); // stop the current mode
664 status = stop_current_mode(); // stop the current mode
612 status = restart_science_tasks( LFR_MODE_BURST ); // restart the science tasks
665 status = restart_science_tasks( LFR_MODE_BURST ); // restart the science tasks
613 if (status == RTEMS_SUCCESSFUL) // relaunch spectral_matrix and waveform_picker modules
666 if (status == RTEMS_SUCCESSFUL) // relaunch spectral_matrix and waveform_picker modules
614 {
667 {
615 launch_spectral_matrix( );
668 launch_spectral_matrix( );
616 launch_waveform_picker( LFR_MODE_BURST, transitionCoarseTime );
669 launch_waveform_picker( LFR_MODE_BURST, transitionCoarseTime );
617 }
670 }
618
671
619 if (status != RTEMS_SUCCESSFUL)
672 if (status != RTEMS_SUCCESSFUL)
620 {
673 {
621 PRINTF1("ERR *** in enter_mode_burst *** status = %d\n", status)
674 PRINTF1("ERR *** in enter_mode_burst *** status = %d\n", status)
622 status = RTEMS_UNSATISFIED;
675 status = RTEMS_UNSATISFIED;
623 }
676 }
624
677
625 return status;
678 return status;
626 }
679 }
627
680
628 int enter_mode_sbm1( unsigned int transitionCoarseTime )
681 int enter_mode_sbm1( unsigned int transitionCoarseTime )
629 {
682 {
630 int status;
683 int status;
631
684
632 #ifdef PRINT_TASK_STATISTICS
685 #ifdef PRINT_TASK_STATISTICS
633 rtems_cpu_usage_reset();
686 rtems_cpu_usage_reset();
634 #endif
687 #endif
635
688
636 status = RTEMS_UNSATISFIED;
689 status = RTEMS_UNSATISFIED;
637
690
638 switch( lfrCurrentMode )
691 switch( lfrCurrentMode )
639 {
692 {
640 case LFR_MODE_STANDBY:
693 case LFR_MODE_STANDBY:
641 status = restart_science_tasks( LFR_MODE_SBM1 ); // restart science tasks
694 status = restart_science_tasks( LFR_MODE_SBM1 ); // restart science tasks
642 if (status == RTEMS_SUCCESSFUL) // relaunch spectral_matrix and waveform_picker modules
695 if (status == RTEMS_SUCCESSFUL) // relaunch spectral_matrix and waveform_picker modules
643 {
696 {
644 launch_spectral_matrix( );
697 launch_spectral_matrix( );
645 launch_waveform_picker( LFR_MODE_SBM1, transitionCoarseTime );
698 launch_waveform_picker( LFR_MODE_SBM1, transitionCoarseTime );
646 }
699 }
647 break;
700 break;
648 case LFR_MODE_NORMAL: // lfrCurrentMode will be updated after the execution of close_action
701 case LFR_MODE_NORMAL: // lfrCurrentMode will be updated after the execution of close_action
702 restart_asm_activities( LFR_MODE_SBM1 );
649 status = LFR_SUCCESSFUL;
703 status = LFR_SUCCESSFUL;
650 break;
704 break;
651 case LFR_MODE_BURST:
705 case LFR_MODE_BURST:
652 status = stop_current_mode(); // stop the current mode
706 status = stop_current_mode(); // stop the current mode
653 status = restart_science_tasks( LFR_MODE_SBM1 ); // restart the science tasks
707 status = restart_science_tasks( LFR_MODE_SBM1 ); // restart the science tasks
654 if (status == RTEMS_SUCCESSFUL) // relaunch spectral_matrix and waveform_picker modules
708 if (status == RTEMS_SUCCESSFUL) // relaunch spectral_matrix and waveform_picker modules
655 {
709 {
656 launch_spectral_matrix( );
710 launch_spectral_matrix( );
657 launch_waveform_picker( LFR_MODE_SBM1, transitionCoarseTime );
711 launch_waveform_picker( LFR_MODE_SBM1, transitionCoarseTime );
658 }
712 }
659 break;
713 break;
660 case LFR_MODE_SBM2:
714 case LFR_MODE_SBM2:
715 restart_asm_activities( LFR_MODE_SBM1 );
661 status = LFR_SUCCESSFUL; // lfrCurrentMode will be updated after the execution of close_action
716 status = LFR_SUCCESSFUL; // lfrCurrentMode will be updated after the execution of close_action
662 break;
717 break;
663 default:
718 default:
664 break;
719 break;
665 }
720 }
666
721
667 if (status != RTEMS_SUCCESSFUL)
722 if (status != RTEMS_SUCCESSFUL)
668 {
723 {
669 PRINTF1("ERR *** in enter_mode_sbm1 *** status = %d\n", status)
724 PRINTF1("ERR *** in enter_mode_sbm1 *** status = %d\n", status)
670 status = RTEMS_UNSATISFIED;
725 status = RTEMS_UNSATISFIED;
671 }
726 }
672
727
673 return status;
728 return status;
674 }
729 }
675
730
676 int enter_mode_sbm2( unsigned int transitionCoarseTime )
731 int enter_mode_sbm2( unsigned int transitionCoarseTime )
677 {
732 {
678 int status;
733 int status;
679
734
680 #ifdef PRINT_TASK_STATISTICS
735 #ifdef PRINT_TASK_STATISTICS
681 rtems_cpu_usage_reset();
736 rtems_cpu_usage_reset();
682 #endif
737 #endif
683
738
684 status = RTEMS_UNSATISFIED;
739 status = RTEMS_UNSATISFIED;
685
740
686 switch( lfrCurrentMode )
741 switch( lfrCurrentMode )
687 {
742 {
688 case LFR_MODE_STANDBY:
743 case LFR_MODE_STANDBY:
689 status = restart_science_tasks( LFR_MODE_SBM2 ); // restart science tasks
744 status = restart_science_tasks( LFR_MODE_SBM2 ); // restart science tasks
690 if (status == RTEMS_SUCCESSFUL) // relaunch spectral_matrix and waveform_picker modules
745 if (status == RTEMS_SUCCESSFUL) // relaunch spectral_matrix and waveform_picker modules
691 {
746 {
692 launch_spectral_matrix( );
747 launch_spectral_matrix( );
693 launch_waveform_picker( LFR_MODE_SBM2, transitionCoarseTime );
748 launch_waveform_picker( LFR_MODE_SBM2, transitionCoarseTime );
694 }
749 }
695 break;
750 break;
696 case LFR_MODE_NORMAL:
751 case LFR_MODE_NORMAL:
752 restart_asm_activities( LFR_MODE_SBM2 );
697 status = LFR_SUCCESSFUL; // lfrCurrentMode will be updated after the execution of close_action
753 status = LFR_SUCCESSFUL; // lfrCurrentMode will be updated after the execution of close_action
698 break;
754 break;
699 case LFR_MODE_BURST:
755 case LFR_MODE_BURST:
700 status = stop_current_mode(); // stop the current mode
756 status = stop_current_mode(); // stop the current mode
701 status = restart_science_tasks( LFR_MODE_SBM2 ); // restart the science tasks
757 status = restart_science_tasks( LFR_MODE_SBM2 ); // restart the science tasks
702 if (status == RTEMS_SUCCESSFUL) // relaunch spectral_matrix and waveform_picker modules
758 if (status == RTEMS_SUCCESSFUL) // relaunch spectral_matrix and waveform_picker modules
703 {
759 {
704 launch_spectral_matrix( );
760 launch_spectral_matrix( );
705 launch_waveform_picker( LFR_MODE_SBM2, transitionCoarseTime );
761 launch_waveform_picker( LFR_MODE_SBM2, transitionCoarseTime );
706 }
762 }
707 break;
763 break;
708 case LFR_MODE_SBM1:
764 case LFR_MODE_SBM1:
765 restart_asm_activities( LFR_MODE_SBM2 );
709 status = LFR_SUCCESSFUL; // lfrCurrentMode will be updated after the execution of close_action
766 status = LFR_SUCCESSFUL; // lfrCurrentMode will be updated after the execution of close_action
710 break;
767 break;
711 default:
768 default:
712 break;
769 break;
713 }
770 }
714
771
715 if (status != RTEMS_SUCCESSFUL)
772 if (status != RTEMS_SUCCESSFUL)
716 {
773 {
717 PRINTF1("ERR *** in enter_mode_sbm2 *** status = %d\n", status)
774 PRINTF1("ERR *** in enter_mode_sbm2 *** status = %d\n", status)
718 status = RTEMS_UNSATISFIED;
775 status = RTEMS_UNSATISFIED;
719 }
776 }
720
777
721 return status;
778 return status;
722 }
779 }
723
780
724 int restart_science_tasks(unsigned char lfrRequestedMode )
781 int restart_science_tasks( unsigned char lfrRequestedMode )
725 {
782 {
726 /** This function is used to restart all science tasks.
783 /** This function is used to restart all science tasks.
727 *
784 *
728 * @return RTEMS directive status codes:
785 * @return RTEMS directive status codes:
729 * - RTEMS_SUCCESSFUL - task restarted successfully
786 * - RTEMS_SUCCESSFUL - task restarted successfully
730 * - RTEMS_INVALID_ID - task id invalid
787 * - RTEMS_INVALID_ID - task id invalid
731 * - RTEMS_INCORRECT_STATE - task never started
788 * - RTEMS_INCORRECT_STATE - task never started
732 * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task
789 * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task
733 *
790 *
734 * Science tasks are AVF0, PRC0, WFRM, CWF3, CW2, CWF1
791 * Science tasks are AVF0, PRC0, WFRM, CWF3, CW2, CWF1
735 *
792 *
736 */
793 */
737
794
738 rtems_status_code status[10];
795 rtems_status_code status[10];
739 rtems_status_code ret;
796 rtems_status_code ret;
740
797
741 ret = RTEMS_SUCCESSFUL;
798 ret = RTEMS_SUCCESSFUL;
742
799
743 status[0] = rtems_task_restart( Task_id[TASKID_AVF0], lfrRequestedMode );
800 status[0] = rtems_task_restart( Task_id[TASKID_AVF0], lfrRequestedMode );
744 if (status[0] != RTEMS_SUCCESSFUL)
801 if (status[0] != RTEMS_SUCCESSFUL)
745 {
802 {
746 PRINTF1("in restart_science_task *** AVF0 ERR %d\n", status[0])
803 PRINTF1("in restart_science_task *** AVF0 ERR %d\n", status[0])
747 }
804 }
748
805
749 status[1] = rtems_task_restart( Task_id[TASKID_PRC0], lfrRequestedMode );
806 status[1] = rtems_task_restart( Task_id[TASKID_PRC0], lfrRequestedMode );
750 if (status[1] != RTEMS_SUCCESSFUL)
807 if (status[1] != RTEMS_SUCCESSFUL)
751 {
808 {
752 PRINTF1("in restart_science_task *** PRC0 ERR %d\n", status[1])
809 PRINTF1("in restart_science_task *** PRC0 ERR %d\n", status[1])
753 }
810 }
754
811
755 status[2] = rtems_task_restart( Task_id[TASKID_WFRM],1 );
812 status[2] = rtems_task_restart( Task_id[TASKID_WFRM],1 );
756 if (status[2] != RTEMS_SUCCESSFUL)
813 if (status[2] != RTEMS_SUCCESSFUL)
757 {
814 {
758 PRINTF1("in restart_science_task *** WFRM ERR %d\n", status[2])
815 PRINTF1("in restart_science_task *** WFRM ERR %d\n", status[2])
759 }
816 }
760
817
761 status[3] = rtems_task_restart( Task_id[TASKID_CWF3],1 );
818 status[3] = rtems_task_restart( Task_id[TASKID_CWF3],1 );
762 if (status[3] != RTEMS_SUCCESSFUL)
819 if (status[3] != RTEMS_SUCCESSFUL)
763 {
820 {
764 PRINTF1("in restart_science_task *** CWF3 ERR %d\n", status[3])
821 PRINTF1("in restart_science_task *** CWF3 ERR %d\n", status[3])
765 }
822 }
766
823
767 status[4] = rtems_task_restart( Task_id[TASKID_CWF2],1 );
824 status[4] = rtems_task_restart( Task_id[TASKID_CWF2],1 );
768 if (status[4] != RTEMS_SUCCESSFUL)
825 if (status[4] != RTEMS_SUCCESSFUL)
769 {
826 {
770 PRINTF1("in restart_science_task *** CWF2 ERR %d\n", status[4])
827 PRINTF1("in restart_science_task *** CWF2 ERR %d\n", status[4])
771 }
828 }
772
829
773 status[5] = rtems_task_restart( Task_id[TASKID_CWF1],1 );
830 status[5] = rtems_task_restart( Task_id[TASKID_CWF1],1 );
774 if (status[5] != RTEMS_SUCCESSFUL)
831 if (status[5] != RTEMS_SUCCESSFUL)
775 {
832 {
776 PRINTF1("in restart_science_task *** CWF1 ERR %d\n", status[5])
833 PRINTF1("in restart_science_task *** CWF1 ERR %d\n", status[5])
777 }
834 }
778
835
779 status[6] = rtems_task_restart( Task_id[TASKID_AVF1], lfrRequestedMode );
836 status[6] = rtems_task_restart( Task_id[TASKID_AVF1], lfrRequestedMode );
780 if (status[6] != RTEMS_SUCCESSFUL)
837 if (status[6] != RTEMS_SUCCESSFUL)
781 {
838 {
782 PRINTF1("in restart_science_task *** AVF1 ERR %d\n", status[6])
839 PRINTF1("in restart_science_task *** AVF1 ERR %d\n", status[6])
783 }
840 }
784
841
785 status[7] = rtems_task_restart( Task_id[TASKID_PRC1],lfrRequestedMode );
842 status[7] = rtems_task_restart( Task_id[TASKID_PRC1],lfrRequestedMode );
786 if (status[7] != RTEMS_SUCCESSFUL)
843 if (status[7] != RTEMS_SUCCESSFUL)
787 {
844 {
788 PRINTF1("in restart_science_task *** PRC1 ERR %d\n", status[7])
845 PRINTF1("in restart_science_task *** PRC1 ERR %d\n", status[7])
789 }
846 }
790
847
791 status[8] = rtems_task_restart( Task_id[TASKID_AVF2], 1 );
848 status[8] = rtems_task_restart( Task_id[TASKID_AVF2], 1 );
792 if (status[8] != RTEMS_SUCCESSFUL)
849 if (status[8] != RTEMS_SUCCESSFUL)
793 {
850 {
794 PRINTF1("in restart_science_task *** AVF2 ERR %d\n", status[8])
851 PRINTF1("in restart_science_task *** AVF2 ERR %d\n", status[8])
795 }
852 }
796
853
797 status[9] = rtems_task_restart( Task_id[TASKID_PRC2], 1 );
854 status[9] = rtems_task_restart( Task_id[TASKID_PRC2], 1 );
798 if (status[9] != RTEMS_SUCCESSFUL)
855 if (status[9] != RTEMS_SUCCESSFUL)
799 {
856 {
800 PRINTF1("in restart_science_task *** PRC2 ERR %d\n", status[9])
857 PRINTF1("in restart_science_task *** PRC2 ERR %d\n", status[9])
801 }
858 }
802
859
803 if ( (status[0] != RTEMS_SUCCESSFUL) || (status[1] != RTEMS_SUCCESSFUL) ||
860 if ( (status[0] != RTEMS_SUCCESSFUL) || (status[1] != RTEMS_SUCCESSFUL) ||
804 (status[2] != RTEMS_SUCCESSFUL) || (status[3] != RTEMS_SUCCESSFUL) ||
861 (status[2] != RTEMS_SUCCESSFUL) || (status[3] != RTEMS_SUCCESSFUL) ||
805 (status[4] != RTEMS_SUCCESSFUL) || (status[5] != RTEMS_SUCCESSFUL) ||
862 (status[4] != RTEMS_SUCCESSFUL) || (status[5] != RTEMS_SUCCESSFUL) ||
806 (status[6] != RTEMS_SUCCESSFUL) || (status[7] != RTEMS_SUCCESSFUL) ||
863 (status[6] != RTEMS_SUCCESSFUL) || (status[7] != RTEMS_SUCCESSFUL) ||
807 (status[8] != RTEMS_SUCCESSFUL) || (status[9] != RTEMS_SUCCESSFUL) )
864 (status[8] != RTEMS_SUCCESSFUL) || (status[9] != RTEMS_SUCCESSFUL) )
808 {
865 {
809 ret = RTEMS_UNSATISFIED;
866 ret = RTEMS_UNSATISFIED;
810 }
867 }
811
868
812 return ret;
869 return ret;
813 }
870 }
814
871
815 int suspend_science_tasks()
872 int restart_asm_tasks( unsigned char lfrRequestedMode )
873 {
874 /** This function is used to restart average spectral matrices tasks.
875 *
876 * @return RTEMS directive status codes:
877 * - RTEMS_SUCCESSFUL - task restarted successfully
878 * - RTEMS_INVALID_ID - task id invalid
879 * - RTEMS_INCORRECT_STATE - task never started
880 * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task
881 *
882 * ASM tasks are AVF0, PRC0, AVF1, PRC1, AVF2 and PRC2
883 *
884 */
885
886 rtems_status_code status[6];
887 rtems_status_code ret;
888
889 ret = RTEMS_SUCCESSFUL;
890
891 status[0] = rtems_task_restart( Task_id[TASKID_AVF0], lfrRequestedMode );
892 if (status[0] != RTEMS_SUCCESSFUL)
893 {
894 PRINTF1("in restart_science_task *** AVF0 ERR %d\n", status[0])
895 }
896
897 status[1] = rtems_task_restart( Task_id[TASKID_PRC0], lfrRequestedMode );
898 if (status[1] != RTEMS_SUCCESSFUL)
899 {
900 PRINTF1("in restart_science_task *** PRC0 ERR %d\n", status[1])
901 }
902
903 status[2] = rtems_task_restart( Task_id[TASKID_AVF1], lfrRequestedMode );
904 if (status[2] != RTEMS_SUCCESSFUL)
905 {
906 PRINTF1("in restart_science_task *** AVF1 ERR %d\n", status[2])
907 }
908
909 status[3] = rtems_task_restart( Task_id[TASKID_PRC1],lfrRequestedMode );
910 if (status[3] != RTEMS_SUCCESSFUL)
911 {
912 PRINTF1("in restart_science_task *** PRC1 ERR %d\n", status[3])
913 }
914
915 status[4] = rtems_task_restart( Task_id[TASKID_AVF2], 1 );
916 if (status[4] != RTEMS_SUCCESSFUL)
917 {
918 PRINTF1("in restart_science_task *** AVF2 ERR %d\n", status[4])
919 }
920
921 status[5] = rtems_task_restart( Task_id[TASKID_PRC2], 1 );
922 if (status[5] != RTEMS_SUCCESSFUL)
923 {
924 PRINTF1("in restart_science_task *** PRC2 ERR %d\n", status[5])
925 }
926
927 if ( (status[0] != RTEMS_SUCCESSFUL) || (status[1] != RTEMS_SUCCESSFUL) ||
928 (status[2] != RTEMS_SUCCESSFUL) || (status[3] != RTEMS_SUCCESSFUL) ||
929 (status[4] != RTEMS_SUCCESSFUL) || (status[5] != RTEMS_SUCCESSFUL) )
930 {
931 ret = RTEMS_UNSATISFIED;
932 }
933
934 return ret;
935 }
936
937 int suspend_science_tasks( void )
816 {
938 {
817 /** This function suspends the science tasks.
939 /** This function suspends the science tasks.
818 *
940 *
819 * @return RTEMS directive status codes:
941 * @return RTEMS directive status codes:
820 * - RTEMS_SUCCESSFUL - task restarted successfully
942 * - RTEMS_SUCCESSFUL - task restarted successfully
821 * - RTEMS_INVALID_ID - task id invalid
943 * - RTEMS_INVALID_ID - task id invalid
822 * - RTEMS_ALREADY_SUSPENDED - task already suspended
944 * - RTEMS_ALREADY_SUSPENDED - task already suspended
823 *
945 *
824 */
946 */
825
947
826 rtems_status_code status;
948 rtems_status_code status;
827
949
828 PRINTF("in suspend_science_tasks\n")
950 PRINTF("in suspend_science_tasks\n")
829
951
830 status = rtems_task_suspend( Task_id[TASKID_AVF0] ); // suspend AVF0
952 status = rtems_task_suspend( Task_id[TASKID_AVF0] ); // suspend AVF0
831 if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED))
953 if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED))
832 {
954 {
833 PRINTF1("in suspend_science_task *** AVF0 ERR %d\n", status)
955 PRINTF1("in suspend_science_task *** AVF0 ERR %d\n", status)
834 }
956 }
835 else
957 else
836 {
958 {
837 status = RTEMS_SUCCESSFUL;
959 status = RTEMS_SUCCESSFUL;
838 }
960 }
839 if (status == RTEMS_SUCCESSFUL) // suspend PRC0
961 if (status == RTEMS_SUCCESSFUL) // suspend PRC0
840 {
962 {
841 status = rtems_task_suspend( Task_id[TASKID_PRC0] );
963 status = rtems_task_suspend( Task_id[TASKID_PRC0] );
842 if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED))
964 if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED))
843 {
965 {
844 PRINTF1("in suspend_science_task *** PRC0 ERR %d\n", status)
966 PRINTF1("in suspend_science_task *** PRC0 ERR %d\n", status)
845 }
967 }
846 else
968 else
847 {
969 {
848 status = RTEMS_SUCCESSFUL;
970 status = RTEMS_SUCCESSFUL;
849 }
971 }
850 }
972 }
851 if (status == RTEMS_SUCCESSFUL) // suspend AVF1
973 if (status == RTEMS_SUCCESSFUL) // suspend AVF1
852 {
974 {
853 status = rtems_task_suspend( Task_id[TASKID_AVF1] );
975 status = rtems_task_suspend( Task_id[TASKID_AVF1] );
854 if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED))
976 if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED))
855 {
977 {
856 PRINTF1("in suspend_science_task *** AVF1 ERR %d\n", status)
978 PRINTF1("in suspend_science_task *** AVF1 ERR %d\n", status)
857 }
979 }
858 else
980 else
859 {
981 {
860 status = RTEMS_SUCCESSFUL;
982 status = RTEMS_SUCCESSFUL;
861 }
983 }
862 }
984 }
863 if (status == RTEMS_SUCCESSFUL) // suspend PRC1
985 if (status == RTEMS_SUCCESSFUL) // suspend PRC1
864 {
986 {
865 status = rtems_task_suspend( Task_id[TASKID_PRC1] );
987 status = rtems_task_suspend( Task_id[TASKID_PRC1] );
866 if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED))
988 if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED))
867 {
989 {
868 PRINTF1("in suspend_science_task *** PRC1 ERR %d\n", status)
990 PRINTF1("in suspend_science_task *** PRC1 ERR %d\n", status)
869 }
991 }
870 else
992 else
871 {
993 {
872 status = RTEMS_SUCCESSFUL;
994 status = RTEMS_SUCCESSFUL;
873 }
995 }
874 }
996 }
875 if (status == RTEMS_SUCCESSFUL) // suspend AVF2
997 if (status == RTEMS_SUCCESSFUL) // suspend AVF2
876 {
998 {
877 status = rtems_task_suspend( Task_id[TASKID_AVF2] );
999 status = rtems_task_suspend( Task_id[TASKID_AVF2] );
878 if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED))
1000 if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED))
879 {
1001 {
880 PRINTF1("in suspend_science_task *** AVF2 ERR %d\n", status)
1002 PRINTF1("in suspend_science_task *** AVF2 ERR %d\n", status)
881 }
1003 }
882 else
1004 else
883 {
1005 {
884 status = RTEMS_SUCCESSFUL;
1006 status = RTEMS_SUCCESSFUL;
885 }
1007 }
886 }
1008 }
887 if (status == RTEMS_SUCCESSFUL) // suspend PRC2
1009 if (status == RTEMS_SUCCESSFUL) // suspend PRC2
888 {
1010 {
889 status = rtems_task_suspend( Task_id[TASKID_PRC2] );
1011 status = rtems_task_suspend( Task_id[TASKID_PRC2] );
890 if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED))
1012 if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED))
891 {
1013 {
892 PRINTF1("in suspend_science_task *** PRC2 ERR %d\n", status)
1014 PRINTF1("in suspend_science_task *** PRC2 ERR %d\n", status)
893 }
1015 }
894 else
1016 else
895 {
1017 {
896 status = RTEMS_SUCCESSFUL;
1018 status = RTEMS_SUCCESSFUL;
897 }
1019 }
898 }
1020 }
899 if (status == RTEMS_SUCCESSFUL) // suspend WFRM
1021 if (status == RTEMS_SUCCESSFUL) // suspend WFRM
900 {
1022 {
901 status = rtems_task_suspend( Task_id[TASKID_WFRM] );
1023 status = rtems_task_suspend( Task_id[TASKID_WFRM] );
902 if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED))
1024 if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED))
903 {
1025 {
904 PRINTF1("in suspend_science_task *** WFRM ERR %d\n", status)
1026 PRINTF1("in suspend_science_task *** WFRM ERR %d\n", status)
905 }
1027 }
906 else
1028 else
907 {
1029 {
908 status = RTEMS_SUCCESSFUL;
1030 status = RTEMS_SUCCESSFUL;
909 }
1031 }
910 }
1032 }
911 if (status == RTEMS_SUCCESSFUL) // suspend CWF3
1033 if (status == RTEMS_SUCCESSFUL) // suspend CWF3
912 {
1034 {
913 status = rtems_task_suspend( Task_id[TASKID_CWF3] );
1035 status = rtems_task_suspend( Task_id[TASKID_CWF3] );
914 if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED))
1036 if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED))
915 {
1037 {
916 PRINTF1("in suspend_science_task *** CWF3 ERR %d\n", status)
1038 PRINTF1("in suspend_science_task *** CWF3 ERR %d\n", status)
917 }
1039 }
918 else
1040 else
919 {
1041 {
920 status = RTEMS_SUCCESSFUL;
1042 status = RTEMS_SUCCESSFUL;
921 }
1043 }
922 }
1044 }
923 if (status == RTEMS_SUCCESSFUL) // suspend CWF2
1045 if (status == RTEMS_SUCCESSFUL) // suspend CWF2
924 {
1046 {
925 status = rtems_task_suspend( Task_id[TASKID_CWF2] );
1047 status = rtems_task_suspend( Task_id[TASKID_CWF2] );
926 if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED))
1048 if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED))
927 {
1049 {
928 PRINTF1("in suspend_science_task *** CWF2 ERR %d\n", status)
1050 PRINTF1("in suspend_science_task *** CWF2 ERR %d\n", status)
929 }
1051 }
930 else
1052 else
931 {
1053 {
932 status = RTEMS_SUCCESSFUL;
1054 status = RTEMS_SUCCESSFUL;
933 }
1055 }
934 }
1056 }
935 if (status == RTEMS_SUCCESSFUL) // suspend CWF1
1057 if (status == RTEMS_SUCCESSFUL) // suspend CWF1
936 {
1058 {
937 status = rtems_task_suspend( Task_id[TASKID_CWF1] );
1059 status = rtems_task_suspend( Task_id[TASKID_CWF1] );
938 if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED))
1060 if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED))
939 {
1061 {
940 PRINTF1("in suspend_science_task *** CWF1 ERR %d\n", status)
1062 PRINTF1("in suspend_science_task *** CWF1 ERR %d\n", status)
941 }
1063 }
942 else
1064 else
943 {
1065 {
944 status = RTEMS_SUCCESSFUL;
1066 status = RTEMS_SUCCESSFUL;
945 }
1067 }
946 }
1068 }
947
1069
948 return status;
1070 return status;
949 }
1071 }
950
1072
1073 int suspend_asm_tasks( void )
1074 {
1075 /** This function suspends the science tasks.
1076 *
1077 * @return RTEMS directive status codes:
1078 * - RTEMS_SUCCESSFUL - task restarted successfully
1079 * - RTEMS_INVALID_ID - task id invalid
1080 * - RTEMS_ALREADY_SUSPENDED - task already suspended
1081 *
1082 */
1083
1084 rtems_status_code status;
1085
1086 PRINTF("in suspend_science_tasks\n")
1087
1088 status = rtems_task_suspend( Task_id[TASKID_AVF0] ); // suspend AVF0
1089 if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED))
1090 {
1091 PRINTF1("in suspend_science_task *** AVF0 ERR %d\n", status)
1092 }
1093 else
1094 {
1095 status = RTEMS_SUCCESSFUL;
1096 }
1097
1098 if (status == RTEMS_SUCCESSFUL) // suspend PRC0
1099 {
1100 status = rtems_task_suspend( Task_id[TASKID_PRC0] );
1101 if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED))
1102 {
1103 PRINTF1("in suspend_science_task *** PRC0 ERR %d\n", status)
1104 }
1105 else
1106 {
1107 status = RTEMS_SUCCESSFUL;
1108 }
1109 }
1110
1111 if (status == RTEMS_SUCCESSFUL) // suspend AVF1
1112 {
1113 status = rtems_task_suspend( Task_id[TASKID_AVF1] );
1114 if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED))
1115 {
1116 PRINTF1("in suspend_science_task *** AVF1 ERR %d\n", status)
1117 }
1118 else
1119 {
1120 status = RTEMS_SUCCESSFUL;
1121 }
1122 }
1123
1124 if (status == RTEMS_SUCCESSFUL) // suspend PRC1
1125 {
1126 status = rtems_task_suspend( Task_id[TASKID_PRC1] );
1127 if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED))
1128 {
1129 PRINTF1("in suspend_science_task *** PRC1 ERR %d\n", status)
1130 }
1131 else
1132 {
1133 status = RTEMS_SUCCESSFUL;
1134 }
1135 }
1136
1137 if (status == RTEMS_SUCCESSFUL) // suspend AVF2
1138 {
1139 status = rtems_task_suspend( Task_id[TASKID_AVF2] );
1140 if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED))
1141 {
1142 PRINTF1("in suspend_science_task *** AVF2 ERR %d\n", status)
1143 }
1144 else
1145 {
1146 status = RTEMS_SUCCESSFUL;
1147 }
1148 }
1149
1150 if (status == RTEMS_SUCCESSFUL) // suspend PRC2
1151 {
1152 status = rtems_task_suspend( Task_id[TASKID_PRC2] );
1153 if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED))
1154 {
1155 PRINTF1("in suspend_science_task *** PRC2 ERR %d\n", status)
1156 }
1157 else
1158 {
1159 status = RTEMS_SUCCESSFUL;
1160 }
1161 }
1162
1163 return status;
1164 }
1165
951 void launch_waveform_picker( unsigned char mode, unsigned int transitionCoarseTime )
1166 void launch_waveform_picker( unsigned char mode, unsigned int transitionCoarseTime )
952 {
1167 {
953 WFP_reset_current_ring_nodes();
1168 WFP_reset_current_ring_nodes();
954
1169
955 reset_waveform_picker_regs();
1170 reset_waveform_picker_regs();
956
1171
957 set_wfp_burst_enable_register( mode );
1172 set_wfp_burst_enable_register( mode );
958
1173
959 LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER );
1174 LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER );
960 LEON_Unmask_interrupt( IRQ_WAVEFORM_PICKER );
1175 LEON_Unmask_interrupt( IRQ_WAVEFORM_PICKER );
961
1176
962 if (transitionCoarseTime == 0)
1177 if (transitionCoarseTime == 0)
963 {
1178 {
964 waveform_picker_regs->start_date = time_management_regs->coarse_time;
1179 waveform_picker_regs->start_date = time_management_regs->coarse_time;
965 }
1180 }
966 else
1181 else
967 {
1182 {
968 waveform_picker_regs->start_date = transitionCoarseTime;
1183 waveform_picker_regs->start_date = transitionCoarseTime;
969 }
1184 }
970
1185
971 }
1186 }
972
1187
973 void launch_spectral_matrix( void )
1188 void launch_spectral_matrix( void )
974 {
1189 {
975 SM_reset_current_ring_nodes();
1190 SM_reset_current_ring_nodes();
976
1191
977 reset_spectral_matrix_regs();
1192 reset_spectral_matrix_regs();
978
1193
979 reset_nb_sm();
1194 reset_nb_sm();
980
1195
981 set_sm_irq_onNewMatrix( 1 );
1196 set_sm_irq_onNewMatrix( 1 );
982
1197
983 LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX );
1198 LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX );
984 LEON_Unmask_interrupt( IRQ_SPECTRAL_MATRIX );
1199 LEON_Unmask_interrupt( IRQ_SPECTRAL_MATRIX );
985
1200
986 }
1201 }
987
1202
988 void launch_spectral_matrix_simu( void )
989 {
990 SM_reset_current_ring_nodes();
991 reset_spectral_matrix_regs();
992 reset_nb_sm();
993
994 // Spectral Matrices simulator
995 timer_start( (gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR );
996 LEON_Clear_interrupt( IRQ_SM_SIMULATOR );
997 LEON_Unmask_interrupt( IRQ_SM_SIMULATOR );
998 }
999
1000 void set_sm_irq_onNewMatrix( unsigned char value )
1203 void set_sm_irq_onNewMatrix( unsigned char value )
1001 {
1204 {
1002 if (value == 1)
1205 if (value == 1)
1003 {
1206 {
1004 spectral_matrix_regs->config = spectral_matrix_regs->config | 0x01;
1207 spectral_matrix_regs->config = spectral_matrix_regs->config | 0x01;
1005 }
1208 }
1006 else
1209 else
1007 {
1210 {
1008 spectral_matrix_regs->config = spectral_matrix_regs->config & 0xfffffffe; // 1110
1211 spectral_matrix_regs->config = spectral_matrix_regs->config & 0xfffffffe; // 1110
1009 }
1212 }
1010 }
1213 }
1011
1214
1012 void set_sm_irq_onError( unsigned char value )
1215 void set_sm_irq_onError( unsigned char value )
1013 {
1216 {
1014 if (value == 1)
1217 if (value == 1)
1015 {
1218 {
1016 spectral_matrix_regs->config = spectral_matrix_regs->config | 0x02;
1219 spectral_matrix_regs->config = spectral_matrix_regs->config | 0x02;
1017 }
1220 }
1018 else
1221 else
1019 {
1222 {
1020 spectral_matrix_regs->config = spectral_matrix_regs->config & 0xfffffffd; // 1101
1223 spectral_matrix_regs->config = spectral_matrix_regs->config & 0xfffffffd; // 1101
1021 }
1224 }
1022 }
1225 }
1023
1226
1024 //*****************************
1227 //*****************************
1025 // CONFIGURE CALIBRATION SIGNAL
1228 // CONFIGURE CALIBRATION SIGNAL
1026 void setCalibrationPrescaler( unsigned int prescaler )
1229 void setCalibrationPrescaler( unsigned int prescaler )
1027 {
1230 {
1028 // prescaling of the master clock (25 MHz)
1231 // prescaling of the master clock (25 MHz)
1029 // master clock is divided by 2^prescaler
1232 // master clock is divided by 2^prescaler
1030 time_management_regs->calPrescaler = prescaler;
1233 time_management_regs->calPrescaler = prescaler;
1031 }
1234 }
1032
1235
1033 void setCalibrationDivisor( unsigned int divisionFactor )
1236 void setCalibrationDivisor( unsigned int divisionFactor )
1034 {
1237 {
1035 // division of the prescaled clock by the division factor
1238 // division of the prescaled clock by the division factor
1036 time_management_regs->calDivisor = divisionFactor;
1239 time_management_regs->calDivisor = divisionFactor;
1037 }
1240 }
1038
1241
1039 void setCalibrationData( void ){
1242 void setCalibrationData( void ){
1040 unsigned int k;
1243 unsigned int k;
1041 unsigned short data;
1244 unsigned short data;
1042 float val;
1245 float val;
1043 float f0;
1246 float f0;
1044 float f1;
1247 float f1;
1045 float fs;
1248 float fs;
1046 float Ts;
1249 float Ts;
1047 float scaleFactor;
1250 float scaleFactor;
1048
1251
1049 f0 = 625;
1252 f0 = 625;
1050 f1 = 10000;
1253 f1 = 10000;
1051 fs = 160256.410;
1254 fs = 160256.410;
1052 Ts = 1. / fs;
1255 Ts = 1. / fs;
1053 scaleFactor = 0.250 / 0.000654; // 191, 500 mVpp, 2 sinus waves => 500 mVpp each, amplitude = 250 mV
1256 scaleFactor = 0.250 / 0.000654; // 191, 500 mVpp, 2 sinus waves => 500 mVpp each, amplitude = 250 mV
1054
1257
1055 time_management_regs->calDataPtr = 0x00;
1258 time_management_regs->calDataPtr = 0x00;
1056
1259
1057 // build the signal for the SCM calibration
1260 // build the signal for the SCM calibration
1058 for (k=0; k<256; k++)
1261 for (k=0; k<256; k++)
1059 {
1262 {
1060 val = sin( 2 * pi * f0 * k * Ts )
1263 val = sin( 2 * pi * f0 * k * Ts )
1061 + sin( 2 * pi * f1 * k * Ts );
1264 + sin( 2 * pi * f1 * k * Ts );
1062 data = (unsigned short) ((val * scaleFactor) + 2048);
1265 data = (unsigned short) ((val * scaleFactor) + 2048);
1063 time_management_regs->calData = data & 0xfff;
1266 time_management_regs->calData = data & 0xfff;
1064 }
1267 }
1065 }
1268 }
1066
1269
1067 void setCalibrationDataInterleaved( void ){
1270 void setCalibrationDataInterleaved( void ){
1068 unsigned int k;
1271 unsigned int k;
1069 float val;
1272 float val;
1070 float f0;
1273 float f0;
1071 float f1;
1274 float f1;
1072 float fs;
1275 float fs;
1073 float Ts;
1276 float Ts;
1074 unsigned short data[384];
1277 unsigned short data[384];
1075 unsigned char *dataPtr;
1278 unsigned char *dataPtr;
1076
1279
1077 f0 = 625;
1280 f0 = 625;
1078 f1 = 10000;
1281 f1 = 10000;
1079 fs = 240384.615;
1282 fs = 240384.615;
1080 Ts = 1. / fs;
1283 Ts = 1. / fs;
1081
1284
1082 time_management_regs->calDataPtr = 0x00;
1285 time_management_regs->calDataPtr = 0x00;
1083
1286
1084 // build the signal for the SCM calibration
1287 // build the signal for the SCM calibration
1085 for (k=0; k<384; k++)
1288 for (k=0; k<384; k++)
1086 {
1289 {
1087 val = sin( 2 * pi * f0 * k * Ts )
1290 val = sin( 2 * pi * f0 * k * Ts )
1088 + sin( 2 * pi * f1 * k * Ts );
1291 + sin( 2 * pi * f1 * k * Ts );
1089 data[k] = (unsigned short) (val * 512 + 2048);
1292 data[k] = (unsigned short) (val * 512 + 2048);
1090 }
1293 }
1091
1294
1092 // write the signal in interleaved mode
1295 // write the signal in interleaved mode
1093 for (k=0; k<128; k++)
1296 for (k=0; k<128; k++)
1094 {
1297 {
1095 dataPtr = (unsigned char*) &data[k*3 + 2];
1298 dataPtr = (unsigned char*) &data[k*3 + 2];
1096 time_management_regs->calData = (data[k*3] & 0xfff)
1299 time_management_regs->calData = (data[k*3] & 0xfff)
1097 + ( (dataPtr[0] & 0x3f) << 12);
1300 + ( (dataPtr[0] & 0x3f) << 12);
1098 time_management_regs->calData = (data[k*3 + 1] & 0xfff)
1301 time_management_regs->calData = (data[k*3 + 1] & 0xfff)
1099 + ( (dataPtr[1] & 0x3f) << 12);
1302 + ( (dataPtr[1] & 0x3f) << 12);
1100 }
1303 }
1101 }
1304 }
1102
1305
1103 void setCalibrationReload( bool state)
1306 void setCalibrationReload( bool state)
1104 {
1307 {
1105 if (state == true)
1308 if (state == true)
1106 {
1309 {
1107 time_management_regs->calDACCtrl = time_management_regs->calDACCtrl | 0x00000010; // [0001 0000]
1310 time_management_regs->calDACCtrl = time_management_regs->calDACCtrl | 0x00000010; // [0001 0000]
1108 }
1311 }
1109 else
1312 else
1110 {
1313 {
1111 time_management_regs->calDACCtrl = time_management_regs->calDACCtrl & 0xffffffef; // [1110 1111]
1314 time_management_regs->calDACCtrl = time_management_regs->calDACCtrl & 0xffffffef; // [1110 1111]
1112 }
1315 }
1113 }
1316 }
1114
1317
1115 void setCalibrationEnable( bool state )
1318 void setCalibrationEnable( bool state )
1116 {
1319 {
1117 // this bit drives the multiplexer
1320 // this bit drives the multiplexer
1118 if (state == true)
1321 if (state == true)
1119 {
1322 {
1120 time_management_regs->calDACCtrl = time_management_regs->calDACCtrl | 0x00000040; // [0100 0000]
1323 time_management_regs->calDACCtrl = time_management_regs->calDACCtrl | 0x00000040; // [0100 0000]
1121 }
1324 }
1122 else
1325 else
1123 {
1326 {
1124 time_management_regs->calDACCtrl = time_management_regs->calDACCtrl & 0xffffffbf; // [1011 1111]
1327 time_management_regs->calDACCtrl = time_management_regs->calDACCtrl & 0xffffffbf; // [1011 1111]
1125 }
1328 }
1126 }
1329 }
1127
1330
1128 void setCalibrationInterleaved( bool state )
1331 void setCalibrationInterleaved( bool state )
1129 {
1332 {
1130 // this bit drives the multiplexer
1333 // this bit drives the multiplexer
1131 if (state == true)
1334 if (state == true)
1132 {
1335 {
1133 time_management_regs->calDACCtrl = time_management_regs->calDACCtrl | 0x00000020; // [0010 0000]
1336 time_management_regs->calDACCtrl = time_management_regs->calDACCtrl | 0x00000020; // [0010 0000]
1134 }
1337 }
1135 else
1338 else
1136 {
1339 {
1137 time_management_regs->calDACCtrl = time_management_regs->calDACCtrl & 0xffffffdf; // [1101 1111]
1340 time_management_regs->calDACCtrl = time_management_regs->calDACCtrl & 0xffffffdf; // [1101 1111]
1138 }
1341 }
1139 }
1342 }
1140
1343
1141 void setCalibration( bool state )
1344 void setCalibration( bool state )
1142 {
1345 {
1143 if (state == true)
1346 if (state == true)
1144 {
1347 {
1145 setCalibrationEnable( true );
1348 setCalibrationEnable( true );
1146 setCalibrationReload( false );
1349 setCalibrationReload( false );
1147 set_hk_lfr_calib_enable( true );
1350 set_hk_lfr_calib_enable( true );
1148 }
1351 }
1149 else
1352 else
1150 {
1353 {
1151 setCalibrationEnable( false );
1354 setCalibrationEnable( false );
1152 setCalibrationReload( true );
1355 setCalibrationReload( true );
1153 set_hk_lfr_calib_enable( false );
1356 set_hk_lfr_calib_enable( false );
1154 }
1357 }
1155 }
1358 }
1156
1359
1157 void configureCalibration( bool interleaved )
1360 void configureCalibration( bool interleaved )
1158 {
1361 {
1159 setCalibration( false );
1362 setCalibration( false );
1160 if ( interleaved == true )
1363 if ( interleaved == true )
1161 {
1364 {
1162 setCalibrationInterleaved( true );
1365 setCalibrationInterleaved( true );
1163 setCalibrationPrescaler( 0 ); // 25 MHz => 25 000 000
1366 setCalibrationPrescaler( 0 ); // 25 MHz => 25 000 000
1164 setCalibrationDivisor( 26 ); // => 240 384
1367 setCalibrationDivisor( 26 ); // => 240 384
1165 setCalibrationDataInterleaved();
1368 setCalibrationDataInterleaved();
1166 }
1369 }
1167 else
1370 else
1168 {
1371 {
1169 setCalibrationPrescaler( 0 ); // 25 MHz => 25 000 000
1372 setCalibrationPrescaler( 0 ); // 25 MHz => 25 000 000
1170 setCalibrationDivisor( 38 ); // => 160 256 (39 - 1)
1373 setCalibrationDivisor( 38 ); // => 160 256 (39 - 1)
1171 setCalibrationData();
1374 setCalibrationData();
1172 }
1375 }
1173 }
1376 }
1174
1377
1175 //****************
1378 //****************
1176 // CLOSING ACTIONS
1379 // CLOSING ACTIONS
1177 void update_last_TC_exe( ccsdsTelecommandPacket_t *TC, unsigned char * time )
1380 void update_last_TC_exe( ccsdsTelecommandPacket_t *TC, unsigned char * time )
1178 {
1381 {
1179 /** This function is used to update the HK packets statistics after a successful TC execution.
1382 /** This function is used to update the HK packets statistics after a successful TC execution.
1180 *
1383 *
1181 * @param TC points to the TC being processed
1384 * @param TC points to the TC being processed
1182 * @param time is the time used to date the TC execution
1385 * @param time is the time used to date the TC execution
1183 *
1386 *
1184 */
1387 */
1185
1388
1186 unsigned int val;
1389 unsigned int val;
1187
1390
1188 housekeeping_packet.hk_lfr_last_exe_tc_id[0] = TC->packetID[0];
1391 housekeeping_packet.hk_lfr_last_exe_tc_id[0] = TC->packetID[0];
1189 housekeeping_packet.hk_lfr_last_exe_tc_id[1] = TC->packetID[1];
1392 housekeeping_packet.hk_lfr_last_exe_tc_id[1] = TC->packetID[1];
1190 housekeeping_packet.hk_lfr_last_exe_tc_type[0] = 0x00;
1393 housekeeping_packet.hk_lfr_last_exe_tc_type[0] = 0x00;
1191 housekeeping_packet.hk_lfr_last_exe_tc_type[1] = TC->serviceType;
1394 housekeeping_packet.hk_lfr_last_exe_tc_type[1] = TC->serviceType;
1192 housekeeping_packet.hk_lfr_last_exe_tc_subtype[0] = 0x00;
1395 housekeeping_packet.hk_lfr_last_exe_tc_subtype[0] = 0x00;
1193 housekeeping_packet.hk_lfr_last_exe_tc_subtype[1] = TC->serviceSubType;
1396 housekeeping_packet.hk_lfr_last_exe_tc_subtype[1] = TC->serviceSubType;
1194 housekeeping_packet.hk_lfr_last_exe_tc_time[0] = time[0];
1397 housekeeping_packet.hk_lfr_last_exe_tc_time[0] = time[0];
1195 housekeeping_packet.hk_lfr_last_exe_tc_time[1] = time[1];
1398 housekeeping_packet.hk_lfr_last_exe_tc_time[1] = time[1];
1196 housekeeping_packet.hk_lfr_last_exe_tc_time[2] = time[2];
1399 housekeeping_packet.hk_lfr_last_exe_tc_time[2] = time[2];
1197 housekeeping_packet.hk_lfr_last_exe_tc_time[3] = time[3];
1400 housekeeping_packet.hk_lfr_last_exe_tc_time[3] = time[3];
1198 housekeeping_packet.hk_lfr_last_exe_tc_time[4] = time[4];
1401 housekeeping_packet.hk_lfr_last_exe_tc_time[4] = time[4];
1199 housekeeping_packet.hk_lfr_last_exe_tc_time[5] = time[5];
1402 housekeeping_packet.hk_lfr_last_exe_tc_time[5] = time[5];
1200
1403
1201 val = housekeeping_packet.hk_lfr_exe_tc_cnt[0] * 256 + housekeeping_packet.hk_lfr_exe_tc_cnt[1];
1404 val = housekeeping_packet.hk_lfr_exe_tc_cnt[0] * 256 + housekeeping_packet.hk_lfr_exe_tc_cnt[1];
1202 val++;
1405 val++;
1203 housekeeping_packet.hk_lfr_exe_tc_cnt[0] = (unsigned char) (val >> 8);
1406 housekeeping_packet.hk_lfr_exe_tc_cnt[0] = (unsigned char) (val >> 8);
1204 housekeeping_packet.hk_lfr_exe_tc_cnt[1] = (unsigned char) (val);
1407 housekeeping_packet.hk_lfr_exe_tc_cnt[1] = (unsigned char) (val);
1205 }
1408 }
1206
1409
1207 void update_last_TC_rej(ccsdsTelecommandPacket_t *TC, unsigned char * time )
1410 void update_last_TC_rej(ccsdsTelecommandPacket_t *TC, unsigned char * time )
1208 {
1411 {
1209 /** This function is used to update the HK packets statistics after a TC rejection.
1412 /** This function is used to update the HK packets statistics after a TC rejection.
1210 *
1413 *
1211 * @param TC points to the TC being processed
1414 * @param TC points to the TC being processed
1212 * @param time is the time used to date the TC rejection
1415 * @param time is the time used to date the TC rejection
1213 *
1416 *
1214 */
1417 */
1215
1418
1216 unsigned int val;
1419 unsigned int val;
1217
1420
1218 housekeeping_packet.hk_lfr_last_rej_tc_id[0] = TC->packetID[0];
1421 housekeeping_packet.hk_lfr_last_rej_tc_id[0] = TC->packetID[0];
1219 housekeeping_packet.hk_lfr_last_rej_tc_id[1] = TC->packetID[1];
1422 housekeeping_packet.hk_lfr_last_rej_tc_id[1] = TC->packetID[1];
1220 housekeeping_packet.hk_lfr_last_rej_tc_type[0] = 0x00;
1423 housekeeping_packet.hk_lfr_last_rej_tc_type[0] = 0x00;
1221 housekeeping_packet.hk_lfr_last_rej_tc_type[1] = TC->serviceType;
1424 housekeeping_packet.hk_lfr_last_rej_tc_type[1] = TC->serviceType;
1222 housekeeping_packet.hk_lfr_last_rej_tc_subtype[0] = 0x00;
1425 housekeeping_packet.hk_lfr_last_rej_tc_subtype[0] = 0x00;
1223 housekeeping_packet.hk_lfr_last_rej_tc_subtype[1] = TC->serviceSubType;
1426 housekeeping_packet.hk_lfr_last_rej_tc_subtype[1] = TC->serviceSubType;
1224 housekeeping_packet.hk_lfr_last_rej_tc_time[0] = time[0];
1427 housekeeping_packet.hk_lfr_last_rej_tc_time[0] = time[0];
1225 housekeeping_packet.hk_lfr_last_rej_tc_time[1] = time[1];
1428 housekeeping_packet.hk_lfr_last_rej_tc_time[1] = time[1];
1226 housekeeping_packet.hk_lfr_last_rej_tc_time[2] = time[2];
1429 housekeeping_packet.hk_lfr_last_rej_tc_time[2] = time[2];
1227 housekeeping_packet.hk_lfr_last_rej_tc_time[3] = time[3];
1430 housekeeping_packet.hk_lfr_last_rej_tc_time[3] = time[3];
1228 housekeeping_packet.hk_lfr_last_rej_tc_time[4] = time[4];
1431 housekeeping_packet.hk_lfr_last_rej_tc_time[4] = time[4];
1229 housekeeping_packet.hk_lfr_last_rej_tc_time[5] = time[5];
1432 housekeeping_packet.hk_lfr_last_rej_tc_time[5] = time[5];
1230
1433
1231 val = housekeeping_packet.hk_lfr_rej_tc_cnt[0] * 256 + housekeeping_packet.hk_lfr_rej_tc_cnt[1];
1434 val = housekeeping_packet.hk_lfr_rej_tc_cnt[0] * 256 + housekeeping_packet.hk_lfr_rej_tc_cnt[1];
1232 val++;
1435 val++;
1233 housekeeping_packet.hk_lfr_rej_tc_cnt[0] = (unsigned char) (val >> 8);
1436 housekeeping_packet.hk_lfr_rej_tc_cnt[0] = (unsigned char) (val >> 8);
1234 housekeeping_packet.hk_lfr_rej_tc_cnt[1] = (unsigned char) (val);
1437 housekeeping_packet.hk_lfr_rej_tc_cnt[1] = (unsigned char) (val);
1235 }
1438 }
1236
1439
1237 void close_action(ccsdsTelecommandPacket_t *TC, int result, rtems_id queue_id )
1440 void close_action(ccsdsTelecommandPacket_t *TC, int result, rtems_id queue_id )
1238 {
1441 {
1239 /** This function is the last step of the TC execution workflow.
1442 /** This function is the last step of the TC execution workflow.
1240 *
1443 *
1241 * @param TC points to the TC being processed
1444 * @param TC points to the TC being processed
1242 * @param result is the result of the TC execution (LFR_SUCCESSFUL / LFR_DEFAULT)
1445 * @param result is the result of the TC execution (LFR_SUCCESSFUL / LFR_DEFAULT)
1243 * @param queue_id is the id of the RTEMS message queue used to send TM packets
1446 * @param queue_id is the id of the RTEMS message queue used to send TM packets
1244 * @param time is the time used to date the TC execution
1447 * @param time is the time used to date the TC execution
1245 *
1448 *
1246 */
1449 */
1247
1450
1248 unsigned char requestedMode;
1451 unsigned char requestedMode;
1249
1452
1250 if (result == LFR_SUCCESSFUL)
1453 if (result == LFR_SUCCESSFUL)
1251 {
1454 {
1252 if ( !( (TC->serviceType==TC_TYPE_TIME) & (TC->serviceSubType==TC_SUBTYPE_UPDT_TIME) )
1455 if ( !( (TC->serviceType==TC_TYPE_TIME) & (TC->serviceSubType==TC_SUBTYPE_UPDT_TIME) )
1253 &
1456 &
1254 !( (TC->serviceType==TC_TYPE_GEN) & (TC->serviceSubType==TC_SUBTYPE_UPDT_INFO))
1457 !( (TC->serviceType==TC_TYPE_GEN) & (TC->serviceSubType==TC_SUBTYPE_UPDT_INFO))
1255 )
1458 )
1256 {
1459 {
1257 send_tm_lfr_tc_exe_success( TC, queue_id );
1460 send_tm_lfr_tc_exe_success( TC, queue_id );
1258 }
1461 }
1259 if ( (TC->serviceType == TC_TYPE_GEN) & (TC->serviceSubType == TC_SUBTYPE_ENTER) )
1462 if ( (TC->serviceType == TC_TYPE_GEN) & (TC->serviceSubType == TC_SUBTYPE_ENTER) )
1260 {
1463 {
1261 //**********************************
1464 //**********************************
1262 // UPDATE THE LFRMODE LOCAL VARIABLE
1465 // UPDATE THE LFRMODE LOCAL VARIABLE
1263 requestedMode = TC->dataAndCRC[1];
1466 requestedMode = TC->dataAndCRC[1];
1264 housekeeping_packet.lfr_status_word[0] = (unsigned char) ((requestedMode << 4) + 0x0d);
1467 housekeeping_packet.lfr_status_word[0] = (unsigned char) ((requestedMode << 4) + 0x0d);
1265 updateLFRCurrentMode();
1468 updateLFRCurrentMode();
1266 }
1469 }
1267 }
1470 }
1268 else if (result == LFR_EXE_ERROR)
1471 else if (result == LFR_EXE_ERROR)
1269 {
1472 {
1270 send_tm_lfr_tc_exe_error( TC, queue_id );
1473 send_tm_lfr_tc_exe_error( TC, queue_id );
1271 }
1474 }
1272 }
1475 }
1273
1476
1274 //***************************
1477 //***************************
1275 // Interrupt Service Routines
1478 // Interrupt Service Routines
1276 rtems_isr commutation_isr1( rtems_vector_number vector )
1479 rtems_isr commutation_isr1( rtems_vector_number vector )
1277 {
1480 {
1278 if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) {
1481 if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) {
1279 PRINTF("In commutation_isr1 *** Error sending event to DUMB\n")
1482 PRINTF("In commutation_isr1 *** Error sending event to DUMB\n")
1280 }
1483 }
1281 }
1484 }
1282
1485
1283 rtems_isr commutation_isr2( rtems_vector_number vector )
1486 rtems_isr commutation_isr2( rtems_vector_number vector )
1284 {
1487 {
1285 if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) {
1488 if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) {
1286 PRINTF("In commutation_isr2 *** Error sending event to DUMB\n")
1489 PRINTF("In commutation_isr2 *** Error sending event to DUMB\n")
1287 }
1490 }
1288 }
1491 }
1289
1492
1290 //****************
1493 //****************
1291 // OTHER FUNCTIONS
1494 // OTHER FUNCTIONS
1292 void updateLFRCurrentMode()
1495 void updateLFRCurrentMode()
1293 {
1496 {
1294 /** This function updates the value of the global variable lfrCurrentMode.
1497 /** This function updates the value of the global variable lfrCurrentMode.
1295 *
1498 *
1296 * lfrCurrentMode is a parameter used by several functions to know in which mode LFR is running.
1499 * lfrCurrentMode is a parameter used by several functions to know in which mode LFR is running.
1297 *
1500 *
1298 */
1501 */
1299 // update the local value of lfrCurrentMode with the value contained in the housekeeping_packet structure
1502 // update the local value of lfrCurrentMode with the value contained in the housekeeping_packet structure
1300 lfrCurrentMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
1503 lfrCurrentMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
1301 }
1504 }
1302
1505
1303 void set_lfr_soft_reset( unsigned char value )
1506 void set_lfr_soft_reset( unsigned char value )
1304 {
1507 {
1305 if (value == 1)
1508 if (value == 1)
1306 {
1509 {
1307 time_management_regs->ctrl = time_management_regs->ctrl | 0x00000004; // [0100]
1510 time_management_regs->ctrl = time_management_regs->ctrl | 0x00000004; // [0100]
1308 }
1511 }
1309 else
1512 else
1310 {
1513 {
1311 time_management_regs->ctrl = time_management_regs->ctrl & 0xfffffffb; // [1011]
1514 time_management_regs->ctrl = time_management_regs->ctrl & 0xfffffffb; // [1011]
1312 }
1515 }
1313 }
1516 }
1314
1517
1315 void reset_lfr( void )
1518 void reset_lfr( void )
1316 {
1519 {
1317 set_lfr_soft_reset( 1 );
1520 set_lfr_soft_reset( 1 );
1318
1521
1319 set_lfr_soft_reset( 0 );
1522 set_lfr_soft_reset( 0 );
1320
1523
1321 set_hk_lfr_sc_potential_flag( true );
1524 set_hk_lfr_sc_potential_flag( true );
1322 }
1525 }
@@ -1,1372 +1,1205
1 /** Functions and tasks related to waveform packet generation.
1 /** Functions and tasks related to waveform packet generation.
2 *
2 *
3 * @file
3 * @file
4 * @author P. LEROY
4 * @author P. LEROY
5 *
5 *
6 * A group of functions to handle waveforms, in snapshot or continuous format.\n
6 * A group of functions to handle waveforms, in snapshot or continuous format.\n
7 *
7 *
8 */
8 */
9
9
10 #include "wf_handler.h"
10 #include "wf_handler.h"
11
11
12 //***************
12 //***************
13 // waveform rings
13 // waveform rings
14 // F0
14 // F0
15 ring_node waveform_ring_f0[NB_RING_NODES_F0];
15 ring_node waveform_ring_f0[NB_RING_NODES_F0];
16 ring_node *current_ring_node_f0;
16 ring_node *current_ring_node_f0;
17 ring_node *ring_node_to_send_swf_f0;
17 ring_node *ring_node_to_send_swf_f0;
18 // F1
18 // F1
19 ring_node waveform_ring_f1[NB_RING_NODES_F1];
19 ring_node waveform_ring_f1[NB_RING_NODES_F1];
20 ring_node *current_ring_node_f1;
20 ring_node *current_ring_node_f1;
21 ring_node *ring_node_to_send_swf_f1;
21 ring_node *ring_node_to_send_swf_f1;
22 ring_node *ring_node_to_send_cwf_f1;
22 ring_node *ring_node_to_send_cwf_f1;
23 // F2
23 // F2
24 ring_node waveform_ring_f2[NB_RING_NODES_F2];
24 ring_node waveform_ring_f2[NB_RING_NODES_F2];
25 ring_node *current_ring_node_f2;
25 ring_node *current_ring_node_f2;
26 ring_node *ring_node_to_send_swf_f2;
26 ring_node *ring_node_to_send_swf_f2;
27 ring_node *ring_node_to_send_cwf_f2;
27 ring_node *ring_node_to_send_cwf_f2;
28 // F3
28 // F3
29 ring_node waveform_ring_f3[NB_RING_NODES_F3];
29 ring_node waveform_ring_f3[NB_RING_NODES_F3];
30 ring_node *current_ring_node_f3;
30 ring_node *current_ring_node_f3;
31 ring_node *ring_node_to_send_cwf_f3;
31 ring_node *ring_node_to_send_cwf_f3;
32 char wf_cont_f3_light[ (NB_SAMPLES_PER_SNAPSHOT) * NB_BYTES_CWF3_LIGHT_BLK ];
32 char wf_cont_f3_light[ (NB_SAMPLES_PER_SNAPSHOT) * NB_BYTES_CWF3_LIGHT_BLK ];
33
33
34 bool extractSWF = false;
34 bool extractSWF1 = false;
35 bool swf_f0_ready = false;
35 bool extractSWF2 = false;
36 bool swf_f1_ready = false;
36 bool swf0_ready_flag_f1 = false;
37 bool swf_f2_ready = false;
37 bool swf0_ready_flag_f2 = false;
38 bool swf1_ready = false;
39 bool swf2_ready = false;
38
40
39 int wf_snap_extracted[ (NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK) ];
41 int swf1_extracted[ (NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK) ];
40 ring_node ring_node_wf_snap_extracted;
42 int swf2_extracted[ (NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK) ];
43 ring_node ring_node_swf1_extracted;
44 ring_node ring_node_swf2_extracted;
41
45
42 //*********************
46 //*********************
43 // Interrupt SubRoutine
47 // Interrupt SubRoutine
44
48
45 ring_node * getRingNodeToSendCWF( unsigned char frequencyChannel)
49 ring_node * getRingNodeToSendCWF( unsigned char frequencyChannel)
46 {
50 {
47 ring_node *node;
51 ring_node *node;
48
52
49 node = NULL;
53 node = NULL;
50 switch ( frequencyChannel ) {
54 switch ( frequencyChannel ) {
51 case 1:
55 case 1:
52 node = ring_node_to_send_cwf_f1;
56 node = ring_node_to_send_cwf_f1;
53 break;
57 break;
54 case 2:
58 case 2:
55 node = ring_node_to_send_cwf_f2;
59 node = ring_node_to_send_cwf_f2;
56 break;
60 break;
57 case 3:
61 case 3:
58 node = ring_node_to_send_cwf_f3;
62 node = ring_node_to_send_cwf_f3;
59 break;
63 break;
60 default:
64 default:
61 break;
65 break;
62 }
66 }
63
67
64 return node;
68 return node;
65 }
69 }
66
70
67 ring_node * getRingNodeToSendSWF( unsigned char frequencyChannel)
71 ring_node * getRingNodeToSendSWF( unsigned char frequencyChannel)
68 {
72 {
69 ring_node *node;
73 ring_node *node;
70
74
71 node = NULL;
75 node = NULL;
72 switch ( frequencyChannel ) {
76 switch ( frequencyChannel ) {
73 case 0:
77 case 0:
74 node = ring_node_to_send_swf_f0;
78 node = ring_node_to_send_swf_f0;
75 break;
79 break;
76 case 1:
80 case 1:
77 node = ring_node_to_send_swf_f1;
81 node = ring_node_to_send_swf_f1;
78 break;
82 break;
79 case 2:
83 case 2:
80 node = ring_node_to_send_swf_f2;
84 node = ring_node_to_send_swf_f2;
81 break;
85 break;
82 default:
86 default:
83 break;
87 break;
84 }
88 }
85
89
86 return node;
90 return node;
87 }
91 }
88
92
89 void reset_extractSWF( void )
93 void reset_extractSWF( void )
90 {
94 {
91 extractSWF = false;
95 extractSWF1 = false;
92 swf_f0_ready = false;
96 extractSWF2 = false;
93 swf_f1_ready = false;
97 swf0_ready_flag_f1 = false;
94 swf_f2_ready = false;
98 swf0_ready_flag_f2 = false;
99 swf1_ready = false;
100 swf2_ready = false;
95 }
101 }
96
102
97 inline void waveforms_isr_f3( void )
103 inline void waveforms_isr_f3( void )
98 {
104 {
99 rtems_status_code spare_status;
105 rtems_status_code spare_status;
100
106
101 if ( (lfrCurrentMode == LFR_MODE_NORMAL) || (lfrCurrentMode == LFR_MODE_BURST) // in BURST the data are used to place v, e1 and e2 in the HK packet
107 if ( (lfrCurrentMode == LFR_MODE_NORMAL) || (lfrCurrentMode == LFR_MODE_BURST) // in BURST the data are used to place v, e1 and e2 in the HK packet
102 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
108 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
103 { // in modes other than STANDBY and BURST, send the CWF_F3 data
109 { // in modes other than STANDBY and BURST, send the CWF_F3 data
104 //***
110 //***
105 // F3
111 // F3
106 if ( (waveform_picker_regs->status & 0xc0) != 0x00 ) { // [1100 0000] check the f3 full bits
112 if ( (waveform_picker_regs->status & 0xc0) != 0x00 ) { // [1100 0000] check the f3 full bits
107 ring_node_to_send_cwf_f3 = current_ring_node_f3->previous;
113 ring_node_to_send_cwf_f3 = current_ring_node_f3->previous;
108 current_ring_node_f3 = current_ring_node_f3->next;
114 current_ring_node_f3 = current_ring_node_f3->next;
109 if ((waveform_picker_regs->status & 0x40) == 0x40){ // [0100 0000] f3 buffer 0 is full
115 if ((waveform_picker_regs->status & 0x40) == 0x40){ // [0100 0000] f3 buffer 0 is full
110 ring_node_to_send_cwf_f3->coarseTime = waveform_picker_regs->f3_0_coarse_time;
116 ring_node_to_send_cwf_f3->coarseTime = waveform_picker_regs->f3_0_coarse_time;
111 ring_node_to_send_cwf_f3->fineTime = waveform_picker_regs->f3_0_fine_time;
117 ring_node_to_send_cwf_f3->fineTime = waveform_picker_regs->f3_0_fine_time;
112 waveform_picker_regs->addr_data_f3_0 = current_ring_node_f3->buffer_address;
118 waveform_picker_regs->addr_data_f3_0 = current_ring_node_f3->buffer_address;
113 waveform_picker_regs->status = waveform_picker_regs->status & 0x00008840; // [1000 1000 0100 0000]
119 waveform_picker_regs->status = waveform_picker_regs->status & 0x00008840; // [1000 1000 0100 0000]
114 }
120 }
115 else if ((waveform_picker_regs->status & 0x80) == 0x80){ // [1000 0000] f3 buffer 1 is full
121 else if ((waveform_picker_regs->status & 0x80) == 0x80){ // [1000 0000] f3 buffer 1 is full
116 ring_node_to_send_cwf_f3->coarseTime = waveform_picker_regs->f3_1_coarse_time;
122 ring_node_to_send_cwf_f3->coarseTime = waveform_picker_regs->f3_1_coarse_time;
117 ring_node_to_send_cwf_f3->fineTime = waveform_picker_regs->f3_1_fine_time;
123 ring_node_to_send_cwf_f3->fineTime = waveform_picker_regs->f3_1_fine_time;
118 waveform_picker_regs->addr_data_f3_1 = current_ring_node_f3->buffer_address;
124 waveform_picker_regs->addr_data_f3_1 = current_ring_node_f3->buffer_address;
119 waveform_picker_regs->status = waveform_picker_regs->status & 0x00008880; // [1000 1000 1000 0000]
125 waveform_picker_regs->status = waveform_picker_regs->status & 0x00008880; // [1000 1000 1000 0000]
120 }
126 }
121 if (rtems_event_send( Task_id[TASKID_CWF3], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) {
127 if (rtems_event_send( Task_id[TASKID_CWF3], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) {
122 spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 );
128 spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 );
123 }
129 }
124 }
130 }
125 }
131 }
126 }
132 }
127
133
128 inline void waveforms_isr_normal( void )
129 {
130 rtems_status_code status;
131
132 if ( ( (waveform_picker_regs->status & 0x30) != 0x00 ) // [0011 0000] check the f2 full bits
133 && ( (waveform_picker_regs->status & 0x0c) != 0x00 ) // [0000 1100] check the f1 full bits
134 && ( (waveform_picker_regs->status & 0x03) != 0x00 )) // [0000 0011] check the f0 full bits
135 {
136 //***
137 // F0
138 ring_node_to_send_swf_f0 = current_ring_node_f0->previous;
139 current_ring_node_f0 = current_ring_node_f0->next;
140 if ( (waveform_picker_regs->status & 0x01) == 0x01)
141 {
142
143 ring_node_to_send_swf_f0->coarseTime = waveform_picker_regs->f0_0_coarse_time;
144 ring_node_to_send_swf_f0->fineTime = waveform_picker_regs->f0_0_fine_time;
145 waveform_picker_regs->addr_data_f0_0 = current_ring_node_f0->buffer_address;
146 waveform_picker_regs->status = waveform_picker_regs->status & 0x00001101; // [0001 0001 0000 0001]
147 }
148 else if ( (waveform_picker_regs->status & 0x02) == 0x02)
149 {
150 ring_node_to_send_swf_f0->coarseTime = waveform_picker_regs->f0_1_coarse_time;
151 ring_node_to_send_swf_f0->fineTime = waveform_picker_regs->f0_1_fine_time;
152 waveform_picker_regs->addr_data_f0_1 = current_ring_node_f0->buffer_address;
153 waveform_picker_regs->status = waveform_picker_regs->status & 0x00001102; // [0001 0001 0000 0010]
154 }
155
156 //***
157 // F1
158 ring_node_to_send_swf_f1 = current_ring_node_f1->previous;
159 current_ring_node_f1 = current_ring_node_f1->next;
160 if ( (waveform_picker_regs->status & 0x04) == 0x04)
161 {
162 ring_node_to_send_swf_f1->coarseTime = waveform_picker_regs->f1_0_coarse_time;
163 ring_node_to_send_swf_f1->fineTime = waveform_picker_regs->f1_0_fine_time;
164 waveform_picker_regs->addr_data_f1_0 = current_ring_node_f1->buffer_address;
165 waveform_picker_regs->status = waveform_picker_regs->status & 0x00002204; // [0010 0010 0000 0100] f1 bits = 0
166 }
167 else if ( (waveform_picker_regs->status & 0x08) == 0x08)
168 {
169 ring_node_to_send_swf_f1->coarseTime = waveform_picker_regs->f1_1_coarse_time;
170 ring_node_to_send_swf_f1->fineTime = waveform_picker_regs->f1_1_fine_time;
171 waveform_picker_regs->addr_data_f1_1 = current_ring_node_f1->buffer_address;
172 waveform_picker_regs->status = waveform_picker_regs->status & 0x00002208; // [0010 0010 0000 1000] f1 bits = 0
173 }
174
175 //***
176 // F2
177 ring_node_to_send_swf_f2 = current_ring_node_f2->previous;
178 current_ring_node_f2 = current_ring_node_f2->next;
179 if ( (waveform_picker_regs->status & 0x10) == 0x10)
180 {
181 ring_node_to_send_swf_f2->coarseTime = waveform_picker_regs->f2_0_coarse_time;
182 ring_node_to_send_swf_f2->fineTime = waveform_picker_regs->f2_0_fine_time;
183 waveform_picker_regs->addr_data_f2_0 = current_ring_node_f2->buffer_address;
184 waveform_picker_regs->status = waveform_picker_regs->status & 0x00004410; // [0100 0100 0001 0000]
185 }
186 else if ( (waveform_picker_regs->status & 0x20) == 0x20)
187 {
188 ring_node_to_send_swf_f2->coarseTime = waveform_picker_regs->f2_1_coarse_time;
189 ring_node_to_send_swf_f2->fineTime = waveform_picker_regs->f2_1_fine_time;
190 waveform_picker_regs->addr_data_f2_1 = current_ring_node_f2->buffer_address;
191 waveform_picker_regs->status = waveform_picker_regs->status & 0x00004420; // [0100 0100 0010 0000]
192 }
193 //
194 status = rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_NORMAL );
195 if ( status != RTEMS_SUCCESSFUL)
196 {
197 status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 );
198 }
199 }
200 }
201
202 inline void waveforms_isr_burst( void )
134 inline void waveforms_isr_burst( void )
203 {
135 {
204 unsigned char status;
136 unsigned char status;
205 rtems_status_code spare_status;
137 rtems_status_code spare_status;
206
138
207 status = (waveform_picker_regs->status & 0x30) >> 4; // [0011 0000] get the status bits for f2
139 status = (waveform_picker_regs->status & 0x30) >> 4; // [0011 0000] get the status bits for f2
208
140
209
141
210 switch(status)
142 switch(status)
211 {
143 {
212 case 1:
144 case 1:
213 ring_node_to_send_cwf_f2 = current_ring_node_f2->previous;
145 ring_node_to_send_cwf_f2 = current_ring_node_f2->previous;
214 ring_node_to_send_cwf_f2->sid = SID_BURST_CWF_F2;
146 ring_node_to_send_cwf_f2->sid = SID_BURST_CWF_F2;
215 ring_node_to_send_cwf_f2->coarseTime = waveform_picker_regs->f2_0_coarse_time;
147 ring_node_to_send_cwf_f2->coarseTime = waveform_picker_regs->f2_0_coarse_time;
216 ring_node_to_send_cwf_f2->fineTime = waveform_picker_regs->f2_0_fine_time;
148 ring_node_to_send_cwf_f2->fineTime = waveform_picker_regs->f2_0_fine_time;
217 current_ring_node_f2 = current_ring_node_f2->next;
149 current_ring_node_f2 = current_ring_node_f2->next;
218 waveform_picker_regs->addr_data_f2_0 = current_ring_node_f2->buffer_address;
150 waveform_picker_regs->addr_data_f2_0 = current_ring_node_f2->buffer_address;
219 if (rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_BURST ) != RTEMS_SUCCESSFUL) {
151 if (rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_BURST ) != RTEMS_SUCCESSFUL) {
220 spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 );
152 spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 );
221 }
153 }
222 waveform_picker_regs->status = waveform_picker_regs->status & 0x00004410; // [0100 0100 0001 0000]
154 waveform_picker_regs->status = waveform_picker_regs->status & 0x00004410; // [0100 0100 0001 0000]
223 break;
155 break;
224 case 2:
156 case 2:
225 ring_node_to_send_cwf_f2 = current_ring_node_f2->previous;
157 ring_node_to_send_cwf_f2 = current_ring_node_f2->previous;
226 ring_node_to_send_cwf_f2->sid = SID_BURST_CWF_F2;
158 ring_node_to_send_cwf_f2->sid = SID_BURST_CWF_F2;
227 ring_node_to_send_cwf_f2->coarseTime = waveform_picker_regs->f2_1_coarse_time;
159 ring_node_to_send_cwf_f2->coarseTime = waveform_picker_regs->f2_1_coarse_time;
228 ring_node_to_send_cwf_f2->fineTime = waveform_picker_regs->f2_1_fine_time;
160 ring_node_to_send_cwf_f2->fineTime = waveform_picker_regs->f2_1_fine_time;
229 current_ring_node_f2 = current_ring_node_f2->next;
161 current_ring_node_f2 = current_ring_node_f2->next;
230 waveform_picker_regs->addr_data_f2_1 = current_ring_node_f2->buffer_address;
162 waveform_picker_regs->addr_data_f2_1 = current_ring_node_f2->buffer_address;
231 if (rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_BURST ) != RTEMS_SUCCESSFUL) {
163 if (rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_BURST ) != RTEMS_SUCCESSFUL) {
232 spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 );
164 spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 );
233 }
165 }
234 waveform_picker_regs->status = waveform_picker_regs->status & 0x00004420; // [0100 0100 0010 0000]
166 waveform_picker_regs->status = waveform_picker_regs->status & 0x00004420; // [0100 0100 0010 0000]
235 break;
167 break;
236 default:
168 default:
237 break;
169 break;
238 }
170 }
239 }
171 }
240
172
241 inline void waveforms_isr_sbm1( void )
173 inline void waveform_isr_normal_sbm1_sbm2( void )
242 {
174 {
243 rtems_status_code status;
175 rtems_status_code status;
244
176
245 //***
177 //***
178 // F0
179 if ( (waveform_picker_regs->status & 0x03) != 0x00 ) // [0000 0011] check the f0 full bits
180 {
181 swf0_ready_flag_f1 = true;
182 swf0_ready_flag_f2 = true;
183 ring_node_to_send_swf_f0 = current_ring_node_f0->previous;
184 current_ring_node_f0 = current_ring_node_f0->next;
185 if ( (waveform_picker_regs->status & 0x01) == 0x01)
186 {
187
188 ring_node_to_send_swf_f0->coarseTime = waveform_picker_regs->f0_0_coarse_time;
189 ring_node_to_send_swf_f0->fineTime = waveform_picker_regs->f0_0_fine_time;
190 waveform_picker_regs->addr_data_f0_0 = current_ring_node_f0->buffer_address;
191 waveform_picker_regs->status = waveform_picker_regs->status & 0x00001101; // [0001 0001 0000 0001]
192 }
193 else if ( (waveform_picker_regs->status & 0x02) == 0x02)
194 {
195 ring_node_to_send_swf_f0->coarseTime = waveform_picker_regs->f0_1_coarse_time;
196 ring_node_to_send_swf_f0->fineTime = waveform_picker_regs->f0_1_fine_time;
197 waveform_picker_regs->addr_data_f0_1 = current_ring_node_f0->buffer_address;
198 waveform_picker_regs->status = waveform_picker_regs->status & 0x00001102; // [0001 0001 0000 0010]
199 }
200 }
201
202 //***
246 // F1
203 // F1
247 if ( (waveform_picker_regs->status & 0x0c) != 0x00 ) { // [0000 1100] check the f1 full bits
204 if ( (waveform_picker_regs->status & 0x0c) != 0x00 ) { // [0000 1100] check the f1 full bits
248 // (1) change the receiving buffer for the waveform picker
205 // (1) change the receiving buffer for the waveform picker
249 ring_node_to_send_cwf_f1 = current_ring_node_f1->previous;
206 ring_node_to_send_cwf_f1 = current_ring_node_f1->previous;
250 current_ring_node_f1 = current_ring_node_f1->next;
207 current_ring_node_f1 = current_ring_node_f1->next;
251 if ( (waveform_picker_regs->status & 0x04) == 0x04)
208 if ( (waveform_picker_regs->status & 0x04) == 0x04)
252 {
209 {
253 ring_node_to_send_cwf_f1->coarseTime = waveform_picker_regs->f1_0_coarse_time;
210 ring_node_to_send_cwf_f1->coarseTime = waveform_picker_regs->f1_0_coarse_time;
254 ring_node_to_send_cwf_f1->fineTime = waveform_picker_regs->f1_0_fine_time;
211 ring_node_to_send_cwf_f1->fineTime = waveform_picker_regs->f1_0_fine_time;
255 waveform_picker_regs->addr_data_f1_0 = current_ring_node_f1->buffer_address;
212 waveform_picker_regs->addr_data_f1_0 = current_ring_node_f1->buffer_address;
256 waveform_picker_regs->status = waveform_picker_regs->status & 0x00002204; // [0010 0010 0000 0100] f1 bits = 0
213 waveform_picker_regs->status = waveform_picker_regs->status & 0x00002204; // [0010 0010 0000 0100] f1 bits = 0
257 }
214 }
258 else if ( (waveform_picker_regs->status & 0x08) == 0x08)
215 else if ( (waveform_picker_regs->status & 0x08) == 0x08)
259 {
216 {
260 ring_node_to_send_cwf_f1->coarseTime = waveform_picker_regs->f1_1_coarse_time;
217 ring_node_to_send_cwf_f1->coarseTime = waveform_picker_regs->f1_1_coarse_time;
261 ring_node_to_send_cwf_f1->fineTime = waveform_picker_regs->f1_1_fine_time;
218 ring_node_to_send_cwf_f1->fineTime = waveform_picker_regs->f1_1_fine_time;
262 waveform_picker_regs->addr_data_f1_1 = current_ring_node_f1->buffer_address;
219 waveform_picker_regs->addr_data_f1_1 = current_ring_node_f1->buffer_address;
263 waveform_picker_regs->status = waveform_picker_regs->status & 0x00002208; // [0010 0010 0000 1000] f1 bits = 0
220 waveform_picker_regs->status = waveform_picker_regs->status & 0x00002208; // [0010 0010 0000 1000] f1 bits = 0
264 }
221 }
265 // (2) send an event for the the CWF1 task for transmission (and snapshot extraction if needed)
222 // (2) send an event for the the CWF1 task for transmission (and snapshot extraction if needed)
266 status = rtems_event_send( Task_id[TASKID_CWF1], RTEMS_EVENT_MODE_SBM1 );
223 status = rtems_event_send( Task_id[TASKID_CWF1], RTEMS_EVENT_MODE_NORM_S1_S2 );
267 }
268
269 //***
270 // F0
271 if ( (waveform_picker_regs->status & 0x03) != 0x00 ) { // [0000 0011] check the f0 full bits
272 swf_f0_ready = true;
273 // change f0 buffer
274 ring_node_to_send_swf_f0 = current_ring_node_f0->previous;
275 current_ring_node_f0 = current_ring_node_f0->next;
276 if ( (waveform_picker_regs->status & 0x01) == 0x01)
277 {
278
279 ring_node_to_send_swf_f0->coarseTime = waveform_picker_regs->f0_0_coarse_time;
280 ring_node_to_send_swf_f0->fineTime = waveform_picker_regs->f0_0_fine_time;
281 waveform_picker_regs->addr_data_f0_0 = current_ring_node_f0->buffer_address;
282 waveform_picker_regs->status = waveform_picker_regs->status & 0x00001101; // [0001 0001 0000 0001]
283 }
284 else if ( (waveform_picker_regs->status & 0x02) == 0x02)
285 {
286 ring_node_to_send_swf_f0->coarseTime = waveform_picker_regs->f0_1_coarse_time;
287 ring_node_to_send_swf_f0->fineTime = waveform_picker_regs->f0_1_fine_time;
288 waveform_picker_regs->addr_data_f0_1 = current_ring_node_f0->buffer_address;
289 waveform_picker_regs->status = waveform_picker_regs->status & 0x00001102; // [0001 0001 0000 0010]
290 }
291 }
224 }
292
225
293 //***
226 //***
294 // F2
227 // F2
295 if ( (waveform_picker_regs->status & 0x30) != 0x00 ) { // [0011 0000] check the f2 full bits
296 swf_f2_ready = true;
297 // change f2 buffer
298 ring_node_to_send_swf_f2 = current_ring_node_f2->previous;
299 current_ring_node_f2 = current_ring_node_f2->next;
300 if ( (waveform_picker_regs->status & 0x10) == 0x10)
301 {
302 ring_node_to_send_swf_f2->coarseTime = waveform_picker_regs->f2_0_coarse_time;
303 ring_node_to_send_swf_f2->fineTime = waveform_picker_regs->f2_0_fine_time;
304 waveform_picker_regs->addr_data_f2_0 = current_ring_node_f2->buffer_address;
305 waveform_picker_regs->status = waveform_picker_regs->status & 0x00004410; // [0100 0100 0001 0000]
306 }
307 else if ( (waveform_picker_regs->status & 0x20) == 0x20)
308 {
309 ring_node_to_send_swf_f2->coarseTime = waveform_picker_regs->f2_1_coarse_time;
310 ring_node_to_send_swf_f2->fineTime = waveform_picker_regs->f2_1_fine_time;
311 waveform_picker_regs->addr_data_f2_1 = current_ring_node_f2->buffer_address;
312 waveform_picker_regs->status = waveform_picker_regs->status & 0x00004420; // [0100 0100 0010 0000]
313 }
314 }
315 }
316
317 inline void waveforms_isr_sbm2( void )
318 {
319 rtems_status_code status;
320
321 //***
322 // F2
323 if ( (waveform_picker_regs->status & 0x30) != 0x00 ) { // [0011 0000] check the f2 full bit
228 if ( (waveform_picker_regs->status & 0x30) != 0x00 ) { // [0011 0000] check the f2 full bit
324 // (1) change the receiving buffer for the waveform picker
229 // (1) change the receiving buffer for the waveform picker
325 ring_node_to_send_cwf_f2 = current_ring_node_f2->previous;
230 ring_node_to_send_cwf_f2 = current_ring_node_f2->previous;
326 ring_node_to_send_cwf_f2->sid = SID_SBM2_CWF_F2;
231 ring_node_to_send_cwf_f2->sid = SID_SBM2_CWF_F2;
327 current_ring_node_f2 = current_ring_node_f2->next;
232 current_ring_node_f2 = current_ring_node_f2->next;
328 if ( (waveform_picker_regs->status & 0x10) == 0x10)
233 if ( (waveform_picker_regs->status & 0x10) == 0x10)
329 {
234 {
330 ring_node_to_send_cwf_f2->coarseTime = waveform_picker_regs->f2_0_coarse_time;
235 ring_node_to_send_cwf_f2->coarseTime = waveform_picker_regs->f2_0_coarse_time;
331 ring_node_to_send_cwf_f2->fineTime = waveform_picker_regs->f2_0_fine_time;
236 ring_node_to_send_cwf_f2->fineTime = waveform_picker_regs->f2_0_fine_time;
332 waveform_picker_regs->addr_data_f2_0 = current_ring_node_f2->buffer_address;
237 waveform_picker_regs->addr_data_f2_0 = current_ring_node_f2->buffer_address;
333 waveform_picker_regs->status = waveform_picker_regs->status & 0x00004410; // [0100 0100 0001 0000]
238 waveform_picker_regs->status = waveform_picker_regs->status & 0x00004410; // [0100 0100 0001 0000]
334 }
239 }
335 else if ( (waveform_picker_regs->status & 0x20) == 0x20)
240 else if ( (waveform_picker_regs->status & 0x20) == 0x20)
336 {
241 {
337 ring_node_to_send_cwf_f2->coarseTime = waveform_picker_regs->f2_1_coarse_time;
242 ring_node_to_send_cwf_f2->coarseTime = waveform_picker_regs->f2_1_coarse_time;
338 ring_node_to_send_cwf_f2->fineTime = waveform_picker_regs->f2_1_fine_time;
243 ring_node_to_send_cwf_f2->fineTime = waveform_picker_regs->f2_1_fine_time;
339 waveform_picker_regs->addr_data_f2_1 = current_ring_node_f2->buffer_address;
244 waveform_picker_regs->addr_data_f2_1 = current_ring_node_f2->buffer_address;
340 waveform_picker_regs->status = waveform_picker_regs->status & 0x00004420; // [0100 0100 0010 0000]
245 waveform_picker_regs->status = waveform_picker_regs->status & 0x00004420; // [0100 0100 0010 0000]
341 }
246 }
342 // (2) send an event for the waveforms transmission
247 // (2) send an event for the waveforms transmission
343 status = rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_SBM2 );
248 status = rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_NORM_S1_S2 );
344 }
345
346 //***
347 // F0
348 if ( (waveform_picker_regs->status & 0x03) != 0x00 ) { // [0000 0011] check the f0 full bit
349 swf_f0_ready = true;
350 // change f0 buffer
351 ring_node_to_send_swf_f0 = current_ring_node_f0->previous;
352 current_ring_node_f0 = current_ring_node_f0->next;
353 if ( (waveform_picker_regs->status & 0x01) == 0x01)
354 {
355
356 ring_node_to_send_swf_f0->coarseTime = waveform_picker_regs->f0_0_coarse_time;
357 ring_node_to_send_swf_f0->fineTime = waveform_picker_regs->f0_0_fine_time;
358 waveform_picker_regs->addr_data_f0_0 = current_ring_node_f0->buffer_address;
359 waveform_picker_regs->status = waveform_picker_regs->status & 0x00001101; // [0001 0001 0000 0001]
360 }
361 else if ( (waveform_picker_regs->status & 0x02) == 0x02)
362 {
363 ring_node_to_send_swf_f0->coarseTime = waveform_picker_regs->f0_1_coarse_time;
364 ring_node_to_send_swf_f0->fineTime = waveform_picker_regs->f0_1_fine_time;
365 waveform_picker_regs->addr_data_f0_1 = current_ring_node_f0->buffer_address;
366 waveform_picker_regs->status = waveform_picker_regs->status & 0x00001102; // [0001 0001 0000 0010]
367 }
368 }
369
370 //***
371 // F1
372 if ( (waveform_picker_regs->status & 0x0c) != 0x00 ) { // [0000 1100] check the f1 full bit
373 swf_f1_ready = true;
374 ring_node_to_send_swf_f1 = current_ring_node_f1->previous;
375 current_ring_node_f1 = current_ring_node_f1->next;
376 if ( (waveform_picker_regs->status & 0x04) == 0x04)
377 {
378 ring_node_to_send_swf_f1->coarseTime = waveform_picker_regs->f1_0_coarse_time;
379 ring_node_to_send_swf_f1->fineTime = waveform_picker_regs->f1_0_fine_time;
380 waveform_picker_regs->addr_data_f1_0 = current_ring_node_f1->buffer_address;
381 waveform_picker_regs->status = waveform_picker_regs->status & 0x00002204; // [0010 0010 0000 0100] f1 bits = 0
382 }
383 else if ( (waveform_picker_regs->status & 0x08) == 0x08)
384 {
385 ring_node_to_send_swf_f1->coarseTime = waveform_picker_regs->f1_1_coarse_time;
386 ring_node_to_send_swf_f1->fineTime = waveform_picker_regs->f1_1_fine_time;
387 waveform_picker_regs->addr_data_f1_1 = current_ring_node_f1->buffer_address;
388 waveform_picker_regs->status = waveform_picker_regs->status & 0x00002208; // [0010 0010 0000 1000] f1 bits = 0
389 }
390 }
249 }
391 }
250 }
392
251
393 rtems_isr waveforms_isr( rtems_vector_number vector )
252 rtems_isr waveforms_isr( rtems_vector_number vector )
394 {
253 {
395 /** This is the interrupt sub routine called by the waveform picker core.
254 /** This is the interrupt sub routine called by the waveform picker core.
396 *
255 *
397 * This ISR launch different actions depending mainly on two pieces of information:
256 * This ISR launch different actions depending mainly on two pieces of information:
398 * 1. the values read in the registers of the waveform picker.
257 * 1. the values read in the registers of the waveform picker.
399 * 2. the current LFR mode.
258 * 2. the current LFR mode.
400 *
259 *
401 */
260 */
402
261
403 // STATUS
262 // STATUS
404 // new error error buffer full
263 // new error error buffer full
405 // 15 14 13 12 11 10 9 8
264 // 15 14 13 12 11 10 9 8
406 // f3 f2 f1 f0 f3 f2 f1 f0
265 // f3 f2 f1 f0 f3 f2 f1 f0
407 //
266 //
408 // ready buffer
267 // ready buffer
409 // 7 6 5 4 3 2 1 0
268 // 7 6 5 4 3 2 1 0
410 // f3_1 f3_0 f2_1 f2_0 f1_1 f1_0 f0_1 f0_0
269 // f3_1 f3_0 f2_1 f2_0 f1_1 f1_0 f0_1 f0_0
411
270
412 rtems_status_code spare_status;
271 rtems_status_code spare_status;
413
272
414 waveforms_isr_f3();
273 waveforms_isr_f3();
415
274
416 if ( (waveform_picker_regs->status & 0xff00) != 0x00) // [1111 1111 0000 0000] check the error bits
275 if ( (waveform_picker_regs->status & 0xff00) != 0x00) // [1111 1111 0000 0000] check the error bits
417 {
276 {
418 spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_10 );
277 spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_10 );
419 }
278 }
420
279
421 switch(lfrCurrentMode)
280 switch(lfrCurrentMode)
422 {
281 {
423 //********
282 //********
424 // STANDBY
283 // STANDBY
425 case(LFR_MODE_STANDBY):
284 case LFR_MODE_STANDBY:
426 break;
285 break;
427
286 //**************************
428 //******
287 // LFR NORMAL, SBM1 and SBM2
429 // NORMAL
288 case LFR_MODE_NORMAL:
430 case(LFR_MODE_NORMAL):
289 case LFR_MODE_SBM1:
431 waveforms_isr_normal();
290 case LFR_MODE_SBM2:
291 waveform_isr_normal_sbm1_sbm2();
432 break;
292 break;
433
293 //******
434 //******
294 // BURST
435 // BURST
295 case LFR_MODE_BURST:
436 case(LFR_MODE_BURST):
437 waveforms_isr_burst();
296 waveforms_isr_burst();
438 break;
297 break;
439
298 //********
440 //*****
299 // DEFAULT
441 // SBM1
300 default:
442 case(LFR_MODE_SBM1):
443 waveforms_isr_sbm1();
444 break;
445
446 //*****
447 // SBM2
448 case(LFR_MODE_SBM2):
449 waveforms_isr_sbm2();
450 break;
451
452 //********
453 // DEFAULT
454 default:
455 break;
301 break;
456 }
302 }
457 }
303 }
458
304
459 //************
305 //************
460 // RTEMS TASKS
306 // RTEMS TASKS
461
307
462 rtems_task wfrm_task(rtems_task_argument argument) //used with the waveform picker VHDL IP
308 rtems_task wfrm_task(rtems_task_argument argument) //used with the waveform picker VHDL IP
463 {
309 {
464 /** This RTEMS task is dedicated to the transmission of snapshots of the NORMAL mode.
310 /** This RTEMS task is dedicated to the transmission of snapshots of the NORMAL mode.
465 *
311 *
466 * @param unused is the starting argument of the RTEMS task
312 * @param unused is the starting argument of the RTEMS task
467 *
313 *
468 * The following data packets are sent by this task:
314 * The following data packets are sent by this task:
469 * - TM_LFR_SCIENCE_NORMAL_SWF_F0
315 * - TM_LFR_SCIENCE_NORMAL_SWF_F0
470 * - TM_LFR_SCIENCE_NORMAL_SWF_F1
316 * - TM_LFR_SCIENCE_NORMAL_SWF_F1
471 * - TM_LFR_SCIENCE_NORMAL_SWF_F2
317 * - TM_LFR_SCIENCE_NORMAL_SWF_F2
472 *
318 *
473 */
319 */
474
320
475 rtems_event_set event_out;
321 rtems_event_set event_out;
476 rtems_id queue_id;
322 rtems_id queue_id;
477 rtems_status_code status;
323 rtems_status_code status;
478 bool resynchronisationEngaged;
324 bool resynchronisationEngaged;
479 ring_node *ring_node_wf_snap_extracted_ptr;
325 ring_node *ring_node_swf1_extracted_ptr;
326 ring_node *ring_node_swf2_extracted_ptr;
480
327
481 ring_node_wf_snap_extracted_ptr = (ring_node *) &ring_node_wf_snap_extracted;
328 ring_node_swf1_extracted_ptr = (ring_node *) &ring_node_swf1_extracted;
329 ring_node_swf2_extracted_ptr = (ring_node *) &ring_node_swf2_extracted;
482
330
483 resynchronisationEngaged = false;
331 resynchronisationEngaged = false;
484
332
485 status = get_message_queue_id_send( &queue_id );
333 status = get_message_queue_id_send( &queue_id );
486 if (status != RTEMS_SUCCESSFUL)
334 if (status != RTEMS_SUCCESSFUL)
487 {
335 {
488 PRINTF1("in WFRM *** ERR get_message_queue_id_send %d\n", status)
336 PRINTF1("in WFRM *** ERR get_message_queue_id_send %d\n", status)
489 }
337 }
490
338
491 BOOT_PRINTF("in WFRM ***\n")
339 BOOT_PRINTF("in WFRM ***\n")
492
340
493 while(1){
341 while(1){
494 // wait for an RTEMS_EVENT
342 // wait for an RTEMS_EVENT
495 rtems_event_receive(RTEMS_EVENT_MODE_NORMAL | RTEMS_EVENT_MODE_SBM1
343 rtems_event_receive(RTEMS_EVENT_MODE_NORMAL,
496 | RTEMS_EVENT_MODE_SBM2 | RTEMS_EVENT_MODE_SBM2_WFRM,
497 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
344 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
498 if(resynchronisationEngaged == false)
345 if(resynchronisationEngaged == false)
499 { // engage resynchronisation
346 { // engage resynchronisation
500 snapshot_resynchronization( (unsigned char *) &ring_node_to_send_swf_f0->coarseTime );
347 snapshot_resynchronization( (unsigned char *) &ring_node_to_send_swf_f0->coarseTime );
501 resynchronisationEngaged = true;
348 resynchronisationEngaged = true;
502 }
349 }
503 else
350 else
504 { // reset delta_snapshot to the nominal value
351 { // reset delta_snapshot to the nominal value
505 PRINTF("no resynchronisation, reset delta_snapshot to the nominal value\n")
352 PRINTF("no resynchronisation, reset delta_snapshot to the nominal value\n")
506 set_wfp_delta_snapshot();
353 set_wfp_delta_snapshot();
507 resynchronisationEngaged = false;
354 resynchronisationEngaged = false;
508 }
355 }
509 //
356 //
510
511 if (event_out == RTEMS_EVENT_MODE_NORMAL)
357 if (event_out == RTEMS_EVENT_MODE_NORMAL)
512 {
358 {
513 DEBUG_PRINTF("WFRM received RTEMS_EVENT_MODE_NORMAL\n")
514 ring_node_to_send_swf_f0->sid = SID_NORM_SWF_F0;
515 ring_node_to_send_swf_f1->sid = SID_NORM_SWF_F1;
516 ring_node_to_send_swf_f2->sid = SID_NORM_SWF_F2;
517 status = rtems_message_queue_send( queue_id, &ring_node_to_send_swf_f0, sizeof( ring_node* ) );
518 status = rtems_message_queue_send( queue_id, &ring_node_to_send_swf_f1, sizeof( ring_node* ) );
519 status = rtems_message_queue_send( queue_id, &ring_node_to_send_swf_f2, sizeof( ring_node* ) );
520 }
521 if (event_out == RTEMS_EVENT_MODE_SBM1)
522 {
523 DEBUG_PRINTF("WFRM received RTEMS_EVENT_MODE_SBM1\n")
524 ring_node_to_send_swf_f0->sid = SID_NORM_SWF_F0;
525 ring_node_wf_snap_extracted_ptr->sid = SID_NORM_SWF_F1;
526 ring_node_to_send_swf_f2->sid = SID_NORM_SWF_F2;
527 status = rtems_message_queue_send( queue_id, &ring_node_to_send_swf_f0, sizeof( ring_node* ) );
528 status = rtems_message_queue_send( queue_id, &ring_node_wf_snap_extracted_ptr, sizeof( ring_node* ) );
529 status = rtems_message_queue_send( queue_id, &ring_node_to_send_swf_f2, sizeof( ring_node* ) );
530 }
531 if (event_out == RTEMS_EVENT_MODE_SBM2)
532 {
533 DEBUG_PRINTF("WFRM received RTEMS_EVENT_MODE_SBM2\n")
359 DEBUG_PRINTF("WFRM received RTEMS_EVENT_MODE_SBM2\n")
534 ring_node_to_send_swf_f0->sid = SID_NORM_SWF_F0;
360 ring_node_to_send_swf_f0->sid = SID_NORM_SWF_F0;
535 ring_node_to_send_swf_f1->sid = SID_NORM_SWF_F1;
361 ring_node_swf1_extracted_ptr->sid = SID_NORM_SWF_F1;
536 ring_node_wf_snap_extracted_ptr->sid = SID_NORM_SWF_F2;
362 ring_node_swf2_extracted_ptr->sid = SID_NORM_SWF_F2;
537 status = rtems_message_queue_send( queue_id, &ring_node_to_send_swf_f0, sizeof( ring_node* ) );
363 status = rtems_message_queue_send( queue_id, &ring_node_to_send_swf_f0, sizeof( ring_node* ) );
538 status = rtems_message_queue_send( queue_id, &ring_node_to_send_swf_f1, sizeof( ring_node* ) );
364 status = rtems_message_queue_send( queue_id, &ring_node_swf1_extracted_ptr, sizeof( ring_node* ) );
539 status = rtems_message_queue_send( queue_id, &ring_node_wf_snap_extracted_ptr, sizeof( ring_node* ) );
365 status = rtems_message_queue_send( queue_id, &ring_node_swf2_extracted_ptr, sizeof( ring_node* ) );
540 }
366 }
541 }
367 }
542 }
368 }
543
369
544 rtems_task cwf3_task(rtems_task_argument argument) //used with the waveform picker VHDL IP
370 rtems_task cwf3_task(rtems_task_argument argument) //used with the waveform picker VHDL IP
545 {
371 {
546 /** This RTEMS task is dedicated to the transmission of continuous waveforms at f3.
372 /** This RTEMS task is dedicated to the transmission of continuous waveforms at f3.
547 *
373 *
548 * @param unused is the starting argument of the RTEMS task
374 * @param unused is the starting argument of the RTEMS task
549 *
375 *
550 * The following data packet is sent by this task:
376 * The following data packet is sent by this task:
551 * - TM_LFR_SCIENCE_NORMAL_CWF_F3
377 * - TM_LFR_SCIENCE_NORMAL_CWF_F3
552 *
378 *
553 */
379 */
554
380
555 rtems_event_set event_out;
381 rtems_event_set event_out;
556 rtems_id queue_id;
382 rtems_id queue_id;
557 rtems_status_code status;
383 rtems_status_code status;
558 ring_node ring_node_cwf3_light;
384 ring_node ring_node_cwf3_light;
559 ring_node *ring_node_to_send_cwf;
385 ring_node *ring_node_to_send_cwf;
560
386
561 status = get_message_queue_id_send( &queue_id );
387 status = get_message_queue_id_send( &queue_id );
562 if (status != RTEMS_SUCCESSFUL)
388 if (status != RTEMS_SUCCESSFUL)
563 {
389 {
564 PRINTF1("in CWF3 *** ERR get_message_queue_id_send %d\n", status)
390 PRINTF1("in CWF3 *** ERR get_message_queue_id_send %d\n", status)
565 }
391 }
566
392
567 ring_node_to_send_cwf_f3->sid = SID_NORM_CWF_LONG_F3;
393 ring_node_to_send_cwf_f3->sid = SID_NORM_CWF_LONG_F3;
568
394
569 // init the ring_node_cwf3_light structure
395 // init the ring_node_cwf3_light structure
570 ring_node_cwf3_light.buffer_address = (int) wf_cont_f3_light;
396 ring_node_cwf3_light.buffer_address = (int) wf_cont_f3_light;
571 ring_node_cwf3_light.coarseTime = 0x00;
397 ring_node_cwf3_light.coarseTime = 0x00;
572 ring_node_cwf3_light.fineTime = 0x00;
398 ring_node_cwf3_light.fineTime = 0x00;
573 ring_node_cwf3_light.next = NULL;
399 ring_node_cwf3_light.next = NULL;
574 ring_node_cwf3_light.previous = NULL;
400 ring_node_cwf3_light.previous = NULL;
575 ring_node_cwf3_light.sid = SID_NORM_CWF_F3;
401 ring_node_cwf3_light.sid = SID_NORM_CWF_F3;
576 ring_node_cwf3_light.status = 0x00;
402 ring_node_cwf3_light.status = 0x00;
577
403
578 BOOT_PRINTF("in CWF3 ***\n")
404 BOOT_PRINTF("in CWF3 ***\n")
579
405
580 while(1){
406 while(1){
581 // wait for an RTEMS_EVENT
407 // wait for an RTEMS_EVENT
582 rtems_event_receive( RTEMS_EVENT_0,
408 rtems_event_receive( RTEMS_EVENT_0,
583 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
409 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
584 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
410 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
585 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode==LFR_MODE_SBM2) )
411 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode==LFR_MODE_SBM2) )
586 {
412 {
587 ring_node_to_send_cwf = getRingNodeToSendCWF( 3 );
413 ring_node_to_send_cwf = getRingNodeToSendCWF( 3 );
588 if ( (parameter_dump_packet.sy_lfr_n_cwf_long_f3 & 0x01) == 0x01)
414 if ( (parameter_dump_packet.sy_lfr_n_cwf_long_f3 & 0x01) == 0x01)
589 {
415 {
590 PRINTF("send CWF_LONG_F3\n")
416 PRINTF("send CWF_LONG_F3\n")
591 ring_node_to_send_cwf_f3->sid = SID_NORM_CWF_LONG_F3;
417 ring_node_to_send_cwf_f3->sid = SID_NORM_CWF_LONG_F3;
592 status = rtems_message_queue_send( queue_id, &ring_node_to_send_cwf, sizeof( ring_node* ) );
418 status = rtems_message_queue_send( queue_id, &ring_node_to_send_cwf, sizeof( ring_node* ) );
593 }
419 }
594 else
420 else
595 {
421 {
596 PRINTF("send CWF_F3 (light)\n")
422 PRINTF("send CWF_F3 (light)\n")
597 send_waveform_CWF3_light( ring_node_to_send_cwf, &ring_node_cwf3_light, queue_id );
423 send_waveform_CWF3_light( ring_node_to_send_cwf, &ring_node_cwf3_light, queue_id );
598 }
424 }
599
425
600 }
426 }
601 else
427 else
602 {
428 {
603 PRINTF1("in CWF3 *** lfrCurrentMode is %d, no data will be sent\n", lfrCurrentMode)
429 PRINTF1("in CWF3 *** lfrCurrentMode is %d, no data will be sent\n", lfrCurrentMode)
604 }
430 }
605 }
431 }
606 }
432 }
607
433
608 rtems_task cwf2_task(rtems_task_argument argument) // ONLY USED IN BURST AND SBM2
434 rtems_task cwf2_task(rtems_task_argument argument) // ONLY USED IN BURST AND SBM2
609 {
435 {
610 /** This RTEMS task is dedicated to the transmission of continuous waveforms at f2.
436 /** This RTEMS task is dedicated to the transmission of continuous waveforms at f2.
611 *
437 *
612 * @param unused is the starting argument of the RTEMS task
438 * @param unused is the starting argument of the RTEMS task
613 *
439 *
614 * The following data packet is sent by this function:
440 * The following data packet is sent by this function:
615 * - TM_LFR_SCIENCE_BURST_CWF_F2
441 * - TM_LFR_SCIENCE_BURST_CWF_F2
616 * - TM_LFR_SCIENCE_SBM2_CWF_F2
442 * - TM_LFR_SCIENCE_SBM2_CWF_F2
617 *
443 *
618 */
444 */
619
445
620 rtems_event_set event_out;
446 rtems_event_set event_out;
621 rtems_id queue_id;
447 rtems_id queue_id;
622 rtems_status_code status;
448 rtems_status_code status;
623 ring_node *ring_node_to_send;
449 ring_node *ring_node_to_send;
624 unsigned long long int acquisitionTimeF0_asLong;
450 unsigned long long int acquisitionTimeF0_asLong;
625
451
626 acquisitionTimeF0_asLong = 0x00;
452 acquisitionTimeF0_asLong = 0x00;
627
453
628 status = get_message_queue_id_send( &queue_id );
454 status = get_message_queue_id_send( &queue_id );
629 if (status != RTEMS_SUCCESSFUL)
455 if (status != RTEMS_SUCCESSFUL)
630 {
456 {
631 PRINTF1("in CWF2 *** ERR get_message_queue_id_send %d\n", status)
457 PRINTF1("in CWF2 *** ERR get_message_queue_id_send %d\n", status)
632 }
458 }
633
459
634 BOOT_PRINTF("in CWF2 ***\n")
460 BOOT_PRINTF("in CWF2 ***\n")
635
461
636 while(1){
462 while(1){
637 // wait for an RTEMS_EVENT
463 // wait for an RTEMS_EVENT
638 rtems_event_receive( RTEMS_EVENT_MODE_BURST | RTEMS_EVENT_MODE_SBM2,
464 rtems_event_receive( RTEMS_EVENT_MODE_NORM_S1_S2 | RTEMS_EVENT_MODE_BURST,
639 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
465 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
640 ring_node_to_send = getRingNodeToSendCWF( 2 );
466 ring_node_to_send = getRingNodeToSendCWF( 2 );
641 if (event_out == RTEMS_EVENT_MODE_BURST)
467 if (event_out == RTEMS_EVENT_MODE_BURST)
642 {
468 {
643 status = rtems_message_queue_send( queue_id, &ring_node_to_send, sizeof( ring_node* ) );
469 status = rtems_message_queue_send( queue_id, &ring_node_to_send, sizeof( ring_node* ) );
644 }
470 }
645 if (event_out == RTEMS_EVENT_MODE_SBM2)
471 else if (event_out == RTEMS_EVENT_MODE_NORM_S1_S2)
646 {
472 {
647 status = rtems_message_queue_send( queue_id, &ring_node_to_send, sizeof( ring_node* ) );
473 if ( lfrCurrentMode == LFR_MODE_SBM2 )
474 {
475 status = rtems_message_queue_send( queue_id, &ring_node_to_send, sizeof( ring_node* ) );
476 }
648 // launch snapshot extraction if needed
477 // launch snapshot extraction if needed
649 if (extractSWF == true)
478 if (extractSWF2 == true)
650 {
479 {
651 ring_node_to_send_swf_f2 = ring_node_to_send_cwf_f2;
480 ring_node_to_send_swf_f2 = ring_node_to_send_cwf_f2;
652 // extract the snapshot
481 // extract the snapshot
653 build_snapshot_from_ring( ring_node_to_send_swf_f2, 2, acquisitionTimeF0_asLong );
482 build_snapshot_from_ring( ring_node_to_send_swf_f2, 2, acquisitionTimeF0_asLong,
483 &ring_node_swf2_extracted, swf2_extracted );
654 // send the snapshot when built
484 // send the snapshot when built
655 status = rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_SBM2 );
485 status = rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_SBM2 );
656 extractSWF = false;
486 extractSWF2 = false;
487 swf2_ready = true;
657 }
488 }
658 if (swf_f0_ready && swf_f1_ready)
489 if (swf0_ready_flag_f2 == true)
659 {
490 {
660 extractSWF = true;
491 extractSWF2 = true;
661 // record the acquition time of the fΓ  snapshot to use to build the snapshot at f2
492 // record the acquition time of the f0 snapshot to use to build the snapshot at f2
662 acquisitionTimeF0_asLong = get_acquisition_time( (unsigned char *) &ring_node_to_send_swf_f0->coarseTime );
493 acquisitionTimeF0_asLong = get_acquisition_time( (unsigned char *) &ring_node_to_send_swf_f0->coarseTime );
663 swf_f0_ready = false;
494 swf0_ready_flag_f2 = false;
664 swf_f1_ready = false;
665 }
495 }
666 }
496 }
667 }
497 }
668 }
498 }
669
499
670 rtems_task cwf1_task(rtems_task_argument argument) // ONLY USED IN SBM1
500 rtems_task cwf1_task(rtems_task_argument argument) // ONLY USED IN SBM1
671 {
501 {
672 /** This RTEMS task is dedicated to the transmission of continuous waveforms at f1.
502 /** This RTEMS task is dedicated to the transmission of continuous waveforms at f1.
673 *
503 *
674 * @param unused is the starting argument of the RTEMS task
504 * @param unused is the starting argument of the RTEMS task
675 *
505 *
676 * The following data packet is sent by this function:
506 * The following data packet is sent by this function:
677 * - TM_LFR_SCIENCE_SBM1_CWF_F1
507 * - TM_LFR_SCIENCE_SBM1_CWF_F1
678 *
508 *
679 */
509 */
680
510
681 rtems_event_set event_out;
511 rtems_event_set event_out;
682 rtems_id queue_id;
512 rtems_id queue_id;
683 rtems_status_code status;
513 rtems_status_code status;
684
514
685 ring_node *ring_node_to_send_cwf;
515 ring_node *ring_node_to_send_cwf;
686
516
687 status = get_message_queue_id_send( &queue_id );
517 status = get_message_queue_id_send( &queue_id );
688 if (status != RTEMS_SUCCESSFUL)
518 if (status != RTEMS_SUCCESSFUL)
689 {
519 {
690 PRINTF1("in CWF1 *** ERR get_message_queue_id_send %d\n", status)
520 PRINTF1("in CWF1 *** ERR get_message_queue_id_send %d\n", status)
691 }
521 }
692
522
693 BOOT_PRINTF("in CWF1 ***\n")
523 BOOT_PRINTF("in CWF1 ***\n")
694
524
695 while(1){
525 while(1){
696 // wait for an RTEMS_EVENT
526 // wait for an RTEMS_EVENT
697 rtems_event_receive( RTEMS_EVENT_MODE_SBM1,
527 rtems_event_receive( RTEMS_EVENT_MODE_NORM_S1_S2,
698 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
528 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
699 ring_node_to_send_cwf = getRingNodeToSendCWF( 1 );
529 ring_node_to_send_cwf = getRingNodeToSendCWF( 1 );
700 ring_node_to_send_cwf_f1->sid = SID_SBM1_CWF_F1;
530 ring_node_to_send_cwf_f1->sid = SID_SBM1_CWF_F1;
701 status = rtems_message_queue_send( queue_id, &ring_node_to_send_cwf, sizeof( ring_node* ) );
531 if (lfrCurrentMode == LFR_MODE_SBM1)
702 if (status != 0)
703 {
532 {
704 PRINTF("cwf sending failed\n")
533 status = rtems_message_queue_send( queue_id, &ring_node_to_send_cwf, sizeof( ring_node* ) );
534 if (status != 0)
535 {
536 PRINTF("cwf sending failed\n")
537 }
705 }
538 }
706 // launch snapshot extraction if needed
539 // launch snapshot extraction if needed
707 if (extractSWF == true)
540 if (extractSWF1 == true)
708 {
541 {
709 ring_node_to_send_swf_f1 = ring_node_to_send_cwf;
542 ring_node_to_send_swf_f1 = ring_node_to_send_cwf;
710 // launch the snapshot extraction
543 // launch the snapshot extraction
711 status = rtems_event_send( Task_id[TASKID_SWBD], RTEMS_EVENT_MODE_SBM1 );
544 status = rtems_event_send( Task_id[TASKID_SWBD], RTEMS_EVENT_MODE_NORM_S1_S2 );
712 extractSWF = false;
545 extractSWF1 = false;
713 }
546 }
714 if (swf_f0_ready == true)
547 if (swf0_ready_flag_f1 == true)
715 {
548 {
716 extractSWF = true;
549 extractSWF1 = true;
717 swf_f0_ready = false; // this step shall be executed only one time
550 swf0_ready_flag_f1 = false; // this step shall be executed only one time
718 }
551 }
719 if ((swf_f1_ready == true) && (swf_f2_ready == true)) // swf_f1 is ready after the extraction
552 if ((swf1_ready == true) && (swf2_ready == true)) // swf_f1 is ready after the extraction
720 {
553 {
721 status = rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_SBM1 );
554 status = rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_NORMAL );
722 swf_f1_ready = false;
555 swf1_ready = false;
723 swf_f2_ready = false;
556 swf2_ready = false;
724 }
557 }
725 }
558 }
726 }
559 }
727
560
728 rtems_task swbd_task(rtems_task_argument argument)
561 rtems_task swbd_task(rtems_task_argument argument)
729 {
562 {
730 /** This RTEMS task is dedicated to the building of snapshots from different continuous waveforms buffers.
563 /** This RTEMS task is dedicated to the building of snapshots from different continuous waveforms buffers.
731 *
564 *
732 * @param unused is the starting argument of the RTEMS task
565 * @param unused is the starting argument of the RTEMS task
733 *
566 *
734 */
567 */
735
568
736 rtems_event_set event_out;
569 rtems_event_set event_out;
737 unsigned long long int acquisitionTimeF0_asLong;
570 unsigned long long int acquisitionTimeF0_asLong;
738
571
739 acquisitionTimeF0_asLong = 0x00;
572 acquisitionTimeF0_asLong = 0x00;
740
573
741 BOOT_PRINTF("in SWBD ***\n")
574 BOOT_PRINTF("in SWBD ***\n")
742
575
743 while(1){
576 while(1){
744 // wait for an RTEMS_EVENT
577 // wait for an RTEMS_EVENT
745 rtems_event_receive( RTEMS_EVENT_MODE_SBM1 | RTEMS_EVENT_MODE_SBM2,
578 rtems_event_receive( RTEMS_EVENT_MODE_NORM_S1_S2,
746 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
579 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
747 if (event_out == RTEMS_EVENT_MODE_SBM1)
580 if (event_out == RTEMS_EVENT_MODE_NORM_S1_S2)
748 {
581 {
749 acquisitionTimeF0_asLong = get_acquisition_time( (unsigned char *) &ring_node_to_send_swf_f0->coarseTime );
582 acquisitionTimeF0_asLong = get_acquisition_time( (unsigned char *) &ring_node_to_send_swf_f0->coarseTime );
750 build_snapshot_from_ring( ring_node_to_send_swf_f1, 1, acquisitionTimeF0_asLong );
583 build_snapshot_from_ring( ring_node_to_send_swf_f1, 1, acquisitionTimeF0_asLong,
751 swf_f1_ready = true; // the snapshot has been extracted and is ready to be sent
584 &ring_node_swf1_extracted, swf1_extracted );
585 swf1_ready = true; // the snapshot has been extracted and is ready to be sent
752 }
586 }
753 else
587 else
754 {
588 {
755 PRINTF1("in SWBD *** unexpected rtems event received %x\n", (int) event_out)
589 PRINTF1("in SWBD *** unexpected rtems event received %x\n", (int) event_out)
756 }
590 }
757 }
591 }
758 }
592 }
759
593
760 //******************
594 //******************
761 // general functions
595 // general functions
762
596
763 void WFP_init_rings( void )
597 void WFP_init_rings( void )
764 {
598 {
765 // F0 RING
599 // F0 RING
766 init_ring( waveform_ring_f0, NB_RING_NODES_F0, wf_buffer_f0, WFRM_BUFFER );
600 init_ring( waveform_ring_f0, NB_RING_NODES_F0, wf_buffer_f0, WFRM_BUFFER );
767 // F1 RING
601 // F1 RING
768 init_ring( waveform_ring_f1, NB_RING_NODES_F1, wf_buffer_f1, WFRM_BUFFER );
602 init_ring( waveform_ring_f1, NB_RING_NODES_F1, wf_buffer_f1, WFRM_BUFFER );
769 // F2 RING
603 // F2 RING
770 init_ring( waveform_ring_f2, NB_RING_NODES_F2, wf_buffer_f2, WFRM_BUFFER );
604 init_ring( waveform_ring_f2, NB_RING_NODES_F2, wf_buffer_f2, WFRM_BUFFER );
771 // F3 RING
605 // F3 RING
772 init_ring( waveform_ring_f3, NB_RING_NODES_F3, wf_buffer_f3, WFRM_BUFFER );
606 init_ring( waveform_ring_f3, NB_RING_NODES_F3, wf_buffer_f3, WFRM_BUFFER );
773
607
774 ring_node_wf_snap_extracted.buffer_address = (int) wf_snap_extracted;
608 ring_node_swf1_extracted.buffer_address = (int) swf1_extracted;
609 ring_node_swf2_extracted.buffer_address = (int) swf2_extracted;
775
610
776 DEBUG_PRINTF1("waveform_ring_f0 @%x\n", (unsigned int) waveform_ring_f0)
611 DEBUG_PRINTF1("waveform_ring_f0 @%x\n", (unsigned int) waveform_ring_f0)
777 DEBUG_PRINTF1("waveform_ring_f1 @%x\n", (unsigned int) waveform_ring_f1)
612 DEBUG_PRINTF1("waveform_ring_f1 @%x\n", (unsigned int) waveform_ring_f1)
778 DEBUG_PRINTF1("waveform_ring_f2 @%x\n", (unsigned int) waveform_ring_f2)
613 DEBUG_PRINTF1("waveform_ring_f2 @%x\n", (unsigned int) waveform_ring_f2)
779 DEBUG_PRINTF1("waveform_ring_f3 @%x\n", (unsigned int) waveform_ring_f3)
614 DEBUG_PRINTF1("waveform_ring_f3 @%x\n", (unsigned int) waveform_ring_f3)
780 DEBUG_PRINTF1("wf_buffer_f0 @%x\n", (unsigned int) wf_buffer_f0)
615 DEBUG_PRINTF1("wf_buffer_f0 @%x\n", (unsigned int) wf_buffer_f0)
781 DEBUG_PRINTF1("wf_buffer_f1 @%x\n", (unsigned int) wf_buffer_f1)
616 DEBUG_PRINTF1("wf_buffer_f1 @%x\n", (unsigned int) wf_buffer_f1)
782 DEBUG_PRINTF1("wf_buffer_f2 @%x\n", (unsigned int) wf_buffer_f2)
617 DEBUG_PRINTF1("wf_buffer_f2 @%x\n", (unsigned int) wf_buffer_f2)
783 DEBUG_PRINTF1("wf_buffer_f3 @%x\n", (unsigned int) wf_buffer_f3)
618 DEBUG_PRINTF1("wf_buffer_f3 @%x\n", (unsigned int) wf_buffer_f3)
784
619
785 }
620 }
786
621
787 void WFP_reset_current_ring_nodes( void )
622 void WFP_reset_current_ring_nodes( void )
788 {
623 {
789 current_ring_node_f0 = waveform_ring_f0[0].next;
624 current_ring_node_f0 = waveform_ring_f0[0].next;
790 current_ring_node_f1 = waveform_ring_f1[0].next;
625 current_ring_node_f1 = waveform_ring_f1[0].next;
791 current_ring_node_f2 = waveform_ring_f2[0].next;
626 current_ring_node_f2 = waveform_ring_f2[0].next;
792 current_ring_node_f3 = waveform_ring_f3[0].next;
627 current_ring_node_f3 = waveform_ring_f3[0].next;
793
628
794 ring_node_to_send_swf_f0 = waveform_ring_f0;
629 ring_node_to_send_swf_f0 = waveform_ring_f0;
795 ring_node_to_send_swf_f1 = waveform_ring_f1;
630 ring_node_to_send_swf_f1 = waveform_ring_f1;
796 ring_node_to_send_swf_f2 = waveform_ring_f2;
631 ring_node_to_send_swf_f2 = waveform_ring_f2;
797
632
798 ring_node_to_send_cwf_f1 = waveform_ring_f1;
633 ring_node_to_send_cwf_f1 = waveform_ring_f1;
799 ring_node_to_send_cwf_f2 = waveform_ring_f2;
634 ring_node_to_send_cwf_f2 = waveform_ring_f2;
800 ring_node_to_send_cwf_f3 = waveform_ring_f3;
635 ring_node_to_send_cwf_f3 = waveform_ring_f3;
801 }
636 }
802
637
803 int send_waveform_CWF3_light( ring_node *ring_node_to_send, ring_node *ring_node_cwf3_light, rtems_id queue_id )
638 int send_waveform_CWF3_light( ring_node *ring_node_to_send, ring_node *ring_node_cwf3_light, rtems_id queue_id )
804 {
639 {
805 /** This function sends CWF_F3 CCSDS packets without the b1, b2 and b3 data.
640 /** This function sends CWF_F3 CCSDS packets without the b1, b2 and b3 data.
806 *
641 *
807 * @param waveform points to the buffer containing the data that will be send.
642 * @param waveform points to the buffer containing the data that will be send.
808 * @param headerCWF points to a table of headers that have been prepared for the data transmission.
643 * @param headerCWF points to a table of headers that have been prepared for the data transmission.
809 * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures
644 * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures
810 * contain information to setup the transmission of the data packets.
645 * contain information to setup the transmission of the data packets.
811 *
646 *
812 * By default, CWF_F3 packet are send without the b1, b2 and b3 data. This function rebuilds a data buffer
647 * By default, CWF_F3 packet are send without the b1, b2 and b3 data. This function rebuilds a data buffer
813 * from the incoming data and sends it in 7 packets, 6 containing 340 blocks and 1 one containing 8 blocks.
648 * from the incoming data and sends it in 7 packets, 6 containing 340 blocks and 1 one containing 8 blocks.
814 *
649 *
815 */
650 */
816
651
817 unsigned int i;
652 unsigned int i;
818 int ret;
653 int ret;
819 rtems_status_code status;
654 rtems_status_code status;
820
655
821 char *sample;
656 char *sample;
822 int *dataPtr;
657 int *dataPtr;
823
658
824 ret = LFR_DEFAULT;
659 ret = LFR_DEFAULT;
825
660
826 dataPtr = (int*) ring_node_to_send->buffer_address;
661 dataPtr = (int*) ring_node_to_send->buffer_address;
827
662
828 ring_node_cwf3_light->coarseTime = ring_node_to_send->coarseTime;
663 ring_node_cwf3_light->coarseTime = ring_node_to_send->coarseTime;
829 ring_node_cwf3_light->fineTime = ring_node_to_send->fineTime;
664 ring_node_cwf3_light->fineTime = ring_node_to_send->fineTime;
830
665
831 //**********************
666 //**********************
832 // BUILD CWF3_light DATA
667 // BUILD CWF3_light DATA
833 for ( i=0; i< NB_SAMPLES_PER_SNAPSHOT; i++)
668 for ( i=0; i< NB_SAMPLES_PER_SNAPSHOT; i++)
834 {
669 {
835 sample = (char*) &dataPtr[ (i * NB_WORDS_SWF_BLK) ];
670 sample = (char*) &dataPtr[ (i * NB_WORDS_SWF_BLK) ];
836 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) ] = sample[ 0 ];
671 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) ] = sample[ 0 ];
837 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 1 ] = sample[ 1 ];
672 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 1 ] = sample[ 1 ];
838 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 2 ] = sample[ 2 ];
673 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 2 ] = sample[ 2 ];
839 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 3 ] = sample[ 3 ];
674 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 3 ] = sample[ 3 ];
840 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 4 ] = sample[ 4 ];
675 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 4 ] = sample[ 4 ];
841 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 5 ] = sample[ 5 ];
676 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 5 ] = sample[ 5 ];
842 }
677 }
843
678
844 // SEND PACKET
679 // SEND PACKET
845 status = rtems_message_queue_send( queue_id, &ring_node_cwf3_light, sizeof( ring_node* ) );
680 status = rtems_message_queue_send( queue_id, &ring_node_cwf3_light, sizeof( ring_node* ) );
846 if (status != RTEMS_SUCCESSFUL) {
681 if (status != RTEMS_SUCCESSFUL) {
847 ret = LFR_DEFAULT;
682 ret = LFR_DEFAULT;
848 }
683 }
849
684
850 return ret;
685 return ret;
851 }
686 }
852
687
853 void compute_acquisition_time( unsigned int coarseTime, unsigned int fineTime,
688 void compute_acquisition_time( unsigned int coarseTime, unsigned int fineTime,
854 unsigned int sid, unsigned char pa_lfr_pkt_nr, unsigned char * acquisitionTime )
689 unsigned int sid, unsigned char pa_lfr_pkt_nr, unsigned char * acquisitionTime )
855 {
690 {
856 unsigned long long int acquisitionTimeAsLong;
691 unsigned long long int acquisitionTimeAsLong;
857 unsigned char localAcquisitionTime[6];
692 unsigned char localAcquisitionTime[6];
858 double deltaT;
693 double deltaT;
859
694
860 deltaT = 0.;
695 deltaT = 0.;
861
696
862 localAcquisitionTime[0] = (unsigned char) ( coarseTime >> 24 );
697 localAcquisitionTime[0] = (unsigned char) ( coarseTime >> 24 );
863 localAcquisitionTime[1] = (unsigned char) ( coarseTime >> 16 );
698 localAcquisitionTime[1] = (unsigned char) ( coarseTime >> 16 );
864 localAcquisitionTime[2] = (unsigned char) ( coarseTime >> 8 );
699 localAcquisitionTime[2] = (unsigned char) ( coarseTime >> 8 );
865 localAcquisitionTime[3] = (unsigned char) ( coarseTime );
700 localAcquisitionTime[3] = (unsigned char) ( coarseTime );
866 localAcquisitionTime[4] = (unsigned char) ( fineTime >> 8 );
701 localAcquisitionTime[4] = (unsigned char) ( fineTime >> 8 );
867 localAcquisitionTime[5] = (unsigned char) ( fineTime );
702 localAcquisitionTime[5] = (unsigned char) ( fineTime );
868
703
869 acquisitionTimeAsLong = ( (unsigned long long int) localAcquisitionTime[0] << 40 )
704 acquisitionTimeAsLong = ( (unsigned long long int) localAcquisitionTime[0] << 40 )
870 + ( (unsigned long long int) localAcquisitionTime[1] << 32 )
705 + ( (unsigned long long int) localAcquisitionTime[1] << 32 )
871 + ( (unsigned long long int) localAcquisitionTime[2] << 24 )
706 + ( (unsigned long long int) localAcquisitionTime[2] << 24 )
872 + ( (unsigned long long int) localAcquisitionTime[3] << 16 )
707 + ( (unsigned long long int) localAcquisitionTime[3] << 16 )
873 + ( (unsigned long long int) localAcquisitionTime[4] << 8 )
708 + ( (unsigned long long int) localAcquisitionTime[4] << 8 )
874 + ( (unsigned long long int) localAcquisitionTime[5] );
709 + ( (unsigned long long int) localAcquisitionTime[5] );
875
710
876 switch( sid )
711 switch( sid )
877 {
712 {
878 case SID_NORM_SWF_F0:
713 case SID_NORM_SWF_F0:
879 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_304 * 65536. / 24576. ;
714 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_304 * 65536. / 24576. ;
880 break;
715 break;
881
716
882 case SID_NORM_SWF_F1:
717 case SID_NORM_SWF_F1:
883 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_304 * 65536. / 4096. ;
718 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_304 * 65536. / 4096. ;
884 break;
719 break;
885
720
886 case SID_NORM_SWF_F2:
721 case SID_NORM_SWF_F2:
887 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_304 * 65536. / 256. ;
722 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_304 * 65536. / 256. ;
888 break;
723 break;
889
724
890 case SID_SBM1_CWF_F1:
725 case SID_SBM1_CWF_F1:
891 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * 65536. / 4096. ;
726 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * 65536. / 4096. ;
892 break;
727 break;
893
728
894 case SID_SBM2_CWF_F2:
729 case SID_SBM2_CWF_F2:
895 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * 65536. / 256. ;
730 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * 65536. / 256. ;
896 break;
731 break;
897
732
898 case SID_BURST_CWF_F2:
733 case SID_BURST_CWF_F2:
899 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * 65536. / 256. ;
734 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * 65536. / 256. ;
900 break;
735 break;
901
736
902 case SID_NORM_CWF_F3:
737 case SID_NORM_CWF_F3:
903 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF_SHORT_F3 * 65536. / 16. ;
738 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF_SHORT_F3 * 65536. / 16. ;
904 break;
739 break;
905
740
906 case SID_NORM_CWF_LONG_F3:
741 case SID_NORM_CWF_LONG_F3:
907 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * 65536. / 16. ;
742 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * 65536. / 16. ;
908 break;
743 break;
909
744
910 default:
745 default:
911 PRINTF1("in compute_acquisition_time *** ERR unexpected sid %d\n", sid)
746 PRINTF1("in compute_acquisition_time *** ERR unexpected sid %d\n", sid)
912 deltaT = 0.;
747 deltaT = 0.;
913 break;
748 break;
914 }
749 }
915
750
916 acquisitionTimeAsLong = acquisitionTimeAsLong + (unsigned long long int) deltaT;
751 acquisitionTimeAsLong = acquisitionTimeAsLong + (unsigned long long int) deltaT;
917 //
752 //
918 acquisitionTime[0] = (unsigned char) (acquisitionTimeAsLong >> 40);
753 acquisitionTime[0] = (unsigned char) (acquisitionTimeAsLong >> 40);
919 acquisitionTime[1] = (unsigned char) (acquisitionTimeAsLong >> 32);
754 acquisitionTime[1] = (unsigned char) (acquisitionTimeAsLong >> 32);
920 acquisitionTime[2] = (unsigned char) (acquisitionTimeAsLong >> 24);
755 acquisitionTime[2] = (unsigned char) (acquisitionTimeAsLong >> 24);
921 acquisitionTime[3] = (unsigned char) (acquisitionTimeAsLong >> 16);
756 acquisitionTime[3] = (unsigned char) (acquisitionTimeAsLong >> 16);
922 acquisitionTime[4] = (unsigned char) (acquisitionTimeAsLong >> 8 );
757 acquisitionTime[4] = (unsigned char) (acquisitionTimeAsLong >> 8 );
923 acquisitionTime[5] = (unsigned char) (acquisitionTimeAsLong );
758 acquisitionTime[5] = (unsigned char) (acquisitionTimeAsLong );
924
759
925 }
760 }
926
761
927 void build_snapshot_from_ring( ring_node *ring_node_to_send, unsigned char frequencyChannel, unsigned long long int acquisitionTimeF0_asLong )
762 void build_snapshot_from_ring( ring_node *ring_node_to_send,
763 unsigned char frequencyChannel,
764 unsigned long long int acquisitionTimeF0_asLong,
765 ring_node *ring_node_swf_extracted,
766 int *swf_extracted)
928 {
767 {
929 unsigned int i;
768 unsigned int i;
930 unsigned long long int centerTime_asLong;
769 unsigned long long int centerTime_asLong;
931 unsigned long long int acquisitionTime_asLong;
770 unsigned long long int acquisitionTime_asLong;
932 unsigned long long int bufferAcquisitionTime_asLong;
771 unsigned long long int bufferAcquisitionTime_asLong;
933 unsigned char *ptr1;
772 unsigned char *ptr1;
934 unsigned char *ptr2;
773 unsigned char *ptr2;
935 unsigned char *timeCharPtr;
774 unsigned char *timeCharPtr;
936 unsigned char nb_ring_nodes;
775 unsigned char nb_ring_nodes;
937 unsigned long long int frequency_asLong;
776 unsigned long long int frequency_asLong;
938 unsigned long long int nbTicksPerSample_asLong;
777 unsigned long long int nbTicksPerSample_asLong;
939 unsigned long long int nbSamplesPart1_asLong;
778 unsigned long long int nbSamplesPart1_asLong;
940 unsigned long long int sampleOffset_asLong;
779 unsigned long long int sampleOffset_asLong;
941
780
942 unsigned int deltaT_F0;
781 unsigned int deltaT_F0;
943 unsigned int deltaT_F1;
782 unsigned int deltaT_F1;
944 unsigned long long int deltaT_F2;
783 unsigned long long int deltaT_F2;
945
784
946 deltaT_F0 = 2731; // (2048. / 24576. / 2.) * 65536. = 2730.667;
785 deltaT_F0 = 2731; // (2048. / 24576. / 2.) * 65536. = 2730.667;
947 deltaT_F1 = 16384; // (2048. / 4096. / 2.) * 65536. = 16384;
786 deltaT_F1 = 16384; // (2048. / 4096. / 2.) * 65536. = 16384;
948 deltaT_F2 = 262144; // (2048. / 256. / 2.) * 65536. = 262144;
787 deltaT_F2 = 262144; // (2048. / 256. / 2.) * 65536. = 262144;
949 sampleOffset_asLong = 0x00;
788 sampleOffset_asLong = 0x00;
950
789
951 // (1) get the f0 acquisition time => the value is passed in argument
790 // (1) get the f0 acquisition time => the value is passed in argument
952
791
953 // (2) compute the central reference time
792 // (2) compute the central reference time
954 centerTime_asLong = acquisitionTimeF0_asLong + deltaT_F0;
793 centerTime_asLong = acquisitionTimeF0_asLong + deltaT_F0;
955
794
956 // (3) compute the acquisition time of the current snapshot
795 // (3) compute the acquisition time of the current snapshot
957 switch(frequencyChannel)
796 switch(frequencyChannel)
958 {
797 {
959 case 1: // 1 is for F1 = 4096 Hz
798 case 1: // 1 is for F1 = 4096 Hz
960 acquisitionTime_asLong = centerTime_asLong - deltaT_F1;
799 acquisitionTime_asLong = centerTime_asLong - deltaT_F1;
961 nb_ring_nodes = NB_RING_NODES_F1;
800 nb_ring_nodes = NB_RING_NODES_F1;
962 frequency_asLong = 4096;
801 frequency_asLong = 4096;
963 nbTicksPerSample_asLong = 16; // 65536 / 4096;
802 nbTicksPerSample_asLong = 16; // 65536 / 4096;
964 break;
803 break;
965 case 2: // 2 is for F2 = 256 Hz
804 case 2: // 2 is for F2 = 256 Hz
966 acquisitionTime_asLong = centerTime_asLong - deltaT_F2;
805 acquisitionTime_asLong = centerTime_asLong - deltaT_F2;
967 nb_ring_nodes = NB_RING_NODES_F2;
806 nb_ring_nodes = NB_RING_NODES_F2;
968 frequency_asLong = 256;
807 frequency_asLong = 256;
969 nbTicksPerSample_asLong = 256; // 65536 / 256;
808 nbTicksPerSample_asLong = 256; // 65536 / 256;
970 break;
809 break;
971 default:
810 default:
972 acquisitionTime_asLong = centerTime_asLong;
811 acquisitionTime_asLong = centerTime_asLong;
973 frequency_asLong = 256;
812 frequency_asLong = 256;
974 nbTicksPerSample_asLong = 256;
813 nbTicksPerSample_asLong = 256;
975 break;
814 break;
976 }
815 }
977
816
978 //****************************************************************************
817 //****************************************************************************
979 // (4) search the ring_node with the acquisition time <= acquisitionTime_asLong
818 // (4) search the ring_node with the acquisition time <= acquisitionTime_asLong
980 for (i=0; i<nb_ring_nodes; i++)
819 for (i=0; i<nb_ring_nodes; i++)
981 {
820 {
982 PRINTF1("%d ... ", i)
821 PRINTF1("%d ... ", i)
983 bufferAcquisitionTime_asLong = get_acquisition_time( (unsigned char *) &ring_node_to_send->coarseTime );
822 bufferAcquisitionTime_asLong = get_acquisition_time( (unsigned char *) &ring_node_to_send->coarseTime );
984 if (bufferAcquisitionTime_asLong <= acquisitionTime_asLong)
823 if (bufferAcquisitionTime_asLong <= acquisitionTime_asLong)
985 {
824 {
986 PRINTF1("buffer found with acquisition time = %llx\n", bufferAcquisitionTime_asLong)
825 PRINTF1("buffer found with acquisition time = %llx\n", bufferAcquisitionTime_asLong)
987 break;
826 break;
988 }
827 }
989 ring_node_to_send = ring_node_to_send->previous;
828 ring_node_to_send = ring_node_to_send->previous;
990 }
829 }
991
830
992 // (5) compute the number of samples to take in the current buffer
831 // (5) compute the number of samples to take in the current buffer
993 sampleOffset_asLong = ((acquisitionTime_asLong - bufferAcquisitionTime_asLong) * frequency_asLong ) >> 16;
832 sampleOffset_asLong = ((acquisitionTime_asLong - bufferAcquisitionTime_asLong) * frequency_asLong ) >> 16;
994 nbSamplesPart1_asLong = NB_SAMPLES_PER_SNAPSHOT - sampleOffset_asLong;
833 nbSamplesPart1_asLong = NB_SAMPLES_PER_SNAPSHOT - sampleOffset_asLong;
995 PRINTF2("sampleOffset_asLong = %lld, nbSamplesPart1_asLong = %lld\n", sampleOffset_asLong, nbSamplesPart1_asLong)
834 PRINTF2("sampleOffset_asLong = %lld, nbSamplesPart1_asLong = %lld\n", sampleOffset_asLong, nbSamplesPart1_asLong)
996
835
997 // (6) compute the final acquisition time
836 // (6) compute the final acquisition time
998 acquisitionTime_asLong = bufferAcquisitionTime_asLong +
837 acquisitionTime_asLong = bufferAcquisitionTime_asLong +
999 sampleOffset_asLong * nbTicksPerSample_asLong;
838 sampleOffset_asLong * nbTicksPerSample_asLong;
1000
839
1001 // (7) copy the acquisition time at the beginning of the extrated snapshot
840 // (7) copy the acquisition time at the beginning of the extrated snapshot
1002 ptr1 = (unsigned char*) &acquisitionTime_asLong;
841 ptr1 = (unsigned char*) &acquisitionTime_asLong;
1003 // fine time
842 // fine time
1004 ptr2 = (unsigned char*) &ring_node_wf_snap_extracted.fineTime;
843 ptr2 = (unsigned char*) &ring_node_swf_extracted->fineTime;
1005 ptr2[2] = ptr1[ 4 + 2 ];
844 ptr2[2] = ptr1[ 4 + 2 ];
1006 ptr2[3] = ptr1[ 5 + 2 ];
845 ptr2[3] = ptr1[ 5 + 2 ];
1007 // coarse time
846 // coarse time
1008 ptr2 = (unsigned char*) &ring_node_wf_snap_extracted.coarseTime;
847 ptr2 = (unsigned char*) &ring_node_swf_extracted->coarseTime;
1009 ptr2[0] = ptr1[ 0 + 2 ];
848 ptr2[0] = ptr1[ 0 + 2 ];
1010 ptr2[1] = ptr1[ 1 + 2 ];
849 ptr2[1] = ptr1[ 1 + 2 ];
1011 ptr2[2] = ptr1[ 2 + 2 ];
850 ptr2[2] = ptr1[ 2 + 2 ];
1012 ptr2[3] = ptr1[ 3 + 2 ];
851 ptr2[3] = ptr1[ 3 + 2 ];
1013
852
1014 // re set the synchronization bit
853 // re set the synchronization bit
1015 timeCharPtr = (unsigned char*) &ring_node_to_send->coarseTime;
854 timeCharPtr = (unsigned char*) &ring_node_to_send->coarseTime;
1016 ptr2[0] = ptr2[0] | (timeCharPtr[0] & 0x80); // [1000 0000]
855 ptr2[0] = ptr2[0] | (timeCharPtr[0] & 0x80); // [1000 0000]
1017
856
1018 if ( (nbSamplesPart1_asLong >= NB_SAMPLES_PER_SNAPSHOT) | (nbSamplesPart1_asLong < 0) )
857 if ( (nbSamplesPart1_asLong >= NB_SAMPLES_PER_SNAPSHOT) | (nbSamplesPart1_asLong < 0) )
1019 {
858 {
1020 nbSamplesPart1_asLong = 0;
859 nbSamplesPart1_asLong = 0;
1021 }
860 }
1022 // copy the part 1 of the snapshot in the extracted buffer
861 // copy the part 1 of the snapshot in the extracted buffer
1023 for ( i = 0; i < (nbSamplesPart1_asLong * NB_WORDS_SWF_BLK); i++ )
862 for ( i = 0; i < (nbSamplesPart1_asLong * NB_WORDS_SWF_BLK); i++ )
1024 {
863 {
1025 wf_snap_extracted[i] =
864 swf_extracted[i] =
1026 ((int*) ring_node_to_send->buffer_address)[ i + (sampleOffset_asLong * NB_WORDS_SWF_BLK) ];
865 ((int*) ring_node_to_send->buffer_address)[ i + (sampleOffset_asLong * NB_WORDS_SWF_BLK) ];
1027 }
866 }
1028 // copy the part 2 of the snapshot in the extracted buffer
867 // copy the part 2 of the snapshot in the extracted buffer
1029 ring_node_to_send = ring_node_to_send->next;
868 ring_node_to_send = ring_node_to_send->next;
1030 for ( i = (nbSamplesPart1_asLong * NB_WORDS_SWF_BLK); i < (NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK); i++ )
869 for ( i = (nbSamplesPart1_asLong * NB_WORDS_SWF_BLK); i < (NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK); i++ )
1031 {
870 {
1032 wf_snap_extracted[i] =
871 swf_extracted[i] =
1033 ((int*) ring_node_to_send->buffer_address)[ (i-(nbSamplesPart1_asLong * NB_WORDS_SWF_BLK)) ];
872 ((int*) ring_node_to_send->buffer_address)[ (i-(nbSamplesPart1_asLong * NB_WORDS_SWF_BLK)) ];
1034 }
873 }
1035 }
874 }
1036
875
1037 void snapshot_resynchronization( unsigned char *timePtr )
876 void snapshot_resynchronization( unsigned char *timePtr )
1038 {
877 {
1039 unsigned long long int acquisitionTime;
878 unsigned long long int acquisitionTime;
1040 unsigned long long int centerTime;
879 unsigned long long int centerTime;
1041 unsigned long long int previousTick;
880 unsigned long long int previousTick;
1042 unsigned long long int nextTick;
881 unsigned long long int nextTick;
1043 unsigned long long int deltaPreviousTick;
882 unsigned long long int deltaPreviousTick;
1044 unsigned long long int deltaNextTick;
883 unsigned long long int deltaNextTick;
1045 unsigned int deltaTickInF2;
884 unsigned int deltaTickInF2;
1046 double deltaPrevious;
885 double deltaPrevious;
1047 double deltaNext;
886 double deltaNext;
1048
887
1049 acquisitionTime = get_acquisition_time( timePtr );
888 acquisitionTime = get_acquisition_time( timePtr );
1050
889
1051 // compute center time
890 // compute center time
1052 centerTime = acquisitionTime + 2731; // (2048. / 24576. / 2.) * 65536. = 2730.667;
891 centerTime = acquisitionTime + 2731; // (2048. / 24576. / 2.) * 65536. = 2730.667;
1053 previousTick = centerTime - (centerTime & 0xffff);
892 previousTick = centerTime - (centerTime & 0xffff);
1054 nextTick = previousTick + 65536;
893 nextTick = previousTick + 65536;
1055
894
1056 deltaPreviousTick = centerTime - previousTick;
895 deltaPreviousTick = centerTime - previousTick;
1057 deltaNextTick = nextTick - centerTime;
896 deltaNextTick = nextTick - centerTime;
1058
897
1059 deltaPrevious = ((double) deltaPreviousTick) / 65536. * 1000.;
898 deltaPrevious = ((double) deltaPreviousTick) / 65536. * 1000.;
1060 deltaNext = ((double) deltaNextTick) / 65536. * 1000.;
899 deltaNext = ((double) deltaNextTick) / 65536. * 1000.;
1061
900
1062 PRINTF2("delta previous = %f ms, delta next = %f ms\n", deltaPrevious, deltaNext)
901 PRINTF2("delta previous = %f ms, delta next = %f ms\n", deltaPrevious, deltaNext)
1063 PRINTF2("delta previous = %llu, delta next = %llu\n", deltaPreviousTick, deltaNextTick)
902 PRINTF2("delta previous = %llu, delta next = %llu\n", deltaPreviousTick, deltaNextTick)
1064
903
1065 // which tick is the closest
904 // which tick is the closest
1066 if (deltaPreviousTick > deltaNextTick)
905 if (deltaPreviousTick > deltaNextTick)
1067 {
906 {
1068 deltaTickInF2 = floor( (deltaNext * 256. / 1000.) ); // the division by 2 is important here
907 deltaTickInF2 = floor( (deltaNext * 256. / 1000.) ); // the division by 2 is important here
1069 waveform_picker_regs->delta_snapshot = waveform_picker_regs->delta_snapshot + deltaTickInF2;
908 waveform_picker_regs->delta_snapshot = waveform_picker_regs->delta_snapshot + deltaTickInF2;
1070 PRINTF1("correction of = + %u\n", deltaTickInF2)
909 PRINTF1("correction of = + %u\n", deltaTickInF2)
1071 }
910 }
1072 else
911 else
1073 {
912 {
1074 deltaTickInF2 = floor( (deltaPrevious * 256. / 1000.) ); // the division by 2 is important here
913 deltaTickInF2 = floor( (deltaPrevious * 256. / 1000.) ); // the division by 2 is important here
1075 waveform_picker_regs->delta_snapshot = waveform_picker_regs->delta_snapshot - deltaTickInF2;
914 waveform_picker_regs->delta_snapshot = waveform_picker_regs->delta_snapshot - deltaTickInF2;
1076 PRINTF1("correction of = - %u\n", deltaTickInF2)
915 PRINTF1("correction of = - %u\n", deltaTickInF2)
1077 }
916 }
1078 }
917 }
1079
918
1080 //**************
919 //**************
1081 // wfp registers
920 // wfp registers
1082 void reset_wfp_burst_enable( void )
921 void reset_wfp_burst_enable( void )
1083 {
922 {
1084 /** This function resets the waveform picker burst_enable register.
923 /** This function resets the waveform picker burst_enable register.
1085 *
924 *
1086 * The burst bits [f2 f1 f0] and the enable bits [f3 f2 f1 f0] are set to 0.
925 * The burst bits [f2 f1 f0] and the enable bits [f3 f2 f1 f0] are set to 0.
1087 *
926 *
1088 */
927 */
1089
928
1090 // [1000 000] burst f2, f1, f0 enable f3, f2, f1, f0
929 // [1000 000] burst f2, f1, f0 enable f3, f2, f1, f0
1091 waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable & 0x80;
930 waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable & 0x80;
1092 }
931 }
1093
932
1094 void reset_wfp_status( void )
933 void reset_wfp_status( void )
1095 {
934 {
1096 /** This function resets the waveform picker status register.
935 /** This function resets the waveform picker status register.
1097 *
936 *
1098 * All status bits are set to 0 [new_err full_err full].
937 * All status bits are set to 0 [new_err full_err full].
1099 *
938 *
1100 */
939 */
1101
940
1102 waveform_picker_regs->status = 0xffff;
941 waveform_picker_regs->status = 0xffff;
1103 }
942 }
1104
943
1105 void reset_wfp_buffer_addresses( void )
944 void reset_wfp_buffer_addresses( void )
1106 {
945 {
1107 // F0
946 // F0
1108 waveform_picker_regs->addr_data_f0_0 = current_ring_node_f0->previous->buffer_address; // 0x08
947 waveform_picker_regs->addr_data_f0_0 = current_ring_node_f0->previous->buffer_address; // 0x08
1109 waveform_picker_regs->addr_data_f0_1 = current_ring_node_f0->buffer_address; // 0x0c
948 waveform_picker_regs->addr_data_f0_1 = current_ring_node_f0->buffer_address; // 0x0c
1110 // F1
949 // F1
1111 waveform_picker_regs->addr_data_f1_0 = current_ring_node_f1->previous->buffer_address; // 0x10
950 waveform_picker_regs->addr_data_f1_0 = current_ring_node_f1->previous->buffer_address; // 0x10
1112 waveform_picker_regs->addr_data_f1_1 = current_ring_node_f1->buffer_address; // 0x14
951 waveform_picker_regs->addr_data_f1_1 = current_ring_node_f1->buffer_address; // 0x14
1113 // F2
952 // F2
1114 waveform_picker_regs->addr_data_f2_0 = current_ring_node_f2->previous->buffer_address; // 0x18
953 waveform_picker_regs->addr_data_f2_0 = current_ring_node_f2->previous->buffer_address; // 0x18
1115 waveform_picker_regs->addr_data_f2_1 = current_ring_node_f2->buffer_address; // 0x1c
954 waveform_picker_regs->addr_data_f2_1 = current_ring_node_f2->buffer_address; // 0x1c
1116 // F3
955 // F3
1117 waveform_picker_regs->addr_data_f3_0 = current_ring_node_f3->previous->buffer_address; // 0x20
956 waveform_picker_regs->addr_data_f3_0 = current_ring_node_f3->previous->buffer_address; // 0x20
1118 waveform_picker_regs->addr_data_f3_1 = current_ring_node_f3->buffer_address; // 0x24
957 waveform_picker_regs->addr_data_f3_1 = current_ring_node_f3->buffer_address; // 0x24
1119 }
958 }
1120
959
1121 void reset_waveform_picker_regs( void )
960 void reset_waveform_picker_regs( void )
1122 {
961 {
1123 /** This function resets the waveform picker module registers.
962 /** This function resets the waveform picker module registers.
1124 *
963 *
1125 * The registers affected by this function are located at the following offset addresses:
964 * The registers affected by this function are located at the following offset addresses:
1126 * - 0x00 data_shaping
965 * - 0x00 data_shaping
1127 * - 0x04 run_burst_enable
966 * - 0x04 run_burst_enable
1128 * - 0x08 addr_data_f0
967 * - 0x08 addr_data_f0
1129 * - 0x0C addr_data_f1
968 * - 0x0C addr_data_f1
1130 * - 0x10 addr_data_f2
969 * - 0x10 addr_data_f2
1131 * - 0x14 addr_data_f3
970 * - 0x14 addr_data_f3
1132 * - 0x18 status
971 * - 0x18 status
1133 * - 0x1C delta_snapshot
972 * - 0x1C delta_snapshot
1134 * - 0x20 delta_f0
973 * - 0x20 delta_f0
1135 * - 0x24 delta_f0_2
974 * - 0x24 delta_f0_2
1136 * - 0x28 delta_f1
975 * - 0x28 delta_f1
1137 * - 0x2c delta_f2
976 * - 0x2c delta_f2
1138 * - 0x30 nb_data_by_buffer
977 * - 0x30 nb_data_by_buffer
1139 * - 0x34 nb_snapshot_param
978 * - 0x34 nb_snapshot_param
1140 * - 0x38 start_date
979 * - 0x38 start_date
1141 * - 0x3c nb_word_in_buffer
980 * - 0x3c nb_word_in_buffer
1142 *
981 *
1143 */
982 */
1144
983
1145 set_wfp_data_shaping(); // 0x00 *** R1 R0 SP1 SP0 BW
984 set_wfp_data_shaping(); // 0x00 *** R1 R0 SP1 SP0 BW
1146
985
1147 reset_wfp_burst_enable(); // 0x04 *** [run *** burst f2, f1, f0 *** enable f3, f2, f1, f0 ]
986 reset_wfp_burst_enable(); // 0x04 *** [run *** burst f2, f1, f0 *** enable f3, f2, f1, f0 ]
1148
987
1149 reset_wfp_buffer_addresses();
988 reset_wfp_buffer_addresses();
1150
989
1151 reset_wfp_status(); // 0x18
990 reset_wfp_status(); // 0x18
1152
991
1153 set_wfp_delta_snapshot(); // 0x1c *** 300 s => 0x12bff
992 set_wfp_delta_snapshot(); // 0x1c *** 300 s => 0x12bff
1154
993
1155 set_wfp_delta_f0_f0_2(); // 0x20, 0x24
994 set_wfp_delta_f0_f0_2(); // 0x20, 0x24
1156
995
1157 set_wfp_delta_f1(); // 0x28
996 set_wfp_delta_f1(); // 0x28
1158
997
1159 set_wfp_delta_f2(); // 0x2c
998 set_wfp_delta_f2(); // 0x2c
1160
999
1161 DEBUG_PRINTF1("delta_snapshot %x\n", waveform_picker_regs->delta_snapshot)
1000 DEBUG_PRINTF1("delta_snapshot %x\n", waveform_picker_regs->delta_snapshot)
1162 DEBUG_PRINTF1("delta_f0 %x\n", waveform_picker_regs->delta_f0)
1001 DEBUG_PRINTF1("delta_f0 %x\n", waveform_picker_regs->delta_f0)
1163 DEBUG_PRINTF1("delta_f0_2 %x\n", waveform_picker_regs->delta_f0_2)
1002 DEBUG_PRINTF1("delta_f0_2 %x\n", waveform_picker_regs->delta_f0_2)
1164 DEBUG_PRINTF1("delta_f1 %x\n", waveform_picker_regs->delta_f1)
1003 DEBUG_PRINTF1("delta_f1 %x\n", waveform_picker_regs->delta_f1)
1165 DEBUG_PRINTF1("delta_f2 %x\n", waveform_picker_regs->delta_f2)
1004 DEBUG_PRINTF1("delta_f2 %x\n", waveform_picker_regs->delta_f2)
1166 // 2688 = 8 * 336
1005 // 2688 = 8 * 336
1167 waveform_picker_regs->nb_data_by_buffer = 0xa7f; // 0x30 *** 2688 - 1 => nb samples -1
1006 waveform_picker_regs->nb_data_by_buffer = 0xa7f; // 0x30 *** 2688 - 1 => nb samples -1
1168 waveform_picker_regs->snapshot_param = 0xa80; // 0x34 *** 2688 => nb samples
1007 waveform_picker_regs->snapshot_param = 0xa80; // 0x34 *** 2688 => nb samples
1169 waveform_picker_regs->start_date = 0x7fffffff; // 0x38
1008 waveform_picker_regs->start_date = 0x7fffffff; // 0x38
1170 //
1009 //
1171 // coarse time and fine time registers are not initialized, they are volatile
1010 // coarse time and fine time registers are not initialized, they are volatile
1172 //
1011 //
1173 waveform_picker_regs->buffer_length = 0x1f8;// buffer length in burst = 3 * 2688 / 16 = 504 = 0x1f8
1012 waveform_picker_regs->buffer_length = 0x1f8;// buffer length in burst = 3 * 2688 / 16 = 504 = 0x1f8
1174 }
1013 }
1175
1014
1176 void set_wfp_data_shaping( void )
1015 void set_wfp_data_shaping( void )
1177 {
1016 {
1178 /** This function sets the data_shaping register of the waveform picker module.
1017 /** This function sets the data_shaping register of the waveform picker module.
1179 *
1018 *
1180 * The value is read from one field of the parameter_dump_packet structure:\n
1019 * The value is read from one field of the parameter_dump_packet structure:\n
1181 * bw_sp0_sp1_r0_r1
1020 * bw_sp0_sp1_r0_r1
1182 *
1021 *
1183 */
1022 */
1184
1023
1185 unsigned char data_shaping;
1024 unsigned char data_shaping;
1186
1025
1187 // get the parameters for the data shaping [BW SP0 SP1 R0 R1] in sy_lfr_common1 and configure the register
1026 // get the parameters for the data shaping [BW SP0 SP1 R0 R1] in sy_lfr_common1 and configure the register
1188 // waveform picker : [R1 R0 SP1 SP0 BW]
1027 // waveform picker : [R1 R0 SP1 SP0 BW]
1189
1028
1190 data_shaping = parameter_dump_packet.sy_lfr_common_parameters;
1029 data_shaping = parameter_dump_packet.sy_lfr_common_parameters;
1191
1030
1192 waveform_picker_regs->data_shaping =
1031 waveform_picker_regs->data_shaping =
1193 ( (data_shaping & 0x20) >> 5 ) // BW
1032 ( (data_shaping & 0x20) >> 5 ) // BW
1194 + ( (data_shaping & 0x10) >> 3 ) // SP0
1033 + ( (data_shaping & 0x10) >> 3 ) // SP0
1195 + ( (data_shaping & 0x08) >> 1 ) // SP1
1034 + ( (data_shaping & 0x08) >> 1 ) // SP1
1196 + ( (data_shaping & 0x04) << 1 ) // R0
1035 + ( (data_shaping & 0x04) << 1 ) // R0
1197 + ( (data_shaping & 0x02) << 3 ) // R1
1036 + ( (data_shaping & 0x02) << 3 ) // R1
1198 + ( (data_shaping & 0x01) << 5 ); // R2
1037 + ( (data_shaping & 0x01) << 5 ); // R2
1199 }
1038 }
1200
1039
1201 void set_wfp_burst_enable_register( unsigned char mode )
1040 void set_wfp_burst_enable_register( unsigned char mode )
1202 {
1041 {
1203 /** This function sets the waveform picker burst_enable register depending on the mode.
1042 /** This function sets the waveform picker burst_enable register depending on the mode.
1204 *
1043 *
1205 * @param mode is the LFR mode to launch.
1044 * @param mode is the LFR mode to launch.
1206 *
1045 *
1207 * The burst bits shall be before the enable bits.
1046 * The burst bits shall be before the enable bits.
1208 *
1047 *
1209 */
1048 */
1210
1049
1211 // [0000 0000] burst f2, f1, f0 enable f3 f2 f1 f0
1050 // [0000 0000] burst f2, f1, f0 enable f3 f2 f1 f0
1212 // the burst bits shall be set first, before the enable bits
1051 // the burst bits shall be set first, before the enable bits
1213 switch(mode) {
1052 switch(mode) {
1214 case(LFR_MODE_NORMAL):
1053 case LFR_MODE_NORMAL:
1215 waveform_picker_regs->run_burst_enable = 0x60; // [0110 0000] enable f2 AND f1 burst
1054 case LFR_MODE_SBM1:
1216 waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | 0x0c; // [1111] enable f3 f2 f1 f0
1055 case LFR_MODE_SBM2:
1217 break;
1056 waveform_picker_regs->run_burst_enable = 0x60; // [0110 0000] enable f2 and f1 burst
1218 case(LFR_MODE_BURST):
1057 waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | 0x0f; // [1111] enable f3 f2 f1 f0
1219 waveform_picker_regs->run_burst_enable = 0x40; // [0100 0000] f2 burst enabled
1220 waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | 0x0c; // [1100] enable f3 AND f2
1221 break;
1058 break;
1222 case(LFR_MODE_SBM1):
1059 case LFR_MODE_BURST:
1223 waveform_picker_regs->run_burst_enable = 0x20; // [0010 0000] f1 burst enabled
1224 waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | 0x0f; // [1111] enable f3 f2 f1 f0
1225 break;
1226 case(LFR_MODE_SBM2):
1227 waveform_picker_regs->run_burst_enable = 0x40; // [0100 0000] f2 burst enabled
1060 waveform_picker_regs->run_burst_enable = 0x40; // [0100 0000] f2 burst enabled
1228 waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | 0x0f; // [1111] enable f3 f2 f1 f0
1061 waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | 0x0c; // [1100] enable f3 and f2
1229 break;
1062 break;
1230 default:
1063 default:
1231 waveform_picker_regs->run_burst_enable = 0x00; // [0000 0000] no burst enabled, no waveform enabled
1064 waveform_picker_regs->run_burst_enable = 0x00; // [0000 0000] no burst enabled, no waveform enabled
1232 break;
1065 break;
1233 }
1066 }
1234 }
1067 }
1235
1068
1236 void set_wfp_delta_snapshot( void )
1069 void set_wfp_delta_snapshot( void )
1237 {
1070 {
1238 /** This function sets the delta_snapshot register of the waveform picker module.
1071 /** This function sets the delta_snapshot register of the waveform picker module.
1239 *
1072 *
1240 * The value is read from two (unsigned char) of the parameter_dump_packet structure:
1073 * The value is read from two (unsigned char) of the parameter_dump_packet structure:
1241 * - sy_lfr_n_swf_p[0]
1074 * - sy_lfr_n_swf_p[0]
1242 * - sy_lfr_n_swf_p[1]
1075 * - sy_lfr_n_swf_p[1]
1243 *
1076 *
1244 */
1077 */
1245
1078
1246 unsigned int delta_snapshot;
1079 unsigned int delta_snapshot;
1247 unsigned int delta_snapshot_in_T2;
1080 unsigned int delta_snapshot_in_T2;
1248
1081
1249 delta_snapshot = parameter_dump_packet.sy_lfr_n_swf_p[0]*256
1082 delta_snapshot = parameter_dump_packet.sy_lfr_n_swf_p[0]*256
1250 + parameter_dump_packet.sy_lfr_n_swf_p[1];
1083 + parameter_dump_packet.sy_lfr_n_swf_p[1];
1251
1084
1252 delta_snapshot_in_T2 = delta_snapshot * 256;
1085 delta_snapshot_in_T2 = delta_snapshot * 256;
1253 waveform_picker_regs->delta_snapshot = delta_snapshot_in_T2 - 1; // max 4 bytes
1086 waveform_picker_regs->delta_snapshot = delta_snapshot_in_T2 - 1; // max 4 bytes
1254 }
1087 }
1255
1088
1256 void set_wfp_delta_f0_f0_2( void )
1089 void set_wfp_delta_f0_f0_2( void )
1257 {
1090 {
1258 unsigned int delta_snapshot;
1091 unsigned int delta_snapshot;
1259 unsigned int nb_samples_per_snapshot;
1092 unsigned int nb_samples_per_snapshot;
1260 float delta_f0_in_float;
1093 float delta_f0_in_float;
1261
1094
1262 delta_snapshot = waveform_picker_regs->delta_snapshot;
1095 delta_snapshot = waveform_picker_regs->delta_snapshot;
1263 nb_samples_per_snapshot = parameter_dump_packet.sy_lfr_n_swf_l[0] * 256 + parameter_dump_packet.sy_lfr_n_swf_l[1];
1096 nb_samples_per_snapshot = parameter_dump_packet.sy_lfr_n_swf_l[0] * 256 + parameter_dump_packet.sy_lfr_n_swf_l[1];
1264 delta_f0_in_float =nb_samples_per_snapshot / 2. * ( 1. / 256. - 1. / 24576.) * 256.;
1097 delta_f0_in_float =nb_samples_per_snapshot / 2. * ( 1. / 256. - 1. / 24576.) * 256.;
1265
1098
1266 waveform_picker_regs->delta_f0 = delta_snapshot - floor( delta_f0_in_float );
1099 waveform_picker_regs->delta_f0 = delta_snapshot - floor( delta_f0_in_float );
1267 waveform_picker_regs->delta_f0_2 = 0x30; // 48 = 11 0000, max 7 bits
1100 waveform_picker_regs->delta_f0_2 = 0x30; // 48 = 11 0000, max 7 bits
1268 }
1101 }
1269
1102
1270 void set_wfp_delta_f1( void )
1103 void set_wfp_delta_f1( void )
1271 {
1104 {
1272 unsigned int delta_snapshot;
1105 unsigned int delta_snapshot;
1273 unsigned int nb_samples_per_snapshot;
1106 unsigned int nb_samples_per_snapshot;
1274 float delta_f1_in_float;
1107 float delta_f1_in_float;
1275
1108
1276 delta_snapshot = waveform_picker_regs->delta_snapshot;
1109 delta_snapshot = waveform_picker_regs->delta_snapshot;
1277 nb_samples_per_snapshot = parameter_dump_packet.sy_lfr_n_swf_l[0] * 256 + parameter_dump_packet.sy_lfr_n_swf_l[1];
1110 nb_samples_per_snapshot = parameter_dump_packet.sy_lfr_n_swf_l[0] * 256 + parameter_dump_packet.sy_lfr_n_swf_l[1];
1278 delta_f1_in_float = nb_samples_per_snapshot / 2. * ( 1. / 256. - 1. / 4096.) * 256.;
1111 delta_f1_in_float = nb_samples_per_snapshot / 2. * ( 1. / 256. - 1. / 4096.) * 256.;
1279
1112
1280 waveform_picker_regs->delta_f1 = delta_snapshot - floor( delta_f1_in_float );
1113 waveform_picker_regs->delta_f1 = delta_snapshot - floor( delta_f1_in_float );
1281 }
1114 }
1282
1115
1283 void set_wfp_delta_f2()
1116 void set_wfp_delta_f2()
1284 {
1117 {
1285 unsigned int delta_snapshot;
1118 unsigned int delta_snapshot;
1286 unsigned int nb_samples_per_snapshot;
1119 unsigned int nb_samples_per_snapshot;
1287
1120
1288 delta_snapshot = waveform_picker_regs->delta_snapshot;
1121 delta_snapshot = waveform_picker_regs->delta_snapshot;
1289 nb_samples_per_snapshot = parameter_dump_packet.sy_lfr_n_swf_l[0] * 256 + parameter_dump_packet.sy_lfr_n_swf_l[1];
1122 nb_samples_per_snapshot = parameter_dump_packet.sy_lfr_n_swf_l[0] * 256 + parameter_dump_packet.sy_lfr_n_swf_l[1];
1290
1123
1291 waveform_picker_regs->delta_f2 = delta_snapshot - nb_samples_per_snapshot / 2;
1124 waveform_picker_regs->delta_f2 = delta_snapshot - nb_samples_per_snapshot / 2;
1292 }
1125 }
1293
1126
1294 //*****************
1127 //*****************
1295 // local parameters
1128 // local parameters
1296
1129
1297 void increment_seq_counter_source_id( unsigned char *packet_sequence_control, unsigned int sid )
1130 void increment_seq_counter_source_id( unsigned char *packet_sequence_control, unsigned int sid )
1298 {
1131 {
1299 /** This function increments the parameter "sequence_cnt" depending on the sid passed in argument.
1132 /** This function increments the parameter "sequence_cnt" depending on the sid passed in argument.
1300 *
1133 *
1301 * @param packet_sequence_control is a pointer toward the parameter sequence_cnt to update.
1134 * @param packet_sequence_control is a pointer toward the parameter sequence_cnt to update.
1302 * @param sid is the source identifier of the packet being updated.
1135 * @param sid is the source identifier of the packet being updated.
1303 *
1136 *
1304 * REQ-LFR-SRS-5240 / SSS-CP-FS-590
1137 * REQ-LFR-SRS-5240 / SSS-CP-FS-590
1305 * The sequence counters shall wrap around from 2^14 to zero.
1138 * The sequence counters shall wrap around from 2^14 to zero.
1306 * The sequence counter shall start at zero at startup.
1139 * The sequence counter shall start at zero at startup.
1307 *
1140 *
1308 * REQ-LFR-SRS-5239 / SSS-CP-FS-580
1141 * REQ-LFR-SRS-5239 / SSS-CP-FS-580
1309 * All TM_LFR_SCIENCE_ packets are sent to ground, i.e. destination id = 0
1142 * All TM_LFR_SCIENCE_ packets are sent to ground, i.e. destination id = 0
1310 *
1143 *
1311 */
1144 */
1312
1145
1313 unsigned short *sequence_cnt;
1146 unsigned short *sequence_cnt;
1314 unsigned short segmentation_grouping_flag;
1147 unsigned short segmentation_grouping_flag;
1315 unsigned short new_packet_sequence_control;
1148 unsigned short new_packet_sequence_control;
1316 rtems_mode initial_mode_set;
1149 rtems_mode initial_mode_set;
1317 rtems_mode current_mode_set;
1150 rtems_mode current_mode_set;
1318 rtems_status_code status;
1151 rtems_status_code status;
1319
1152
1320 //******************************************
1153 //******************************************
1321 // CHANGE THE MODE OF THE CALLING RTEMS TASK
1154 // CHANGE THE MODE OF THE CALLING RTEMS TASK
1322 status = rtems_task_mode( RTEMS_NO_PREEMPT, RTEMS_PREEMPT_MASK, &initial_mode_set );
1155 status = rtems_task_mode( RTEMS_NO_PREEMPT, RTEMS_PREEMPT_MASK, &initial_mode_set );
1323
1156
1324 if ( (sid == SID_NORM_SWF_F0) || (sid == SID_NORM_SWF_F1) || (sid == SID_NORM_SWF_F2)
1157 if ( (sid == SID_NORM_SWF_F0) || (sid == SID_NORM_SWF_F1) || (sid == SID_NORM_SWF_F2)
1325 || (sid == SID_NORM_CWF_F3) || (sid == SID_NORM_CWF_LONG_F3)
1158 || (sid == SID_NORM_CWF_F3) || (sid == SID_NORM_CWF_LONG_F3)
1326 || (sid == SID_BURST_CWF_F2)
1159 || (sid == SID_BURST_CWF_F2)
1327 || (sid == SID_NORM_ASM_F0) || (sid == SID_NORM_ASM_F1) || (sid == SID_NORM_ASM_F2)
1160 || (sid == SID_NORM_ASM_F0) || (sid == SID_NORM_ASM_F1) || (sid == SID_NORM_ASM_F2)
1328 || (sid == SID_NORM_BP1_F0) || (sid == SID_NORM_BP1_F1) || (sid == SID_NORM_BP1_F2)
1161 || (sid == SID_NORM_BP1_F0) || (sid == SID_NORM_BP1_F1) || (sid == SID_NORM_BP1_F2)
1329 || (sid == SID_NORM_BP2_F0) || (sid == SID_NORM_BP2_F1) || (sid == SID_NORM_BP2_F2)
1162 || (sid == SID_NORM_BP2_F0) || (sid == SID_NORM_BP2_F1) || (sid == SID_NORM_BP2_F2)
1330 || (sid == SID_BURST_BP1_F0) || (sid == SID_BURST_BP2_F0)
1163 || (sid == SID_BURST_BP1_F0) || (sid == SID_BURST_BP2_F0)
1331 || (sid == SID_BURST_BP1_F1) || (sid == SID_BURST_BP2_F1) )
1164 || (sid == SID_BURST_BP1_F1) || (sid == SID_BURST_BP2_F1) )
1332 {
1165 {
1333 sequence_cnt = (unsigned short *) &sequenceCounters_SCIENCE_NORMAL_BURST;
1166 sequence_cnt = (unsigned short *) &sequenceCounters_SCIENCE_NORMAL_BURST;
1334 }
1167 }
1335 else if ( (sid ==SID_SBM1_CWF_F1) || (sid ==SID_SBM2_CWF_F2)
1168 else if ( (sid ==SID_SBM1_CWF_F1) || (sid ==SID_SBM2_CWF_F2)
1336 || (sid == SID_SBM1_BP1_F0) || (sid == SID_SBM1_BP2_F0)
1169 || (sid == SID_SBM1_BP1_F0) || (sid == SID_SBM1_BP2_F0)
1337 || (sid == SID_SBM2_BP1_F0) || (sid == SID_SBM2_BP2_F0)
1170 || (sid == SID_SBM2_BP1_F0) || (sid == SID_SBM2_BP2_F0)
1338 || (sid == SID_SBM2_BP1_F1) || (sid == SID_SBM2_BP2_F1) )
1171 || (sid == SID_SBM2_BP1_F1) || (sid == SID_SBM2_BP2_F1) )
1339 {
1172 {
1340 sequence_cnt = (unsigned short *) &sequenceCounters_SCIENCE_SBM1_SBM2;
1173 sequence_cnt = (unsigned short *) &sequenceCounters_SCIENCE_SBM1_SBM2;
1341 }
1174 }
1342 else
1175 else
1343 {
1176 {
1344 sequence_cnt = (unsigned short *) NULL;
1177 sequence_cnt = (unsigned short *) NULL;
1345 PRINTF1("in increment_seq_counter_source_id *** ERR apid_destid %d not known\n", sid)
1178 PRINTF1("in increment_seq_counter_source_id *** ERR apid_destid %d not known\n", sid)
1346 }
1179 }
1347
1180
1348 if (sequence_cnt != NULL)
1181 if (sequence_cnt != NULL)
1349 {
1182 {
1350 segmentation_grouping_flag = TM_PACKET_SEQ_CTRL_STANDALONE << 8;
1183 segmentation_grouping_flag = TM_PACKET_SEQ_CTRL_STANDALONE << 8;
1351 *sequence_cnt = (*sequence_cnt) & 0x3fff;
1184 *sequence_cnt = (*sequence_cnt) & 0x3fff;
1352
1185
1353 new_packet_sequence_control = segmentation_grouping_flag | (*sequence_cnt) ;
1186 new_packet_sequence_control = segmentation_grouping_flag | (*sequence_cnt) ;
1354
1187
1355 packet_sequence_control[0] = (unsigned char) (new_packet_sequence_control >> 8);
1188 packet_sequence_control[0] = (unsigned char) (new_packet_sequence_control >> 8);
1356 packet_sequence_control[1] = (unsigned char) (new_packet_sequence_control );
1189 packet_sequence_control[1] = (unsigned char) (new_packet_sequence_control );
1357
1190
1358 // increment the sequence counter
1191 // increment the sequence counter
1359 if ( *sequence_cnt < SEQ_CNT_MAX)
1192 if ( *sequence_cnt < SEQ_CNT_MAX)
1360 {
1193 {
1361 *sequence_cnt = *sequence_cnt + 1;
1194 *sequence_cnt = *sequence_cnt + 1;
1362 }
1195 }
1363 else
1196 else
1364 {
1197 {
1365 *sequence_cnt = 0;
1198 *sequence_cnt = 0;
1366 }
1199 }
1367 }
1200 }
1368
1201
1369 //*************************************
1202 //*************************************
1370 // RESTORE THE MODE OF THE CALLING TASK
1203 // RESTORE THE MODE OF THE CALLING TASK
1371 status = rtems_task_mode( initial_mode_set, RTEMS_PREEMPT_MASK, &current_mode_set );
1204 status = rtems_task_mode( initial_mode_set, RTEMS_PREEMPT_MASK, &current_mode_set );
1372 }
1205 }
General Comments 0
You need to be logged in to leave comments. Login now