@@ -1,2 +1,2 | |||||
1 | 3081d1f9bb20b2b64a192585337a292a9804e0c5 LFR_basic-parameters |
|
1 | 3081d1f9bb20b2b64a192585337a292a9804e0c5 LFR_basic-parameters | |
2 | bb9afa759d57093f7646d3be18f4a9923a4cbf84 header/lfr_common_headers |
|
2 | a0ca246cc2057880086d028aab3cf35be244efbc header/lfr_common_headers |
@@ -1,113 +1,113 | |||||
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 |
|
5 | CONFIG += console verbose lpp_dpu_destid 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=9 # internal |
|
15 | DEFINES += SW_VERSION_N4=9 # 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 | #LIBS += -lgcov /opt/GCOV/HOWTO_gcov_for_lfr_test/01A/lib/overload.o -lc |
|
20 | #LIBS += -lgcov /opt/GCOV/HOWTO_gcov_for_lfr_test/01A/lib/overload.o -lc | |
21 | # </GCOV> |
|
21 | # </GCOV> | |
22 |
|
22 | |||
23 | # <CHANGE BEFORE FLIGHT> |
|
23 | # <CHANGE BEFORE FLIGHT> | |
24 | contains( CONFIG, lpp_dpu_destid ) { |
|
24 | contains( CONFIG, lpp_dpu_destid ) { | |
25 | DEFINES += LPP_DPU_DESTID |
|
25 | DEFINES += LPP_DPU_DESTID | |
26 | } |
|
26 | } | |
27 | # </CHANGE BEFORE FLIGHT> |
|
27 | # </CHANGE BEFORE FLIGHT> | |
28 |
|
28 | |||
29 | contains( CONFIG, debug_tch ) { |
|
29 | contains( CONFIG, debug_tch ) { | |
30 | DEFINES += DEBUG_TCH |
|
30 | DEFINES += DEBUG_TCH | |
31 | } |
|
31 | } | |
32 | DEFINES += MSB_FIRST_TCH |
|
32 | DEFINES += MSB_FIRST_TCH | |
33 |
|
33 | |||
34 | contains( CONFIG, vhdl_dev ) { |
|
34 | contains( CONFIG, vhdl_dev ) { | |
35 | DEFINES += VHDL_DEV |
|
35 | DEFINES += VHDL_DEV | |
36 | } |
|
36 | } | |
37 |
|
37 | |||
38 | contains( CONFIG, verbose ) { |
|
38 | contains( CONFIG, verbose ) { | |
39 | DEFINES += PRINT_MESSAGES_ON_CONSOLE |
|
39 | DEFINES += PRINT_MESSAGES_ON_CONSOLE | |
40 | } |
|
40 | } | |
41 |
|
41 | |||
42 | contains( CONFIG, debug_messages ) { |
|
42 | contains( CONFIG, debug_messages ) { | |
43 | DEFINES += DEBUG_MESSAGES |
|
43 | DEFINES += DEBUG_MESSAGES | |
44 | } |
|
44 | } | |
45 |
|
45 | |||
46 | contains( CONFIG, cpu_usage_report ) { |
|
46 | contains( CONFIG, cpu_usage_report ) { | |
47 | DEFINES += PRINT_TASK_STATISTICS |
|
47 | DEFINES += PRINT_TASK_STATISTICS | |
48 | } |
|
48 | } | |
49 |
|
49 | |||
50 | contains( CONFIG, stack_report ) { |
|
50 | contains( CONFIG, stack_report ) { | |
51 | DEFINES += PRINT_STACK_REPORT |
|
51 | DEFINES += PRINT_STACK_REPORT | |
52 | } |
|
52 | } | |
53 |
|
53 | |||
54 | contains( CONFIG, boot_messages ) { |
|
54 | contains( CONFIG, boot_messages ) { | |
55 | DEFINES += BOOT_MESSAGES |
|
55 | DEFINES += BOOT_MESSAGES | |
56 | } |
|
56 | } | |
57 |
|
57 | |||
58 | #doxygen.target = doxygen |
|
58 | #doxygen.target = doxygen | |
59 | #doxygen.commands = doxygen ../doc/Doxyfile |
|
59 | #doxygen.commands = doxygen ../doc/Doxyfile | |
60 | #QMAKE_EXTRA_TARGETS += doxygen |
|
60 | #QMAKE_EXTRA_TARGETS += doxygen | |
61 |
|
61 | |||
62 | TARGET = fsw |
|
62 | TARGET = fsw | |
63 |
|
63 | |||
64 | INCLUDEPATH += \ |
|
64 | INCLUDEPATH += \ | |
65 | $${PWD}/../src \ |
|
65 | $${PWD}/../src \ | |
66 | $${PWD}/../header \ |
|
66 | $${PWD}/../header \ | |
67 | $${PWD}/../header/lfr_common_headers \ |
|
67 | $${PWD}/../header/lfr_common_headers \ | |
68 | $${PWD}/../header/processing \ |
|
68 | $${PWD}/../header/processing \ | |
69 | $${PWD}/../LFR_basic-parameters |
|
69 | $${PWD}/../LFR_basic-parameters | |
70 |
|
70 | |||
71 | SOURCES += \ |
|
71 | SOURCES += \ | |
72 | ../src/wf_handler.c \ |
|
72 | ../src/wf_handler.c \ | |
73 | ../src/tc_handler.c \ |
|
73 | ../src/tc_handler.c \ | |
74 | ../src/fsw_misc.c \ |
|
74 | ../src/fsw_misc.c \ | |
75 | ../src/fsw_init.c \ |
|
75 | ../src/fsw_init.c \ | |
76 | ../src/fsw_globals.c \ |
|
76 | ../src/fsw_globals.c \ | |
77 | ../src/fsw_spacewire.c \ |
|
77 | ../src/fsw_spacewire.c \ | |
78 | ../src/tc_load_dump_parameters.c \ |
|
78 | ../src/tc_load_dump_parameters.c \ | |
79 | ../src/tm_lfr_tc_exe.c \ |
|
79 | ../src/tm_lfr_tc_exe.c \ | |
80 | ../src/tc_acceptance.c \ |
|
80 | ../src/tc_acceptance.c \ | |
81 | ../src/processing/fsw_processing.c \ |
|
81 | ../src/processing/fsw_processing.c \ | |
82 | ../src/processing/avf0_prc0.c \ |
|
82 | ../src/processing/avf0_prc0.c \ | |
83 | ../src/processing/avf1_prc1.c \ |
|
83 | ../src/processing/avf1_prc1.c \ | |
84 | ../src/processing/avf2_prc2.c \ |
|
84 | ../src/processing/avf2_prc2.c \ | |
85 | ../src/lfr_cpu_usage_report.c \ |
|
85 | ../src/lfr_cpu_usage_report.c \ | |
86 | ../LFR_basic-parameters/basic_parameters.c |
|
86 | ../LFR_basic-parameters/basic_parameters.c | |
87 |
|
87 | |||
88 | HEADERS += \ |
|
88 | HEADERS += \ | |
89 | ../header/wf_handler.h \ |
|
89 | ../header/wf_handler.h \ | |
90 | ../header/tc_handler.h \ |
|
90 | ../header/tc_handler.h \ | |
91 | ../header/grlib_regs.h \ |
|
91 | ../header/grlib_regs.h \ | |
92 | ../header/fsw_misc.h \ |
|
92 | ../header/fsw_misc.h \ | |
93 | ../header/fsw_init.h \ |
|
93 | ../header/fsw_init.h \ | |
94 | ../header/fsw_spacewire.h \ |
|
94 | ../header/fsw_spacewire.h \ | |
95 | ../header/tc_load_dump_parameters.h \ |
|
95 | ../header/tc_load_dump_parameters.h \ | |
96 | ../header/tm_lfr_tc_exe.h \ |
|
96 | ../header/tm_lfr_tc_exe.h \ | |
97 | ../header/tc_acceptance.h \ |
|
97 | ../header/tc_acceptance.h \ | |
98 | ../header/processing/fsw_processing.h \ |
|
98 | ../header/processing/fsw_processing.h \ | |
99 | ../header/processing/avf0_prc0.h \ |
|
99 | ../header/processing/avf0_prc0.h \ | |
100 | ../header/processing/avf1_prc1.h \ |
|
100 | ../header/processing/avf1_prc1.h \ | |
101 | ../header/processing/avf2_prc2.h \ |
|
101 | ../header/processing/avf2_prc2.h \ | |
102 | ../header/fsw_params_wf_handler.h \ |
|
102 | ../header/fsw_params_wf_handler.h \ | |
103 | ../header/lfr_cpu_usage_report.h \ |
|
103 | ../header/lfr_cpu_usage_report.h \ | |
104 | ../header/lfr_common_headers/ccsds_types.h \ |
|
104 | ../header/lfr_common_headers/ccsds_types.h \ | |
105 | ../header/lfr_common_headers/fsw_params.h \ |
|
105 | ../header/lfr_common_headers/fsw_params.h \ | |
106 | ../header/lfr_common_headers/fsw_params_nb_bytes.h \ |
|
106 | ../header/lfr_common_headers/fsw_params_nb_bytes.h \ | |
107 | ../header/lfr_common_headers/fsw_params_processing.h \ |
|
107 | ../header/lfr_common_headers/fsw_params_processing.h \ | |
108 | ../header/lfr_common_headers/TC_types.h \ |
|
108 | ../header/lfr_common_headers/TC_types.h \ | |
109 | ../header/lfr_common_headers/tm_byte_positions.h \ |
|
109 | ../header/lfr_common_headers/tm_byte_positions.h \ | |
110 | ../LFR_basic-parameters/basic_parameters.h \ |
|
110 | ../LFR_basic-parameters/basic_parameters.h \ | |
111 | ../LFR_basic-parameters/basic_parameters_params.h \ |
|
111 | ../LFR_basic-parameters/basic_parameters_params.h \ | |
112 | ../header/GscMemoryLPP.hpp |
|
112 | ../header/GscMemoryLPP.hpp | |
113 |
|
113 |
@@ -1,50 +1,51 | |||||
1 | #ifndef FSW_INIT_H_INCLUDED |
|
1 | #ifndef FSW_INIT_H_INCLUDED | |
2 | #define FSW_INIT_H_INCLUDED |
|
2 | #define FSW_INIT_H_INCLUDED | |
3 |
|
3 | |||
4 | #include <rtems.h> |
|
4 | #include <rtems.h> | |
5 | #include <leon.h> |
|
5 | #include <leon.h> | |
6 |
|
6 | |||
7 | #include "fsw_params.h" |
|
7 | #include "fsw_params.h" | |
8 | #include "fsw_misc.h" |
|
8 | #include "fsw_misc.h" | |
9 | #include "fsw_processing.h" |
|
9 | #include "fsw_processing.h" | |
10 |
|
10 | |||
11 | #include "tc_handler.h" |
|
11 | #include "tc_handler.h" | |
12 | #include "wf_handler.h" |
|
12 | #include "wf_handler.h" | |
13 | #include "fsw_spacewire.h" |
|
13 | #include "fsw_spacewire.h" | |
14 |
|
14 | |||
15 | #include "avf0_prc0.h" |
|
15 | #include "avf0_prc0.h" | |
16 | #include "avf1_prc1.h" |
|
16 | #include "avf1_prc1.h" | |
17 | #include "avf2_prc2.h" |
|
17 | #include "avf2_prc2.h" | |
18 |
|
18 | |||
19 | extern rtems_name Task_name[20]; /* array of task names */ |
|
19 | extern rtems_name Task_name[20]; /* array of task names */ | |
20 | extern rtems_id Task_id[20]; /* array of task ids */ |
|
20 | extern rtems_id Task_id[20]; /* array of task ids */ | |
|
21 | extern unsigned char pa_bia_status_info; | |||
21 |
|
22 | |||
22 | // RTEMS TASKS |
|
23 | // RTEMS TASKS | |
23 | rtems_task Init( rtems_task_argument argument); |
|
24 | rtems_task Init( rtems_task_argument argument); | |
24 |
|
25 | |||
25 | // OTHER functions |
|
26 | // OTHER functions | |
26 | void create_names( void ); |
|
27 | void create_names( void ); | |
27 | int create_all_tasks( void ); |
|
28 | int create_all_tasks( void ); | |
28 | int start_all_tasks( void ); |
|
29 | int start_all_tasks( void ); | |
29 | // |
|
30 | // | |
30 | rtems_status_code create_message_queues( void ); |
|
31 | rtems_status_code create_message_queues( void ); | |
31 | rtems_status_code get_message_queue_id_send( rtems_id *queue_id ); |
|
32 | rtems_status_code get_message_queue_id_send( rtems_id *queue_id ); | |
32 | rtems_status_code get_message_queue_id_recv( rtems_id *queue_id ); |
|
33 | rtems_status_code get_message_queue_id_recv( rtems_id *queue_id ); | |
33 | rtems_status_code get_message_queue_id_prc0( rtems_id *queue_id ); |
|
34 | rtems_status_code get_message_queue_id_prc0( rtems_id *queue_id ); | |
34 | rtems_status_code get_message_queue_id_prc1( rtems_id *queue_id ); |
|
35 | rtems_status_code get_message_queue_id_prc1( rtems_id *queue_id ); | |
35 | rtems_status_code get_message_queue_id_prc2( rtems_id *queue_id ); |
|
36 | rtems_status_code get_message_queue_id_prc2( rtems_id *queue_id ); | |
36 | void update_queue_max_count( rtems_id queue_id, unsigned char*fifo_size_max ); |
|
37 | void update_queue_max_count( rtems_id queue_id, unsigned char*fifo_size_max ); | |
37 | void init_ring(ring_node ring[], unsigned char nbNodes, volatile int buffer[], unsigned int bufferSize ); |
|
38 | void init_ring(ring_node ring[], unsigned char nbNodes, volatile int buffer[], unsigned int bufferSize ); | |
38 | // |
|
39 | // | |
39 | int start_recv_send_tasks( void ); |
|
40 | int start_recv_send_tasks( void ); | |
40 | // |
|
41 | // | |
41 | void init_local_mode_parameters( void ); |
|
42 | void init_local_mode_parameters( void ); | |
42 | void reset_local_time( void ); |
|
43 | void reset_local_time( void ); | |
43 |
|
44 | |||
44 | extern void rtems_cpu_usage_report( void ); |
|
45 | extern void rtems_cpu_usage_report( void ); | |
45 | extern void rtems_cpu_usage_reset( void ); |
|
46 | extern void rtems_cpu_usage_reset( void ); | |
46 | extern void rtems_stack_checker_report_usage( void ); |
|
47 | extern void rtems_stack_checker_report_usage( void ); | |
47 |
|
48 | |||
48 | extern int sched_yield( void ); |
|
49 | extern int sched_yield( void ); | |
49 |
|
50 | |||
50 | #endif // FSW_INIT_H_INCLUDED |
|
51 | #endif // FSW_INIT_H_INCLUDED |
@@ -1,57 +1,58 | |||||
1 | #ifndef FSW_MISC_H_INCLUDED |
|
1 | #ifndef FSW_MISC_H_INCLUDED | |
2 | #define FSW_MISC_H_INCLUDED |
|
2 | #define FSW_MISC_H_INCLUDED | |
3 |
|
3 | |||
4 | #include <rtems.h> |
|
4 | #include <rtems.h> | |
5 | #include <stdio.h> |
|
5 | #include <stdio.h> | |
6 | #include <grspw.h> |
|
6 | #include <grspw.h> | |
7 | #include <grlib_regs.h> |
|
7 | #include <grlib_regs.h> | |
8 |
|
8 | |||
9 | #include "fsw_params.h" |
|
9 | #include "fsw_params.h" | |
10 | #include "fsw_spacewire.h" |
|
10 | #include "fsw_spacewire.h" | |
11 | #include "lfr_cpu_usage_report.h" |
|
11 | #include "lfr_cpu_usage_report.h" | |
12 |
|
12 | |||
13 | rtems_name name_hk_rate_monotonic; // name of the HK rate monotonic |
|
13 | rtems_name name_hk_rate_monotonic; // name of the HK rate monotonic | |
14 | rtems_id HK_id; // id of the HK rate monotonic period |
|
14 | rtems_id HK_id; // id of the HK rate monotonic period | |
15 |
|
15 | |||
16 | void configure_timer(gptimer_regs_t *gptimer_regs, unsigned char timer, unsigned int clock_divider, |
|
16 | void configure_timer(gptimer_regs_t *gptimer_regs, unsigned char timer, unsigned int clock_divider, | |
17 | unsigned char interrupt_level, rtems_isr (*timer_isr)() ); |
|
17 | unsigned char interrupt_level, rtems_isr (*timer_isr)() ); | |
18 | void timer_start( gptimer_regs_t *gptimer_regs, unsigned char timer ); |
|
18 | void timer_start( gptimer_regs_t *gptimer_regs, unsigned char timer ); | |
19 | void timer_stop( gptimer_regs_t *gptimer_regs, unsigned char timer ); |
|
19 | void timer_stop( gptimer_regs_t *gptimer_regs, unsigned char timer ); | |
20 | void timer_set_clock_divider(gptimer_regs_t *gptimer_regs, unsigned char timer, unsigned int clock_divider); |
|
20 | void timer_set_clock_divider(gptimer_regs_t *gptimer_regs, unsigned char timer, unsigned int clock_divider); | |
21 |
|
21 | |||
22 | // SERIAL LINK |
|
22 | // SERIAL LINK | |
23 | int send_console_outputs_on_apbuart_port( void ); |
|
23 | int send_console_outputs_on_apbuart_port( void ); | |
24 | int enable_apbuart_transmitter( void ); |
|
24 | int enable_apbuart_transmitter( void ); | |
25 | void set_apbuart_scaler_reload_register(unsigned int regs, unsigned int value); |
|
25 | void set_apbuart_scaler_reload_register(unsigned int regs, unsigned int value); | |
26 |
|
26 | |||
27 | // RTEMS TASKS |
|
27 | // RTEMS TASKS | |
28 | rtems_task stat_task( rtems_task_argument argument ); |
|
28 | rtems_task stat_task( rtems_task_argument argument ); | |
29 | rtems_task hous_task( rtems_task_argument argument ); |
|
29 | rtems_task hous_task( rtems_task_argument argument ); | |
30 | rtems_task dumb_task( rtems_task_argument unused ); |
|
30 | rtems_task dumb_task( rtems_task_argument unused ); | |
31 |
|
31 | |||
32 | void init_housekeeping_parameters( void ); |
|
32 | void init_housekeeping_parameters( void ); | |
33 | void increment_seq_counter(unsigned short *packetSequenceControl); |
|
33 | void increment_seq_counter(unsigned short *packetSequenceControl); | |
34 | void getTime( unsigned char *time); |
|
34 | void getTime( unsigned char *time); | |
35 | unsigned long long int getTimeAsUnsignedLongLongInt( ); |
|
35 | unsigned long long int getTimeAsUnsignedLongLongInt( ); | |
36 | void send_dumb_hk( void ); |
|
36 | void send_dumb_hk( void ); | |
37 | void get_temperatures( unsigned char *temperatures ); |
|
37 | void get_temperatures( unsigned char *temperatures ); | |
38 | void get_v_e1_e2_f3( unsigned char *spacecraft_potential ); |
|
38 | void get_v_e1_e2_f3( unsigned char *spacecraft_potential ); | |
39 | void get_cpu_load( unsigned char *resource_statistics ); |
|
39 | void get_cpu_load( unsigned char *resource_statistics ); | |
40 | void set_hk_lfr_sc_potential_flag( bool state ); |
|
40 | void set_hk_lfr_sc_potential_flag( bool state ); | |
|
41 | void set_hk_lfr_mag_fields_flag( bool state ); | |||
41 | void set_hk_lfr_calib_enable( bool state ); |
|
42 | void set_hk_lfr_calib_enable( bool state ); | |
42 |
|
43 | |||
43 |
|
44 | |||
44 | extern int sched_yield( void ); |
|
45 | extern int sched_yield( void ); | |
45 | extern void rtems_cpu_usage_reset(); |
|
46 | extern void rtems_cpu_usage_reset(); | |
46 | extern ring_node *current_ring_node_f3; |
|
47 | extern ring_node *current_ring_node_f3; | |
47 | extern ring_node *ring_node_to_send_cwf_f3; |
|
48 | extern ring_node *ring_node_to_send_cwf_f3; | |
48 | extern ring_node waveform_ring_f3[]; |
|
49 | extern ring_node waveform_ring_f3[]; | |
49 | extern unsigned short sequenceCounterHK; |
|
50 | extern unsigned short sequenceCounterHK; | |
50 |
|
51 | |||
51 | extern unsigned char hk_lfr_q_sd_fifo_size_max; |
|
52 | extern unsigned char hk_lfr_q_sd_fifo_size_max; | |
52 | extern unsigned char hk_lfr_q_rv_fifo_size_max; |
|
53 | extern unsigned char hk_lfr_q_rv_fifo_size_max; | |
53 | extern unsigned char hk_lfr_q_p0_fifo_size_max; |
|
54 | extern unsigned char hk_lfr_q_p0_fifo_size_max; | |
54 | extern unsigned char hk_lfr_q_p1_fifo_size_max; |
|
55 | extern unsigned char hk_lfr_q_p1_fifo_size_max; | |
55 | extern unsigned char hk_lfr_q_p2_fifo_size_max; |
|
56 | extern unsigned char hk_lfr_q_p2_fifo_size_max; | |
56 |
|
57 | |||
57 | #endif // FSW_MISC_H_INCLUDED |
|
58 | #endif // FSW_MISC_H_INCLUDED |
@@ -1,78 +1,79 | |||||
1 | /** Global variables of the LFR flight software. |
|
1 | /** Global variables of the LFR flight software. | |
2 | * |
|
2 | * | |
3 | * @file |
|
3 | * @file | |
4 | * @author P. LEROY |
|
4 | * @author P. LEROY | |
5 | * |
|
5 | * | |
6 | * Among global variables, there are: |
|
6 | * Among global variables, there are: | |
7 | * - RTEMS names and id. |
|
7 | * - RTEMS names and id. | |
8 | * - APB configuration registers. |
|
8 | * - APB configuration registers. | |
9 | * - waveforms global buffers, used by the waveform picker hardware module to store data. |
|
9 | * - waveforms global buffers, used by the waveform picker hardware module to store data. | |
10 | * - spectral matrices buffesr, used by the hardware module to store data. |
|
10 | * - spectral matrices buffesr, used by the hardware module to store data. | |
11 | * - variable related to LFR modes parameters. |
|
11 | * - variable related to LFR modes parameters. | |
12 | * - the global HK packet buffer. |
|
12 | * - the global HK packet buffer. | |
13 | * - the global dump parameter buffer. |
|
13 | * - the global dump parameter buffer. | |
14 | * |
|
14 | * | |
15 | */ |
|
15 | */ | |
16 |
|
16 | |||
17 | #include <rtems.h> |
|
17 | #include <rtems.h> | |
18 | #include <grspw.h> |
|
18 | #include <grspw.h> | |
19 |
|
19 | |||
20 | #include "ccsds_types.h" |
|
20 | #include "ccsds_types.h" | |
21 | #include "grlib_regs.h" |
|
21 | #include "grlib_regs.h" | |
22 | #include "fsw_params.h" |
|
22 | #include "fsw_params.h" | |
23 | #include "fsw_params_wf_handler.h" |
|
23 | #include "fsw_params_wf_handler.h" | |
24 |
|
24 | |||
25 | // RTEMS GLOBAL VARIABLES |
|
25 | // RTEMS GLOBAL VARIABLES | |
26 | rtems_name misc_name[5]; |
|
26 | rtems_name misc_name[5]; | |
27 | rtems_name Task_name[20]; /* array of task names */ |
|
27 | rtems_name Task_name[20]; /* array of task names */ | |
28 | rtems_id Task_id[20]; /* array of task ids */ |
|
28 | rtems_id Task_id[20]; /* array of task ids */ | |
29 | int fdSPW = 0; |
|
29 | int fdSPW = 0; | |
30 | int fdUART = 0; |
|
30 | int fdUART = 0; | |
31 | unsigned char lfrCurrentMode; |
|
31 | unsigned char lfrCurrentMode; | |
|
32 | unsigned char pa_bia_status_info; | |||
32 |
|
33 | |||
33 | // WAVEFORMS GLOBAL VARIABLES // 2048 * 3 * 4 + 2 * 4 = 24576 + 8 bytes = 24584 |
|
34 | // WAVEFORMS GLOBAL VARIABLES // 2048 * 3 * 4 + 2 * 4 = 24576 + 8 bytes = 24584 | |
34 | // 97 * 256 = 24832 => delta = 248 bytes = 62 words |
|
35 | // 97 * 256 = 24832 => delta = 248 bytes = 62 words | |
35 | // WAVEFORMS GLOBAL VARIABLES // 2688 * 3 * 4 + 2 * 4 = 32256 + 8 bytes = 32264 |
|
36 | // WAVEFORMS GLOBAL VARIABLES // 2688 * 3 * 4 + 2 * 4 = 32256 + 8 bytes = 32264 | |
36 | // 127 * 256 = 32512 => delta = 248 bytes = 62 words |
|
37 | // 127 * 256 = 32512 => delta = 248 bytes = 62 words | |
37 | // F0 F1 F2 F3 |
|
38 | // F0 F1 F2 F3 | |
38 | volatile int wf_buffer_f0[ NB_RING_NODES_F0 * WFRM_BUFFER ] __attribute__((aligned(0x100))); |
|
39 | volatile int wf_buffer_f0[ NB_RING_NODES_F0 * WFRM_BUFFER ] __attribute__((aligned(0x100))); | |
39 | volatile int wf_buffer_f1[ NB_RING_NODES_F1 * WFRM_BUFFER ] __attribute__((aligned(0x100))); |
|
40 | volatile int wf_buffer_f1[ NB_RING_NODES_F1 * WFRM_BUFFER ] __attribute__((aligned(0x100))); | |
40 | volatile int wf_buffer_f2[ NB_RING_NODES_F2 * WFRM_BUFFER ] __attribute__((aligned(0x100))); |
|
41 | volatile int wf_buffer_f2[ NB_RING_NODES_F2 * WFRM_BUFFER ] __attribute__((aligned(0x100))); | |
41 | volatile int wf_buffer_f3[ NB_RING_NODES_F3 * WFRM_BUFFER ] __attribute__((aligned(0x100))); |
|
42 | volatile int wf_buffer_f3[ NB_RING_NODES_F3 * WFRM_BUFFER ] __attribute__((aligned(0x100))); | |
42 |
|
43 | |||
43 | //*********************************** |
|
44 | //*********************************** | |
44 | // SPECTRAL MATRICES GLOBAL VARIABLES |
|
45 | // SPECTRAL MATRICES GLOBAL VARIABLES | |
45 |
|
46 | |||
46 | // alignment constraints for the spectral matrices buffers => the first data after the time (8 bytes) shall be aligned on 0x00 |
|
47 | // alignment constraints for the spectral matrices buffers => the first data after the time (8 bytes) shall be aligned on 0x00 | |
47 | volatile int sm_f0[ NB_RING_NODES_SM_F0 * TOTAL_SIZE_SM ] __attribute__((aligned(0x100))); |
|
48 | volatile int sm_f0[ NB_RING_NODES_SM_F0 * TOTAL_SIZE_SM ] __attribute__((aligned(0x100))); | |
48 | volatile int sm_f1[ NB_RING_NODES_SM_F1 * TOTAL_SIZE_SM ] __attribute__((aligned(0x100))); |
|
49 | volatile int sm_f1[ NB_RING_NODES_SM_F1 * TOTAL_SIZE_SM ] __attribute__((aligned(0x100))); | |
49 | volatile int sm_f2[ NB_RING_NODES_SM_F2 * TOTAL_SIZE_SM ] __attribute__((aligned(0x100))); |
|
50 | volatile int sm_f2[ NB_RING_NODES_SM_F2 * TOTAL_SIZE_SM ] __attribute__((aligned(0x100))); | |
50 |
|
51 | |||
51 | // APB CONFIGURATION REGISTERS |
|
52 | // APB CONFIGURATION REGISTERS | |
52 | time_management_regs_t *time_management_regs = (time_management_regs_t*) REGS_ADDR_TIME_MANAGEMENT; |
|
53 | time_management_regs_t *time_management_regs = (time_management_regs_t*) REGS_ADDR_TIME_MANAGEMENT; | |
53 | gptimer_regs_t *gptimer_regs = (gptimer_regs_t *) REGS_ADDR_GPTIMER; |
|
54 | gptimer_regs_t *gptimer_regs = (gptimer_regs_t *) REGS_ADDR_GPTIMER; | |
54 | waveform_picker_regs_0_1_18_t *waveform_picker_regs = (waveform_picker_regs_0_1_18_t*) REGS_ADDR_WAVEFORM_PICKER; |
|
55 | waveform_picker_regs_0_1_18_t *waveform_picker_regs = (waveform_picker_regs_0_1_18_t*) REGS_ADDR_WAVEFORM_PICKER; | |
55 | spectral_matrix_regs_t *spectral_matrix_regs = (spectral_matrix_regs_t*) REGS_ADDR_SPECTRAL_MATRIX; |
|
56 | spectral_matrix_regs_t *spectral_matrix_regs = (spectral_matrix_regs_t*) REGS_ADDR_SPECTRAL_MATRIX; | |
56 |
|
57 | |||
57 | // MODE PARAMETERS |
|
58 | // MODE PARAMETERS | |
58 | Packet_TM_LFR_PARAMETER_DUMP_t parameter_dump_packet; |
|
59 | Packet_TM_LFR_PARAMETER_DUMP_t parameter_dump_packet; | |
59 | struct param_local_str param_local; |
|
60 | struct param_local_str param_local; | |
60 |
|
61 | |||
61 | // HK PACKETS |
|
62 | // HK PACKETS | |
62 | Packet_TM_LFR_HK_t housekeeping_packet; |
|
63 | Packet_TM_LFR_HK_t housekeeping_packet; | |
63 | // message queues occupancy |
|
64 | // message queues occupancy | |
64 | unsigned char hk_lfr_q_sd_fifo_size_max; |
|
65 | unsigned char hk_lfr_q_sd_fifo_size_max; | |
65 | unsigned char hk_lfr_q_rv_fifo_size_max; |
|
66 | unsigned char hk_lfr_q_rv_fifo_size_max; | |
66 | unsigned char hk_lfr_q_p0_fifo_size_max; |
|
67 | unsigned char hk_lfr_q_p0_fifo_size_max; | |
67 | unsigned char hk_lfr_q_p1_fifo_size_max; |
|
68 | unsigned char hk_lfr_q_p1_fifo_size_max; | |
68 | unsigned char hk_lfr_q_p2_fifo_size_max; |
|
69 | unsigned char hk_lfr_q_p2_fifo_size_max; | |
69 | // sequence counters are incremented by APID (PID + CAT) and destination ID |
|
70 | // sequence counters are incremented by APID (PID + CAT) and destination ID | |
70 | unsigned short sequenceCounters_SCIENCE_NORMAL_BURST; |
|
71 | unsigned short sequenceCounters_SCIENCE_NORMAL_BURST; | |
71 | unsigned short sequenceCounters_SCIENCE_SBM1_SBM2; |
|
72 | unsigned short sequenceCounters_SCIENCE_SBM1_SBM2; | |
72 | unsigned short sequenceCounters_TC_EXE[SEQ_CNT_NB_DEST_ID]; |
|
73 | unsigned short sequenceCounters_TC_EXE[SEQ_CNT_NB_DEST_ID]; | |
73 | unsigned short sequenceCounterHK; |
|
74 | unsigned short sequenceCounterHK; | |
74 | unsigned short sequenceCounterParameterDump; |
|
75 | unsigned short sequenceCounterParameterDump; | |
75 | spw_stats spacewire_stats; |
|
76 | spw_stats spacewire_stats; | |
76 | spw_stats spacewire_stats_backup; |
|
77 | spw_stats spacewire_stats_backup; | |
77 |
|
78 | |||
78 |
|
79 |
@@ -1,869 +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 | printf("(0) cacheControlRegister = %x\n", cacheControlRegister); |
|
70 | printf("(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 | printf("(1) cacheControlRegister = %x\n", cacheControlRegister); |
|
79 | printf("(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 |
|
142 | |||
142 | // waveform picker initialization |
|
143 | // waveform picker initialization | |
143 | WFP_init_rings(); // initialize the waveform rings |
|
144 | WFP_init_rings(); // initialize the waveform rings | |
144 | WFP_reset_current_ring_nodes(); |
|
145 | WFP_reset_current_ring_nodes(); | |
145 | reset_waveform_picker_regs(); |
|
146 | reset_waveform_picker_regs(); | |
146 |
|
147 | |||
147 | // spectral matrices initialization |
|
148 | // spectral matrices initialization | |
148 | SM_init_rings(); // initialize spectral matrices rings |
|
149 | SM_init_rings(); // initialize spectral matrices rings | |
149 | SM_reset_current_ring_nodes(); |
|
150 | SM_reset_current_ring_nodes(); | |
150 | reset_spectral_matrix_regs(); |
|
151 | reset_spectral_matrix_regs(); | |
151 |
|
152 | |||
152 | // configure calibration |
|
153 | // configure calibration | |
153 | configureCalibration( false ); // true means interleaved mode, false is for normal mode |
|
154 | configureCalibration( false ); // true means interleaved mode, false is for normal mode | |
154 |
|
155 | |||
155 | updateLFRCurrentMode(); |
|
156 | updateLFRCurrentMode(); | |
156 |
|
157 | |||
157 | BOOT_PRINTF1("in INIT *** lfrCurrentMode is %d\n", lfrCurrentMode) |
|
158 | BOOT_PRINTF1("in INIT *** lfrCurrentMode is %d\n", lfrCurrentMode) | |
158 |
|
159 | |||
159 | create_names(); // create all names |
|
160 | create_names(); // create all names | |
160 |
|
161 | |||
161 | status = create_message_queues(); // create message queues |
|
162 | status = create_message_queues(); // create message queues | |
162 | if (status != RTEMS_SUCCESSFUL) |
|
163 | if (status != RTEMS_SUCCESSFUL) | |
163 | { |
|
164 | { | |
164 | PRINTF1("in INIT *** ERR in create_message_queues, code %d", status) |
|
165 | PRINTF1("in INIT *** ERR in create_message_queues, code %d", status) | |
165 | } |
|
166 | } | |
166 |
|
167 | |||
167 | status = create_all_tasks(); // create all tasks |
|
168 | status = create_all_tasks(); // create all tasks | |
168 | if (status != RTEMS_SUCCESSFUL) |
|
169 | if (status != RTEMS_SUCCESSFUL) | |
169 | { |
|
170 | { | |
170 | 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) | |
171 | } |
|
172 | } | |
172 |
|
173 | |||
173 | // ************************** |
|
174 | // ************************** | |
174 | // <SPACEWIRE INITIALIZATION> |
|
175 | // <SPACEWIRE INITIALIZATION> | |
175 | grspw_timecode_callback = &timecode_irq_handler; |
|
176 | grspw_timecode_callback = &timecode_irq_handler; | |
176 |
|
177 | |||
177 | status_spw = spacewire_open_link(); // (1) open the link |
|
178 | status_spw = spacewire_open_link(); // (1) open the link | |
178 | if ( status_spw != RTEMS_SUCCESSFUL ) |
|
179 | if ( status_spw != RTEMS_SUCCESSFUL ) | |
179 | { |
|
180 | { | |
180 | 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 ) | |
181 | } |
|
182 | } | |
182 |
|
183 | |||
183 | if ( status_spw == RTEMS_SUCCESSFUL ) // (2) configure the link |
|
184 | if ( status_spw == RTEMS_SUCCESSFUL ) // (2) configure the link | |
184 | { |
|
185 | { | |
185 | status_spw = spacewire_configure_link( fdSPW ); |
|
186 | status_spw = spacewire_configure_link( fdSPW ); | |
186 | if ( status_spw != RTEMS_SUCCESSFUL ) |
|
187 | if ( status_spw != RTEMS_SUCCESSFUL ) | |
187 | { |
|
188 | { | |
188 | 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 ) | |
189 | } |
|
190 | } | |
190 | } |
|
191 | } | |
191 |
|
192 | |||
192 | if ( status_spw == RTEMS_SUCCESSFUL) // (3) start the link |
|
193 | if ( status_spw == RTEMS_SUCCESSFUL) // (3) start the link | |
193 | { |
|
194 | { | |
194 | status_spw = spacewire_start_link( fdSPW ); |
|
195 | status_spw = spacewire_start_link( fdSPW ); | |
195 | if ( status_spw != RTEMS_SUCCESSFUL ) |
|
196 | if ( status_spw != RTEMS_SUCCESSFUL ) | |
196 | { |
|
197 | { | |
197 | 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 ) | |
198 | } |
|
199 | } | |
199 | } |
|
200 | } | |
200 | // </SPACEWIRE INITIALIZATION> |
|
201 | // </SPACEWIRE INITIALIZATION> | |
201 | // *************************** |
|
202 | // *************************** | |
202 |
|
203 | |||
203 | status = start_all_tasks(); // start all tasks |
|
204 | status = start_all_tasks(); // start all tasks | |
204 | if (status != RTEMS_SUCCESSFUL) |
|
205 | if (status != RTEMS_SUCCESSFUL) | |
205 | { |
|
206 | { | |
206 | PRINTF1("in INIT *** ERR in start_all_tasks, code %d", status) |
|
207 | PRINTF1("in INIT *** ERR in start_all_tasks, code %d", status) | |
207 | } |
|
208 | } | |
208 |
|
209 | |||
209 | // 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 | |
210 | status = start_recv_send_tasks(); |
|
211 | status = start_recv_send_tasks(); | |
211 | if ( status != RTEMS_SUCCESSFUL ) |
|
212 | if ( status != RTEMS_SUCCESSFUL ) | |
212 | { |
|
213 | { | |
213 | 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 ) | |
214 | } |
|
215 | } | |
215 |
|
216 | |||
216 | // 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 | |
217 | 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) | |
218 | if (status != RTEMS_SUCCESSFUL) |
|
219 | if (status != RTEMS_SUCCESSFUL) | |
219 | { |
|
220 | { | |
220 | 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) | |
221 | } |
|
222 | } | |
222 |
|
223 | |||
223 | //****************************** |
|
224 | //****************************** | |
224 | // <SPECTRAL MATRICES SIMULATOR> |
|
225 | // <SPECTRAL MATRICES SIMULATOR> | |
225 | LEON_Mask_interrupt( IRQ_SM_SIMULATOR ); |
|
226 | LEON_Mask_interrupt( IRQ_SM_SIMULATOR ); | |
226 | 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, | |
227 | IRQ_SPARC_SM_SIMULATOR, spectral_matrices_isr_simu ); |
|
228 | IRQ_SPARC_SM_SIMULATOR, spectral_matrices_isr_simu ); | |
228 | // </SPECTRAL MATRICES SIMULATOR> |
|
229 | // </SPECTRAL MATRICES SIMULATOR> | |
229 | //******************************* |
|
230 | //******************************* | |
230 |
|
231 | |||
231 | // configure IRQ handling for the waveform picker unit |
|
232 | // configure IRQ handling for the waveform picker unit | |
232 | status = rtems_interrupt_catch( waveforms_isr, |
|
233 | status = rtems_interrupt_catch( waveforms_isr, | |
233 | IRQ_SPARC_WAVEFORM_PICKER, |
|
234 | IRQ_SPARC_WAVEFORM_PICKER, | |
234 | &old_isr_handler) ; |
|
235 | &old_isr_handler) ; | |
235 | // configure IRQ handling for the spectral matrices unit |
|
236 | // configure IRQ handling for the spectral matrices unit | |
236 | status = rtems_interrupt_catch( spectral_matrices_isr, |
|
237 | status = rtems_interrupt_catch( spectral_matrices_isr, | |
237 | IRQ_SPARC_SPECTRAL_MATRIX, |
|
238 | IRQ_SPARC_SPECTRAL_MATRIX, | |
238 | &old_isr_handler) ; |
|
239 | &old_isr_handler) ; | |
239 |
|
240 | |||
240 | // 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 | |
241 | if ( status_spw != RTEMS_SUCCESSFUL ) |
|
242 | if ( status_spw != RTEMS_SUCCESSFUL ) | |
242 | { |
|
243 | { | |
243 | status = rtems_event_send( Task_id[TASKID_SPIQ], SPW_LINKERR_EVENT ); |
|
244 | status = rtems_event_send( Task_id[TASKID_SPIQ], SPW_LINKERR_EVENT ); | |
244 | if ( status != RTEMS_SUCCESSFUL ) { |
|
245 | if ( status != RTEMS_SUCCESSFUL ) { | |
245 | 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 ) | |
246 | } |
|
247 | } | |
247 | } |
|
248 | } | |
248 |
|
249 | |||
249 | BOOT_PRINTF("delete INIT\n") |
|
250 | BOOT_PRINTF("delete INIT\n") | |
250 |
|
251 | |||
|
252 | set_hk_lfr_sc_potential_flag( true ); | |||
|
253 | ||||
251 | status = rtems_task_delete(RTEMS_SELF); |
|
254 | status = rtems_task_delete(RTEMS_SELF); | |
252 |
|
255 | |||
253 | } |
|
256 | } | |
254 |
|
257 | |||
255 | void init_local_mode_parameters( void ) |
|
258 | void init_local_mode_parameters( void ) | |
256 | { |
|
259 | { | |
257 | /** This function initialize the param_local global variable with default values. |
|
260 | /** This function initialize the param_local global variable with default values. | |
258 | * |
|
261 | * | |
259 | */ |
|
262 | */ | |
260 |
|
263 | |||
261 | unsigned int i; |
|
264 | unsigned int i; | |
262 |
|
265 | |||
263 | // LOCAL PARAMETERS |
|
266 | // LOCAL PARAMETERS | |
264 |
|
267 | |||
265 | 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) | |
266 | 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) | |
267 | 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) | |
268 |
|
271 | |||
269 | // init sequence counters |
|
272 | // init sequence counters | |
270 |
|
273 | |||
271 | for(i = 0; i<SEQ_CNT_NB_DEST_ID; i++) |
|
274 | for(i = 0; i<SEQ_CNT_NB_DEST_ID; i++) | |
272 | { |
|
275 | { | |
273 | sequenceCounters_TC_EXE[i] = 0x00; |
|
276 | sequenceCounters_TC_EXE[i] = 0x00; | |
274 | } |
|
277 | } | |
275 | sequenceCounters_SCIENCE_NORMAL_BURST = 0x00; |
|
278 | sequenceCounters_SCIENCE_NORMAL_BURST = 0x00; | |
276 | sequenceCounters_SCIENCE_SBM1_SBM2 = 0x00; |
|
279 | sequenceCounters_SCIENCE_SBM1_SBM2 = 0x00; | |
277 | sequenceCounterHK = TM_PACKET_SEQ_CTRL_STANDALONE << 8; |
|
280 | sequenceCounterHK = TM_PACKET_SEQ_CTRL_STANDALONE << 8; | |
278 | sequenceCounterParameterDump = TM_PACKET_SEQ_CTRL_STANDALONE << 8; |
|
281 | sequenceCounterParameterDump = TM_PACKET_SEQ_CTRL_STANDALONE << 8; | |
279 | } |
|
282 | } | |
280 |
|
283 | |||
281 | void reset_local_time( void ) |
|
284 | void reset_local_time( void ) | |
282 | { |
|
285 | { | |
283 | 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 | |
284 | } |
|
287 | } | |
285 |
|
288 | |||
286 | void create_names( void ) // create all names for tasks and queues |
|
289 | void create_names( void ) // create all names for tasks and queues | |
287 | { |
|
290 | { | |
288 | /** 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. | |
289 | * |
|
292 | * | |
290 | * @return RTEMS directive status codes: |
|
293 | * @return RTEMS directive status codes: | |
291 | * - RTEMS_SUCCESSFUL - successful completion |
|
294 | * - RTEMS_SUCCESSFUL - successful completion | |
292 | * |
|
295 | * | |
293 | */ |
|
296 | */ | |
294 |
|
297 | |||
295 | // task names |
|
298 | // task names | |
296 | Task_name[TASKID_RECV] = rtems_build_name( 'R', 'E', 'C', 'V' ); |
|
299 | Task_name[TASKID_RECV] = rtems_build_name( 'R', 'E', 'C', 'V' ); | |
297 | Task_name[TASKID_ACTN] = rtems_build_name( 'A', 'C', 'T', 'N' ); |
|
300 | Task_name[TASKID_ACTN] = rtems_build_name( 'A', 'C', 'T', 'N' ); | |
298 | Task_name[TASKID_SPIQ] = rtems_build_name( 'S', 'P', 'I', 'Q' ); |
|
301 | Task_name[TASKID_SPIQ] = rtems_build_name( 'S', 'P', 'I', 'Q' ); | |
299 | Task_name[TASKID_STAT] = rtems_build_name( 'S', 'T', 'A', 'T' ); |
|
302 | Task_name[TASKID_STAT] = rtems_build_name( 'S', 'T', 'A', 'T' ); | |
300 | Task_name[TASKID_AVF0] = rtems_build_name( 'A', 'V', 'F', '0' ); |
|
303 | Task_name[TASKID_AVF0] = rtems_build_name( 'A', 'V', 'F', '0' ); | |
301 | Task_name[TASKID_SWBD] = rtems_build_name( 'S', 'W', 'B', 'D' ); |
|
304 | Task_name[TASKID_SWBD] = rtems_build_name( 'S', 'W', 'B', 'D' ); | |
302 | Task_name[TASKID_WFRM] = rtems_build_name( 'W', 'F', 'R', 'M' ); |
|
305 | Task_name[TASKID_WFRM] = rtems_build_name( 'W', 'F', 'R', 'M' ); | |
303 | Task_name[TASKID_DUMB] = rtems_build_name( 'D', 'U', 'M', 'B' ); |
|
306 | Task_name[TASKID_DUMB] = rtems_build_name( 'D', 'U', 'M', 'B' ); | |
304 | Task_name[TASKID_HOUS] = rtems_build_name( 'H', 'O', 'U', 'S' ); |
|
307 | Task_name[TASKID_HOUS] = rtems_build_name( 'H', 'O', 'U', 'S' ); | |
305 | Task_name[TASKID_PRC0] = rtems_build_name( 'P', 'R', 'C', '0' ); |
|
308 | Task_name[TASKID_PRC0] = rtems_build_name( 'P', 'R', 'C', '0' ); | |
306 | Task_name[TASKID_CWF3] = rtems_build_name( 'C', 'W', 'F', '3' ); |
|
309 | Task_name[TASKID_CWF3] = rtems_build_name( 'C', 'W', 'F', '3' ); | |
307 | Task_name[TASKID_CWF2] = rtems_build_name( 'C', 'W', 'F', '2' ); |
|
310 | Task_name[TASKID_CWF2] = rtems_build_name( 'C', 'W', 'F', '2' ); | |
308 | Task_name[TASKID_CWF1] = rtems_build_name( 'C', 'W', 'F', '1' ); |
|
311 | Task_name[TASKID_CWF1] = rtems_build_name( 'C', 'W', 'F', '1' ); | |
309 | Task_name[TASKID_SEND] = rtems_build_name( 'S', 'E', 'N', 'D' ); |
|
312 | Task_name[TASKID_SEND] = rtems_build_name( 'S', 'E', 'N', 'D' ); | |
310 | Task_name[TASKID_WTDG] = rtems_build_name( 'W', 'T', 'D', 'G' ); |
|
313 | Task_name[TASKID_WTDG] = rtems_build_name( 'W', 'T', 'D', 'G' ); | |
311 | Task_name[TASKID_AVF1] = rtems_build_name( 'A', 'V', 'F', '1' ); |
|
314 | Task_name[TASKID_AVF1] = rtems_build_name( 'A', 'V', 'F', '1' ); | |
312 | Task_name[TASKID_PRC1] = rtems_build_name( 'P', 'R', 'C', '1' ); |
|
315 | Task_name[TASKID_PRC1] = rtems_build_name( 'P', 'R', 'C', '1' ); | |
313 | Task_name[TASKID_AVF2] = rtems_build_name( 'A', 'V', 'F', '2' ); |
|
316 | Task_name[TASKID_AVF2] = rtems_build_name( 'A', 'V', 'F', '2' ); | |
314 | Task_name[TASKID_PRC2] = rtems_build_name( 'P', 'R', 'C', '2' ); |
|
317 | Task_name[TASKID_PRC2] = rtems_build_name( 'P', 'R', 'C', '2' ); | |
315 |
|
318 | |||
316 | // rate monotonic period names |
|
319 | // rate monotonic period names | |
317 | name_hk_rate_monotonic = rtems_build_name( 'H', 'O', 'U', 'S' ); |
|
320 | name_hk_rate_monotonic = rtems_build_name( 'H', 'O', 'U', 'S' ); | |
318 |
|
321 | |||
319 | misc_name[QUEUE_RECV] = rtems_build_name( 'Q', '_', 'R', 'V' ); |
|
322 | misc_name[QUEUE_RECV] = rtems_build_name( 'Q', '_', 'R', 'V' ); | |
320 | misc_name[QUEUE_SEND] = rtems_build_name( 'Q', '_', 'S', 'D' ); |
|
323 | misc_name[QUEUE_SEND] = rtems_build_name( 'Q', '_', 'S', 'D' ); | |
321 | misc_name[QUEUE_PRC0] = rtems_build_name( 'Q', '_', 'P', '0' ); |
|
324 | misc_name[QUEUE_PRC0] = rtems_build_name( 'Q', '_', 'P', '0' ); | |
322 | misc_name[QUEUE_PRC1] = rtems_build_name( 'Q', '_', 'P', '1' ); |
|
325 | misc_name[QUEUE_PRC1] = rtems_build_name( 'Q', '_', 'P', '1' ); | |
323 | misc_name[QUEUE_PRC2] = rtems_build_name( 'Q', '_', 'P', '2' ); |
|
326 | misc_name[QUEUE_PRC2] = rtems_build_name( 'Q', '_', 'P', '2' ); | |
324 | } |
|
327 | } | |
325 |
|
328 | |||
326 | 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 | |
327 | { |
|
330 | { | |
328 | /** This function creates all RTEMS tasks used in the software. |
|
331 | /** This function creates all RTEMS tasks used in the software. | |
329 | * |
|
332 | * | |
330 | * @return RTEMS directive status codes: |
|
333 | * @return RTEMS directive status codes: | |
331 | * - RTEMS_SUCCESSFUL - task created successfully |
|
334 | * - RTEMS_SUCCESSFUL - task created successfully | |
332 | * - RTEMS_INVALID_ADDRESS - id is NULL |
|
335 | * - RTEMS_INVALID_ADDRESS - id is NULL | |
333 | * - RTEMS_INVALID_NAME - invalid task name |
|
336 | * - RTEMS_INVALID_NAME - invalid task name | |
334 | * - RTEMS_INVALID_PRIORITY - invalid task priority |
|
337 | * - RTEMS_INVALID_PRIORITY - invalid task priority | |
335 | * - RTEMS_MP_NOT_CONFIGURED - multiprocessing not configured |
|
338 | * - RTEMS_MP_NOT_CONFIGURED - multiprocessing not configured | |
336 | * - RTEMS_TOO_MANY - too many tasks created |
|
339 | * - RTEMS_TOO_MANY - too many tasks created | |
337 | * - RTEMS_UNSATISFIED - not enough memory for stack/FP context |
|
340 | * - RTEMS_UNSATISFIED - not enough memory for stack/FP context | |
338 | * - RTEMS_TOO_MANY - too many global objects |
|
341 | * - RTEMS_TOO_MANY - too many global objects | |
339 | * |
|
342 | * | |
340 | */ |
|
343 | */ | |
341 |
|
344 | |||
342 | rtems_status_code status; |
|
345 | rtems_status_code status; | |
343 |
|
346 | |||
344 | //********** |
|
347 | //********** | |
345 | // SPACEWIRE |
|
348 | // SPACEWIRE | |
346 | // RECV |
|
349 | // RECV | |
347 | status = rtems_task_create( |
|
350 | status = rtems_task_create( | |
348 | Task_name[TASKID_RECV], TASK_PRIORITY_RECV, RTEMS_MINIMUM_STACK_SIZE, |
|
351 | Task_name[TASKID_RECV], TASK_PRIORITY_RECV, RTEMS_MINIMUM_STACK_SIZE, | |
349 | RTEMS_DEFAULT_MODES, |
|
352 | RTEMS_DEFAULT_MODES, | |
350 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_RECV] |
|
353 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_RECV] | |
351 | ); |
|
354 | ); | |
352 | if (status == RTEMS_SUCCESSFUL) // SEND |
|
355 | if (status == RTEMS_SUCCESSFUL) // SEND | |
353 | { |
|
356 | { | |
354 | status = rtems_task_create( |
|
357 | status = rtems_task_create( | |
355 | 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, | |
356 | RTEMS_DEFAULT_MODES, |
|
359 | RTEMS_DEFAULT_MODES, | |
357 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_SEND] |
|
360 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_SEND] | |
358 | ); |
|
361 | ); | |
359 | } |
|
362 | } | |
360 | if (status == RTEMS_SUCCESSFUL) // WTDG |
|
363 | if (status == RTEMS_SUCCESSFUL) // WTDG | |
361 | { |
|
364 | { | |
362 | status = rtems_task_create( |
|
365 | status = rtems_task_create( | |
363 | Task_name[TASKID_WTDG], TASK_PRIORITY_WTDG, RTEMS_MINIMUM_STACK_SIZE, |
|
366 | Task_name[TASKID_WTDG], TASK_PRIORITY_WTDG, RTEMS_MINIMUM_STACK_SIZE, | |
364 | RTEMS_DEFAULT_MODES, |
|
367 | RTEMS_DEFAULT_MODES, | |
365 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_WTDG] |
|
368 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_WTDG] | |
366 | ); |
|
369 | ); | |
367 | } |
|
370 | } | |
368 | if (status == RTEMS_SUCCESSFUL) // ACTN |
|
371 | if (status == RTEMS_SUCCESSFUL) // ACTN | |
369 | { |
|
372 | { | |
370 | status = rtems_task_create( |
|
373 | status = rtems_task_create( | |
371 | Task_name[TASKID_ACTN], TASK_PRIORITY_ACTN, RTEMS_MINIMUM_STACK_SIZE, |
|
374 | Task_name[TASKID_ACTN], TASK_PRIORITY_ACTN, RTEMS_MINIMUM_STACK_SIZE, | |
372 | RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT, |
|
375 | RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT, | |
373 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_ACTN] |
|
376 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_ACTN] | |
374 | ); |
|
377 | ); | |
375 | } |
|
378 | } | |
376 | if (status == RTEMS_SUCCESSFUL) // SPIQ |
|
379 | if (status == RTEMS_SUCCESSFUL) // SPIQ | |
377 | { |
|
380 | { | |
378 | status = rtems_task_create( |
|
381 | status = rtems_task_create( | |
379 | Task_name[TASKID_SPIQ], TASK_PRIORITY_SPIQ, RTEMS_MINIMUM_STACK_SIZE, |
|
382 | Task_name[TASKID_SPIQ], TASK_PRIORITY_SPIQ, RTEMS_MINIMUM_STACK_SIZE, | |
380 | RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT, |
|
383 | RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT, | |
381 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SPIQ] |
|
384 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SPIQ] | |
382 | ); |
|
385 | ); | |
383 | } |
|
386 | } | |
384 |
|
387 | |||
385 | //****************** |
|
388 | //****************** | |
386 | // SPECTRAL MATRICES |
|
389 | // SPECTRAL MATRICES | |
387 | if (status == RTEMS_SUCCESSFUL) // AVF0 |
|
390 | if (status == RTEMS_SUCCESSFUL) // AVF0 | |
388 | { |
|
391 | { | |
389 | status = rtems_task_create( |
|
392 | status = rtems_task_create( | |
390 | Task_name[TASKID_AVF0], TASK_PRIORITY_AVF0, RTEMS_MINIMUM_STACK_SIZE, |
|
393 | Task_name[TASKID_AVF0], TASK_PRIORITY_AVF0, RTEMS_MINIMUM_STACK_SIZE, | |
391 | RTEMS_DEFAULT_MODES, |
|
394 | RTEMS_DEFAULT_MODES, | |
392 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF0] |
|
395 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF0] | |
393 | ); |
|
396 | ); | |
394 | } |
|
397 | } | |
395 | if (status == RTEMS_SUCCESSFUL) // PRC0 |
|
398 | if (status == RTEMS_SUCCESSFUL) // PRC0 | |
396 | { |
|
399 | { | |
397 | status = rtems_task_create( |
|
400 | status = rtems_task_create( | |
398 | 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, | |
399 | RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT, |
|
402 | RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT, | |
400 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_PRC0] |
|
403 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_PRC0] | |
401 | ); |
|
404 | ); | |
402 | } |
|
405 | } | |
403 | if (status == RTEMS_SUCCESSFUL) // AVF1 |
|
406 | if (status == RTEMS_SUCCESSFUL) // AVF1 | |
404 | { |
|
407 | { | |
405 | status = rtems_task_create( |
|
408 | status = rtems_task_create( | |
406 | Task_name[TASKID_AVF1], TASK_PRIORITY_AVF1, RTEMS_MINIMUM_STACK_SIZE, |
|
409 | Task_name[TASKID_AVF1], TASK_PRIORITY_AVF1, RTEMS_MINIMUM_STACK_SIZE, | |
407 | RTEMS_DEFAULT_MODES, |
|
410 | RTEMS_DEFAULT_MODES, | |
408 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF1] |
|
411 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF1] | |
409 | ); |
|
412 | ); | |
410 | } |
|
413 | } | |
411 | if (status == RTEMS_SUCCESSFUL) // PRC1 |
|
414 | if (status == RTEMS_SUCCESSFUL) // PRC1 | |
412 | { |
|
415 | { | |
413 | status = rtems_task_create( |
|
416 | status = rtems_task_create( | |
414 | 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, | |
415 | RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT, |
|
418 | RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT, | |
416 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_PRC1] |
|
419 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_PRC1] | |
417 | ); |
|
420 | ); | |
418 | } |
|
421 | } | |
419 | if (status == RTEMS_SUCCESSFUL) // AVF2 |
|
422 | if (status == RTEMS_SUCCESSFUL) // AVF2 | |
420 | { |
|
423 | { | |
421 | status = rtems_task_create( |
|
424 | status = rtems_task_create( | |
422 | Task_name[TASKID_AVF2], TASK_PRIORITY_AVF2, RTEMS_MINIMUM_STACK_SIZE, |
|
425 | Task_name[TASKID_AVF2], TASK_PRIORITY_AVF2, RTEMS_MINIMUM_STACK_SIZE, | |
423 | RTEMS_DEFAULT_MODES, |
|
426 | RTEMS_DEFAULT_MODES, | |
424 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF2] |
|
427 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF2] | |
425 | ); |
|
428 | ); | |
426 | } |
|
429 | } | |
427 | if (status == RTEMS_SUCCESSFUL) // PRC2 |
|
430 | if (status == RTEMS_SUCCESSFUL) // PRC2 | |
428 | { |
|
431 | { | |
429 | status = rtems_task_create( |
|
432 | status = rtems_task_create( | |
430 | 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, | |
431 | RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT, |
|
434 | RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT, | |
432 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_PRC2] |
|
435 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_PRC2] | |
433 | ); |
|
436 | ); | |
434 | } |
|
437 | } | |
435 |
|
438 | |||
436 | //**************** |
|
439 | //**************** | |
437 | // WAVEFORM PICKER |
|
440 | // WAVEFORM PICKER | |
438 | if (status == RTEMS_SUCCESSFUL) // WFRM |
|
441 | if (status == RTEMS_SUCCESSFUL) // WFRM | |
439 | { |
|
442 | { | |
440 | status = rtems_task_create( |
|
443 | status = rtems_task_create( | |
441 | Task_name[TASKID_WFRM], TASK_PRIORITY_WFRM, RTEMS_MINIMUM_STACK_SIZE, |
|
444 | Task_name[TASKID_WFRM], TASK_PRIORITY_WFRM, RTEMS_MINIMUM_STACK_SIZE, | |
442 | RTEMS_DEFAULT_MODES, |
|
445 | RTEMS_DEFAULT_MODES, | |
443 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_WFRM] |
|
446 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_WFRM] | |
444 | ); |
|
447 | ); | |
445 | } |
|
448 | } | |
446 | if (status == RTEMS_SUCCESSFUL) // CWF3 |
|
449 | if (status == RTEMS_SUCCESSFUL) // CWF3 | |
447 | { |
|
450 | { | |
448 | status = rtems_task_create( |
|
451 | status = rtems_task_create( | |
449 | Task_name[TASKID_CWF3], TASK_PRIORITY_CWF3, RTEMS_MINIMUM_STACK_SIZE, |
|
452 | Task_name[TASKID_CWF3], TASK_PRIORITY_CWF3, RTEMS_MINIMUM_STACK_SIZE, | |
450 | RTEMS_DEFAULT_MODES, |
|
453 | RTEMS_DEFAULT_MODES, | |
451 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_CWF3] |
|
454 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_CWF3] | |
452 | ); |
|
455 | ); | |
453 | } |
|
456 | } | |
454 | if (status == RTEMS_SUCCESSFUL) // CWF2 |
|
457 | if (status == RTEMS_SUCCESSFUL) // CWF2 | |
455 | { |
|
458 | { | |
456 | status = rtems_task_create( |
|
459 | status = rtems_task_create( | |
457 | Task_name[TASKID_CWF2], TASK_PRIORITY_CWF2, RTEMS_MINIMUM_STACK_SIZE, |
|
460 | Task_name[TASKID_CWF2], TASK_PRIORITY_CWF2, RTEMS_MINIMUM_STACK_SIZE, | |
458 | RTEMS_DEFAULT_MODES, |
|
461 | RTEMS_DEFAULT_MODES, | |
459 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_CWF2] |
|
462 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_CWF2] | |
460 | ); |
|
463 | ); | |
461 | } |
|
464 | } | |
462 | if (status == RTEMS_SUCCESSFUL) // CWF1 |
|
465 | if (status == RTEMS_SUCCESSFUL) // CWF1 | |
463 | { |
|
466 | { | |
464 | status = rtems_task_create( |
|
467 | status = rtems_task_create( | |
465 | Task_name[TASKID_CWF1], TASK_PRIORITY_CWF1, RTEMS_MINIMUM_STACK_SIZE, |
|
468 | Task_name[TASKID_CWF1], TASK_PRIORITY_CWF1, RTEMS_MINIMUM_STACK_SIZE, | |
466 | RTEMS_DEFAULT_MODES, |
|
469 | RTEMS_DEFAULT_MODES, | |
467 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_CWF1] |
|
470 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_CWF1] | |
468 | ); |
|
471 | ); | |
469 | } |
|
472 | } | |
470 | if (status == RTEMS_SUCCESSFUL) // SWBD |
|
473 | if (status == RTEMS_SUCCESSFUL) // SWBD | |
471 | { |
|
474 | { | |
472 | status = rtems_task_create( |
|
475 | status = rtems_task_create( | |
473 | Task_name[TASKID_SWBD], TASK_PRIORITY_SWBD, RTEMS_MINIMUM_STACK_SIZE, |
|
476 | Task_name[TASKID_SWBD], TASK_PRIORITY_SWBD, RTEMS_MINIMUM_STACK_SIZE, | |
474 | RTEMS_DEFAULT_MODES, |
|
477 | RTEMS_DEFAULT_MODES, | |
475 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_SWBD] |
|
478 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_SWBD] | |
476 | ); |
|
479 | ); | |
477 | } |
|
480 | } | |
478 |
|
481 | |||
479 | //***** |
|
482 | //***** | |
480 | // MISC |
|
483 | // MISC | |
481 | if (status == RTEMS_SUCCESSFUL) // STAT |
|
484 | if (status == RTEMS_SUCCESSFUL) // STAT | |
482 | { |
|
485 | { | |
483 | status = rtems_task_create( |
|
486 | status = rtems_task_create( | |
484 | Task_name[TASKID_STAT], TASK_PRIORITY_STAT, RTEMS_MINIMUM_STACK_SIZE, |
|
487 | Task_name[TASKID_STAT], TASK_PRIORITY_STAT, RTEMS_MINIMUM_STACK_SIZE, | |
485 | RTEMS_DEFAULT_MODES, |
|
488 | RTEMS_DEFAULT_MODES, | |
486 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_STAT] |
|
489 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_STAT] | |
487 | ); |
|
490 | ); | |
488 | } |
|
491 | } | |
489 | if (status == RTEMS_SUCCESSFUL) // DUMB |
|
492 | if (status == RTEMS_SUCCESSFUL) // DUMB | |
490 | { |
|
493 | { | |
491 | status = rtems_task_create( |
|
494 | status = rtems_task_create( | |
492 | Task_name[TASKID_DUMB], TASK_PRIORITY_DUMB, RTEMS_MINIMUM_STACK_SIZE, |
|
495 | Task_name[TASKID_DUMB], TASK_PRIORITY_DUMB, RTEMS_MINIMUM_STACK_SIZE, | |
493 | RTEMS_DEFAULT_MODES, |
|
496 | RTEMS_DEFAULT_MODES, | |
494 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_DUMB] |
|
497 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_DUMB] | |
495 | ); |
|
498 | ); | |
496 | } |
|
499 | } | |
497 | if (status == RTEMS_SUCCESSFUL) // HOUS |
|
500 | if (status == RTEMS_SUCCESSFUL) // HOUS | |
498 | { |
|
501 | { | |
499 | status = rtems_task_create( |
|
502 | status = rtems_task_create( | |
500 | Task_name[TASKID_HOUS], TASK_PRIORITY_HOUS, RTEMS_MINIMUM_STACK_SIZE, |
|
503 | Task_name[TASKID_HOUS], TASK_PRIORITY_HOUS, RTEMS_MINIMUM_STACK_SIZE, | |
501 | RTEMS_DEFAULT_MODES, |
|
504 | RTEMS_DEFAULT_MODES, | |
502 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_HOUS] |
|
505 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_HOUS] | |
503 | ); |
|
506 | ); | |
504 | } |
|
507 | } | |
505 |
|
508 | |||
506 | return status; |
|
509 | return status; | |
507 | } |
|
510 | } | |
508 |
|
511 | |||
509 | int start_recv_send_tasks( void ) |
|
512 | int start_recv_send_tasks( void ) | |
510 | { |
|
513 | { | |
511 | rtems_status_code status; |
|
514 | rtems_status_code status; | |
512 |
|
515 | |||
513 | status = rtems_task_start( Task_id[TASKID_RECV], recv_task, 1 ); |
|
516 | status = rtems_task_start( Task_id[TASKID_RECV], recv_task, 1 ); | |
514 | if (status!=RTEMS_SUCCESSFUL) { |
|
517 | if (status!=RTEMS_SUCCESSFUL) { | |
515 | BOOT_PRINTF("in INIT *** Error starting TASK_RECV\n") |
|
518 | BOOT_PRINTF("in INIT *** Error starting TASK_RECV\n") | |
516 | } |
|
519 | } | |
517 |
|
520 | |||
518 | if (status == RTEMS_SUCCESSFUL) // SEND |
|
521 | if (status == RTEMS_SUCCESSFUL) // SEND | |
519 | { |
|
522 | { | |
520 | status = rtems_task_start( Task_id[TASKID_SEND], send_task, 1 ); |
|
523 | status = rtems_task_start( Task_id[TASKID_SEND], send_task, 1 ); | |
521 | if (status!=RTEMS_SUCCESSFUL) { |
|
524 | if (status!=RTEMS_SUCCESSFUL) { | |
522 | BOOT_PRINTF("in INIT *** Error starting TASK_SEND\n") |
|
525 | BOOT_PRINTF("in INIT *** Error starting TASK_SEND\n") | |
523 | } |
|
526 | } | |
524 | } |
|
527 | } | |
525 |
|
528 | |||
526 | return status; |
|
529 | return status; | |
527 | } |
|
530 | } | |
528 |
|
531 | |||
529 | 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 | |
530 | { |
|
533 | { | |
531 | /** This function starts all RTEMS tasks used in the software. |
|
534 | /** This function starts all RTEMS tasks used in the software. | |
532 | * |
|
535 | * | |
533 | * @return RTEMS directive status codes: |
|
536 | * @return RTEMS directive status codes: | |
534 | * - RTEMS_SUCCESSFUL - ask started successfully |
|
537 | * - RTEMS_SUCCESSFUL - ask started successfully | |
535 | * - RTEMS_INVALID_ADDRESS - invalid task entry point |
|
538 | * - RTEMS_INVALID_ADDRESS - invalid task entry point | |
536 | * - RTEMS_INVALID_ID - invalid task id |
|
539 | * - RTEMS_INVALID_ID - invalid task id | |
537 | * - RTEMS_INCORRECT_STATE - task not in the dormant state |
|
540 | * - RTEMS_INCORRECT_STATE - task not in the dormant state | |
538 | * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot start remote task |
|
541 | * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot start remote task | |
539 | * |
|
542 | * | |
540 | */ |
|
543 | */ | |
541 | // starts all the tasks fot eh flight software |
|
544 | // starts all the tasks fot eh flight software | |
542 |
|
545 | |||
543 | rtems_status_code status; |
|
546 | rtems_status_code status; | |
544 |
|
547 | |||
545 | //********** |
|
548 | //********** | |
546 | // SPACEWIRE |
|
549 | // SPACEWIRE | |
547 | status = rtems_task_start( Task_id[TASKID_SPIQ], spiq_task, 1 ); |
|
550 | status = rtems_task_start( Task_id[TASKID_SPIQ], spiq_task, 1 ); | |
548 | if (status!=RTEMS_SUCCESSFUL) { |
|
551 | if (status!=RTEMS_SUCCESSFUL) { | |
549 | BOOT_PRINTF("in INIT *** Error starting TASK_SPIQ\n") |
|
552 | BOOT_PRINTF("in INIT *** Error starting TASK_SPIQ\n") | |
550 | } |
|
553 | } | |
551 |
|
554 | |||
552 | if (status == RTEMS_SUCCESSFUL) // WTDG |
|
555 | if (status == RTEMS_SUCCESSFUL) // WTDG | |
553 | { |
|
556 | { | |
554 | status = rtems_task_start( Task_id[TASKID_WTDG], wtdg_task, 1 ); |
|
557 | status = rtems_task_start( Task_id[TASKID_WTDG], wtdg_task, 1 ); | |
555 | if (status!=RTEMS_SUCCESSFUL) { |
|
558 | if (status!=RTEMS_SUCCESSFUL) { | |
556 | BOOT_PRINTF("in INIT *** Error starting TASK_WTDG\n") |
|
559 | BOOT_PRINTF("in INIT *** Error starting TASK_WTDG\n") | |
557 | } |
|
560 | } | |
558 | } |
|
561 | } | |
559 |
|
562 | |||
560 | if (status == RTEMS_SUCCESSFUL) // ACTN |
|
563 | if (status == RTEMS_SUCCESSFUL) // ACTN | |
561 | { |
|
564 | { | |
562 | status = rtems_task_start( Task_id[TASKID_ACTN], actn_task, 1 ); |
|
565 | status = rtems_task_start( Task_id[TASKID_ACTN], actn_task, 1 ); | |
563 | if (status!=RTEMS_SUCCESSFUL) { |
|
566 | if (status!=RTEMS_SUCCESSFUL) { | |
564 | BOOT_PRINTF("in INIT *** Error starting TASK_ACTN\n") |
|
567 | BOOT_PRINTF("in INIT *** Error starting TASK_ACTN\n") | |
565 | } |
|
568 | } | |
566 | } |
|
569 | } | |
567 |
|
570 | |||
568 | //****************** |
|
571 | //****************** | |
569 | // SPECTRAL MATRICES |
|
572 | // SPECTRAL MATRICES | |
570 | if (status == RTEMS_SUCCESSFUL) // AVF0 |
|
573 | if (status == RTEMS_SUCCESSFUL) // AVF0 | |
571 | { |
|
574 | { | |
572 | 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 ); | |
573 | if (status!=RTEMS_SUCCESSFUL) { |
|
576 | if (status!=RTEMS_SUCCESSFUL) { | |
574 | BOOT_PRINTF("in INIT *** Error starting TASK_AVF0\n") |
|
577 | BOOT_PRINTF("in INIT *** Error starting TASK_AVF0\n") | |
575 | } |
|
578 | } | |
576 | } |
|
579 | } | |
577 | if (status == RTEMS_SUCCESSFUL) // PRC0 |
|
580 | if (status == RTEMS_SUCCESSFUL) // PRC0 | |
578 | { |
|
581 | { | |
579 | 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 ); | |
580 | if (status!=RTEMS_SUCCESSFUL) { |
|
583 | if (status!=RTEMS_SUCCESSFUL) { | |
581 | BOOT_PRINTF("in INIT *** Error starting TASK_PRC0\n") |
|
584 | BOOT_PRINTF("in INIT *** Error starting TASK_PRC0\n") | |
582 | } |
|
585 | } | |
583 | } |
|
586 | } | |
584 | if (status == RTEMS_SUCCESSFUL) // AVF1 |
|
587 | if (status == RTEMS_SUCCESSFUL) // AVF1 | |
585 | { |
|
588 | { | |
586 | 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 ); | |
587 | if (status!=RTEMS_SUCCESSFUL) { |
|
590 | if (status!=RTEMS_SUCCESSFUL) { | |
588 | BOOT_PRINTF("in INIT *** Error starting TASK_AVF1\n") |
|
591 | BOOT_PRINTF("in INIT *** Error starting TASK_AVF1\n") | |
589 | } |
|
592 | } | |
590 | } |
|
593 | } | |
591 | if (status == RTEMS_SUCCESSFUL) // PRC1 |
|
594 | if (status == RTEMS_SUCCESSFUL) // PRC1 | |
592 | { |
|
595 | { | |
593 | 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 ); | |
594 | if (status!=RTEMS_SUCCESSFUL) { |
|
597 | if (status!=RTEMS_SUCCESSFUL) { | |
595 | BOOT_PRINTF("in INIT *** Error starting TASK_PRC1\n") |
|
598 | BOOT_PRINTF("in INIT *** Error starting TASK_PRC1\n") | |
596 | } |
|
599 | } | |
597 | } |
|
600 | } | |
598 | if (status == RTEMS_SUCCESSFUL) // AVF2 |
|
601 | if (status == RTEMS_SUCCESSFUL) // AVF2 | |
599 | { |
|
602 | { | |
600 | status = rtems_task_start( Task_id[TASKID_AVF2], avf2_task, 1 ); |
|
603 | status = rtems_task_start( Task_id[TASKID_AVF2], avf2_task, 1 ); | |
601 | if (status!=RTEMS_SUCCESSFUL) { |
|
604 | if (status!=RTEMS_SUCCESSFUL) { | |
602 | BOOT_PRINTF("in INIT *** Error starting TASK_AVF2\n") |
|
605 | BOOT_PRINTF("in INIT *** Error starting TASK_AVF2\n") | |
603 | } |
|
606 | } | |
604 | } |
|
607 | } | |
605 | if (status == RTEMS_SUCCESSFUL) // PRC2 |
|
608 | if (status == RTEMS_SUCCESSFUL) // PRC2 | |
606 | { |
|
609 | { | |
607 | status = rtems_task_start( Task_id[TASKID_PRC2], prc2_task, 1 ); |
|
610 | status = rtems_task_start( Task_id[TASKID_PRC2], prc2_task, 1 ); | |
608 | if (status!=RTEMS_SUCCESSFUL) { |
|
611 | if (status!=RTEMS_SUCCESSFUL) { | |
609 | BOOT_PRINTF("in INIT *** Error starting TASK_PRC2\n") |
|
612 | BOOT_PRINTF("in INIT *** Error starting TASK_PRC2\n") | |
610 | } |
|
613 | } | |
611 | } |
|
614 | } | |
612 |
|
615 | |||
613 | //**************** |
|
616 | //**************** | |
614 | // WAVEFORM PICKER |
|
617 | // WAVEFORM PICKER | |
615 | if (status == RTEMS_SUCCESSFUL) // WFRM |
|
618 | if (status == RTEMS_SUCCESSFUL) // WFRM | |
616 | { |
|
619 | { | |
617 | status = rtems_task_start( Task_id[TASKID_WFRM], wfrm_task, 1 ); |
|
620 | status = rtems_task_start( Task_id[TASKID_WFRM], wfrm_task, 1 ); | |
618 | if (status!=RTEMS_SUCCESSFUL) { |
|
621 | if (status!=RTEMS_SUCCESSFUL) { | |
619 | BOOT_PRINTF("in INIT *** Error starting TASK_WFRM\n") |
|
622 | BOOT_PRINTF("in INIT *** Error starting TASK_WFRM\n") | |
620 | } |
|
623 | } | |
621 | } |
|
624 | } | |
622 | if (status == RTEMS_SUCCESSFUL) // CWF3 |
|
625 | if (status == RTEMS_SUCCESSFUL) // CWF3 | |
623 | { |
|
626 | { | |
624 | status = rtems_task_start( Task_id[TASKID_CWF3], cwf3_task, 1 ); |
|
627 | status = rtems_task_start( Task_id[TASKID_CWF3], cwf3_task, 1 ); | |
625 | if (status!=RTEMS_SUCCESSFUL) { |
|
628 | if (status!=RTEMS_SUCCESSFUL) { | |
626 | BOOT_PRINTF("in INIT *** Error starting TASK_CWF3\n") |
|
629 | BOOT_PRINTF("in INIT *** Error starting TASK_CWF3\n") | |
627 | } |
|
630 | } | |
628 | } |
|
631 | } | |
629 | if (status == RTEMS_SUCCESSFUL) // CWF2 |
|
632 | if (status == RTEMS_SUCCESSFUL) // CWF2 | |
630 | { |
|
633 | { | |
631 | status = rtems_task_start( Task_id[TASKID_CWF2], cwf2_task, 1 ); |
|
634 | status = rtems_task_start( Task_id[TASKID_CWF2], cwf2_task, 1 ); | |
632 | if (status!=RTEMS_SUCCESSFUL) { |
|
635 | if (status!=RTEMS_SUCCESSFUL) { | |
633 | BOOT_PRINTF("in INIT *** Error starting TASK_CWF2\n") |
|
636 | BOOT_PRINTF("in INIT *** Error starting TASK_CWF2\n") | |
634 | } |
|
637 | } | |
635 | } |
|
638 | } | |
636 | if (status == RTEMS_SUCCESSFUL) // CWF1 |
|
639 | if (status == RTEMS_SUCCESSFUL) // CWF1 | |
637 | { |
|
640 | { | |
638 | status = rtems_task_start( Task_id[TASKID_CWF1], cwf1_task, 1 ); |
|
641 | status = rtems_task_start( Task_id[TASKID_CWF1], cwf1_task, 1 ); | |
639 | if (status!=RTEMS_SUCCESSFUL) { |
|
642 | if (status!=RTEMS_SUCCESSFUL) { | |
640 | BOOT_PRINTF("in INIT *** Error starting TASK_CWF1\n") |
|
643 | BOOT_PRINTF("in INIT *** Error starting TASK_CWF1\n") | |
641 | } |
|
644 | } | |
642 | } |
|
645 | } | |
643 | if (status == RTEMS_SUCCESSFUL) // SWBD |
|
646 | if (status == RTEMS_SUCCESSFUL) // SWBD | |
644 | { |
|
647 | { | |
645 | status = rtems_task_start( Task_id[TASKID_SWBD], swbd_task, 1 ); |
|
648 | status = rtems_task_start( Task_id[TASKID_SWBD], swbd_task, 1 ); | |
646 | if (status!=RTEMS_SUCCESSFUL) { |
|
649 | if (status!=RTEMS_SUCCESSFUL) { | |
647 | BOOT_PRINTF("in INIT *** Error starting TASK_SWBD\n") |
|
650 | BOOT_PRINTF("in INIT *** Error starting TASK_SWBD\n") | |
648 | } |
|
651 | } | |
649 | } |
|
652 | } | |
650 |
|
653 | |||
651 | //***** |
|
654 | //***** | |
652 | // MISC |
|
655 | // MISC | |
653 | if (status == RTEMS_SUCCESSFUL) // HOUS |
|
656 | if (status == RTEMS_SUCCESSFUL) // HOUS | |
654 | { |
|
657 | { | |
655 | status = rtems_task_start( Task_id[TASKID_HOUS], hous_task, 1 ); |
|
658 | status = rtems_task_start( Task_id[TASKID_HOUS], hous_task, 1 ); | |
656 | if (status!=RTEMS_SUCCESSFUL) { |
|
659 | if (status!=RTEMS_SUCCESSFUL) { | |
657 | BOOT_PRINTF("in INIT *** Error starting TASK_HOUS\n") |
|
660 | BOOT_PRINTF("in INIT *** Error starting TASK_HOUS\n") | |
658 | } |
|
661 | } | |
659 | } |
|
662 | } | |
660 | if (status == RTEMS_SUCCESSFUL) // DUMB |
|
663 | if (status == RTEMS_SUCCESSFUL) // DUMB | |
661 | { |
|
664 | { | |
662 | status = rtems_task_start( Task_id[TASKID_DUMB], dumb_task, 1 ); |
|
665 | status = rtems_task_start( Task_id[TASKID_DUMB], dumb_task, 1 ); | |
663 | if (status!=RTEMS_SUCCESSFUL) { |
|
666 | if (status!=RTEMS_SUCCESSFUL) { | |
664 | BOOT_PRINTF("in INIT *** Error starting TASK_DUMB\n") |
|
667 | BOOT_PRINTF("in INIT *** Error starting TASK_DUMB\n") | |
665 | } |
|
668 | } | |
666 | } |
|
669 | } | |
667 | if (status == RTEMS_SUCCESSFUL) // STAT |
|
670 | if (status == RTEMS_SUCCESSFUL) // STAT | |
668 | { |
|
671 | { | |
669 | status = rtems_task_start( Task_id[TASKID_STAT], stat_task, 1 ); |
|
672 | status = rtems_task_start( Task_id[TASKID_STAT], stat_task, 1 ); | |
670 | if (status!=RTEMS_SUCCESSFUL) { |
|
673 | if (status!=RTEMS_SUCCESSFUL) { | |
671 | BOOT_PRINTF("in INIT *** Error starting TASK_STAT\n") |
|
674 | BOOT_PRINTF("in INIT *** Error starting TASK_STAT\n") | |
672 | } |
|
675 | } | |
673 | } |
|
676 | } | |
674 |
|
677 | |||
675 | return status; |
|
678 | return status; | |
676 | } |
|
679 | } | |
677 |
|
680 | |||
678 | 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 | |
679 | { |
|
682 | { | |
680 | rtems_status_code status_recv; |
|
683 | rtems_status_code status_recv; | |
681 | rtems_status_code status_send; |
|
684 | rtems_status_code status_send; | |
682 | rtems_status_code status_q_p0; |
|
685 | rtems_status_code status_q_p0; | |
683 | rtems_status_code status_q_p1; |
|
686 | rtems_status_code status_q_p1; | |
684 | rtems_status_code status_q_p2; |
|
687 | rtems_status_code status_q_p2; | |
685 | rtems_status_code ret; |
|
688 | rtems_status_code ret; | |
686 | rtems_id queue_id; |
|
689 | rtems_id queue_id; | |
687 |
|
690 | |||
688 | //**************************************** |
|
691 | //**************************************** | |
689 | // create the queue for handling valid TCs |
|
692 | // create the queue for handling valid TCs | |
690 | status_recv = rtems_message_queue_create( misc_name[QUEUE_RECV], |
|
693 | status_recv = rtems_message_queue_create( misc_name[QUEUE_RECV], | |
691 | MSG_QUEUE_COUNT_RECV, CCSDS_TC_PKT_MAX_SIZE, |
|
694 | MSG_QUEUE_COUNT_RECV, CCSDS_TC_PKT_MAX_SIZE, | |
692 | RTEMS_FIFO | RTEMS_LOCAL, &queue_id ); |
|
695 | RTEMS_FIFO | RTEMS_LOCAL, &queue_id ); | |
693 | if ( status_recv != RTEMS_SUCCESSFUL ) { |
|
696 | if ( status_recv != RTEMS_SUCCESSFUL ) { | |
694 | 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) | |
695 | } |
|
698 | } | |
696 |
|
699 | |||
697 | //************************************************ |
|
700 | //************************************************ | |
698 | // create the queue for handling TM packet sending |
|
701 | // create the queue for handling TM packet sending | |
699 | status_send = rtems_message_queue_create( misc_name[QUEUE_SEND], |
|
702 | status_send = rtems_message_queue_create( misc_name[QUEUE_SEND], | |
700 | MSG_QUEUE_COUNT_SEND, MSG_QUEUE_SIZE_SEND, |
|
703 | MSG_QUEUE_COUNT_SEND, MSG_QUEUE_SIZE_SEND, | |
701 | RTEMS_FIFO | RTEMS_LOCAL, &queue_id ); |
|
704 | RTEMS_FIFO | RTEMS_LOCAL, &queue_id ); | |
702 | if ( status_send != RTEMS_SUCCESSFUL ) { |
|
705 | if ( status_send != RTEMS_SUCCESSFUL ) { | |
703 | 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) | |
704 | } |
|
707 | } | |
705 |
|
708 | |||
706 | //***************************************************************************** |
|
709 | //***************************************************************************** | |
707 | // create the queue for handling averaged spectral matrices for processing @ f0 |
|
710 | // create the queue for handling averaged spectral matrices for processing @ f0 | |
708 | status_q_p0 = rtems_message_queue_create( misc_name[QUEUE_PRC0], |
|
711 | status_q_p0 = rtems_message_queue_create( misc_name[QUEUE_PRC0], | |
709 | MSG_QUEUE_COUNT_PRC0, MSG_QUEUE_SIZE_PRC0, |
|
712 | MSG_QUEUE_COUNT_PRC0, MSG_QUEUE_SIZE_PRC0, | |
710 | RTEMS_FIFO | RTEMS_LOCAL, &queue_id ); |
|
713 | RTEMS_FIFO | RTEMS_LOCAL, &queue_id ); | |
711 | if ( status_q_p0 != RTEMS_SUCCESSFUL ) { |
|
714 | if ( status_q_p0 != RTEMS_SUCCESSFUL ) { | |
712 | 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) | |
713 | } |
|
716 | } | |
714 |
|
717 | |||
715 | //***************************************************************************** |
|
718 | //***************************************************************************** | |
716 | // create the queue for handling averaged spectral matrices for processing @ f1 |
|
719 | // create the queue for handling averaged spectral matrices for processing @ f1 | |
717 | status_q_p1 = rtems_message_queue_create( misc_name[QUEUE_PRC1], |
|
720 | status_q_p1 = rtems_message_queue_create( misc_name[QUEUE_PRC1], | |
718 | MSG_QUEUE_COUNT_PRC1, MSG_QUEUE_SIZE_PRC1, |
|
721 | MSG_QUEUE_COUNT_PRC1, MSG_QUEUE_SIZE_PRC1, | |
719 | RTEMS_FIFO | RTEMS_LOCAL, &queue_id ); |
|
722 | RTEMS_FIFO | RTEMS_LOCAL, &queue_id ); | |
720 | if ( status_q_p1 != RTEMS_SUCCESSFUL ) { |
|
723 | if ( status_q_p1 != RTEMS_SUCCESSFUL ) { | |
721 | 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) | |
722 | } |
|
725 | } | |
723 |
|
726 | |||
724 | //***************************************************************************** |
|
727 | //***************************************************************************** | |
725 | // create the queue for handling averaged spectral matrices for processing @ f2 |
|
728 | // create the queue for handling averaged spectral matrices for processing @ f2 | |
726 | status_q_p2 = rtems_message_queue_create( misc_name[QUEUE_PRC2], |
|
729 | status_q_p2 = rtems_message_queue_create( misc_name[QUEUE_PRC2], | |
727 | MSG_QUEUE_COUNT_PRC2, MSG_QUEUE_SIZE_PRC2, |
|
730 | MSG_QUEUE_COUNT_PRC2, MSG_QUEUE_SIZE_PRC2, | |
728 | RTEMS_FIFO | RTEMS_LOCAL, &queue_id ); |
|
731 | RTEMS_FIFO | RTEMS_LOCAL, &queue_id ); | |
729 | if ( status_q_p2 != RTEMS_SUCCESSFUL ) { |
|
732 | if ( status_q_p2 != RTEMS_SUCCESSFUL ) { | |
730 | 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) | |
731 | } |
|
734 | } | |
732 |
|
735 | |||
733 | if ( status_recv != RTEMS_SUCCESSFUL ) |
|
736 | if ( status_recv != RTEMS_SUCCESSFUL ) | |
734 | { |
|
737 | { | |
735 | ret = status_recv; |
|
738 | ret = status_recv; | |
736 | } |
|
739 | } | |
737 | else if( status_send != RTEMS_SUCCESSFUL ) |
|
740 | else if( status_send != RTEMS_SUCCESSFUL ) | |
738 | { |
|
741 | { | |
739 | ret = status_send; |
|
742 | ret = status_send; | |
740 | } |
|
743 | } | |
741 | else if( status_q_p0 != RTEMS_SUCCESSFUL ) |
|
744 | else if( status_q_p0 != RTEMS_SUCCESSFUL ) | |
742 | { |
|
745 | { | |
743 | ret = status_q_p0; |
|
746 | ret = status_q_p0; | |
744 | } |
|
747 | } | |
745 | else if( status_q_p1 != RTEMS_SUCCESSFUL ) |
|
748 | else if( status_q_p1 != RTEMS_SUCCESSFUL ) | |
746 | { |
|
749 | { | |
747 | ret = status_q_p1; |
|
750 | ret = status_q_p1; | |
748 | } |
|
751 | } | |
749 | else |
|
752 | else | |
750 | { |
|
753 | { | |
751 | ret = status_q_p2; |
|
754 | ret = status_q_p2; | |
752 | } |
|
755 | } | |
753 |
|
756 | |||
754 | return ret; |
|
757 | return ret; | |
755 | } |
|
758 | } | |
756 |
|
759 | |||
757 | 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 ) | |
758 | { |
|
761 | { | |
759 | rtems_status_code status; |
|
762 | rtems_status_code status; | |
760 | rtems_name queue_name; |
|
763 | rtems_name queue_name; | |
761 |
|
764 | |||
762 | queue_name = rtems_build_name( 'Q', '_', 'S', 'D' ); |
|
765 | queue_name = rtems_build_name( 'Q', '_', 'S', 'D' ); | |
763 |
|
766 | |||
764 | status = rtems_message_queue_ident( queue_name, 0, queue_id ); |
|
767 | status = rtems_message_queue_ident( queue_name, 0, queue_id ); | |
765 |
|
768 | |||
766 | return status; |
|
769 | return status; | |
767 | } |
|
770 | } | |
768 |
|
771 | |||
769 | 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 ) | |
770 | { |
|
773 | { | |
771 | rtems_status_code status; |
|
774 | rtems_status_code status; | |
772 | rtems_name queue_name; |
|
775 | rtems_name queue_name; | |
773 |
|
776 | |||
774 | queue_name = rtems_build_name( 'Q', '_', 'R', 'V' ); |
|
777 | queue_name = rtems_build_name( 'Q', '_', 'R', 'V' ); | |
775 |
|
778 | |||
776 | status = rtems_message_queue_ident( queue_name, 0, queue_id ); |
|
779 | status = rtems_message_queue_ident( queue_name, 0, queue_id ); | |
777 |
|
780 | |||
778 | return status; |
|
781 | return status; | |
779 | } |
|
782 | } | |
780 |
|
783 | |||
781 | 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 ) | |
782 | { |
|
785 | { | |
783 | rtems_status_code status; |
|
786 | rtems_status_code status; | |
784 | rtems_name queue_name; |
|
787 | rtems_name queue_name; | |
785 |
|
788 | |||
786 | queue_name = rtems_build_name( 'Q', '_', 'P', '0' ); |
|
789 | queue_name = rtems_build_name( 'Q', '_', 'P', '0' ); | |
787 |
|
790 | |||
788 | status = rtems_message_queue_ident( queue_name, 0, queue_id ); |
|
791 | status = rtems_message_queue_ident( queue_name, 0, queue_id ); | |
789 |
|
792 | |||
790 | return status; |
|
793 | return status; | |
791 | } |
|
794 | } | |
792 |
|
795 | |||
793 | 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 ) | |
794 | { |
|
797 | { | |
795 | rtems_status_code status; |
|
798 | rtems_status_code status; | |
796 | rtems_name queue_name; |
|
799 | rtems_name queue_name; | |
797 |
|
800 | |||
798 | queue_name = rtems_build_name( 'Q', '_', 'P', '1' ); |
|
801 | queue_name = rtems_build_name( 'Q', '_', 'P', '1' ); | |
799 |
|
802 | |||
800 | status = rtems_message_queue_ident( queue_name, 0, queue_id ); |
|
803 | status = rtems_message_queue_ident( queue_name, 0, queue_id ); | |
801 |
|
804 | |||
802 | return status; |
|
805 | return status; | |
803 | } |
|
806 | } | |
804 |
|
807 | |||
805 | 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 ) | |
806 | { |
|
809 | { | |
807 | rtems_status_code status; |
|
810 | rtems_status_code status; | |
808 | rtems_name queue_name; |
|
811 | rtems_name queue_name; | |
809 |
|
812 | |||
810 | queue_name = rtems_build_name( 'Q', '_', 'P', '2' ); |
|
813 | queue_name = rtems_build_name( 'Q', '_', 'P', '2' ); | |
811 |
|
814 | |||
812 | status = rtems_message_queue_ident( queue_name, 0, queue_id ); |
|
815 | status = rtems_message_queue_ident( queue_name, 0, queue_id ); | |
813 |
|
816 | |||
814 | return status; |
|
817 | return status; | |
815 | } |
|
818 | } | |
816 |
|
819 | |||
817 | 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 ) | |
818 | { |
|
821 | { | |
819 | u_int32_t count; |
|
822 | u_int32_t count; | |
820 | rtems_status_code status; |
|
823 | rtems_status_code status; | |
821 |
|
824 | |||
822 | status = rtems_message_queue_get_number_pending( queue_id, &count ); |
|
825 | status = rtems_message_queue_get_number_pending( queue_id, &count ); | |
823 |
|
826 | |||
824 | count = count + 1; |
|
827 | count = count + 1; | |
825 |
|
828 | |||
826 | if (status != RTEMS_SUCCESSFUL) |
|
829 | if (status != RTEMS_SUCCESSFUL) | |
827 | { |
|
830 | { | |
828 | PRINTF1("in update_queue_max_count *** ERR = %d\n", status) |
|
831 | PRINTF1("in update_queue_max_count *** ERR = %d\n", status) | |
829 | } |
|
832 | } | |
830 | else |
|
833 | else | |
831 | { |
|
834 | { | |
832 | if (count > *fifo_size_max) |
|
835 | if (count > *fifo_size_max) | |
833 | { |
|
836 | { | |
834 | *fifo_size_max = count; |
|
837 | *fifo_size_max = count; | |
835 | } |
|
838 | } | |
836 | } |
|
839 | } | |
837 | } |
|
840 | } | |
838 |
|
841 | |||
839 | 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 ) | |
840 | { |
|
843 | { | |
841 | unsigned char i; |
|
844 | unsigned char i; | |
842 |
|
845 | |||
843 | //*************** |
|
846 | //*************** | |
844 | // BUFFER ADDRESS |
|
847 | // BUFFER ADDRESS | |
845 | for(i=0; i<nbNodes; i++) |
|
848 | for(i=0; i<nbNodes; i++) | |
846 | { |
|
849 | { | |
847 | ring[i].coarseTime = 0xffffffff; |
|
850 | ring[i].coarseTime = 0xffffffff; | |
848 | ring[i].fineTime = 0xffffffff; |
|
851 | ring[i].fineTime = 0xffffffff; | |
849 | ring[i].sid = 0x00; |
|
852 | ring[i].sid = 0x00; | |
850 | ring[i].status = 0x00; |
|
853 | ring[i].status = 0x00; | |
851 | ring[i].buffer_address = (int) &buffer[ i * bufferSize ]; |
|
854 | ring[i].buffer_address = (int) &buffer[ i * bufferSize ]; | |
852 | } |
|
855 | } | |
853 |
|
856 | |||
854 | //***** |
|
857 | //***** | |
855 | // NEXT |
|
858 | // NEXT | |
856 | ring[ nbNodes - 1 ].next = (ring_node*) &ring[ 0 ]; |
|
859 | ring[ nbNodes - 1 ].next = (ring_node*) &ring[ 0 ]; | |
857 | for(i=0; i<nbNodes-1; i++) |
|
860 | for(i=0; i<nbNodes-1; i++) | |
858 | { |
|
861 | { | |
859 | ring[i].next = (ring_node*) &ring[ i + 1 ]; |
|
862 | ring[i].next = (ring_node*) &ring[ i + 1 ]; | |
860 | } |
|
863 | } | |
861 |
|
864 | |||
862 | //********* |
|
865 | //********* | |
863 | // PREVIOUS |
|
866 | // PREVIOUS | |
864 | ring[ 0 ].previous = (ring_node*) &ring[ nbNodes - 1 ]; |
|
867 | ring[ 0 ].previous = (ring_node*) &ring[ nbNodes - 1 ]; | |
865 | for(i=1; i<nbNodes; i++) |
|
868 | for(i=1; i<nbNodes; i++) | |
866 | { |
|
869 | { | |
867 | ring[i].previous = (ring_node*) &ring[ i - 1 ]; |
|
870 | ring[i].previous = (ring_node*) &ring[ i - 1 ]; | |
868 | } |
|
871 | } | |
869 | } |
|
872 | } |
@@ -1,551 +1,564 | |||||
1 | /** General usage functions and RTEMS tasks. |
|
1 | /** General usage functions and RTEMS tasks. | |
2 | * |
|
2 | * | |
3 | * @file |
|
3 | * @file | |
4 | * @author P. LEROY |
|
4 | * @author P. LEROY | |
5 | * |
|
5 | * | |
6 | */ |
|
6 | */ | |
7 |
|
7 | |||
8 | #include "fsw_misc.h" |
|
8 | #include "fsw_misc.h" | |
9 |
|
9 | |||
10 | void configure_timer(gptimer_regs_t *gptimer_regs, unsigned char timer, unsigned int clock_divider, |
|
10 | void configure_timer(gptimer_regs_t *gptimer_regs, unsigned char timer, unsigned int clock_divider, | |
11 | unsigned char interrupt_level, rtems_isr (*timer_isr)() ) |
|
11 | unsigned char interrupt_level, rtems_isr (*timer_isr)() ) | |
12 | { |
|
12 | { | |
13 | /** This function configures a GPTIMER timer instantiated in the VHDL design. |
|
13 | /** This function configures a GPTIMER timer instantiated in the VHDL design. | |
14 | * |
|
14 | * | |
15 | * @param gptimer_regs points to the APB registers of the GPTIMER IP core. |
|
15 | * @param gptimer_regs points to the APB registers of the GPTIMER IP core. | |
16 | * @param timer is the number of the timer in the IP core (several timers can be instantiated). |
|
16 | * @param timer is the number of the timer in the IP core (several timers can be instantiated). | |
17 | * @param clock_divider is the divider of the 1 MHz clock that will be configured. |
|
17 | * @param clock_divider is the divider of the 1 MHz clock that will be configured. | |
18 | * @param interrupt_level is the interrupt level that the timer drives. |
|
18 | * @param interrupt_level is the interrupt level that the timer drives. | |
19 | * @param timer_isr is the interrupt subroutine that will be attached to the IRQ driven by the timer. |
|
19 | * @param timer_isr is the interrupt subroutine that will be attached to the IRQ driven by the timer. | |
20 | * |
|
20 | * | |
21 | * Interrupt levels are described in the SPARC documentation sparcv8.pdf p.76 |
|
21 | * Interrupt levels are described in the SPARC documentation sparcv8.pdf p.76 | |
22 | * |
|
22 | * | |
23 | */ |
|
23 | */ | |
24 |
|
24 | |||
25 | rtems_status_code status; |
|
25 | rtems_status_code status; | |
26 | rtems_isr_entry old_isr_handler; |
|
26 | rtems_isr_entry old_isr_handler; | |
27 |
|
27 | |||
28 | gptimer_regs->timer[timer].ctrl = 0x00; // reset the control register |
|
28 | gptimer_regs->timer[timer].ctrl = 0x00; // reset the control register | |
29 |
|
29 | |||
30 | status = rtems_interrupt_catch( timer_isr, interrupt_level, &old_isr_handler) ; // see sparcv8.pdf p.76 for interrupt levels |
|
30 | status = rtems_interrupt_catch( timer_isr, interrupt_level, &old_isr_handler) ; // see sparcv8.pdf p.76 for interrupt levels | |
31 | if (status!=RTEMS_SUCCESSFUL) |
|
31 | if (status!=RTEMS_SUCCESSFUL) | |
32 | { |
|
32 | { | |
33 | PRINTF("in configure_timer *** ERR rtems_interrupt_catch\n") |
|
33 | PRINTF("in configure_timer *** ERR rtems_interrupt_catch\n") | |
34 | } |
|
34 | } | |
35 |
|
35 | |||
36 | timer_set_clock_divider( gptimer_regs, timer, clock_divider); |
|
36 | timer_set_clock_divider( gptimer_regs, timer, clock_divider); | |
37 | } |
|
37 | } | |
38 |
|
38 | |||
39 | void timer_start(gptimer_regs_t *gptimer_regs, unsigned char timer) |
|
39 | void timer_start(gptimer_regs_t *gptimer_regs, unsigned char timer) | |
40 | { |
|
40 | { | |
41 | /** This function starts a GPTIMER timer. |
|
41 | /** This function starts a GPTIMER timer. | |
42 | * |
|
42 | * | |
43 | * @param gptimer_regs points to the APB registers of the GPTIMER IP core. |
|
43 | * @param gptimer_regs points to the APB registers of the GPTIMER IP core. | |
44 | * @param timer is the number of the timer in the IP core (several timers can be instantiated). |
|
44 | * @param timer is the number of the timer in the IP core (several timers can be instantiated). | |
45 | * |
|
45 | * | |
46 | */ |
|
46 | */ | |
47 |
|
47 | |||
48 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000010; // clear pending IRQ if any |
|
48 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000010; // clear pending IRQ if any | |
49 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000004; // LD load value from the reload register |
|
49 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000004; // LD load value from the reload register | |
50 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000001; // EN enable the timer |
|
50 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000001; // EN enable the timer | |
51 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000002; // RS restart |
|
51 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000002; // RS restart | |
52 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000008; // IE interrupt enable |
|
52 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000008; // IE interrupt enable | |
53 | } |
|
53 | } | |
54 |
|
54 | |||
55 | void timer_stop(gptimer_regs_t *gptimer_regs, unsigned char timer) |
|
55 | void timer_stop(gptimer_regs_t *gptimer_regs, unsigned char timer) | |
56 | { |
|
56 | { | |
57 | /** This function stops a GPTIMER timer. |
|
57 | /** This function stops a GPTIMER timer. | |
58 | * |
|
58 | * | |
59 | * @param gptimer_regs points to the APB registers of the GPTIMER IP core. |
|
59 | * @param gptimer_regs points to the APB registers of the GPTIMER IP core. | |
60 | * @param timer is the number of the timer in the IP core (several timers can be instantiated). |
|
60 | * @param timer is the number of the timer in the IP core (several timers can be instantiated). | |
61 | * |
|
61 | * | |
62 | */ |
|
62 | */ | |
63 |
|
63 | |||
64 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl & 0xfffffffe; // EN enable the timer |
|
64 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl & 0xfffffffe; // EN enable the timer | |
65 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl & 0xffffffef; // IE interrupt enable |
|
65 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl & 0xffffffef; // IE interrupt enable | |
66 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000010; // clear pending IRQ if any |
|
66 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000010; // clear pending IRQ if any | |
67 | } |
|
67 | } | |
68 |
|
68 | |||
69 | void timer_set_clock_divider(gptimer_regs_t *gptimer_regs, unsigned char timer, unsigned int clock_divider) |
|
69 | void timer_set_clock_divider(gptimer_regs_t *gptimer_regs, unsigned char timer, unsigned int clock_divider) | |
70 | { |
|
70 | { | |
71 | /** This function sets the clock divider of a GPTIMER timer. |
|
71 | /** This function sets the clock divider of a GPTIMER timer. | |
72 | * |
|
72 | * | |
73 | * @param gptimer_regs points to the APB registers of the GPTIMER IP core. |
|
73 | * @param gptimer_regs points to the APB registers of the GPTIMER IP core. | |
74 | * @param timer is the number of the timer in the IP core (several timers can be instantiated). |
|
74 | * @param timer is the number of the timer in the IP core (several timers can be instantiated). | |
75 | * @param clock_divider is the divider of the 1 MHz clock that will be configured. |
|
75 | * @param clock_divider is the divider of the 1 MHz clock that will be configured. | |
76 | * |
|
76 | * | |
77 | */ |
|
77 | */ | |
78 |
|
78 | |||
79 | gptimer_regs->timer[timer].reload = clock_divider; // base clock frequency is 1 MHz |
|
79 | gptimer_regs->timer[timer].reload = clock_divider; // base clock frequency is 1 MHz | |
80 | } |
|
80 | } | |
81 |
|
81 | |||
82 | int send_console_outputs_on_apbuart_port( void ) // Send the console outputs on the apbuart port |
|
82 | int send_console_outputs_on_apbuart_port( void ) // Send the console outputs on the apbuart port | |
83 | { |
|
83 | { | |
84 | struct apbuart_regs_str *apbuart_regs = (struct apbuart_regs_str *) REGS_ADDR_APBUART; |
|
84 | struct apbuart_regs_str *apbuart_regs = (struct apbuart_regs_str *) REGS_ADDR_APBUART; | |
85 |
|
85 | |||
86 | apbuart_regs->ctrl = APBUART_CTRL_REG_MASK_TE; |
|
86 | apbuart_regs->ctrl = APBUART_CTRL_REG_MASK_TE; | |
87 |
|
87 | |||
88 | return 0; |
|
88 | return 0; | |
89 | } |
|
89 | } | |
90 |
|
90 | |||
91 | int enable_apbuart_transmitter( void ) // set the bit 1, TE Transmitter Enable to 1 in the APBUART control register |
|
91 | int enable_apbuart_transmitter( void ) // set the bit 1, TE Transmitter Enable to 1 in the APBUART control register | |
92 | { |
|
92 | { | |
93 | struct apbuart_regs_str *apbuart_regs = (struct apbuart_regs_str *) REGS_ADDR_APBUART; |
|
93 | struct apbuart_regs_str *apbuart_regs = (struct apbuart_regs_str *) REGS_ADDR_APBUART; | |
94 |
|
94 | |||
95 | apbuart_regs->ctrl = apbuart_regs->ctrl | APBUART_CTRL_REG_MASK_TE; |
|
95 | apbuart_regs->ctrl = apbuart_regs->ctrl | APBUART_CTRL_REG_MASK_TE; | |
96 |
|
96 | |||
97 | return 0; |
|
97 | return 0; | |
98 | } |
|
98 | } | |
99 |
|
99 | |||
100 | void set_apbuart_scaler_reload_register(unsigned int regs, unsigned int value) |
|
100 | void set_apbuart_scaler_reload_register(unsigned int regs, unsigned int value) | |
101 | { |
|
101 | { | |
102 | /** This function sets the scaler reload register of the apbuart module |
|
102 | /** This function sets the scaler reload register of the apbuart module | |
103 | * |
|
103 | * | |
104 | * @param regs is the address of the apbuart registers in memory |
|
104 | * @param regs is the address of the apbuart registers in memory | |
105 | * @param value is the value that will be stored in the scaler register |
|
105 | * @param value is the value that will be stored in the scaler register | |
106 | * |
|
106 | * | |
107 | * The value shall be set by the software to get data on the serial interface. |
|
107 | * The value shall be set by the software to get data on the serial interface. | |
108 | * |
|
108 | * | |
109 | */ |
|
109 | */ | |
110 |
|
110 | |||
111 | struct apbuart_regs_str *apbuart_regs = (struct apbuart_regs_str *) regs; |
|
111 | struct apbuart_regs_str *apbuart_regs = (struct apbuart_regs_str *) regs; | |
112 |
|
112 | |||
113 | apbuart_regs->scaler = value; |
|
113 | apbuart_regs->scaler = value; | |
114 | BOOT_PRINTF1("OK *** apbuart port scaler reload register set to 0x%x\n", value) |
|
114 | BOOT_PRINTF1("OK *** apbuart port scaler reload register set to 0x%x\n", value) | |
115 | } |
|
115 | } | |
116 |
|
116 | |||
117 | //************ |
|
117 | //************ | |
118 | // RTEMS TASKS |
|
118 | // RTEMS TASKS | |
119 |
|
119 | |||
120 | rtems_task stat_task(rtems_task_argument argument) |
|
120 | rtems_task stat_task(rtems_task_argument argument) | |
121 | { |
|
121 | { | |
122 | int i; |
|
122 | int i; | |
123 | int j; |
|
123 | int j; | |
124 | i = 0; |
|
124 | i = 0; | |
125 | j = 0; |
|
125 | j = 0; | |
126 | BOOT_PRINTF("in STAT *** \n") |
|
126 | BOOT_PRINTF("in STAT *** \n") | |
127 | while(1){ |
|
127 | while(1){ | |
128 | rtems_task_wake_after(1000); |
|
128 | rtems_task_wake_after(1000); | |
129 | PRINTF1("%d\n", j) |
|
129 | PRINTF1("%d\n", j) | |
130 | if (i == CPU_USAGE_REPORT_PERIOD) { |
|
130 | if (i == CPU_USAGE_REPORT_PERIOD) { | |
131 | // #ifdef PRINT_TASK_STATISTICS |
|
131 | // #ifdef PRINT_TASK_STATISTICS | |
132 | // rtems_cpu_usage_report(); |
|
132 | // rtems_cpu_usage_report(); | |
133 | // rtems_cpu_usage_reset(); |
|
133 | // rtems_cpu_usage_reset(); | |
134 | // #endif |
|
134 | // #endif | |
135 | i = 0; |
|
135 | i = 0; | |
136 | } |
|
136 | } | |
137 | else i++; |
|
137 | else i++; | |
138 | j++; |
|
138 | j++; | |
139 | } |
|
139 | } | |
140 | } |
|
140 | } | |
141 |
|
141 | |||
142 | rtems_task hous_task(rtems_task_argument argument) |
|
142 | rtems_task hous_task(rtems_task_argument argument) | |
143 | { |
|
143 | { | |
144 | rtems_status_code status; |
|
144 | rtems_status_code status; | |
145 | rtems_status_code spare_status; |
|
145 | rtems_status_code spare_status; | |
146 | rtems_id queue_id; |
|
146 | rtems_id queue_id; | |
147 | rtems_rate_monotonic_period_status period_status; |
|
147 | rtems_rate_monotonic_period_status period_status; | |
148 |
|
148 | |||
149 | status = get_message_queue_id_send( &queue_id ); |
|
149 | status = get_message_queue_id_send( &queue_id ); | |
150 | if (status != RTEMS_SUCCESSFUL) |
|
150 | if (status != RTEMS_SUCCESSFUL) | |
151 | { |
|
151 | { | |
152 | PRINTF1("in HOUS *** ERR get_message_queue_id_send %d\n", status) |
|
152 | PRINTF1("in HOUS *** ERR get_message_queue_id_send %d\n", status) | |
153 | } |
|
153 | } | |
154 |
|
154 | |||
155 | BOOT_PRINTF("in HOUS ***\n") |
|
155 | BOOT_PRINTF("in HOUS ***\n") | |
156 |
|
156 | |||
157 | if (rtems_rate_monotonic_ident( name_hk_rate_monotonic, &HK_id) != RTEMS_SUCCESSFUL) { |
|
157 | if (rtems_rate_monotonic_ident( name_hk_rate_monotonic, &HK_id) != RTEMS_SUCCESSFUL) { | |
158 | status = rtems_rate_monotonic_create( name_hk_rate_monotonic, &HK_id ); |
|
158 | status = rtems_rate_monotonic_create( name_hk_rate_monotonic, &HK_id ); | |
159 | if( status != RTEMS_SUCCESSFUL ) { |
|
159 | if( status != RTEMS_SUCCESSFUL ) { | |
160 | PRINTF1( "rtems_rate_monotonic_create failed with status of %d\n", status ) |
|
160 | PRINTF1( "rtems_rate_monotonic_create failed with status of %d\n", status ) | |
161 | } |
|
161 | } | |
162 | } |
|
162 | } | |
163 |
|
163 | |||
164 | status = rtems_rate_monotonic_cancel(HK_id); |
|
164 | status = rtems_rate_monotonic_cancel(HK_id); | |
165 | if( status != RTEMS_SUCCESSFUL ) { |
|
165 | if( status != RTEMS_SUCCESSFUL ) { | |
166 | PRINTF1( "ERR *** in HOUS *** rtems_rate_monotonic_cancel(HK_id) ***code: %d\n", status ) |
|
166 | PRINTF1( "ERR *** in HOUS *** rtems_rate_monotonic_cancel(HK_id) ***code: %d\n", status ) | |
167 | } |
|
167 | } | |
168 | else { |
|
168 | else { | |
169 | DEBUG_PRINTF("OK *** in HOUS *** rtems_rate_monotonic_cancel(HK_id)\n") |
|
169 | DEBUG_PRINTF("OK *** in HOUS *** rtems_rate_monotonic_cancel(HK_id)\n") | |
170 | } |
|
170 | } | |
171 |
|
171 | |||
172 | // startup phase |
|
172 | // startup phase | |
173 | status = rtems_rate_monotonic_period( HK_id, SY_LFR_TIME_SYN_TIMEOUT_in_ticks ); |
|
173 | status = rtems_rate_monotonic_period( HK_id, SY_LFR_TIME_SYN_TIMEOUT_in_ticks ); | |
174 | status = rtems_rate_monotonic_get_status( HK_id, &period_status ); |
|
174 | status = rtems_rate_monotonic_get_status( HK_id, &period_status ); | |
175 | DEBUG_PRINTF1("startup HK, HK_id status = %d\n", period_status.state) |
|
175 | DEBUG_PRINTF1("startup HK, HK_id status = %d\n", period_status.state) | |
176 | while(period_status.state != RATE_MONOTONIC_EXPIRED ) // after SY_LFR_TIME_SYN_TIMEOUT ms, starts HK anyway |
|
176 | while(period_status.state != RATE_MONOTONIC_EXPIRED ) // after SY_LFR_TIME_SYN_TIMEOUT ms, starts HK anyway | |
177 | { |
|
177 | { | |
178 | if ((time_management_regs->coarse_time & 0x80000000) == 0x00000000) // check time synchronization |
|
178 | if ((time_management_regs->coarse_time & 0x80000000) == 0x00000000) // check time synchronization | |
179 | { |
|
179 | { | |
180 | break; // break if LFR is synchronized |
|
180 | break; // break if LFR is synchronized | |
181 | } |
|
181 | } | |
182 | else |
|
182 | else | |
183 | { |
|
183 | { | |
184 | status = rtems_rate_monotonic_get_status( HK_id, &period_status ); |
|
184 | status = rtems_rate_monotonic_get_status( HK_id, &period_status ); | |
185 | // sched_yield(); |
|
185 | // sched_yield(); | |
186 | status = rtems_task_wake_after( 10 ); // wait SY_LFR_DPU_CONNECT_TIMEOUT 100 ms = 10 * 10 ms |
|
186 | status = rtems_task_wake_after( 10 ); // wait SY_LFR_DPU_CONNECT_TIMEOUT 100 ms = 10 * 10 ms | |
187 | } |
|
187 | } | |
188 | } |
|
188 | } | |
189 | status = rtems_rate_monotonic_cancel(HK_id); |
|
189 | status = rtems_rate_monotonic_cancel(HK_id); | |
190 | DEBUG_PRINTF1("startup HK, HK_id status = %d\n", period_status.state) |
|
190 | DEBUG_PRINTF1("startup HK, HK_id status = %d\n", period_status.state) | |
191 |
|
191 | |||
192 | while(1){ // launch the rate monotonic task |
|
192 | while(1){ // launch the rate monotonic task | |
193 | status = rtems_rate_monotonic_period( HK_id, HK_PERIOD ); |
|
193 | status = rtems_rate_monotonic_period( HK_id, HK_PERIOD ); | |
194 | if ( status != RTEMS_SUCCESSFUL ) { |
|
194 | if ( status != RTEMS_SUCCESSFUL ) { | |
195 | PRINTF1( "in HOUS *** ERR period: %d\n", status); |
|
195 | PRINTF1( "in HOUS *** ERR period: %d\n", status); | |
196 | spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_6 ); |
|
196 | spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_6 ); | |
197 | } |
|
197 | } | |
198 | else { |
|
198 | else { | |
199 | housekeeping_packet.packetSequenceControl[0] = (unsigned char) (sequenceCounterHK >> 8); |
|
199 | housekeeping_packet.packetSequenceControl[0] = (unsigned char) (sequenceCounterHK >> 8); | |
200 | housekeeping_packet.packetSequenceControl[1] = (unsigned char) (sequenceCounterHK ); |
|
200 | housekeeping_packet.packetSequenceControl[1] = (unsigned char) (sequenceCounterHK ); | |
201 | increment_seq_counter( &sequenceCounterHK ); |
|
201 | increment_seq_counter( &sequenceCounterHK ); | |
202 |
|
202 | |||
203 | housekeeping_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24); |
|
203 | housekeeping_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24); | |
204 | housekeeping_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16); |
|
204 | housekeeping_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16); | |
205 | housekeeping_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8); |
|
205 | housekeeping_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8); | |
206 | housekeeping_packet.time[3] = (unsigned char) (time_management_regs->coarse_time); |
|
206 | housekeeping_packet.time[3] = (unsigned char) (time_management_regs->coarse_time); | |
207 | housekeeping_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8); |
|
207 | housekeeping_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8); | |
208 | housekeeping_packet.time[5] = (unsigned char) (time_management_regs->fine_time); |
|
208 | housekeeping_packet.time[5] = (unsigned char) (time_management_regs->fine_time); | |
209 |
|
209 | |||
210 | spacewire_update_statistics(); |
|
210 | spacewire_update_statistics(); | |
211 |
|
211 | |||
212 | housekeeping_packet.hk_lfr_q_sd_fifo_size_max = hk_lfr_q_sd_fifo_size_max; |
|
212 | housekeeping_packet.hk_lfr_q_sd_fifo_size_max = hk_lfr_q_sd_fifo_size_max; | |
213 | housekeeping_packet.hk_lfr_q_rv_fifo_size_max = hk_lfr_q_rv_fifo_size_max; |
|
213 | housekeeping_packet.hk_lfr_q_rv_fifo_size_max = hk_lfr_q_rv_fifo_size_max; | |
214 | housekeeping_packet.hk_lfr_q_p0_fifo_size_max = hk_lfr_q_p0_fifo_size_max; |
|
214 | housekeeping_packet.hk_lfr_q_p0_fifo_size_max = hk_lfr_q_p0_fifo_size_max; | |
215 | housekeeping_packet.hk_lfr_q_p1_fifo_size_max = hk_lfr_q_p1_fifo_size_max; |
|
215 | housekeeping_packet.hk_lfr_q_p1_fifo_size_max = hk_lfr_q_p1_fifo_size_max; | |
216 | housekeeping_packet.hk_lfr_q_p2_fifo_size_max = hk_lfr_q_p2_fifo_size_max; |
|
216 | housekeeping_packet.hk_lfr_q_p2_fifo_size_max = hk_lfr_q_p2_fifo_size_max; | |
217 |
|
217 | |||
218 | housekeeping_packet.sy_lfr_common_parameters_spare = parameter_dump_packet.sy_lfr_common_parameters_spare; |
|
218 | housekeeping_packet.sy_lfr_common_parameters_spare = parameter_dump_packet.sy_lfr_common_parameters_spare; | |
219 | housekeeping_packet.sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters; |
|
219 | housekeeping_packet.sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters; | |
220 | get_temperatures( housekeeping_packet.hk_lfr_temp_scm ); |
|
220 | get_temperatures( housekeeping_packet.hk_lfr_temp_scm ); | |
221 | get_v_e1_e2_f3( housekeeping_packet.hk_lfr_sc_v_f3 ); |
|
221 | get_v_e1_e2_f3( housekeeping_packet.hk_lfr_sc_v_f3 ); | |
222 | get_cpu_load( (unsigned char *) &housekeeping_packet.hk_lfr_cpu_load ); |
|
222 | get_cpu_load( (unsigned char *) &housekeeping_packet.hk_lfr_cpu_load ); | |
223 |
|
223 | |||
224 | // SEND PACKET |
|
224 | // SEND PACKET | |
225 | status = rtems_message_queue_send( queue_id, &housekeeping_packet, |
|
225 | status = rtems_message_queue_send( queue_id, &housekeeping_packet, | |
226 | PACKET_LENGTH_HK + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES); |
|
226 | PACKET_LENGTH_HK + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES); | |
227 | if (status != RTEMS_SUCCESSFUL) { |
|
227 | if (status != RTEMS_SUCCESSFUL) { | |
228 | PRINTF1("in HOUS *** ERR send: %d\n", status) |
|
228 | PRINTF1("in HOUS *** ERR send: %d\n", status) | |
229 | } |
|
229 | } | |
230 | } |
|
230 | } | |
231 | } |
|
231 | } | |
232 |
|
232 | |||
233 | PRINTF("in HOUS *** deleting task\n") |
|
233 | PRINTF("in HOUS *** deleting task\n") | |
234 |
|
234 | |||
235 | status = rtems_task_delete( RTEMS_SELF ); // should not return |
|
235 | status = rtems_task_delete( RTEMS_SELF ); // should not return | |
236 | printf( "rtems_task_delete returned with status of %d.\n", status ); |
|
236 | printf( "rtems_task_delete returned with status of %d.\n", status ); | |
237 | return; |
|
237 | return; | |
238 | } |
|
238 | } | |
239 |
|
239 | |||
240 | rtems_task dumb_task( rtems_task_argument unused ) |
|
240 | rtems_task dumb_task( rtems_task_argument unused ) | |
241 | { |
|
241 | { | |
242 | /** This RTEMS taks is used to print messages without affecting the general behaviour of the software. |
|
242 | /** This RTEMS taks is used to print messages without affecting the general behaviour of the software. | |
243 | * |
|
243 | * | |
244 | * @param unused is the starting argument of the RTEMS task |
|
244 | * @param unused is the starting argument of the RTEMS task | |
245 | * |
|
245 | * | |
246 | * The DUMB taks waits for RTEMS events and print messages depending on the incoming events. |
|
246 | * The DUMB taks waits for RTEMS events and print messages depending on the incoming events. | |
247 | * |
|
247 | * | |
248 | */ |
|
248 | */ | |
249 |
|
249 | |||
250 | unsigned int i; |
|
250 | unsigned int i; | |
251 | unsigned int intEventOut; |
|
251 | unsigned int intEventOut; | |
252 | unsigned int coarse_time = 0; |
|
252 | unsigned int coarse_time = 0; | |
253 | unsigned int fine_time = 0; |
|
253 | unsigned int fine_time = 0; | |
254 | rtems_event_set event_out; |
|
254 | rtems_event_set event_out; | |
255 |
|
255 | |||
256 | char *DumbMessages[12] = {"in DUMB *** default", // RTEMS_EVENT_0 |
|
256 | char *DumbMessages[12] = {"in DUMB *** default", // RTEMS_EVENT_0 | |
257 | "in DUMB *** timecode_irq_handler", // RTEMS_EVENT_1 |
|
257 | "in DUMB *** timecode_irq_handler", // RTEMS_EVENT_1 | |
258 | "in DUMB *** f3 buffer changed", // RTEMS_EVENT_2 |
|
258 | "in DUMB *** f3 buffer changed", // RTEMS_EVENT_2 | |
259 | "in DUMB *** in SMIQ *** Error sending event to AVF0", // RTEMS_EVENT_3 |
|
259 | "in DUMB *** in SMIQ *** Error sending event to AVF0", // RTEMS_EVENT_3 | |
260 | "in DUMB *** spectral_matrices_isr *** Error sending event to SMIQ", // RTEMS_EVENT_4 |
|
260 | "in DUMB *** spectral_matrices_isr *** Error sending event to SMIQ", // RTEMS_EVENT_4 | |
261 | "in DUMB *** waveforms_simulator_isr", // RTEMS_EVENT_5 |
|
261 | "in DUMB *** waveforms_simulator_isr", // RTEMS_EVENT_5 | |
262 | "VHDL SM *** two buffers f0 ready", // RTEMS_EVENT_6 |
|
262 | "VHDL SM *** two buffers f0 ready", // RTEMS_EVENT_6 | |
263 | "ready for dump", // RTEMS_EVENT_7 |
|
263 | "ready for dump", // RTEMS_EVENT_7 | |
264 | "VHDL ERR *** spectral matrix", // RTEMS_EVENT_8 |
|
264 | "VHDL ERR *** spectral matrix", // RTEMS_EVENT_8 | |
265 | "tick", // RTEMS_EVENT_9 |
|
265 | "tick", // RTEMS_EVENT_9 | |
266 | "VHDL ERR *** waveform picker", // RTEMS_EVENT_10 |
|
266 | "VHDL ERR *** waveform picker", // RTEMS_EVENT_10 | |
267 | "VHDL ERR *** unexpected ready matrix values" // RTEMS_EVENT_11 |
|
267 | "VHDL ERR *** unexpected ready matrix values" // RTEMS_EVENT_11 | |
268 | }; |
|
268 | }; | |
269 |
|
269 | |||
270 | BOOT_PRINTF("in DUMB *** \n") |
|
270 | BOOT_PRINTF("in DUMB *** \n") | |
271 |
|
271 | |||
272 | while(1){ |
|
272 | while(1){ | |
273 | rtems_event_receive(RTEMS_EVENT_0 | RTEMS_EVENT_1 | RTEMS_EVENT_2 | RTEMS_EVENT_3 |
|
273 | rtems_event_receive(RTEMS_EVENT_0 | RTEMS_EVENT_1 | RTEMS_EVENT_2 | RTEMS_EVENT_3 | |
274 | | RTEMS_EVENT_4 | RTEMS_EVENT_5 | RTEMS_EVENT_6 | RTEMS_EVENT_7 |
|
274 | | RTEMS_EVENT_4 | RTEMS_EVENT_5 | RTEMS_EVENT_6 | RTEMS_EVENT_7 | |
275 | | RTEMS_EVENT_8 | RTEMS_EVENT_9, |
|
275 | | RTEMS_EVENT_8 | RTEMS_EVENT_9, | |
276 | RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT |
|
276 | RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT | |
277 | intEventOut = (unsigned int) event_out; |
|
277 | intEventOut = (unsigned int) event_out; | |
278 | for ( i=0; i<32; i++) |
|
278 | for ( i=0; i<32; i++) | |
279 | { |
|
279 | { | |
280 | if ( ((intEventOut >> i) & 0x0001) != 0) |
|
280 | if ( ((intEventOut >> i) & 0x0001) != 0) | |
281 | { |
|
281 | { | |
282 | coarse_time = time_management_regs->coarse_time; |
|
282 | coarse_time = time_management_regs->coarse_time; | |
283 | fine_time = time_management_regs->fine_time; |
|
283 | fine_time = time_management_regs->fine_time; | |
284 | printf("in DUMB *** coarse: %x, fine: %x, %s\n", coarse_time, fine_time, DumbMessages[i]); |
|
284 | printf("in DUMB *** coarse: %x, fine: %x, %s\n", coarse_time, fine_time, DumbMessages[i]); | |
285 | if (i==8) |
|
285 | if (i==8) | |
286 | { |
|
286 | { | |
287 | } |
|
287 | } | |
288 | if (i==10) |
|
288 | if (i==10) | |
289 | { |
|
289 | { | |
290 | } |
|
290 | } | |
291 | } |
|
291 | } | |
292 | } |
|
292 | } | |
293 | } |
|
293 | } | |
294 | } |
|
294 | } | |
295 |
|
295 | |||
296 | //***************************** |
|
296 | //***************************** | |
297 | // init housekeeping parameters |
|
297 | // init housekeeping parameters | |
298 |
|
298 | |||
299 | void init_housekeeping_parameters( void ) |
|
299 | void init_housekeeping_parameters( void ) | |
300 | { |
|
300 | { | |
301 | /** This function initialize the housekeeping_packet global variable with default values. |
|
301 | /** This function initialize the housekeeping_packet global variable with default values. | |
302 | * |
|
302 | * | |
303 | */ |
|
303 | */ | |
304 |
|
304 | |||
305 | unsigned int i = 0; |
|
305 | unsigned int i = 0; | |
306 | unsigned char *parameters; |
|
306 | unsigned char *parameters; | |
307 | unsigned char sizeOfHK; |
|
307 | unsigned char sizeOfHK; | |
308 |
|
308 | |||
309 | sizeOfHK = sizeof( Packet_TM_LFR_HK_t ); |
|
309 | sizeOfHK = sizeof( Packet_TM_LFR_HK_t ); | |
310 |
|
310 | |||
311 | parameters = (unsigned char*) &housekeeping_packet; |
|
311 | parameters = (unsigned char*) &housekeeping_packet; | |
312 |
|
312 | |||
313 | for(i = 0; i< sizeOfHK; i++) |
|
313 | for(i = 0; i< sizeOfHK; i++) | |
314 | { |
|
314 | { | |
315 | parameters[i] = 0x00; |
|
315 | parameters[i] = 0x00; | |
316 | } |
|
316 | } | |
317 |
|
317 | |||
318 | housekeeping_packet.targetLogicalAddress = CCSDS_DESTINATION_ID; |
|
318 | housekeeping_packet.targetLogicalAddress = CCSDS_DESTINATION_ID; | |
319 | housekeeping_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID; |
|
319 | housekeeping_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID; | |
320 | housekeeping_packet.reserved = DEFAULT_RESERVED; |
|
320 | housekeeping_packet.reserved = DEFAULT_RESERVED; | |
321 | housekeeping_packet.userApplication = CCSDS_USER_APP; |
|
321 | housekeeping_packet.userApplication = CCSDS_USER_APP; | |
322 | housekeeping_packet.packetID[0] = (unsigned char) (APID_TM_HK >> 8); |
|
322 | housekeeping_packet.packetID[0] = (unsigned char) (APID_TM_HK >> 8); | |
323 | housekeeping_packet.packetID[1] = (unsigned char) (APID_TM_HK); |
|
323 | housekeeping_packet.packetID[1] = (unsigned char) (APID_TM_HK); | |
324 | housekeeping_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; |
|
324 | housekeeping_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; | |
325 | housekeeping_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT; |
|
325 | housekeeping_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT; | |
326 | housekeeping_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_HK >> 8); |
|
326 | housekeeping_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_HK >> 8); | |
327 | housekeeping_packet.packetLength[1] = (unsigned char) (PACKET_LENGTH_HK ); |
|
327 | housekeeping_packet.packetLength[1] = (unsigned char) (PACKET_LENGTH_HK ); | |
328 | housekeeping_packet.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2; |
|
328 | housekeeping_packet.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2; | |
329 | housekeeping_packet.serviceType = TM_TYPE_HK; |
|
329 | housekeeping_packet.serviceType = TM_TYPE_HK; | |
330 | housekeeping_packet.serviceSubType = TM_SUBTYPE_HK; |
|
330 | housekeeping_packet.serviceSubType = TM_SUBTYPE_HK; | |
331 | housekeeping_packet.destinationID = TM_DESTINATION_ID_GROUND; |
|
331 | housekeeping_packet.destinationID = TM_DESTINATION_ID_GROUND; | |
332 | housekeeping_packet.sid = SID_HK; |
|
332 | housekeeping_packet.sid = SID_HK; | |
333 |
|
333 | |||
334 | // init status word |
|
334 | // init status word | |
335 | housekeeping_packet.lfr_status_word[0] = DEFAULT_STATUS_WORD_BYTE0; |
|
335 | housekeeping_packet.lfr_status_word[0] = DEFAULT_STATUS_WORD_BYTE0; | |
336 | housekeeping_packet.lfr_status_word[1] = DEFAULT_STATUS_WORD_BYTE1; |
|
336 | housekeeping_packet.lfr_status_word[1] = DEFAULT_STATUS_WORD_BYTE1; | |
337 | // init software version |
|
337 | // init software version | |
338 | housekeeping_packet.lfr_sw_version[0] = SW_VERSION_N1; |
|
338 | housekeeping_packet.lfr_sw_version[0] = SW_VERSION_N1; | |
339 | housekeeping_packet.lfr_sw_version[1] = SW_VERSION_N2; |
|
339 | housekeeping_packet.lfr_sw_version[1] = SW_VERSION_N2; | |
340 | housekeeping_packet.lfr_sw_version[2] = SW_VERSION_N3; |
|
340 | housekeeping_packet.lfr_sw_version[2] = SW_VERSION_N3; | |
341 | housekeeping_packet.lfr_sw_version[3] = SW_VERSION_N4; |
|
341 | housekeeping_packet.lfr_sw_version[3] = SW_VERSION_N4; | |
342 | // init fpga version |
|
342 | // init fpga version | |
343 | parameters = (unsigned char *) (REGS_ADDR_VHDL_VERSION); |
|
343 | parameters = (unsigned char *) (REGS_ADDR_VHDL_VERSION); | |
344 | housekeeping_packet.lfr_fpga_version[0] = parameters[1]; // n1 |
|
344 | housekeeping_packet.lfr_fpga_version[0] = parameters[1]; // n1 | |
345 | housekeeping_packet.lfr_fpga_version[1] = parameters[2]; // n2 |
|
345 | housekeeping_packet.lfr_fpga_version[1] = parameters[2]; // n2 | |
346 | housekeeping_packet.lfr_fpga_version[2] = parameters[3]; // n3 |
|
346 | housekeeping_packet.lfr_fpga_version[2] = parameters[3]; // n3 | |
347 |
|
347 | |||
348 | housekeeping_packet.hk_lfr_q_sd_fifo_size = MSG_QUEUE_COUNT_SEND; |
|
348 | housekeeping_packet.hk_lfr_q_sd_fifo_size = MSG_QUEUE_COUNT_SEND; | |
349 | housekeeping_packet.hk_lfr_q_rv_fifo_size = MSG_QUEUE_COUNT_RECV; |
|
349 | housekeeping_packet.hk_lfr_q_rv_fifo_size = MSG_QUEUE_COUNT_RECV; | |
350 | housekeeping_packet.hk_lfr_q_p0_fifo_size = MSG_QUEUE_COUNT_PRC0; |
|
350 | housekeeping_packet.hk_lfr_q_p0_fifo_size = MSG_QUEUE_COUNT_PRC0; | |
351 | housekeeping_packet.hk_lfr_q_p1_fifo_size = MSG_QUEUE_COUNT_PRC1; |
|
351 | housekeeping_packet.hk_lfr_q_p1_fifo_size = MSG_QUEUE_COUNT_PRC1; | |
352 | housekeeping_packet.hk_lfr_q_p2_fifo_size = MSG_QUEUE_COUNT_PRC2; |
|
352 | housekeeping_packet.hk_lfr_q_p2_fifo_size = MSG_QUEUE_COUNT_PRC2; | |
353 | } |
|
353 | } | |
354 |
|
354 | |||
355 | void increment_seq_counter( unsigned short *packetSequenceControl ) |
|
355 | void increment_seq_counter( unsigned short *packetSequenceControl ) | |
356 | { |
|
356 | { | |
357 | /** This function increment the sequence counter passes in argument. |
|
357 | /** This function increment the sequence counter passes in argument. | |
358 | * |
|
358 | * | |
359 | * The increment does not affect the grouping flag. In case of an overflow, the counter is reset to 0. |
|
359 | * The increment does not affect the grouping flag. In case of an overflow, the counter is reset to 0. | |
360 | * |
|
360 | * | |
361 | */ |
|
361 | */ | |
362 |
|
362 | |||
363 | unsigned short segmentation_grouping_flag; |
|
363 | unsigned short segmentation_grouping_flag; | |
364 | unsigned short sequence_cnt; |
|
364 | unsigned short sequence_cnt; | |
365 |
|
365 | |||
366 | segmentation_grouping_flag = TM_PACKET_SEQ_CTRL_STANDALONE << 8; // keep bits 7 downto 6 |
|
366 | segmentation_grouping_flag = TM_PACKET_SEQ_CTRL_STANDALONE << 8; // keep bits 7 downto 6 | |
367 | sequence_cnt = (*packetSequenceControl) & 0x3fff; // [0011 1111 1111 1111] |
|
367 | sequence_cnt = (*packetSequenceControl) & 0x3fff; // [0011 1111 1111 1111] | |
368 |
|
368 | |||
369 | if ( sequence_cnt < SEQ_CNT_MAX) |
|
369 | if ( sequence_cnt < SEQ_CNT_MAX) | |
370 | { |
|
370 | { | |
371 | sequence_cnt = sequence_cnt + 1; |
|
371 | sequence_cnt = sequence_cnt + 1; | |
372 | } |
|
372 | } | |
373 | else |
|
373 | else | |
374 | { |
|
374 | { | |
375 | sequence_cnt = 0; |
|
375 | sequence_cnt = 0; | |
376 | } |
|
376 | } | |
377 |
|
377 | |||
378 | *packetSequenceControl = segmentation_grouping_flag | sequence_cnt ; |
|
378 | *packetSequenceControl = segmentation_grouping_flag | sequence_cnt ; | |
379 | } |
|
379 | } | |
380 |
|
380 | |||
381 | void getTime( unsigned char *time) |
|
381 | void getTime( unsigned char *time) | |
382 | { |
|
382 | { | |
383 | /** This function write the current local time in the time buffer passed in argument. |
|
383 | /** This function write the current local time in the time buffer passed in argument. | |
384 | * |
|
384 | * | |
385 | */ |
|
385 | */ | |
386 |
|
386 | |||
387 | time[0] = (unsigned char) (time_management_regs->coarse_time>>24); |
|
387 | time[0] = (unsigned char) (time_management_regs->coarse_time>>24); | |
388 | time[1] = (unsigned char) (time_management_regs->coarse_time>>16); |
|
388 | time[1] = (unsigned char) (time_management_regs->coarse_time>>16); | |
389 | time[2] = (unsigned char) (time_management_regs->coarse_time>>8); |
|
389 | time[2] = (unsigned char) (time_management_regs->coarse_time>>8); | |
390 | time[3] = (unsigned char) (time_management_regs->coarse_time); |
|
390 | time[3] = (unsigned char) (time_management_regs->coarse_time); | |
391 | time[4] = (unsigned char) (time_management_regs->fine_time>>8); |
|
391 | time[4] = (unsigned char) (time_management_regs->fine_time>>8); | |
392 | time[5] = (unsigned char) (time_management_regs->fine_time); |
|
392 | time[5] = (unsigned char) (time_management_regs->fine_time); | |
393 | } |
|
393 | } | |
394 |
|
394 | |||
395 | unsigned long long int getTimeAsUnsignedLongLongInt( ) |
|
395 | unsigned long long int getTimeAsUnsignedLongLongInt( ) | |
396 | { |
|
396 | { | |
397 | /** This function write the current local time in the time buffer passed in argument. |
|
397 | /** This function write the current local time in the time buffer passed in argument. | |
398 | * |
|
398 | * | |
399 | */ |
|
399 | */ | |
400 | unsigned long long int time; |
|
400 | unsigned long long int time; | |
401 |
|
401 | |||
402 | time = ( (unsigned long long int) (time_management_regs->coarse_time & 0x7fffffff) << 16 ) |
|
402 | time = ( (unsigned long long int) (time_management_regs->coarse_time & 0x7fffffff) << 16 ) | |
403 | + time_management_regs->fine_time; |
|
403 | + time_management_regs->fine_time; | |
404 |
|
404 | |||
405 | return time; |
|
405 | return time; | |
406 | } |
|
406 | } | |
407 |
|
407 | |||
408 | void send_dumb_hk( void ) |
|
408 | void send_dumb_hk( void ) | |
409 | { |
|
409 | { | |
410 | Packet_TM_LFR_HK_t dummy_hk_packet; |
|
410 | Packet_TM_LFR_HK_t dummy_hk_packet; | |
411 | unsigned char *parameters; |
|
411 | unsigned char *parameters; | |
412 | unsigned int i; |
|
412 | unsigned int i; | |
413 | rtems_id queue_id; |
|
413 | rtems_id queue_id; | |
414 |
|
414 | |||
415 | dummy_hk_packet.targetLogicalAddress = CCSDS_DESTINATION_ID; |
|
415 | dummy_hk_packet.targetLogicalAddress = CCSDS_DESTINATION_ID; | |
416 | dummy_hk_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID; |
|
416 | dummy_hk_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID; | |
417 | dummy_hk_packet.reserved = DEFAULT_RESERVED; |
|
417 | dummy_hk_packet.reserved = DEFAULT_RESERVED; | |
418 | dummy_hk_packet.userApplication = CCSDS_USER_APP; |
|
418 | dummy_hk_packet.userApplication = CCSDS_USER_APP; | |
419 | dummy_hk_packet.packetID[0] = (unsigned char) (APID_TM_HK >> 8); |
|
419 | dummy_hk_packet.packetID[0] = (unsigned char) (APID_TM_HK >> 8); | |
420 | dummy_hk_packet.packetID[1] = (unsigned char) (APID_TM_HK); |
|
420 | dummy_hk_packet.packetID[1] = (unsigned char) (APID_TM_HK); | |
421 | dummy_hk_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; |
|
421 | dummy_hk_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; | |
422 | dummy_hk_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT; |
|
422 | dummy_hk_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT; | |
423 | dummy_hk_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_HK >> 8); |
|
423 | dummy_hk_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_HK >> 8); | |
424 | dummy_hk_packet.packetLength[1] = (unsigned char) (PACKET_LENGTH_HK ); |
|
424 | dummy_hk_packet.packetLength[1] = (unsigned char) (PACKET_LENGTH_HK ); | |
425 | dummy_hk_packet.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2; |
|
425 | dummy_hk_packet.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2; | |
426 | dummy_hk_packet.serviceType = TM_TYPE_HK; |
|
426 | dummy_hk_packet.serviceType = TM_TYPE_HK; | |
427 | dummy_hk_packet.serviceSubType = TM_SUBTYPE_HK; |
|
427 | dummy_hk_packet.serviceSubType = TM_SUBTYPE_HK; | |
428 | dummy_hk_packet.destinationID = TM_DESTINATION_ID_GROUND; |
|
428 | dummy_hk_packet.destinationID = TM_DESTINATION_ID_GROUND; | |
429 | dummy_hk_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24); |
|
429 | dummy_hk_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24); | |
430 | dummy_hk_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16); |
|
430 | dummy_hk_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16); | |
431 | dummy_hk_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8); |
|
431 | dummy_hk_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8); | |
432 | dummy_hk_packet.time[3] = (unsigned char) (time_management_regs->coarse_time); |
|
432 | dummy_hk_packet.time[3] = (unsigned char) (time_management_regs->coarse_time); | |
433 | dummy_hk_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8); |
|
433 | dummy_hk_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8); | |
434 | dummy_hk_packet.time[5] = (unsigned char) (time_management_regs->fine_time); |
|
434 | dummy_hk_packet.time[5] = (unsigned char) (time_management_regs->fine_time); | |
435 | dummy_hk_packet.sid = SID_HK; |
|
435 | dummy_hk_packet.sid = SID_HK; | |
436 |
|
436 | |||
437 | // init status word |
|
437 | // init status word | |
438 | dummy_hk_packet.lfr_status_word[0] = 0xff; |
|
438 | dummy_hk_packet.lfr_status_word[0] = 0xff; | |
439 | dummy_hk_packet.lfr_status_word[1] = 0xff; |
|
439 | dummy_hk_packet.lfr_status_word[1] = 0xff; | |
440 | // init software version |
|
440 | // init software version | |
441 | dummy_hk_packet.lfr_sw_version[0] = SW_VERSION_N1; |
|
441 | dummy_hk_packet.lfr_sw_version[0] = SW_VERSION_N1; | |
442 | dummy_hk_packet.lfr_sw_version[1] = SW_VERSION_N2; |
|
442 | dummy_hk_packet.lfr_sw_version[1] = SW_VERSION_N2; | |
443 | dummy_hk_packet.lfr_sw_version[2] = SW_VERSION_N3; |
|
443 | dummy_hk_packet.lfr_sw_version[2] = SW_VERSION_N3; | |
444 | dummy_hk_packet.lfr_sw_version[3] = SW_VERSION_N4; |
|
444 | dummy_hk_packet.lfr_sw_version[3] = SW_VERSION_N4; | |
445 | // init fpga version |
|
445 | // init fpga version | |
446 | parameters = (unsigned char *) (REGS_ADDR_WAVEFORM_PICKER + 0xb0); |
|
446 | parameters = (unsigned char *) (REGS_ADDR_WAVEFORM_PICKER + 0xb0); | |
447 | dummy_hk_packet.lfr_fpga_version[0] = parameters[1]; // n1 |
|
447 | dummy_hk_packet.lfr_fpga_version[0] = parameters[1]; // n1 | |
448 | dummy_hk_packet.lfr_fpga_version[1] = parameters[2]; // n2 |
|
448 | dummy_hk_packet.lfr_fpga_version[1] = parameters[2]; // n2 | |
449 | dummy_hk_packet.lfr_fpga_version[2] = parameters[3]; // n3 |
|
449 | dummy_hk_packet.lfr_fpga_version[2] = parameters[3]; // n3 | |
450 |
|
450 | |||
451 | parameters = (unsigned char *) &dummy_hk_packet.hk_lfr_cpu_load; |
|
451 | parameters = (unsigned char *) &dummy_hk_packet.hk_lfr_cpu_load; | |
452 |
|
452 | |||
453 | for (i=0; i<100; i++) |
|
453 | for (i=0; i<100; i++) | |
454 | { |
|
454 | { | |
455 | parameters[i] = 0xff; |
|
455 | parameters[i] = 0xff; | |
456 | } |
|
456 | } | |
457 |
|
457 | |||
458 | get_message_queue_id_send( &queue_id ); |
|
458 | get_message_queue_id_send( &queue_id ); | |
459 |
|
459 | |||
460 | rtems_message_queue_send( queue_id, &dummy_hk_packet, |
|
460 | rtems_message_queue_send( queue_id, &dummy_hk_packet, | |
461 | PACKET_LENGTH_HK + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES); |
|
461 | PACKET_LENGTH_HK + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES); | |
462 | } |
|
462 | } | |
463 |
|
463 | |||
464 | void get_temperatures( unsigned char *temperatures ) |
|
464 | void get_temperatures( unsigned char *temperatures ) | |
465 | { |
|
465 | { | |
466 | unsigned char* temp_scm_ptr; |
|
466 | unsigned char* temp_scm_ptr; | |
467 | unsigned char* temp_pcb_ptr; |
|
467 | unsigned char* temp_pcb_ptr; | |
468 | unsigned char* temp_fpga_ptr; |
|
468 | unsigned char* temp_fpga_ptr; | |
469 |
|
469 | |||
470 | // SEL1 SEL0 |
|
470 | // SEL1 SEL0 | |
471 | // 0 0 => PCB |
|
471 | // 0 0 => PCB | |
472 | // 0 1 => FPGA |
|
472 | // 0 1 => FPGA | |
473 | // 1 0 => SCM |
|
473 | // 1 0 => SCM | |
474 |
|
474 | |||
475 | temp_scm_ptr = (unsigned char *) &time_management_regs->temp_scm; |
|
475 | temp_scm_ptr = (unsigned char *) &time_management_regs->temp_scm; | |
476 | temp_pcb_ptr = (unsigned char *) &time_management_regs->temp_pcb; |
|
476 | temp_pcb_ptr = (unsigned char *) &time_management_regs->temp_pcb; | |
477 | temp_fpga_ptr = (unsigned char *) &time_management_regs->temp_fpga; |
|
477 | temp_fpga_ptr = (unsigned char *) &time_management_regs->temp_fpga; | |
478 |
|
478 | |||
479 | temperatures[0] = temp_scm_ptr[2]; |
|
479 | temperatures[0] = temp_scm_ptr[2]; | |
480 | temperatures[1] = temp_scm_ptr[3]; |
|
480 | temperatures[1] = temp_scm_ptr[3]; | |
481 | temperatures[2] = temp_pcb_ptr[2]; |
|
481 | temperatures[2] = temp_pcb_ptr[2]; | |
482 | temperatures[3] = temp_pcb_ptr[3]; |
|
482 | temperatures[3] = temp_pcb_ptr[3]; | |
483 | temperatures[4] = temp_fpga_ptr[2]; |
|
483 | temperatures[4] = temp_fpga_ptr[2]; | |
484 | temperatures[5] = temp_fpga_ptr[3]; |
|
484 | temperatures[5] = temp_fpga_ptr[3]; | |
485 | } |
|
485 | } | |
486 |
|
486 | |||
487 | void get_v_e1_e2_f3( unsigned char *spacecraft_potential ) |
|
487 | void get_v_e1_e2_f3( unsigned char *spacecraft_potential ) | |
488 | { |
|
488 | { | |
489 | unsigned char* v_ptr; |
|
489 | unsigned char* v_ptr; | |
490 | unsigned char* e1_ptr; |
|
490 | unsigned char* e1_ptr; | |
491 | unsigned char* e2_ptr; |
|
491 | unsigned char* e2_ptr; | |
492 |
|
492 | |||
493 | v_ptr = (unsigned char *) &waveform_picker_regs->v; |
|
493 | v_ptr = (unsigned char *) &waveform_picker_regs->v; | |
494 | e1_ptr = (unsigned char *) &waveform_picker_regs->e1; |
|
494 | e1_ptr = (unsigned char *) &waveform_picker_regs->e1; | |
495 | e2_ptr = (unsigned char *) &waveform_picker_regs->e2; |
|
495 | e2_ptr = (unsigned char *) &waveform_picker_regs->e2; | |
496 |
|
496 | |||
497 | spacecraft_potential[0] = v_ptr[2]; |
|
497 | spacecraft_potential[0] = v_ptr[2]; | |
498 | spacecraft_potential[1] = v_ptr[3]; |
|
498 | spacecraft_potential[1] = v_ptr[3]; | |
499 | spacecraft_potential[2] = e1_ptr[2]; |
|
499 | spacecraft_potential[2] = e1_ptr[2]; | |
500 | spacecraft_potential[3] = e1_ptr[3]; |
|
500 | spacecraft_potential[3] = e1_ptr[3]; | |
501 | spacecraft_potential[4] = e2_ptr[2]; |
|
501 | spacecraft_potential[4] = e2_ptr[2]; | |
502 | spacecraft_potential[5] = e2_ptr[3]; |
|
502 | spacecraft_potential[5] = e2_ptr[3]; | |
503 | } |
|
503 | } | |
504 |
|
504 | |||
505 | void get_cpu_load( unsigned char *resource_statistics ) |
|
505 | void get_cpu_load( unsigned char *resource_statistics ) | |
506 | { |
|
506 | { | |
507 | unsigned char cpu_load; |
|
507 | unsigned char cpu_load; | |
508 |
|
508 | |||
509 | cpu_load = lfr_rtems_cpu_usage_report(); |
|
509 | cpu_load = lfr_rtems_cpu_usage_report(); | |
510 |
|
510 | |||
511 | // HK_LFR_CPU_LOAD |
|
511 | // HK_LFR_CPU_LOAD | |
512 | resource_statistics[0] = cpu_load; |
|
512 | resource_statistics[0] = cpu_load; | |
513 |
|
513 | |||
514 | // HK_LFR_CPU_LOAD_MAX |
|
514 | // HK_LFR_CPU_LOAD_MAX | |
515 | if (cpu_load > resource_statistics[1]) |
|
515 | if (cpu_load > resource_statistics[1]) | |
516 | { |
|
516 | { | |
517 | resource_statistics[1] = cpu_load; |
|
517 | resource_statistics[1] = cpu_load; | |
518 | } |
|
518 | } | |
519 |
|
519 | |||
520 | // CPU_LOAD_AVE |
|
520 | // CPU_LOAD_AVE | |
521 | resource_statistics[2] = 0; |
|
521 | resource_statistics[2] = 0; | |
522 |
|
522 | |||
523 | #ifndef PRINT_TASK_STATISTICS |
|
523 | #ifndef PRINT_TASK_STATISTICS | |
524 | rtems_cpu_usage_reset(); |
|
524 | rtems_cpu_usage_reset(); | |
525 | #endif |
|
525 | #endif | |
526 |
|
526 | |||
527 | } |
|
527 | } | |
528 |
|
528 | |||
529 | void set_hk_lfr_sc_potential_flag( bool state ) |
|
529 | void set_hk_lfr_sc_potential_flag( bool state ) | |
530 | { |
|
530 | { | |
531 | if (state == true) |
|
531 | if (state == true) | |
532 | { |
|
532 | { | |
533 | housekeeping_packet.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1] | 0x40; // [0100 0000] |
|
533 | housekeeping_packet.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1] | 0x40; // [0100 0000] | |
534 | } |
|
534 | } | |
535 | else |
|
535 | else | |
536 | { |
|
536 | { | |
537 | housekeeping_packet.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1] & 0xbf; // [1011 1111] |
|
537 | housekeeping_packet.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1] & 0xbf; // [1011 1111] | |
538 | } |
|
538 | } | |
539 | } |
|
539 | } | |
540 |
|
540 | |||
|
541 | void set_hk_lfr_mag_fields_flag( bool state ) | |||
|
542 | { | |||
|
543 | if (state == true) | |||
|
544 | { | |||
|
545 | housekeeping_packet.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1] | 0x20; // [0010 0000] | |||
|
546 | } | |||
|
547 | else | |||
|
548 | { | |||
|
549 | housekeeping_packet.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1] & 0xd7; // [1101 1111] | |||
|
550 | } | |||
|
551 | } | |||
|
552 | ||||
541 | void set_hk_lfr_calib_enable( bool state ) |
|
553 | void set_hk_lfr_calib_enable( bool state ) | |
542 | { |
|
554 | { | |
543 | if (state == true) |
|
555 | if (state == true) | |
544 | { |
|
556 | { | |
545 | housekeeping_packet.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1] | 0x08; // [0000 1000] |
|
557 | housekeeping_packet.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1] | 0x08; // [0000 1000] | |
546 | } |
|
558 | } | |
547 | else |
|
559 | else | |
548 | { |
|
560 | { | |
549 | housekeeping_packet.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1] & 0xf7; // [1111 0111] |
|
561 | housekeeping_packet.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1] & 0xf7; // [1111 0111] | |
550 | } |
|
562 | } | |
551 | } |
|
563 | } | |
|
564 |
@@ -1,1283 +1,1289 | |||||
1 | /** Functions related to the SpaceWire interface. |
|
1 | /** Functions related to the SpaceWire interface. | |
2 | * |
|
2 | * | |
3 | * @file |
|
3 | * @file | |
4 | * @author P. LEROY |
|
4 | * @author P. LEROY | |
5 | * |
|
5 | * | |
6 | * A group of functions to handle SpaceWire transmissions: |
|
6 | * A group of functions to handle SpaceWire transmissions: | |
7 | * - configuration of the SpaceWire link |
|
7 | * - configuration of the SpaceWire link | |
8 | * - SpaceWire related interruption requests processing |
|
8 | * - SpaceWire related interruption requests processing | |
9 | * - transmission of TeleMetry packets by a dedicated RTEMS task |
|
9 | * - transmission of TeleMetry packets by a dedicated RTEMS task | |
10 | * - reception of TeleCommands by a dedicated RTEMS task |
|
10 | * - reception of TeleCommands by a dedicated RTEMS task | |
11 | * |
|
11 | * | |
12 | */ |
|
12 | */ | |
13 |
|
13 | |||
14 | #include "fsw_spacewire.h" |
|
14 | #include "fsw_spacewire.h" | |
15 |
|
15 | |||
16 | rtems_name semq_name; |
|
16 | rtems_name semq_name; | |
17 | rtems_id semq_id; |
|
17 | rtems_id semq_id; | |
18 |
|
18 | |||
19 | //***************** |
|
19 | //***************** | |
20 | // waveform headers |
|
20 | // waveform headers | |
21 | Header_TM_LFR_SCIENCE_CWF_t headerCWF; |
|
21 | Header_TM_LFR_SCIENCE_CWF_t headerCWF; | |
22 | Header_TM_LFR_SCIENCE_SWF_t headerSWF; |
|
22 | Header_TM_LFR_SCIENCE_SWF_t headerSWF; | |
23 | Header_TM_LFR_SCIENCE_ASM_t headerASM; |
|
23 | Header_TM_LFR_SCIENCE_ASM_t headerASM; | |
24 |
|
24 | |||
25 | //*********** |
|
25 | //*********** | |
26 | // RTEMS TASK |
|
26 | // RTEMS TASK | |
27 | rtems_task spiq_task(rtems_task_argument unused) |
|
27 | rtems_task spiq_task(rtems_task_argument unused) | |
28 | { |
|
28 | { | |
29 | /** This RTEMS task is awaken by an rtems_event sent by the interruption subroutine of the SpaceWire driver. |
|
29 | /** This RTEMS task is awaken by an rtems_event sent by the interruption subroutine of the SpaceWire driver. | |
30 | * |
|
30 | * | |
31 | * @param unused is the starting argument of the RTEMS task |
|
31 | * @param unused is the starting argument of the RTEMS task | |
32 | * |
|
32 | * | |
33 | */ |
|
33 | */ | |
34 |
|
34 | |||
35 | rtems_event_set event_out; |
|
35 | rtems_event_set event_out; | |
36 | rtems_status_code status; |
|
36 | rtems_status_code status; | |
37 | int linkStatus; |
|
37 | int linkStatus; | |
38 |
|
38 | |||
39 | BOOT_PRINTF("in SPIQ *** \n") |
|
39 | BOOT_PRINTF("in SPIQ *** \n") | |
40 |
|
40 | |||
41 | while(true){ |
|
41 | while(true){ | |
42 | rtems_event_receive(SPW_LINKERR_EVENT, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an SPW_LINKERR_EVENT |
|
42 | rtems_event_receive(SPW_LINKERR_EVENT, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an SPW_LINKERR_EVENT | |
43 | PRINTF("in SPIQ *** got SPW_LINKERR_EVENT\n") |
|
43 | PRINTF("in SPIQ *** got SPW_LINKERR_EVENT\n") | |
44 |
|
44 | |||
45 | // [0] SUSPEND RECV AND SEND TASKS |
|
45 | // [0] SUSPEND RECV AND SEND TASKS | |
46 | status = rtems_task_suspend( Task_id[ TASKID_RECV ] ); |
|
46 | status = rtems_task_suspend( Task_id[ TASKID_RECV ] ); | |
47 | if ( status != RTEMS_SUCCESSFUL ) { |
|
47 | if ( status != RTEMS_SUCCESSFUL ) { | |
48 | PRINTF("in SPIQ *** ERR suspending RECV Task\n") |
|
48 | PRINTF("in SPIQ *** ERR suspending RECV Task\n") | |
49 | } |
|
49 | } | |
50 | status = rtems_task_suspend( Task_id[ TASKID_SEND ] ); |
|
50 | status = rtems_task_suspend( Task_id[ TASKID_SEND ] ); | |
51 | if ( status != RTEMS_SUCCESSFUL ) { |
|
51 | if ( status != RTEMS_SUCCESSFUL ) { | |
52 | PRINTF("in SPIQ *** ERR suspending SEND Task\n") |
|
52 | PRINTF("in SPIQ *** ERR suspending SEND Task\n") | |
53 | } |
|
53 | } | |
54 |
|
54 | |||
55 | // [1] CHECK THE LINK |
|
55 | // [1] CHECK THE LINK | |
56 | status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status (1) |
|
56 | status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status (1) | |
57 | if ( linkStatus != 5) { |
|
57 | if ( linkStatus != 5) { | |
58 | PRINTF1("in SPIQ *** linkStatus %d, wait...\n", linkStatus) |
|
58 | PRINTF1("in SPIQ *** linkStatus %d, wait...\n", linkStatus) | |
59 | status = rtems_task_wake_after( SY_LFR_DPU_CONNECT_TIMEOUT ); // wait SY_LFR_DPU_CONNECT_TIMEOUT 1000 ms |
|
59 | status = rtems_task_wake_after( SY_LFR_DPU_CONNECT_TIMEOUT ); // wait SY_LFR_DPU_CONNECT_TIMEOUT 1000 ms | |
60 | } |
|
60 | } | |
61 |
|
61 | |||
62 | // [2] RECHECK THE LINK AFTER SY_LFR_DPU_CONNECT_TIMEOUT |
|
62 | // [2] RECHECK THE LINK AFTER SY_LFR_DPU_CONNECT_TIMEOUT | |
63 | status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status (2) |
|
63 | status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status (2) | |
64 | if ( linkStatus != 5 ) // [2.a] not in run state, reset the link |
|
64 | if ( linkStatus != 5 ) // [2.a] not in run state, reset the link | |
65 | { |
|
65 | { | |
66 | spacewire_compute_stats_offsets(); |
|
66 | spacewire_compute_stats_offsets(); | |
67 | status = spacewire_reset_link( ); |
|
67 | status = spacewire_reset_link( ); | |
68 | } |
|
68 | } | |
69 | else // [2.b] in run state, start the link |
|
69 | else // [2.b] in run state, start the link | |
70 | { |
|
70 | { | |
71 | status = spacewire_stop_and_start_link( fdSPW ); // start the link |
|
71 | status = spacewire_stop_and_start_link( fdSPW ); // start the link | |
72 | if ( status != RTEMS_SUCCESSFUL) |
|
72 | if ( status != RTEMS_SUCCESSFUL) | |
73 | { |
|
73 | { | |
74 | PRINTF1("in SPIQ *** ERR spacewire_stop_and_start_link %d\n", status) |
|
74 | PRINTF1("in SPIQ *** ERR spacewire_stop_and_start_link %d\n", status) | |
75 | } |
|
75 | } | |
76 | } |
|
76 | } | |
77 |
|
77 | |||
78 | // [3] COMPLETE RECOVERY ACTION AFTER SY_LFR_DPU_CONNECT_ATTEMPTS |
|
78 | // [3] COMPLETE RECOVERY ACTION AFTER SY_LFR_DPU_CONNECT_ATTEMPTS | |
79 | if ( status == RTEMS_SUCCESSFUL ) // [3.a] the link is in run state and has been started successfully |
|
79 | if ( status == RTEMS_SUCCESSFUL ) // [3.a] the link is in run state and has been started successfully | |
80 | { |
|
80 | { | |
81 | status = rtems_task_restart( Task_id[ TASKID_SEND ], 1 ); |
|
81 | status = rtems_task_restart( Task_id[ TASKID_SEND ], 1 ); | |
82 | if ( status != RTEMS_SUCCESSFUL ) { |
|
82 | if ( status != RTEMS_SUCCESSFUL ) { | |
83 | PRINTF("in SPIQ *** ERR resuming SEND Task\n") |
|
83 | PRINTF("in SPIQ *** ERR resuming SEND Task\n") | |
84 | } |
|
84 | } | |
85 | status = rtems_task_restart( Task_id[ TASKID_RECV ], 1 ); |
|
85 | status = rtems_task_restart( Task_id[ TASKID_RECV ], 1 ); | |
86 | if ( status != RTEMS_SUCCESSFUL ) { |
|
86 | if ( status != RTEMS_SUCCESSFUL ) { | |
87 | PRINTF("in SPIQ *** ERR resuming RECV Task\n") |
|
87 | PRINTF("in SPIQ *** ERR resuming RECV Task\n") | |
88 | } |
|
88 | } | |
89 | } |
|
89 | } | |
90 | else // [3.b] the link is not in run state, go in STANDBY mode |
|
90 | else // [3.b] the link is not in run state, go in STANDBY mode | |
91 | { |
|
91 | { | |
92 | status = enter_mode( LFR_MODE_STANDBY, 0 ); |
|
92 | status = enter_mode( LFR_MODE_STANDBY, 0 ); | |
93 | if ( status != RTEMS_SUCCESSFUL ) { |
|
93 | if ( status != RTEMS_SUCCESSFUL ) { | |
94 | PRINTF1("in SPIQ *** ERR enter_standby_mode *** code %d\n", status) |
|
94 | PRINTF1("in SPIQ *** ERR enter_standby_mode *** code %d\n", status) | |
95 | } |
|
95 | } | |
96 | // wake the WTDG task up to wait for the link recovery |
|
96 | // wake the WTDG task up to wait for the link recovery | |
97 | status = rtems_event_send ( Task_id[TASKID_WTDG], RTEMS_EVENT_0 ); |
|
97 | status = rtems_event_send ( Task_id[TASKID_WTDG], RTEMS_EVENT_0 ); | |
98 | status = rtems_task_suspend( RTEMS_SELF ); |
|
98 | status = rtems_task_suspend( RTEMS_SELF ); | |
99 | } |
|
99 | } | |
100 | } |
|
100 | } | |
101 | } |
|
101 | } | |
102 |
|
102 | |||
103 | rtems_task recv_task( rtems_task_argument unused ) |
|
103 | rtems_task recv_task( rtems_task_argument unused ) | |
104 | { |
|
104 | { | |
105 | /** This RTEMS task is dedicated to the reception of incoming TeleCommands. |
|
105 | /** This RTEMS task is dedicated to the reception of incoming TeleCommands. | |
106 | * |
|
106 | * | |
107 | * @param unused is the starting argument of the RTEMS task |
|
107 | * @param unused is the starting argument of the RTEMS task | |
108 | * |
|
108 | * | |
109 | * The RECV task blocks on a call to the read system call, waiting for incoming SpaceWire data. When unblocked: |
|
109 | * The RECV task blocks on a call to the read system call, waiting for incoming SpaceWire data. When unblocked: | |
110 | * 1. It reads the incoming data. |
|
110 | * 1. It reads the incoming data. | |
111 | * 2. Launches the acceptance procedure. |
|
111 | * 2. Launches the acceptance procedure. | |
112 | * 3. If the Telecommand is valid, sends it to a dedicated RTEMS message queue. |
|
112 | * 3. If the Telecommand is valid, sends it to a dedicated RTEMS message queue. | |
113 | * |
|
113 | * | |
114 | */ |
|
114 | */ | |
115 |
|
115 | |||
116 | int len; |
|
116 | int len; | |
117 | ccsdsTelecommandPacket_t currentTC; |
|
117 | ccsdsTelecommandPacket_t currentTC; | |
118 | unsigned char computed_CRC[ 2 ]; |
|
118 | unsigned char computed_CRC[ 2 ]; | |
119 | unsigned char currentTC_LEN_RCV[ 2 ]; |
|
119 | unsigned char currentTC_LEN_RCV[ 2 ]; | |
120 | unsigned char destinationID; |
|
120 | unsigned char destinationID; | |
121 | unsigned int estimatedPacketLength; |
|
121 | unsigned int estimatedPacketLength; | |
122 | unsigned int parserCode; |
|
122 | unsigned int parserCode; | |
123 | rtems_status_code status; |
|
123 | rtems_status_code status; | |
124 | rtems_id queue_recv_id; |
|
124 | rtems_id queue_recv_id; | |
125 | rtems_id queue_send_id; |
|
125 | rtems_id queue_send_id; | |
126 |
|
126 | |||
127 | initLookUpTableForCRC(); // the table is used to compute Cyclic Redundancy Codes |
|
127 | initLookUpTableForCRC(); // the table is used to compute Cyclic Redundancy Codes | |
128 |
|
128 | |||
129 | status = get_message_queue_id_recv( &queue_recv_id ); |
|
129 | status = get_message_queue_id_recv( &queue_recv_id ); | |
130 | if (status != RTEMS_SUCCESSFUL) |
|
130 | if (status != RTEMS_SUCCESSFUL) | |
131 | { |
|
131 | { | |
132 | PRINTF1("in RECV *** ERR get_message_queue_id_recv %d\n", status) |
|
132 | PRINTF1("in RECV *** ERR get_message_queue_id_recv %d\n", status) | |
133 | } |
|
133 | } | |
134 |
|
134 | |||
135 | status = get_message_queue_id_send( &queue_send_id ); |
|
135 | status = get_message_queue_id_send( &queue_send_id ); | |
136 | if (status != RTEMS_SUCCESSFUL) |
|
136 | if (status != RTEMS_SUCCESSFUL) | |
137 | { |
|
137 | { | |
138 | PRINTF1("in RECV *** ERR get_message_queue_id_send %d\n", status) |
|
138 | PRINTF1("in RECV *** ERR get_message_queue_id_send %d\n", status) | |
139 | } |
|
139 | } | |
140 |
|
140 | |||
141 | BOOT_PRINTF("in RECV *** \n") |
|
141 | BOOT_PRINTF("in RECV *** \n") | |
142 |
|
142 | |||
143 | while(1) |
|
143 | while(1) | |
144 | { |
|
144 | { | |
145 | len = read( fdSPW, (char*) ¤tTC, CCSDS_TC_PKT_MAX_SIZE ); // the call to read is blocking |
|
145 | len = read( fdSPW, (char*) ¤tTC, CCSDS_TC_PKT_MAX_SIZE ); // the call to read is blocking | |
146 | if (len == -1){ // error during the read call |
|
146 | if (len == -1){ // error during the read call | |
147 | PRINTF1("in RECV *** last read call returned -1, ERRNO %d\n", errno) |
|
147 | PRINTF1("in RECV *** last read call returned -1, ERRNO %d\n", errno) | |
148 | } |
|
148 | } | |
149 | else { |
|
149 | else { | |
150 | if ( (len+1) < CCSDS_TC_PKT_MIN_SIZE ) { |
|
150 | if ( (len+1) < CCSDS_TC_PKT_MIN_SIZE ) { | |
151 | PRINTF("in RECV *** packet lenght too short\n") |
|
151 | PRINTF("in RECV *** packet lenght too short\n") | |
152 | } |
|
152 | } | |
153 | else { |
|
153 | else { | |
154 | estimatedPacketLength = (unsigned int) (len - CCSDS_TC_TM_PACKET_OFFSET - 3); // => -3 is for Prot ID, Reserved and User App bytes |
|
154 | estimatedPacketLength = (unsigned int) (len - CCSDS_TC_TM_PACKET_OFFSET - 3); // => -3 is for Prot ID, Reserved and User App bytes | |
155 | currentTC_LEN_RCV[ 0 ] = (unsigned char) (estimatedPacketLength >> 8); |
|
155 | currentTC_LEN_RCV[ 0 ] = (unsigned char) (estimatedPacketLength >> 8); | |
156 | currentTC_LEN_RCV[ 1 ] = (unsigned char) (estimatedPacketLength ); |
|
156 | currentTC_LEN_RCV[ 1 ] = (unsigned char) (estimatedPacketLength ); | |
157 | // CHECK THE TC |
|
157 | // CHECK THE TC | |
158 | parserCode = tc_parser( ¤tTC, estimatedPacketLength, computed_CRC ) ; |
|
158 | parserCode = tc_parser( ¤tTC, estimatedPacketLength, computed_CRC ) ; | |
159 | if ( (parserCode == ILLEGAL_APID) || (parserCode == WRONG_LEN_PKT) |
|
159 | if ( (parserCode == ILLEGAL_APID) || (parserCode == WRONG_LEN_PKT) | |
160 | || (parserCode == INCOR_CHECKSUM) || (parserCode == ILL_TYPE) |
|
160 | || (parserCode == INCOR_CHECKSUM) || (parserCode == ILL_TYPE) | |
161 | || (parserCode == ILL_SUBTYPE) || (parserCode == WRONG_APP_DATA) |
|
161 | || (parserCode == ILL_SUBTYPE) || (parserCode == WRONG_APP_DATA) | |
162 | || (parserCode == WRONG_SRC_ID) ) |
|
162 | || (parserCode == WRONG_SRC_ID) ) | |
163 | { // send TM_LFR_TC_EXE_CORRUPTED |
|
163 | { // send TM_LFR_TC_EXE_CORRUPTED | |
164 | PRINTF1("TC corrupted received, with code: %d\n", parserCode) |
|
164 | PRINTF1("TC corrupted received, with code: %d\n", parserCode) | |
165 | if ( !( (currentTC.serviceType==TC_TYPE_TIME) && (currentTC.serviceSubType==TC_SUBTYPE_UPDT_TIME) ) |
|
165 | if ( !( (currentTC.serviceType==TC_TYPE_TIME) && (currentTC.serviceSubType==TC_SUBTYPE_UPDT_TIME) ) | |
166 | && |
|
166 | && | |
167 | !( (currentTC.serviceType==TC_TYPE_GEN) && (currentTC.serviceSubType==TC_SUBTYPE_UPDT_INFO)) |
|
167 | !( (currentTC.serviceType==TC_TYPE_GEN) && (currentTC.serviceSubType==TC_SUBTYPE_UPDT_INFO)) | |
168 | ) |
|
168 | ) | |
169 | { |
|
169 | { | |
170 | if ( parserCode == WRONG_SRC_ID ) |
|
170 | if ( parserCode == WRONG_SRC_ID ) | |
171 | { |
|
171 | { | |
172 | destinationID = SID_TC_GROUND; |
|
172 | destinationID = SID_TC_GROUND; | |
173 | } |
|
173 | } | |
174 | else |
|
174 | else | |
175 | { |
|
175 | { | |
176 | destinationID = currentTC.sourceID; |
|
176 | destinationID = currentTC.sourceID; | |
177 | } |
|
177 | } | |
178 | send_tm_lfr_tc_exe_corrupted( ¤tTC, queue_send_id, |
|
178 | send_tm_lfr_tc_exe_corrupted( ¤tTC, queue_send_id, | |
179 | computed_CRC, currentTC_LEN_RCV, |
|
179 | computed_CRC, currentTC_LEN_RCV, | |
180 | destinationID ); |
|
180 | destinationID ); | |
181 | } |
|
181 | } | |
182 | } |
|
182 | } | |
183 | else |
|
183 | else | |
184 | { // send valid TC to the action launcher |
|
184 | { // send valid TC to the action launcher | |
185 | status = rtems_message_queue_send( queue_recv_id, ¤tTC, |
|
185 | status = rtems_message_queue_send( queue_recv_id, ¤tTC, | |
186 | estimatedPacketLength + CCSDS_TC_TM_PACKET_OFFSET + 3); |
|
186 | estimatedPacketLength + CCSDS_TC_TM_PACKET_OFFSET + 3); | |
187 | } |
|
187 | } | |
188 | } |
|
188 | } | |
189 | } |
|
189 | } | |
190 |
|
190 | |||
191 | update_queue_max_count( queue_recv_id, &hk_lfr_q_rv_fifo_size_max ); |
|
191 | update_queue_max_count( queue_recv_id, &hk_lfr_q_rv_fifo_size_max ); | |
192 |
|
192 | |||
193 | } |
|
193 | } | |
194 | } |
|
194 | } | |
195 |
|
195 | |||
196 | rtems_task send_task( rtems_task_argument argument) |
|
196 | rtems_task send_task( rtems_task_argument argument) | |
197 | { |
|
197 | { | |
198 | /** This RTEMS task is dedicated to the transmission of TeleMetry packets. |
|
198 | /** This RTEMS task is dedicated to the transmission of TeleMetry packets. | |
199 | * |
|
199 | * | |
200 | * @param unused is the starting argument of the RTEMS task |
|
200 | * @param unused is the starting argument of the RTEMS task | |
201 | * |
|
201 | * | |
202 | * The SEND task waits for a message to become available in the dedicated RTEMS queue. When a message arrives: |
|
202 | * The SEND task waits for a message to become available in the dedicated RTEMS queue. When a message arrives: | |
203 | * - if the first byte is equal to CCSDS_DESTINATION_ID, the message is sent as is using the write system call. |
|
203 | * - if the first byte is equal to CCSDS_DESTINATION_ID, the message is sent as is using the write system call. | |
204 | * - if the first byte is not equal to CCSDS_DESTINATION_ID, the message is handled as a spw_ioctl_pkt_send. After |
|
204 | * - if the first byte is not equal to CCSDS_DESTINATION_ID, the message is handled as a spw_ioctl_pkt_send. After | |
205 | * analyzis, the packet is sent either using the write system call or using the ioctl call SPACEWIRE_IOCTRL_SEND, depending on the |
|
205 | * analyzis, the packet is sent either using the write system call or using the ioctl call SPACEWIRE_IOCTRL_SEND, depending on the | |
206 | * data it contains. |
|
206 | * data it contains. | |
207 | * |
|
207 | * | |
208 | */ |
|
208 | */ | |
209 |
|
209 | |||
210 | rtems_status_code status; // RTEMS status code |
|
210 | rtems_status_code status; // RTEMS status code | |
211 | char incomingData[MSG_QUEUE_SIZE_SEND]; // incoming data buffer |
|
211 | char incomingData[MSG_QUEUE_SIZE_SEND]; // incoming data buffer | |
212 | ring_node *incomingRingNodePtr; |
|
212 | ring_node *incomingRingNodePtr; | |
213 | int ring_node_address; |
|
213 | int ring_node_address; | |
214 | char *charPtr; |
|
214 | char *charPtr; | |
215 | spw_ioctl_pkt_send *spw_ioctl_send; |
|
215 | spw_ioctl_pkt_send *spw_ioctl_send; | |
216 | size_t size; // size of the incoming TC packet |
|
216 | size_t size; // size of the incoming TC packet | |
217 | rtems_id queue_send_id; |
|
217 | rtems_id queue_send_id; | |
218 | unsigned int sid; |
|
218 | unsigned int sid; | |
219 |
|
219 | |||
220 | incomingRingNodePtr = NULL; |
|
220 | incomingRingNodePtr = NULL; | |
221 | ring_node_address = 0; |
|
221 | ring_node_address = 0; | |
222 | charPtr = (char *) &ring_node_address; |
|
222 | charPtr = (char *) &ring_node_address; | |
223 | sid = 0; |
|
223 | sid = 0; | |
224 |
|
224 | |||
225 | init_header_cwf( &headerCWF ); |
|
225 | init_header_cwf( &headerCWF ); | |
226 | init_header_swf( &headerSWF ); |
|
226 | init_header_swf( &headerSWF ); | |
227 | init_header_asm( &headerASM ); |
|
227 | init_header_asm( &headerASM ); | |
228 |
|
228 | |||
229 | status = get_message_queue_id_send( &queue_send_id ); |
|
229 | status = get_message_queue_id_send( &queue_send_id ); | |
230 | if (status != RTEMS_SUCCESSFUL) |
|
230 | if (status != RTEMS_SUCCESSFUL) | |
231 | { |
|
231 | { | |
232 | PRINTF1("in HOUS *** ERR get_message_queue_id_send %d\n", status) |
|
232 | PRINTF1("in HOUS *** ERR get_message_queue_id_send %d\n", status) | |
233 | } |
|
233 | } | |
234 |
|
234 | |||
235 | BOOT_PRINTF("in SEND *** \n") |
|
235 | BOOT_PRINTF("in SEND *** \n") | |
236 |
|
236 | |||
237 | while(1) |
|
237 | while(1) | |
238 | { |
|
238 | { | |
239 | status = rtems_message_queue_receive( queue_send_id, incomingData, &size, |
|
239 | status = rtems_message_queue_receive( queue_send_id, incomingData, &size, | |
240 | RTEMS_WAIT, RTEMS_NO_TIMEOUT ); |
|
240 | RTEMS_WAIT, RTEMS_NO_TIMEOUT ); | |
241 |
|
241 | |||
242 | if (status!=RTEMS_SUCCESSFUL) |
|
242 | if (status!=RTEMS_SUCCESSFUL) | |
243 | { |
|
243 | { | |
244 | PRINTF1("in SEND *** (1) ERR = %d\n", status) |
|
244 | PRINTF1("in SEND *** (1) ERR = %d\n", status) | |
245 | } |
|
245 | } | |
246 | else |
|
246 | else | |
247 | { |
|
247 | { | |
248 | if ( size == sizeof(ring_node*) ) |
|
248 | if ( size == sizeof(ring_node*) ) | |
249 | { |
|
249 | { | |
250 | charPtr[0] = incomingData[0]; |
|
250 | charPtr[0] = incomingData[0]; | |
251 | charPtr[1] = incomingData[1]; |
|
251 | charPtr[1] = incomingData[1]; | |
252 | charPtr[2] = incomingData[2]; |
|
252 | charPtr[2] = incomingData[2]; | |
253 | charPtr[3] = incomingData[3]; |
|
253 | charPtr[3] = incomingData[3]; | |
254 | incomingRingNodePtr = (ring_node*) ring_node_address; |
|
254 | incomingRingNodePtr = (ring_node*) ring_node_address; | |
255 | sid = incomingRingNodePtr->sid; |
|
255 | sid = incomingRingNodePtr->sid; | |
256 | if ( (sid==SID_NORM_CWF_LONG_F3) |
|
256 | if ( (sid==SID_NORM_CWF_LONG_F3) | |
257 | || (sid==SID_BURST_CWF_F2 ) |
|
257 | || (sid==SID_BURST_CWF_F2 ) | |
258 | || (sid==SID_SBM1_CWF_F1 ) |
|
258 | || (sid==SID_SBM1_CWF_F1 ) | |
259 | || (sid==SID_SBM2_CWF_F2 )) |
|
259 | || (sid==SID_SBM2_CWF_F2 )) | |
260 | { |
|
260 | { | |
261 | spw_send_waveform_CWF( incomingRingNodePtr, &headerCWF ); |
|
261 | spw_send_waveform_CWF( incomingRingNodePtr, &headerCWF ); | |
262 | } |
|
262 | } | |
263 | else if ( (sid==SID_NORM_SWF_F0) || (sid== SID_NORM_SWF_F1) || (sid==SID_NORM_SWF_F2) ) |
|
263 | else if ( (sid==SID_NORM_SWF_F0) || (sid== SID_NORM_SWF_F1) || (sid==SID_NORM_SWF_F2) ) | |
264 | { |
|
264 | { | |
265 | spw_send_waveform_SWF( incomingRingNodePtr, &headerSWF ); |
|
265 | spw_send_waveform_SWF( incomingRingNodePtr, &headerSWF ); | |
266 | } |
|
266 | } | |
267 | else if ( (sid==SID_NORM_CWF_F3) ) |
|
267 | else if ( (sid==SID_NORM_CWF_F3) ) | |
268 | { |
|
268 | { | |
269 | spw_send_waveform_CWF3_light( incomingRingNodePtr, &headerCWF ); |
|
269 | spw_send_waveform_CWF3_light( incomingRingNodePtr, &headerCWF ); | |
270 | } |
|
270 | } | |
271 | else if (sid==SID_NORM_ASM_F0) |
|
271 | else if (sid==SID_NORM_ASM_F0) | |
272 | { |
|
272 | { | |
273 | spw_send_asm_f0( incomingRingNodePtr, &headerASM ); |
|
273 | spw_send_asm_f0( incomingRingNodePtr, &headerASM ); | |
274 | } |
|
274 | } | |
275 | else if (sid==SID_NORM_ASM_F1) |
|
275 | else if (sid==SID_NORM_ASM_F1) | |
276 | { |
|
276 | { | |
277 | spw_send_asm_f1( incomingRingNodePtr, &headerASM ); |
|
277 | spw_send_asm_f1( incomingRingNodePtr, &headerASM ); | |
278 | } |
|
278 | } | |
279 | else if (sid==SID_NORM_ASM_F2) |
|
279 | else if (sid==SID_NORM_ASM_F2) | |
280 | { |
|
280 | { | |
281 | spw_send_asm_f2( incomingRingNodePtr, &headerASM ); |
|
281 | spw_send_asm_f2( incomingRingNodePtr, &headerASM ); | |
282 | } |
|
282 | } | |
283 | else if ( sid==TM_CODE_K_DUMP ) |
|
283 | else if ( sid==TM_CODE_K_DUMP ) | |
284 | { |
|
284 | { | |
285 | spw_send_k_dump( incomingRingNodePtr ); |
|
285 | spw_send_k_dump( incomingRingNodePtr ); | |
286 | } |
|
286 | } | |
287 | else |
|
287 | else | |
288 | { |
|
288 | { | |
289 | printf("unexpected sid = %d\n", sid); |
|
289 | printf("unexpected sid = %d\n", sid); | |
290 | } |
|
290 | } | |
291 | } |
|
291 | } | |
292 | else if ( incomingData[0] == CCSDS_DESTINATION_ID ) // the incoming message is a ccsds packet |
|
292 | else if ( incomingData[0] == CCSDS_DESTINATION_ID ) // the incoming message is a ccsds packet | |
293 | { |
|
293 | { | |
294 | status = write( fdSPW, incomingData, size ); |
|
294 | status = write( fdSPW, incomingData, size ); | |
295 | if (status == -1){ |
|
295 | if (status == -1){ | |
296 | PRINTF2("in SEND *** (2.a) ERRNO = %d, size = %d\n", errno, size) |
|
296 | PRINTF2("in SEND *** (2.a) ERRNO = %d, size = %d\n", errno, size) | |
297 | } |
|
297 | } | |
298 | } |
|
298 | } | |
299 | else // the incoming message is a spw_ioctl_pkt_send structure |
|
299 | else // the incoming message is a spw_ioctl_pkt_send structure | |
300 | { |
|
300 | { | |
301 | spw_ioctl_send = (spw_ioctl_pkt_send*) incomingData; |
|
301 | spw_ioctl_send = (spw_ioctl_pkt_send*) incomingData; | |
302 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, spw_ioctl_send ); |
|
302 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, spw_ioctl_send ); | |
303 | if (status == -1){ |
|
303 | if (status == -1){ | |
304 | printf("size = %d, %x, %x, %x, %x, %x\n", |
|
304 | printf("size = %d, %x, %x, %x, %x, %x\n", | |
305 | size, |
|
305 | size, | |
306 | incomingData[0], |
|
306 | incomingData[0], | |
307 | incomingData[1], |
|
307 | incomingData[1], | |
308 | incomingData[2], |
|
308 | incomingData[2], | |
309 | incomingData[3], |
|
309 | incomingData[3], | |
310 | incomingData[4]); |
|
310 | incomingData[4]); | |
311 | PRINTF2("in SEND *** (2.b) ERRNO = %d, RTEMS = %d\n", errno, status) |
|
311 | PRINTF2("in SEND *** (2.b) ERRNO = %d, RTEMS = %d\n", errno, status) | |
312 | } |
|
312 | } | |
313 | } |
|
313 | } | |
314 | } |
|
314 | } | |
315 |
|
315 | |||
316 | update_queue_max_count( queue_send_id, &hk_lfr_q_sd_fifo_size_max ); |
|
316 | update_queue_max_count( queue_send_id, &hk_lfr_q_sd_fifo_size_max ); | |
317 |
|
317 | |||
318 | } |
|
318 | } | |
319 | } |
|
319 | } | |
320 |
|
320 | |||
321 | rtems_task wtdg_task( rtems_task_argument argument ) |
|
321 | rtems_task wtdg_task( rtems_task_argument argument ) | |
322 | { |
|
322 | { | |
323 | rtems_event_set event_out; |
|
323 | rtems_event_set event_out; | |
324 | rtems_status_code status; |
|
324 | rtems_status_code status; | |
325 | int linkStatus; |
|
325 | int linkStatus; | |
326 |
|
326 | |||
327 | BOOT_PRINTF("in WTDG ***\n") |
|
327 | BOOT_PRINTF("in WTDG ***\n") | |
328 |
|
328 | |||
329 | while(1) |
|
329 | while(1) | |
330 | { |
|
330 | { | |
331 | // wait for an RTEMS_EVENT |
|
331 | // wait for an RTEMS_EVENT | |
332 | rtems_event_receive( RTEMS_EVENT_0, |
|
332 | rtems_event_receive( RTEMS_EVENT_0, | |
333 | RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); |
|
333 | RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); | |
334 | PRINTF("in WTDG *** wait for the link\n") |
|
334 | PRINTF("in WTDG *** wait for the link\n") | |
335 | status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status |
|
335 | status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status | |
336 | while( linkStatus != 5) // wait for the link |
|
336 | while( linkStatus != 5) // wait for the link | |
337 | { |
|
337 | { | |
338 | status = rtems_task_wake_after( 10 ); // monitor the link each 100ms |
|
338 | status = rtems_task_wake_after( 10 ); // monitor the link each 100ms | |
339 | status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status |
|
339 | status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status | |
340 | } |
|
340 | } | |
341 |
|
341 | |||
342 | status = spacewire_stop_and_start_link( fdSPW ); |
|
342 | status = spacewire_stop_and_start_link( fdSPW ); | |
343 |
|
343 | |||
344 | if (status != RTEMS_SUCCESSFUL) |
|
344 | if (status != RTEMS_SUCCESSFUL) | |
345 | { |
|
345 | { | |
346 | PRINTF1("in WTDG *** ERR link not started %d\n", status) |
|
346 | PRINTF1("in WTDG *** ERR link not started %d\n", status) | |
347 | } |
|
347 | } | |
348 | else |
|
348 | else | |
349 | { |
|
349 | { | |
350 | PRINTF("in WTDG *** OK link started\n") |
|
350 | PRINTF("in WTDG *** OK link started\n") | |
351 | } |
|
351 | } | |
352 |
|
352 | |||
353 | // restart the SPIQ task |
|
353 | // restart the SPIQ task | |
354 | status = rtems_task_restart( Task_id[TASKID_SPIQ], 1 ); |
|
354 | status = rtems_task_restart( Task_id[TASKID_SPIQ], 1 ); | |
355 | if ( status != RTEMS_SUCCESSFUL ) { |
|
355 | if ( status != RTEMS_SUCCESSFUL ) { | |
356 | PRINTF("in SPIQ *** ERR restarting SPIQ Task\n") |
|
356 | PRINTF("in SPIQ *** ERR restarting SPIQ Task\n") | |
357 | } |
|
357 | } | |
358 |
|
358 | |||
359 | // restart RECV and SEND |
|
359 | // restart RECV and SEND | |
360 | status = rtems_task_restart( Task_id[ TASKID_SEND ], 1 ); |
|
360 | status = rtems_task_restart( Task_id[ TASKID_SEND ], 1 ); | |
361 | if ( status != RTEMS_SUCCESSFUL ) { |
|
361 | if ( status != RTEMS_SUCCESSFUL ) { | |
362 | PRINTF("in SPIQ *** ERR restarting SEND Task\n") |
|
362 | PRINTF("in SPIQ *** ERR restarting SEND Task\n") | |
363 | } |
|
363 | } | |
364 | status = rtems_task_restart( Task_id[ TASKID_RECV ], 1 ); |
|
364 | status = rtems_task_restart( Task_id[ TASKID_RECV ], 1 ); | |
365 | if ( status != RTEMS_SUCCESSFUL ) { |
|
365 | if ( status != RTEMS_SUCCESSFUL ) { | |
366 | PRINTF("in SPIQ *** ERR restarting RECV Task\n") |
|
366 | PRINTF("in SPIQ *** ERR restarting RECV Task\n") | |
367 | } |
|
367 | } | |
368 | } |
|
368 | } | |
369 | } |
|
369 | } | |
370 |
|
370 | |||
371 | //**************** |
|
371 | //**************** | |
372 | // OTHER FUNCTIONS |
|
372 | // OTHER FUNCTIONS | |
373 | int spacewire_open_link( void ) // by default, the driver resets the core: [SPW_CTRL_WRITE(pDev, SPW_CTRL_RESET);] |
|
373 | int spacewire_open_link( void ) // by default, the driver resets the core: [SPW_CTRL_WRITE(pDev, SPW_CTRL_RESET);] | |
374 | { |
|
374 | { | |
375 | /** This function opens the SpaceWire link. |
|
375 | /** This function opens the SpaceWire link. | |
376 | * |
|
376 | * | |
377 | * @return a valid file descriptor in case of success, -1 in case of a failure |
|
377 | * @return a valid file descriptor in case of success, -1 in case of a failure | |
378 | * |
|
378 | * | |
379 | */ |
|
379 | */ | |
380 | rtems_status_code status; |
|
380 | rtems_status_code status; | |
381 |
|
381 | |||
382 | fdSPW = open(GRSPW_DEVICE_NAME, O_RDWR); // open the device. the open call resets the hardware |
|
382 | fdSPW = open(GRSPW_DEVICE_NAME, O_RDWR); // open the device. the open call resets the hardware | |
383 | if ( fdSPW < 0 ) { |
|
383 | if ( fdSPW < 0 ) { | |
384 | PRINTF1("ERR *** in configure_spw_link *** error opening "GRSPW_DEVICE_NAME" with ERR %d\n", errno) |
|
384 | PRINTF1("ERR *** in configure_spw_link *** error opening "GRSPW_DEVICE_NAME" with ERR %d\n", errno) | |
385 | } |
|
385 | } | |
386 | else |
|
386 | else | |
387 | { |
|
387 | { | |
388 | status = RTEMS_SUCCESSFUL; |
|
388 | status = RTEMS_SUCCESSFUL; | |
389 | } |
|
389 | } | |
390 |
|
390 | |||
391 | return status; |
|
391 | return status; | |
392 | } |
|
392 | } | |
393 |
|
393 | |||
394 | int spacewire_start_link( int fd ) |
|
394 | int spacewire_start_link( int fd ) | |
395 | { |
|
395 | { | |
396 | rtems_status_code status; |
|
396 | rtems_status_code status; | |
397 |
|
397 | |||
398 | status = ioctl( fd, SPACEWIRE_IOCTRL_START, -1); // returns successfuly if the link is started |
|
398 | status = ioctl( fd, SPACEWIRE_IOCTRL_START, -1); // returns successfuly if the link is started | |
399 | // -1 default hardcoded driver timeout |
|
399 | // -1 default hardcoded driver timeout | |
400 |
|
400 | |||
401 | return status; |
|
401 | return status; | |
402 | } |
|
402 | } | |
403 |
|
403 | |||
404 | int spacewire_stop_and_start_link( int fd ) |
|
404 | int spacewire_stop_and_start_link( int fd ) | |
405 | { |
|
405 | { | |
406 | rtems_status_code status; |
|
406 | rtems_status_code status; | |
407 |
|
407 | |||
408 | status = ioctl( fd, SPACEWIRE_IOCTRL_STOP); // start fails if link pDev->running != 0 |
|
408 | status = ioctl( fd, SPACEWIRE_IOCTRL_STOP); // start fails if link pDev->running != 0 | |
409 | status = ioctl( fd, SPACEWIRE_IOCTRL_START, -1); // returns successfuly if the link is started |
|
409 | status = ioctl( fd, SPACEWIRE_IOCTRL_START, -1); // returns successfuly if the link is started | |
410 | // -1 default hardcoded driver timeout |
|
410 | // -1 default hardcoded driver timeout | |
411 |
|
411 | |||
412 | return status; |
|
412 | return status; | |
413 | } |
|
413 | } | |
414 |
|
414 | |||
415 | int spacewire_configure_link( int fd ) |
|
415 | int spacewire_configure_link( int fd ) | |
416 | { |
|
416 | { | |
417 | /** This function configures the SpaceWire link. |
|
417 | /** This function configures the SpaceWire link. | |
418 | * |
|
418 | * | |
419 | * @return GR-RTEMS-DRIVER directive status codes: |
|
419 | * @return GR-RTEMS-DRIVER directive status codes: | |
420 | * - 22 EINVAL - Null pointer or an out of range value was given as the argument. |
|
420 | * - 22 EINVAL - Null pointer or an out of range value was given as the argument. | |
421 | * - 16 EBUSY - Only used for SEND. Returned when no descriptors are avialble in non-blocking mode. |
|
421 | * - 16 EBUSY - Only used for SEND. Returned when no descriptors are avialble in non-blocking mode. | |
422 | * - 88 ENOSYS - Returned for SET_DESTKEY if RMAP command handler is not available or if a non-implemented call is used. |
|
422 | * - 88 ENOSYS - Returned for SET_DESTKEY if RMAP command handler is not available or if a non-implemented call is used. | |
423 | * - 116 ETIMEDOUT - REturned for SET_PACKET_SIZE and START if the link could not be brought up. |
|
423 | * - 116 ETIMEDOUT - REturned for SET_PACKET_SIZE and START if the link could not be brought up. | |
424 | * - 12 ENOMEM - Returned for SET_PACKETSIZE if it was unable to allocate the new buffers. |
|
424 | * - 12 ENOMEM - Returned for SET_PACKETSIZE if it was unable to allocate the new buffers. | |
425 | * - 5 EIO - Error when writing to grswp hardware registers. |
|
425 | * - 5 EIO - Error when writing to grswp hardware registers. | |
426 | * - 2 ENOENT - No such file or directory |
|
426 | * - 2 ENOENT - No such file or directory | |
427 | */ |
|
427 | */ | |
428 |
|
428 | |||
429 | rtems_status_code status; |
|
429 | rtems_status_code status; | |
430 |
|
430 | |||
431 | spacewire_set_NP(1, REGS_ADDR_GRSPW); // [N]o [P]ort force |
|
431 | spacewire_set_NP(1, REGS_ADDR_GRSPW); // [N]o [P]ort force | |
432 | spacewire_set_RE(1, REGS_ADDR_GRSPW); // [R]MAP [E]nable, the dedicated call seems to break the no port force configuration |
|
432 | spacewire_set_RE(1, REGS_ADDR_GRSPW); // [R]MAP [E]nable, the dedicated call seems to break the no port force configuration | |
433 |
|
433 | |||
434 | status = ioctl(fd, SPACEWIRE_IOCTRL_SET_RXBLOCK, 1); // sets the blocking mode for reception |
|
434 | status = ioctl(fd, SPACEWIRE_IOCTRL_SET_RXBLOCK, 1); // sets the blocking mode for reception | |
435 | if (status!=RTEMS_SUCCESSFUL) { |
|
435 | if (status!=RTEMS_SUCCESSFUL) { | |
436 | PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_RXBLOCK\n") |
|
436 | PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_RXBLOCK\n") | |
437 | } |
|
437 | } | |
438 | // |
|
438 | // | |
439 | status = ioctl(fd, SPACEWIRE_IOCTRL_SET_EVENT_ID, Task_id[TASKID_SPIQ]); // sets the task ID to which an event is sent when a |
|
439 | status = ioctl(fd, SPACEWIRE_IOCTRL_SET_EVENT_ID, Task_id[TASKID_SPIQ]); // sets the task ID to which an event is sent when a | |
440 | if (status!=RTEMS_SUCCESSFUL) { |
|
440 | if (status!=RTEMS_SUCCESSFUL) { | |
441 | PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_EVENT_ID\n") // link-error interrupt occurs |
|
441 | PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_EVENT_ID\n") // link-error interrupt occurs | |
442 | } |
|
442 | } | |
443 | // |
|
443 | // | |
444 | status = ioctl(fd, SPACEWIRE_IOCTRL_SET_DISABLE_ERR, 0); // automatic link-disabling due to link-error interrupts |
|
444 | status = ioctl(fd, SPACEWIRE_IOCTRL_SET_DISABLE_ERR, 0); // automatic link-disabling due to link-error interrupts | |
445 | if (status!=RTEMS_SUCCESSFUL) { |
|
445 | if (status!=RTEMS_SUCCESSFUL) { | |
446 | PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_DISABLE_ERR\n") |
|
446 | PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_DISABLE_ERR\n") | |
447 | } |
|
447 | } | |
448 | // |
|
448 | // | |
449 | status = ioctl(fd, SPACEWIRE_IOCTRL_SET_LINK_ERR_IRQ, 1); // sets the link-error interrupt bit |
|
449 | status = ioctl(fd, SPACEWIRE_IOCTRL_SET_LINK_ERR_IRQ, 1); // sets the link-error interrupt bit | |
450 | if (status!=RTEMS_SUCCESSFUL) { |
|
450 | if (status!=RTEMS_SUCCESSFUL) { | |
451 | PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_LINK_ERR_IRQ\n") |
|
451 | PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_LINK_ERR_IRQ\n") | |
452 | } |
|
452 | } | |
453 | // |
|
453 | // | |
454 | status = ioctl(fd, SPACEWIRE_IOCTRL_SET_TXBLOCK, 1); // transmission blocks |
|
454 | status = ioctl(fd, SPACEWIRE_IOCTRL_SET_TXBLOCK, 1); // transmission blocks | |
455 | if (status!=RTEMS_SUCCESSFUL) { |
|
455 | if (status!=RTEMS_SUCCESSFUL) { | |
456 | PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_TXBLOCK\n") |
|
456 | PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_TXBLOCK\n") | |
457 | } |
|
457 | } | |
458 | // |
|
458 | // | |
459 | status = ioctl(fd, SPACEWIRE_IOCTRL_SET_TXBLOCK_ON_FULL, 1); // transmission blocks when no transmission descriptor is available |
|
459 | status = ioctl(fd, SPACEWIRE_IOCTRL_SET_TXBLOCK_ON_FULL, 1); // transmission blocks when no transmission descriptor is available | |
460 | if (status!=RTEMS_SUCCESSFUL) { |
|
460 | if (status!=RTEMS_SUCCESSFUL) { | |
461 | PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_TXBLOCK_ON_FULL\n") |
|
461 | PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_TXBLOCK_ON_FULL\n") | |
462 | } |
|
462 | } | |
463 | // |
|
463 | // | |
464 | status = ioctl(fd, SPACEWIRE_IOCTRL_SET_TCODE_CTRL, 0x0909); // [Time Rx : Time Tx : Link error : Tick-out IRQ] |
|
464 | status = ioctl(fd, SPACEWIRE_IOCTRL_SET_TCODE_CTRL, 0x0909); // [Time Rx : Time Tx : Link error : Tick-out IRQ] | |
465 | if (status!=RTEMS_SUCCESSFUL) { |
|
465 | if (status!=RTEMS_SUCCESSFUL) { | |
466 | PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_TCODE_CTRL,\n") |
|
466 | PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_TCODE_CTRL,\n") | |
467 | } |
|
467 | } | |
468 |
|
468 | |||
469 | return status; |
|
469 | return status; | |
470 | } |
|
470 | } | |
471 |
|
471 | |||
472 | int spacewire_reset_link( void ) |
|
472 | int spacewire_reset_link( void ) | |
473 | { |
|
473 | { | |
474 | /** This function is executed by the SPIQ rtems_task wehn it has been awaken by an interruption raised by the SpaceWire driver. |
|
474 | /** This function is executed by the SPIQ rtems_task wehn it has been awaken by an interruption raised by the SpaceWire driver. | |
475 | * |
|
475 | * | |
476 | * @return RTEMS directive status code: |
|
476 | * @return RTEMS directive status code: | |
477 | * - RTEMS_UNSATISFIED is returned is the link is not in the running state after 10 s. |
|
477 | * - RTEMS_UNSATISFIED is returned is the link is not in the running state after 10 s. | |
478 | * - RTEMS_SUCCESSFUL is returned if the link is up before the timeout. |
|
478 | * - RTEMS_SUCCESSFUL is returned if the link is up before the timeout. | |
479 | * |
|
479 | * | |
480 | */ |
|
480 | */ | |
481 |
|
481 | |||
482 | rtems_status_code status_spw; |
|
482 | rtems_status_code status_spw; | |
483 | rtems_status_code status; |
|
483 | rtems_status_code status; | |
484 | int i; |
|
484 | int i; | |
485 |
|
485 | |||
486 | for ( i=0; i<SY_LFR_DPU_CONNECT_ATTEMPT; i++ ) |
|
486 | for ( i=0; i<SY_LFR_DPU_CONNECT_ATTEMPT; i++ ) | |
487 | { |
|
487 | { | |
488 | PRINTF1("in spacewire_reset_link *** link recovery, try %d\n", i); |
|
488 | PRINTF1("in spacewire_reset_link *** link recovery, try %d\n", i); | |
489 |
|
489 | |||
490 | // CLOSING THE DRIVER AT THIS POINT WILL MAKE THE SEND TASK BLOCK THE SYSTEM |
|
490 | // CLOSING THE DRIVER AT THIS POINT WILL MAKE THE SEND TASK BLOCK THE SYSTEM | |
491 |
|
491 | |||
492 | status = rtems_task_wake_after( SY_LFR_DPU_CONNECT_TIMEOUT ); // wait SY_LFR_DPU_CONNECT_TIMEOUT 1000 ms |
|
492 | status = rtems_task_wake_after( SY_LFR_DPU_CONNECT_TIMEOUT ); // wait SY_LFR_DPU_CONNECT_TIMEOUT 1000 ms | |
493 |
|
493 | |||
494 | status_spw = spacewire_stop_and_start_link( fdSPW ); |
|
494 | status_spw = spacewire_stop_and_start_link( fdSPW ); | |
495 | if ( status_spw != RTEMS_SUCCESSFUL ) |
|
495 | if ( status_spw != RTEMS_SUCCESSFUL ) | |
496 | { |
|
496 | { | |
497 | PRINTF1("in spacewire_reset_link *** ERR spacewire_start_link code %d\n", status_spw) |
|
497 | PRINTF1("in spacewire_reset_link *** ERR spacewire_start_link code %d\n", status_spw) | |
498 | } |
|
498 | } | |
499 |
|
499 | |||
500 | if ( status_spw == RTEMS_SUCCESSFUL) |
|
500 | if ( status_spw == RTEMS_SUCCESSFUL) | |
501 | { |
|
501 | { | |
502 | break; |
|
502 | break; | |
503 | } |
|
503 | } | |
504 | } |
|
504 | } | |
505 |
|
505 | |||
506 | return status_spw; |
|
506 | return status_spw; | |
507 | } |
|
507 | } | |
508 |
|
508 | |||
509 | void spacewire_set_NP( unsigned char val, unsigned int regAddr ) // [N]o [P]ort force |
|
509 | void spacewire_set_NP( unsigned char val, unsigned int regAddr ) // [N]o [P]ort force | |
510 | { |
|
510 | { | |
511 | /** This function sets the [N]o [P]ort force bit of the GRSPW control register. |
|
511 | /** This function sets the [N]o [P]ort force bit of the GRSPW control register. | |
512 | * |
|
512 | * | |
513 | * @param val is the value, 0 or 1, used to set the value of the NP bit. |
|
513 | * @param val is the value, 0 or 1, used to set the value of the NP bit. | |
514 | * @param regAddr is the address of the GRSPW control register. |
|
514 | * @param regAddr is the address of the GRSPW control register. | |
515 | * |
|
515 | * | |
516 | * NP is the bit 20 of the GRSPW control register. |
|
516 | * NP is the bit 20 of the GRSPW control register. | |
517 | * |
|
517 | * | |
518 | */ |
|
518 | */ | |
519 |
|
519 | |||
520 | unsigned int *spwptr = (unsigned int*) regAddr; |
|
520 | unsigned int *spwptr = (unsigned int*) regAddr; | |
521 |
|
521 | |||
522 | if (val == 1) { |
|
522 | if (val == 1) { | |
523 | *spwptr = *spwptr | 0x00100000; // [NP] set the No port force bit |
|
523 | *spwptr = *spwptr | 0x00100000; // [NP] set the No port force bit | |
524 | } |
|
524 | } | |
525 | if (val== 0) { |
|
525 | if (val== 0) { | |
526 | *spwptr = *spwptr & 0xffdfffff; |
|
526 | *spwptr = *spwptr & 0xffdfffff; | |
527 | } |
|
527 | } | |
528 | } |
|
528 | } | |
529 |
|
529 | |||
530 | void spacewire_set_RE( unsigned char val, unsigned int regAddr ) // [R]MAP [E]nable |
|
530 | void spacewire_set_RE( unsigned char val, unsigned int regAddr ) // [R]MAP [E]nable | |
531 | { |
|
531 | { | |
532 | /** This function sets the [R]MAP [E]nable bit of the GRSPW control register. |
|
532 | /** This function sets the [R]MAP [E]nable bit of the GRSPW control register. | |
533 | * |
|
533 | * | |
534 | * @param val is the value, 0 or 1, used to set the value of the RE bit. |
|
534 | * @param val is the value, 0 or 1, used to set the value of the RE bit. | |
535 | * @param regAddr is the address of the GRSPW control register. |
|
535 | * @param regAddr is the address of the GRSPW control register. | |
536 | * |
|
536 | * | |
537 | * RE is the bit 16 of the GRSPW control register. |
|
537 | * RE is the bit 16 of the GRSPW control register. | |
538 | * |
|
538 | * | |
539 | */ |
|
539 | */ | |
540 |
|
540 | |||
541 | unsigned int *spwptr = (unsigned int*) regAddr; |
|
541 | unsigned int *spwptr = (unsigned int*) regAddr; | |
542 |
|
542 | |||
543 | if (val == 1) |
|
543 | if (val == 1) | |
544 | { |
|
544 | { | |
545 | *spwptr = *spwptr | 0x00010000; // [RE] set the RMAP Enable bit |
|
545 | *spwptr = *spwptr | 0x00010000; // [RE] set the RMAP Enable bit | |
546 | } |
|
546 | } | |
547 | if (val== 0) |
|
547 | if (val== 0) | |
548 | { |
|
548 | { | |
549 | *spwptr = *spwptr & 0xfffdffff; |
|
549 | *spwptr = *spwptr & 0xfffdffff; | |
550 | } |
|
550 | } | |
551 | } |
|
551 | } | |
552 |
|
552 | |||
553 | void spacewire_compute_stats_offsets( void ) |
|
553 | void spacewire_compute_stats_offsets( void ) | |
554 | { |
|
554 | { | |
555 | /** This function computes the SpaceWire statistics offsets in case of a SpaceWire related interruption raising. |
|
555 | /** This function computes the SpaceWire statistics offsets in case of a SpaceWire related interruption raising. | |
556 | * |
|
556 | * | |
557 | * The offsets keep a record of the statistics in case of a reset of the statistics. They are added to the current statistics |
|
557 | * The offsets keep a record of the statistics in case of a reset of the statistics. They are added to the current statistics | |
558 | * to keep the counters consistent even after a reset of the SpaceWire driver (the counter are set to zero by the driver when it |
|
558 | * to keep the counters consistent even after a reset of the SpaceWire driver (the counter are set to zero by the driver when it | |
559 | * during the open systel call). |
|
559 | * during the open systel call). | |
560 | * |
|
560 | * | |
561 | */ |
|
561 | */ | |
562 |
|
562 | |||
563 | spw_stats spacewire_stats_grspw; |
|
563 | spw_stats spacewire_stats_grspw; | |
564 | rtems_status_code status; |
|
564 | rtems_status_code status; | |
565 |
|
565 | |||
566 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_GET_STATISTICS, &spacewire_stats_grspw ); |
|
566 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_GET_STATISTICS, &spacewire_stats_grspw ); | |
567 |
|
567 | |||
568 | spacewire_stats_backup.packets_received = spacewire_stats_grspw.packets_received |
|
568 | spacewire_stats_backup.packets_received = spacewire_stats_grspw.packets_received | |
569 | + spacewire_stats.packets_received; |
|
569 | + spacewire_stats.packets_received; | |
570 | spacewire_stats_backup.packets_sent = spacewire_stats_grspw.packets_sent |
|
570 | spacewire_stats_backup.packets_sent = spacewire_stats_grspw.packets_sent | |
571 | + spacewire_stats.packets_sent; |
|
571 | + spacewire_stats.packets_sent; | |
572 | spacewire_stats_backup.parity_err = spacewire_stats_grspw.parity_err |
|
572 | spacewire_stats_backup.parity_err = spacewire_stats_grspw.parity_err | |
573 | + spacewire_stats.parity_err; |
|
573 | + spacewire_stats.parity_err; | |
574 | spacewire_stats_backup.disconnect_err = spacewire_stats_grspw.disconnect_err |
|
574 | spacewire_stats_backup.disconnect_err = spacewire_stats_grspw.disconnect_err | |
575 | + spacewire_stats.disconnect_err; |
|
575 | + spacewire_stats.disconnect_err; | |
576 | spacewire_stats_backup.escape_err = spacewire_stats_grspw.escape_err |
|
576 | spacewire_stats_backup.escape_err = spacewire_stats_grspw.escape_err | |
577 | + spacewire_stats.escape_err; |
|
577 | + spacewire_stats.escape_err; | |
578 | spacewire_stats_backup.credit_err = spacewire_stats_grspw.credit_err |
|
578 | spacewire_stats_backup.credit_err = spacewire_stats_grspw.credit_err | |
579 | + spacewire_stats.credit_err; |
|
579 | + spacewire_stats.credit_err; | |
580 | spacewire_stats_backup.write_sync_err = spacewire_stats_grspw.write_sync_err |
|
580 | spacewire_stats_backup.write_sync_err = spacewire_stats_grspw.write_sync_err | |
581 | + spacewire_stats.write_sync_err; |
|
581 | + spacewire_stats.write_sync_err; | |
582 | spacewire_stats_backup.rx_rmap_header_crc_err = spacewire_stats_grspw.rx_rmap_header_crc_err |
|
582 | spacewire_stats_backup.rx_rmap_header_crc_err = spacewire_stats_grspw.rx_rmap_header_crc_err | |
583 | + spacewire_stats.rx_rmap_header_crc_err; |
|
583 | + spacewire_stats.rx_rmap_header_crc_err; | |
584 | spacewire_stats_backup.rx_rmap_data_crc_err = spacewire_stats_grspw.rx_rmap_data_crc_err |
|
584 | spacewire_stats_backup.rx_rmap_data_crc_err = spacewire_stats_grspw.rx_rmap_data_crc_err | |
585 | + spacewire_stats.rx_rmap_data_crc_err; |
|
585 | + spacewire_stats.rx_rmap_data_crc_err; | |
586 | spacewire_stats_backup.early_ep = spacewire_stats_grspw.early_ep |
|
586 | spacewire_stats_backup.early_ep = spacewire_stats_grspw.early_ep | |
587 | + spacewire_stats.early_ep; |
|
587 | + spacewire_stats.early_ep; | |
588 | spacewire_stats_backup.invalid_address = spacewire_stats_grspw.invalid_address |
|
588 | spacewire_stats_backup.invalid_address = spacewire_stats_grspw.invalid_address | |
589 | + spacewire_stats.invalid_address; |
|
589 | + spacewire_stats.invalid_address; | |
590 | spacewire_stats_backup.rx_eep_err = spacewire_stats_grspw.rx_eep_err |
|
590 | spacewire_stats_backup.rx_eep_err = spacewire_stats_grspw.rx_eep_err | |
591 | + spacewire_stats.rx_eep_err; |
|
591 | + spacewire_stats.rx_eep_err; | |
592 | spacewire_stats_backup.rx_truncated = spacewire_stats_grspw.rx_truncated |
|
592 | spacewire_stats_backup.rx_truncated = spacewire_stats_grspw.rx_truncated | |
593 | + spacewire_stats.rx_truncated; |
|
593 | + spacewire_stats.rx_truncated; | |
594 | } |
|
594 | } | |
595 |
|
595 | |||
596 | void spacewire_update_statistics( void ) |
|
596 | void spacewire_update_statistics( void ) | |
597 | { |
|
597 | { | |
598 | rtems_status_code status; |
|
598 | rtems_status_code status; | |
599 | spw_stats spacewire_stats_grspw; |
|
599 | spw_stats spacewire_stats_grspw; | |
600 |
|
600 | |||
601 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_GET_STATISTICS, &spacewire_stats_grspw ); |
|
601 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_GET_STATISTICS, &spacewire_stats_grspw ); | |
602 |
|
602 | |||
603 | spacewire_stats.packets_received = spacewire_stats_backup.packets_received |
|
603 | spacewire_stats.packets_received = spacewire_stats_backup.packets_received | |
604 | + spacewire_stats_grspw.packets_received; |
|
604 | + spacewire_stats_grspw.packets_received; | |
605 | spacewire_stats.packets_sent = spacewire_stats_backup.packets_sent |
|
605 | spacewire_stats.packets_sent = spacewire_stats_backup.packets_sent | |
606 | + spacewire_stats_grspw.packets_sent; |
|
606 | + spacewire_stats_grspw.packets_sent; | |
607 | spacewire_stats.parity_err = spacewire_stats_backup.parity_err |
|
607 | spacewire_stats.parity_err = spacewire_stats_backup.parity_err | |
608 | + spacewire_stats_grspw.parity_err; |
|
608 | + spacewire_stats_grspw.parity_err; | |
609 | spacewire_stats.disconnect_err = spacewire_stats_backup.disconnect_err |
|
609 | spacewire_stats.disconnect_err = spacewire_stats_backup.disconnect_err | |
610 | + spacewire_stats_grspw.disconnect_err; |
|
610 | + spacewire_stats_grspw.disconnect_err; | |
611 | spacewire_stats.escape_err = spacewire_stats_backup.escape_err |
|
611 | spacewire_stats.escape_err = spacewire_stats_backup.escape_err | |
612 | + spacewire_stats_grspw.escape_err; |
|
612 | + spacewire_stats_grspw.escape_err; | |
613 | spacewire_stats.credit_err = spacewire_stats_backup.credit_err |
|
613 | spacewire_stats.credit_err = spacewire_stats_backup.credit_err | |
614 | + spacewire_stats_grspw.credit_err; |
|
614 | + spacewire_stats_grspw.credit_err; | |
615 | spacewire_stats.write_sync_err = spacewire_stats_backup.write_sync_err |
|
615 | spacewire_stats.write_sync_err = spacewire_stats_backup.write_sync_err | |
616 | + spacewire_stats_grspw.write_sync_err; |
|
616 | + spacewire_stats_grspw.write_sync_err; | |
617 | spacewire_stats.rx_rmap_header_crc_err = spacewire_stats_backup.rx_rmap_header_crc_err |
|
617 | spacewire_stats.rx_rmap_header_crc_err = spacewire_stats_backup.rx_rmap_header_crc_err | |
618 | + spacewire_stats_grspw.rx_rmap_header_crc_err; |
|
618 | + spacewire_stats_grspw.rx_rmap_header_crc_err; | |
619 | spacewire_stats.rx_rmap_data_crc_err = spacewire_stats_backup.rx_rmap_data_crc_err |
|
619 | spacewire_stats.rx_rmap_data_crc_err = spacewire_stats_backup.rx_rmap_data_crc_err | |
620 | + spacewire_stats_grspw.rx_rmap_data_crc_err; |
|
620 | + spacewire_stats_grspw.rx_rmap_data_crc_err; | |
621 | spacewire_stats.early_ep = spacewire_stats_backup.early_ep |
|
621 | spacewire_stats.early_ep = spacewire_stats_backup.early_ep | |
622 | + spacewire_stats_grspw.early_ep; |
|
622 | + spacewire_stats_grspw.early_ep; | |
623 | spacewire_stats.invalid_address = spacewire_stats_backup.invalid_address |
|
623 | spacewire_stats.invalid_address = spacewire_stats_backup.invalid_address | |
624 | + spacewire_stats_grspw.invalid_address; |
|
624 | + spacewire_stats_grspw.invalid_address; | |
625 | spacewire_stats.rx_eep_err = spacewire_stats_backup.rx_eep_err |
|
625 | spacewire_stats.rx_eep_err = spacewire_stats_backup.rx_eep_err | |
626 | + spacewire_stats_grspw.rx_eep_err; |
|
626 | + spacewire_stats_grspw.rx_eep_err; | |
627 | spacewire_stats.rx_truncated = spacewire_stats_backup.rx_truncated |
|
627 | spacewire_stats.rx_truncated = spacewire_stats_backup.rx_truncated | |
628 | + spacewire_stats_grspw.rx_truncated; |
|
628 | + spacewire_stats_grspw.rx_truncated; | |
629 | //spacewire_stats.tx_link_err; |
|
629 | //spacewire_stats.tx_link_err; | |
630 |
|
630 | |||
631 | //**************************** |
|
631 | //**************************** | |
632 | // DPU_SPACEWIRE_IF_STATISTICS |
|
632 | // DPU_SPACEWIRE_IF_STATISTICS | |
633 | housekeeping_packet.hk_lfr_dpu_spw_pkt_rcv_cnt[0] = (unsigned char) (spacewire_stats.packets_received >> 8); |
|
633 | housekeeping_packet.hk_lfr_dpu_spw_pkt_rcv_cnt[0] = (unsigned char) (spacewire_stats.packets_received >> 8); | |
634 | housekeeping_packet.hk_lfr_dpu_spw_pkt_rcv_cnt[1] = (unsigned char) (spacewire_stats.packets_received); |
|
634 | housekeeping_packet.hk_lfr_dpu_spw_pkt_rcv_cnt[1] = (unsigned char) (spacewire_stats.packets_received); | |
635 | housekeeping_packet.hk_lfr_dpu_spw_pkt_sent_cnt[0] = (unsigned char) (spacewire_stats.packets_sent >> 8); |
|
635 | housekeeping_packet.hk_lfr_dpu_spw_pkt_sent_cnt[0] = (unsigned char) (spacewire_stats.packets_sent >> 8); | |
636 | housekeeping_packet.hk_lfr_dpu_spw_pkt_sent_cnt[1] = (unsigned char) (spacewire_stats.packets_sent); |
|
636 | housekeeping_packet.hk_lfr_dpu_spw_pkt_sent_cnt[1] = (unsigned char) (spacewire_stats.packets_sent); | |
637 | //housekeeping_packet.hk_lfr_dpu_spw_tick_out_cnt; |
|
637 | //housekeeping_packet.hk_lfr_dpu_spw_tick_out_cnt; | |
638 | //housekeeping_packet.hk_lfr_dpu_spw_last_timc; |
|
638 | //housekeeping_packet.hk_lfr_dpu_spw_last_timc; | |
639 |
|
639 | |||
640 | //****************************************** |
|
640 | //****************************************** | |
641 | // ERROR COUNTERS / SPACEWIRE / LOW SEVERITY |
|
641 | // ERROR COUNTERS / SPACEWIRE / LOW SEVERITY | |
642 | housekeeping_packet.hk_lfr_dpu_spw_parity = (unsigned char) spacewire_stats.parity_err; |
|
642 | housekeeping_packet.hk_lfr_dpu_spw_parity = (unsigned char) spacewire_stats.parity_err; | |
643 | housekeeping_packet.hk_lfr_dpu_spw_disconnect = (unsigned char) spacewire_stats.disconnect_err; |
|
643 | housekeeping_packet.hk_lfr_dpu_spw_disconnect = (unsigned char) spacewire_stats.disconnect_err; | |
644 | housekeeping_packet.hk_lfr_dpu_spw_escape = (unsigned char) spacewire_stats.escape_err; |
|
644 | housekeeping_packet.hk_lfr_dpu_spw_escape = (unsigned char) spacewire_stats.escape_err; | |
645 | housekeeping_packet.hk_lfr_dpu_spw_credit = (unsigned char) spacewire_stats.credit_err; |
|
645 | housekeeping_packet.hk_lfr_dpu_spw_credit = (unsigned char) spacewire_stats.credit_err; | |
646 | housekeeping_packet.hk_lfr_dpu_spw_write_sync = (unsigned char) spacewire_stats.write_sync_err; |
|
646 | housekeeping_packet.hk_lfr_dpu_spw_write_sync = (unsigned char) spacewire_stats.write_sync_err; | |
647 |
|
647 | |||
648 | //********************************************* |
|
648 | //********************************************* | |
649 | // ERROR COUNTERS / SPACEWIRE / MEDIUM SEVERITY |
|
649 | // ERROR COUNTERS / SPACEWIRE / MEDIUM SEVERITY | |
650 | housekeeping_packet.hk_lfr_dpu_spw_early_eop = (unsigned char) spacewire_stats.early_ep; |
|
650 | housekeeping_packet.hk_lfr_dpu_spw_early_eop = (unsigned char) spacewire_stats.early_ep; | |
651 | housekeeping_packet.hk_lfr_dpu_spw_invalid_addr = (unsigned char) spacewire_stats.invalid_address; |
|
651 | housekeeping_packet.hk_lfr_dpu_spw_invalid_addr = (unsigned char) spacewire_stats.invalid_address; | |
652 | housekeeping_packet.hk_lfr_dpu_spw_eep = (unsigned char) spacewire_stats.rx_eep_err; |
|
652 | housekeeping_packet.hk_lfr_dpu_spw_eep = (unsigned char) spacewire_stats.rx_eep_err; | |
653 | housekeeping_packet.hk_lfr_dpu_spw_rx_too_big = (unsigned char) spacewire_stats.rx_truncated; |
|
653 | housekeeping_packet.hk_lfr_dpu_spw_rx_too_big = (unsigned char) spacewire_stats.rx_truncated; | |
654 | } |
|
654 | } | |
655 |
|
655 | |||
656 | void timecode_irq_handler( void *pDev, void *regs, int minor, unsigned int tc ) |
|
656 | void timecode_irq_handler( void *pDev, void *regs, int minor, unsigned int tc ) | |
657 | { |
|
657 | { | |
658 | // a valid timecode has been received, write it in the HK report |
|
658 | // a valid timecode has been received, write it in the HK report | |
659 | unsigned int * grspwPtr; |
|
659 | unsigned int * grspwPtr; | |
660 |
|
660 | |||
661 | grspwPtr = (unsigned int *) (REGS_ADDR_GRSPW + APB_OFFSET_GRSPW_TIME_REGISTER); |
|
661 | grspwPtr = (unsigned int *) (REGS_ADDR_GRSPW + APB_OFFSET_GRSPW_TIME_REGISTER); | |
662 |
|
662 | |||
663 | housekeeping_packet.hk_lfr_dpu_spw_last_timc = (unsigned char) (grspwPtr[0] & 0xff); // [11 1111] |
|
663 | housekeeping_packet.hk_lfr_dpu_spw_last_timc = (unsigned char) (grspwPtr[0] & 0xff); // [11 1111] | |
664 |
|
664 | |||
665 | // update the number of valid timecodes that have been received |
|
665 | // update the number of valid timecodes that have been received | |
666 | if (housekeeping_packet.hk_lfr_dpu_spw_tick_out_cnt == 255) |
|
666 | if (housekeeping_packet.hk_lfr_dpu_spw_tick_out_cnt == 255) | |
667 | { |
|
667 | { | |
668 | housekeeping_packet.hk_lfr_dpu_spw_tick_out_cnt = 0; |
|
668 | housekeeping_packet.hk_lfr_dpu_spw_tick_out_cnt = 0; | |
669 | } |
|
669 | } | |
670 | else |
|
670 | else | |
671 | { |
|
671 | { | |
672 | housekeeping_packet.hk_lfr_dpu_spw_tick_out_cnt = housekeeping_packet.hk_lfr_dpu_spw_tick_out_cnt + 1; |
|
672 | housekeeping_packet.hk_lfr_dpu_spw_tick_out_cnt = housekeeping_packet.hk_lfr_dpu_spw_tick_out_cnt + 1; | |
673 | } |
|
673 | } | |
674 | } |
|
674 | } | |
675 |
|
675 | |||
676 | rtems_timer_service_routine user_routine( rtems_id timer_id, void *user_data ) |
|
676 | rtems_timer_service_routine user_routine( rtems_id timer_id, void *user_data ) | |
677 | { |
|
677 | { | |
678 | int linkStatus; |
|
678 | int linkStatus; | |
679 | rtems_status_code status; |
|
679 | rtems_status_code status; | |
680 |
|
680 | |||
681 | status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status |
|
681 | status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status | |
682 |
|
682 | |||
683 | if ( linkStatus == 5) { |
|
683 | if ( linkStatus == 5) { | |
684 | PRINTF("in spacewire_reset_link *** link is running\n") |
|
684 | PRINTF("in spacewire_reset_link *** link is running\n") | |
685 | status = RTEMS_SUCCESSFUL; |
|
685 | status = RTEMS_SUCCESSFUL; | |
686 | } |
|
686 | } | |
687 | } |
|
687 | } | |
688 |
|
688 | |||
689 | void init_header_cwf( Header_TM_LFR_SCIENCE_CWF_t *header ) |
|
689 | void init_header_cwf( Header_TM_LFR_SCIENCE_CWF_t *header ) | |
690 | { |
|
690 | { | |
691 | header->targetLogicalAddress = CCSDS_DESTINATION_ID; |
|
691 | header->targetLogicalAddress = CCSDS_DESTINATION_ID; | |
692 | header->protocolIdentifier = CCSDS_PROTOCOLE_ID; |
|
692 | header->protocolIdentifier = CCSDS_PROTOCOLE_ID; | |
693 | header->reserved = DEFAULT_RESERVED; |
|
693 | header->reserved = DEFAULT_RESERVED; | |
694 | header->userApplication = CCSDS_USER_APP; |
|
694 | header->userApplication = CCSDS_USER_APP; | |
695 | header->packetSequenceControl[0]= TM_PACKET_SEQ_CTRL_STANDALONE; |
|
695 | header->packetSequenceControl[0]= TM_PACKET_SEQ_CTRL_STANDALONE; | |
696 | header->packetSequenceControl[1]= TM_PACKET_SEQ_CNT_DEFAULT; |
|
696 | header->packetSequenceControl[1]= TM_PACKET_SEQ_CNT_DEFAULT; | |
697 | header->packetLength[0] = 0x00; |
|
697 | header->packetLength[0] = 0x00; | |
698 | header->packetLength[1] = 0x00; |
|
698 | header->packetLength[1] = 0x00; | |
699 | // DATA FIELD HEADER |
|
699 | // DATA FIELD HEADER | |
700 | header->spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2; |
|
700 | header->spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2; | |
701 | header->serviceType = TM_TYPE_LFR_SCIENCE; // service type |
|
701 | header->serviceType = TM_TYPE_LFR_SCIENCE; // service type | |
702 | header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE_6; // service subtype |
|
702 | header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE_6; // service subtype | |
703 | header->destinationID = TM_DESTINATION_ID_GROUND; |
|
703 | header->destinationID = TM_DESTINATION_ID_GROUND; | |
704 | header->time[0] = 0x00; |
|
704 | header->time[0] = 0x00; | |
705 | header->time[0] = 0x00; |
|
705 | header->time[0] = 0x00; | |
706 | header->time[0] = 0x00; |
|
706 | header->time[0] = 0x00; | |
707 | header->time[0] = 0x00; |
|
707 | header->time[0] = 0x00; | |
708 | header->time[0] = 0x00; |
|
708 | header->time[0] = 0x00; | |
709 | header->time[0] = 0x00; |
|
709 | header->time[0] = 0x00; | |
710 | // AUXILIARY DATA HEADER |
|
710 | // AUXILIARY DATA HEADER | |
711 | header->sid = 0x00; |
|
711 | header->sid = 0x00; | |
712 | header->hkBIA = DEFAULT_HKBIA; |
|
712 | header->hkBIA = DEFAULT_HKBIA; | |
713 | header->blkNr[0] = 0x00; |
|
713 | header->blkNr[0] = 0x00; | |
714 | header->blkNr[1] = 0x00; |
|
714 | header->blkNr[1] = 0x00; | |
715 | } |
|
715 | } | |
716 |
|
716 | |||
717 | void init_header_swf( Header_TM_LFR_SCIENCE_SWF_t *header ) |
|
717 | void init_header_swf( Header_TM_LFR_SCIENCE_SWF_t *header ) | |
718 | { |
|
718 | { | |
719 | header->targetLogicalAddress = CCSDS_DESTINATION_ID; |
|
719 | header->targetLogicalAddress = CCSDS_DESTINATION_ID; | |
720 | header->protocolIdentifier = CCSDS_PROTOCOLE_ID; |
|
720 | header->protocolIdentifier = CCSDS_PROTOCOLE_ID; | |
721 | header->reserved = DEFAULT_RESERVED; |
|
721 | header->reserved = DEFAULT_RESERVED; | |
722 | header->userApplication = CCSDS_USER_APP; |
|
722 | header->userApplication = CCSDS_USER_APP; | |
723 | header->packetID[0] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST >> 8); |
|
723 | header->packetID[0] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST >> 8); | |
724 | header->packetID[1] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST); |
|
724 | header->packetID[1] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST); | |
725 | header->packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; |
|
725 | header->packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; | |
726 | header->packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT; |
|
726 | header->packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT; | |
727 | header->packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF_336 >> 8); |
|
727 | header->packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF_336 >> 8); | |
728 | header->packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF_336 ); |
|
728 | header->packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF_336 ); | |
729 | // DATA FIELD HEADER |
|
729 | // DATA FIELD HEADER | |
730 | header->spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2; |
|
730 | header->spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2; | |
731 | header->serviceType = TM_TYPE_LFR_SCIENCE; // service type |
|
731 | header->serviceType = TM_TYPE_LFR_SCIENCE; // service type | |
732 | header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE_6; // service subtype |
|
732 | header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE_6; // service subtype | |
733 | header->destinationID = TM_DESTINATION_ID_GROUND; |
|
733 | header->destinationID = TM_DESTINATION_ID_GROUND; | |
734 | header->time[0] = 0x00; |
|
734 | header->time[0] = 0x00; | |
735 | header->time[0] = 0x00; |
|
735 | header->time[0] = 0x00; | |
736 | header->time[0] = 0x00; |
|
736 | header->time[0] = 0x00; | |
737 | header->time[0] = 0x00; |
|
737 | header->time[0] = 0x00; | |
738 | header->time[0] = 0x00; |
|
738 | header->time[0] = 0x00; | |
739 | header->time[0] = 0x00; |
|
739 | header->time[0] = 0x00; | |
740 | // AUXILIARY DATA HEADER |
|
740 | // AUXILIARY DATA HEADER | |
741 | header->sid = 0x00; |
|
741 | header->sid = 0x00; | |
742 | header->hkBIA = DEFAULT_HKBIA; |
|
742 | header->hkBIA = DEFAULT_HKBIA; | |
743 | header->pktCnt = DEFAULT_PKTCNT; // PKT_CNT |
|
743 | header->pktCnt = DEFAULT_PKTCNT; // PKT_CNT | |
744 | header->pktNr = 0x00; |
|
744 | header->pktNr = 0x00; | |
745 | header->blkNr[0] = (unsigned char) (BLK_NR_CWF >> 8); |
|
745 | header->blkNr[0] = (unsigned char) (BLK_NR_CWF >> 8); | |
746 | header->blkNr[1] = (unsigned char) (BLK_NR_CWF ); |
|
746 | header->blkNr[1] = (unsigned char) (BLK_NR_CWF ); | |
747 | } |
|
747 | } | |
748 |
|
748 | |||
749 | void init_header_asm( Header_TM_LFR_SCIENCE_ASM_t *header ) |
|
749 | void init_header_asm( Header_TM_LFR_SCIENCE_ASM_t *header ) | |
750 | { |
|
750 | { | |
751 | header->targetLogicalAddress = CCSDS_DESTINATION_ID; |
|
751 | header->targetLogicalAddress = CCSDS_DESTINATION_ID; | |
752 | header->protocolIdentifier = CCSDS_PROTOCOLE_ID; |
|
752 | header->protocolIdentifier = CCSDS_PROTOCOLE_ID; | |
753 | header->reserved = DEFAULT_RESERVED; |
|
753 | header->reserved = DEFAULT_RESERVED; | |
754 | header->userApplication = CCSDS_USER_APP; |
|
754 | header->userApplication = CCSDS_USER_APP; | |
755 | header->packetID[0] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST >> 8); |
|
755 | header->packetID[0] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST >> 8); | |
756 | header->packetID[1] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST); |
|
756 | header->packetID[1] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST); | |
757 | header->packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; |
|
757 | header->packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; | |
758 | header->packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT; |
|
758 | header->packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT; | |
759 | header->packetLength[0] = 0x00; |
|
759 | header->packetLength[0] = 0x00; | |
760 | header->packetLength[1] = 0x00; |
|
760 | header->packetLength[1] = 0x00; | |
761 | // DATA FIELD HEADER |
|
761 | // DATA FIELD HEADER | |
762 | header->spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2; |
|
762 | header->spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2; | |
763 | header->serviceType = TM_TYPE_LFR_SCIENCE; // service type |
|
763 | header->serviceType = TM_TYPE_LFR_SCIENCE; // service type | |
764 | header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE_3; // service subtype |
|
764 | header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE_3; // service subtype | |
765 | header->destinationID = TM_DESTINATION_ID_GROUND; |
|
765 | header->destinationID = TM_DESTINATION_ID_GROUND; | |
766 | header->time[0] = 0x00; |
|
766 | header->time[0] = 0x00; | |
767 | header->time[0] = 0x00; |
|
767 | header->time[0] = 0x00; | |
768 | header->time[0] = 0x00; |
|
768 | header->time[0] = 0x00; | |
769 | header->time[0] = 0x00; |
|
769 | header->time[0] = 0x00; | |
770 | header->time[0] = 0x00; |
|
770 | header->time[0] = 0x00; | |
771 | header->time[0] = 0x00; |
|
771 | header->time[0] = 0x00; | |
772 | // AUXILIARY DATA HEADER |
|
772 | // AUXILIARY DATA HEADER | |
773 | header->sid = 0x00; |
|
773 | header->sid = 0x00; | |
774 | header->biaStatusInfo = 0x00; |
|
774 | header->biaStatusInfo = 0x00; | |
775 | header->pa_lfr_pkt_cnt_asm = 0x00; |
|
775 | header->pa_lfr_pkt_cnt_asm = 0x00; | |
776 | header->pa_lfr_pkt_nr_asm = 0x00; |
|
776 | header->pa_lfr_pkt_nr_asm = 0x00; | |
777 | header->pa_lfr_asm_blk_nr[0] = 0x00; |
|
777 | header->pa_lfr_asm_blk_nr[0] = 0x00; | |
778 | header->pa_lfr_asm_blk_nr[1] = 0x00; |
|
778 | header->pa_lfr_asm_blk_nr[1] = 0x00; | |
779 | } |
|
779 | } | |
780 |
|
780 | |||
781 | int spw_send_waveform_CWF( ring_node *ring_node_to_send, |
|
781 | int spw_send_waveform_CWF( ring_node *ring_node_to_send, | |
782 | Header_TM_LFR_SCIENCE_CWF_t *header ) |
|
782 | Header_TM_LFR_SCIENCE_CWF_t *header ) | |
783 | { |
|
783 | { | |
784 | /** This function sends CWF CCSDS packets (F2, F1 or F0). |
|
784 | /** This function sends CWF CCSDS packets (F2, F1 or F0). | |
785 | * |
|
785 | * | |
786 | * @param waveform points to the buffer containing the data that will be send. |
|
786 | * @param waveform points to the buffer containing the data that will be send. | |
787 | * @param sid is the source identifier of the data that will be sent. |
|
787 | * @param sid is the source identifier of the data that will be sent. | |
788 | * @param headerCWF points to a table of headers that have been prepared for the data transmission. |
|
788 | * @param headerCWF points to a table of headers that have been prepared for the data transmission. | |
789 | * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures |
|
789 | * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures | |
790 | * contain information to setup the transmission of the data packets. |
|
790 | * contain information to setup the transmission of the data packets. | |
791 | * |
|
791 | * | |
792 | * One group of 2048 samples is sent as 7 consecutive packets, 6 packets containing 340 blocks and 8 packets containing 8 blocks. |
|
792 | * One group of 2048 samples is sent as 7 consecutive packets, 6 packets containing 340 blocks and 8 packets containing 8 blocks. | |
793 | * |
|
793 | * | |
794 | */ |
|
794 | */ | |
795 |
|
795 | |||
796 | unsigned int i; |
|
796 | unsigned int i; | |
797 | int ret; |
|
797 | int ret; | |
798 | unsigned int coarseTime; |
|
798 | unsigned int coarseTime; | |
799 | unsigned int fineTime; |
|
799 | unsigned int fineTime; | |
800 | rtems_status_code status; |
|
800 | rtems_status_code status; | |
801 | spw_ioctl_pkt_send spw_ioctl_send_CWF; |
|
801 | spw_ioctl_pkt_send spw_ioctl_send_CWF; | |
802 | int *dataPtr; |
|
802 | int *dataPtr; | |
803 | unsigned char sid; |
|
803 | unsigned char sid; | |
804 |
|
804 | |||
805 | spw_ioctl_send_CWF.hlen = HEADER_LENGTH_TM_LFR_SCIENCE_CWF; |
|
805 | spw_ioctl_send_CWF.hlen = HEADER_LENGTH_TM_LFR_SCIENCE_CWF; | |
806 | spw_ioctl_send_CWF.options = 0; |
|
806 | spw_ioctl_send_CWF.options = 0; | |
807 |
|
807 | |||
808 | ret = LFR_DEFAULT; |
|
808 | ret = LFR_DEFAULT; | |
809 | sid = (unsigned char) ring_node_to_send->sid; |
|
809 | sid = (unsigned char) ring_node_to_send->sid; | |
810 |
|
810 | |||
811 | coarseTime = ring_node_to_send->coarseTime; |
|
811 | coarseTime = ring_node_to_send->coarseTime; | |
812 | fineTime = ring_node_to_send->fineTime; |
|
812 | fineTime = ring_node_to_send->fineTime; | |
813 | dataPtr = (int*) ring_node_to_send->buffer_address; |
|
813 | dataPtr = (int*) ring_node_to_send->buffer_address; | |
814 |
|
814 | |||
815 | header->packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF_336 >> 8); |
|
815 | header->packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF_336 >> 8); | |
816 | header->packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF_336 ); |
|
816 | header->packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF_336 ); | |
|
817 | header->hkBIA = pa_bia_status_info; | |||
817 | header->sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters; |
|
818 | header->sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters; | |
818 | header->blkNr[0] = (unsigned char) (BLK_NR_CWF >> 8); |
|
819 | header->blkNr[0] = (unsigned char) (BLK_NR_CWF >> 8); | |
819 | header->blkNr[1] = (unsigned char) (BLK_NR_CWF ); |
|
820 | header->blkNr[1] = (unsigned char) (BLK_NR_CWF ); | |
820 |
|
821 | |||
821 | for (i=0; i<NB_PACKETS_PER_GROUP_OF_CWF; i++) // send waveform |
|
822 | for (i=0; i<NB_PACKETS_PER_GROUP_OF_CWF; i++) // send waveform | |
822 | { |
|
823 | { | |
823 | spw_ioctl_send_CWF.data = (char*) &dataPtr[ (i * BLK_NR_CWF * NB_WORDS_SWF_BLK) ]; |
|
824 | spw_ioctl_send_CWF.data = (char*) &dataPtr[ (i * BLK_NR_CWF * NB_WORDS_SWF_BLK) ]; | |
824 | spw_ioctl_send_CWF.hdr = (char*) header; |
|
825 | spw_ioctl_send_CWF.hdr = (char*) header; | |
825 | // BUILD THE DATA |
|
826 | // BUILD THE DATA | |
826 | spw_ioctl_send_CWF.dlen = BLK_NR_CWF * NB_BYTES_SWF_BLK; |
|
827 | spw_ioctl_send_CWF.dlen = BLK_NR_CWF * NB_BYTES_SWF_BLK; | |
827 |
|
828 | |||
828 | // SET PACKET SEQUENCE CONTROL |
|
829 | // SET PACKET SEQUENCE CONTROL | |
829 | increment_seq_counter_source_id( header->packetSequenceControl, sid ); |
|
830 | increment_seq_counter_source_id( header->packetSequenceControl, sid ); | |
830 |
|
831 | |||
831 | // SET SID |
|
832 | // SET SID | |
832 | header->sid = sid; |
|
833 | header->sid = sid; | |
833 |
|
834 | |||
834 | // SET PACKET TIME |
|
835 | // SET PACKET TIME | |
835 | compute_acquisition_time( coarseTime, fineTime, sid, i, header->acquisitionTime); |
|
836 | compute_acquisition_time( coarseTime, fineTime, sid, i, header->acquisitionTime); | |
836 | // |
|
837 | // | |
837 | header->time[0] = header->acquisitionTime[0]; |
|
838 | header->time[0] = header->acquisitionTime[0]; | |
838 | header->time[1] = header->acquisitionTime[1]; |
|
839 | header->time[1] = header->acquisitionTime[1]; | |
839 | header->time[2] = header->acquisitionTime[2]; |
|
840 | header->time[2] = header->acquisitionTime[2]; | |
840 | header->time[3] = header->acquisitionTime[3]; |
|
841 | header->time[3] = header->acquisitionTime[3]; | |
841 | header->time[4] = header->acquisitionTime[4]; |
|
842 | header->time[4] = header->acquisitionTime[4]; | |
842 | header->time[5] = header->acquisitionTime[5]; |
|
843 | header->time[5] = header->acquisitionTime[5]; | |
843 |
|
844 | |||
844 | // SET PACKET ID |
|
845 | // SET PACKET ID | |
845 | if ( (sid == SID_SBM1_CWF_F1) || (sid == SID_SBM2_CWF_F2) ) |
|
846 | if ( (sid == SID_SBM1_CWF_F1) || (sid == SID_SBM2_CWF_F2) ) | |
846 | { |
|
847 | { | |
847 | header->packetID[0] = (unsigned char) (APID_TM_SCIENCE_SBM1_SBM2 >> 8); |
|
848 | header->packetID[0] = (unsigned char) (APID_TM_SCIENCE_SBM1_SBM2 >> 8); | |
848 | header->packetID[1] = (unsigned char) (APID_TM_SCIENCE_SBM1_SBM2); |
|
849 | header->packetID[1] = (unsigned char) (APID_TM_SCIENCE_SBM1_SBM2); | |
849 | } |
|
850 | } | |
850 | else |
|
851 | else | |
851 | { |
|
852 | { | |
852 | header->packetID[0] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST >> 8); |
|
853 | header->packetID[0] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST >> 8); | |
853 | header->packetID[1] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST); |
|
854 | header->packetID[1] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST); | |
854 | } |
|
855 | } | |
855 |
|
856 | |||
856 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, &spw_ioctl_send_CWF ); |
|
857 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, &spw_ioctl_send_CWF ); | |
857 | if (status != RTEMS_SUCCESSFUL) { |
|
858 | if (status != RTEMS_SUCCESSFUL) { | |
858 | printf("%d-%d, ERR %d\n", sid, i, (int) status); |
|
859 | printf("%d-%d, ERR %d\n", sid, i, (int) status); | |
859 | ret = LFR_DEFAULT; |
|
860 | ret = LFR_DEFAULT; | |
860 | } |
|
861 | } | |
861 | } |
|
862 | } | |
862 |
|
863 | |||
863 | return ret; |
|
864 | return ret; | |
864 | } |
|
865 | } | |
865 |
|
866 | |||
866 | int spw_send_waveform_SWF( ring_node *ring_node_to_send, |
|
867 | int spw_send_waveform_SWF( ring_node *ring_node_to_send, | |
867 | Header_TM_LFR_SCIENCE_SWF_t *header ) |
|
868 | Header_TM_LFR_SCIENCE_SWF_t *header ) | |
868 | { |
|
869 | { | |
869 | /** This function sends SWF CCSDS packets (F2, F1 or F0). |
|
870 | /** This function sends SWF CCSDS packets (F2, F1 or F0). | |
870 | * |
|
871 | * | |
871 | * @param waveform points to the buffer containing the data that will be send. |
|
872 | * @param waveform points to the buffer containing the data that will be send. | |
872 | * @param sid is the source identifier of the data that will be sent. |
|
873 | * @param sid is the source identifier of the data that will be sent. | |
873 | * @param headerSWF points to a table of headers that have been prepared for the data transmission. |
|
874 | * @param headerSWF points to a table of headers that have been prepared for the data transmission. | |
874 | * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures |
|
875 | * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures | |
875 | * contain information to setup the transmission of the data packets. |
|
876 | * contain information to setup the transmission of the data packets. | |
876 | * |
|
877 | * | |
877 | * One group of 2048 samples is sent as 7 consecutive packets, 6 packets containing 340 blocks and 8 packets containing 8 blocks. |
|
878 | * One group of 2048 samples is sent as 7 consecutive packets, 6 packets containing 340 blocks and 8 packets containing 8 blocks. | |
878 | * |
|
879 | * | |
879 | */ |
|
880 | */ | |
880 |
|
881 | |||
881 | unsigned int i; |
|
882 | unsigned int i; | |
882 | int ret; |
|
883 | int ret; | |
883 | unsigned int coarseTime; |
|
884 | unsigned int coarseTime; | |
884 | unsigned int fineTime; |
|
885 | unsigned int fineTime; | |
885 | rtems_status_code status; |
|
886 | rtems_status_code status; | |
886 | spw_ioctl_pkt_send spw_ioctl_send_SWF; |
|
887 | spw_ioctl_pkt_send spw_ioctl_send_SWF; | |
887 | int *dataPtr; |
|
888 | int *dataPtr; | |
888 | unsigned char sid; |
|
889 | unsigned char sid; | |
889 |
|
890 | |||
890 | spw_ioctl_send_SWF.hlen = HEADER_LENGTH_TM_LFR_SCIENCE_SWF; |
|
891 | spw_ioctl_send_SWF.hlen = HEADER_LENGTH_TM_LFR_SCIENCE_SWF; | |
891 | spw_ioctl_send_SWF.options = 0; |
|
892 | spw_ioctl_send_SWF.options = 0; | |
892 |
|
893 | |||
893 | ret = LFR_DEFAULT; |
|
894 | ret = LFR_DEFAULT; | |
894 |
|
895 | |||
895 | coarseTime = ring_node_to_send->coarseTime; |
|
896 | coarseTime = ring_node_to_send->coarseTime; | |
896 | fineTime = ring_node_to_send->fineTime; |
|
897 | fineTime = ring_node_to_send->fineTime; | |
897 | dataPtr = (int*) ring_node_to_send->buffer_address; |
|
898 | dataPtr = (int*) ring_node_to_send->buffer_address; | |
898 | sid = ring_node_to_send->sid; |
|
899 | sid = ring_node_to_send->sid; | |
899 |
|
900 | |||
|
901 | header->hkBIA = pa_bia_status_info; | |||
900 | header->sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters; |
|
902 | header->sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters; | |
901 |
|
903 | |||
902 | for (i=0; i<7; i++) // send waveform |
|
904 | for (i=0; i<7; i++) // send waveform | |
903 | { |
|
905 | { | |
904 | spw_ioctl_send_SWF.data = (char*) &dataPtr[ (i * BLK_NR_304 * NB_WORDS_SWF_BLK) ]; |
|
906 | spw_ioctl_send_SWF.data = (char*) &dataPtr[ (i * BLK_NR_304 * NB_WORDS_SWF_BLK) ]; | |
905 | spw_ioctl_send_SWF.hdr = (char*) header; |
|
907 | spw_ioctl_send_SWF.hdr = (char*) header; | |
906 |
|
908 | |||
907 | // SET PACKET SEQUENCE CONTROL |
|
909 | // SET PACKET SEQUENCE CONTROL | |
908 | increment_seq_counter_source_id( header->packetSequenceControl, sid ); |
|
910 | increment_seq_counter_source_id( header->packetSequenceControl, sid ); | |
909 |
|
911 | |||
910 | // SET PACKET LENGTH AND BLKNR |
|
912 | // SET PACKET LENGTH AND BLKNR | |
911 | if (i == 6) |
|
913 | if (i == 6) | |
912 | { |
|
914 | { | |
913 | spw_ioctl_send_SWF.dlen = BLK_NR_224 * NB_BYTES_SWF_BLK; |
|
915 | spw_ioctl_send_SWF.dlen = BLK_NR_224 * NB_BYTES_SWF_BLK; | |
914 | header->packetLength[0] = (unsigned char) (TM_LEN_SCI_SWF_224 >> 8); |
|
916 | header->packetLength[0] = (unsigned char) (TM_LEN_SCI_SWF_224 >> 8); | |
915 | header->packetLength[1] = (unsigned char) (TM_LEN_SCI_SWF_224 ); |
|
917 | header->packetLength[1] = (unsigned char) (TM_LEN_SCI_SWF_224 ); | |
916 | header->blkNr[0] = (unsigned char) (BLK_NR_224 >> 8); |
|
918 | header->blkNr[0] = (unsigned char) (BLK_NR_224 >> 8); | |
917 | header->blkNr[1] = (unsigned char) (BLK_NR_224 ); |
|
919 | header->blkNr[1] = (unsigned char) (BLK_NR_224 ); | |
918 | } |
|
920 | } | |
919 | else |
|
921 | else | |
920 | { |
|
922 | { | |
921 | spw_ioctl_send_SWF.dlen = BLK_NR_304 * NB_BYTES_SWF_BLK; |
|
923 | spw_ioctl_send_SWF.dlen = BLK_NR_304 * NB_BYTES_SWF_BLK; | |
922 | header->packetLength[0] = (unsigned char) (TM_LEN_SCI_SWF_304 >> 8); |
|
924 | header->packetLength[0] = (unsigned char) (TM_LEN_SCI_SWF_304 >> 8); | |
923 | header->packetLength[1] = (unsigned char) (TM_LEN_SCI_SWF_304 ); |
|
925 | header->packetLength[1] = (unsigned char) (TM_LEN_SCI_SWF_304 ); | |
924 | header->blkNr[0] = (unsigned char) (BLK_NR_304 >> 8); |
|
926 | header->blkNr[0] = (unsigned char) (BLK_NR_304 >> 8); | |
925 | header->blkNr[1] = (unsigned char) (BLK_NR_304 ); |
|
927 | header->blkNr[1] = (unsigned char) (BLK_NR_304 ); | |
926 | } |
|
928 | } | |
927 |
|
929 | |||
928 | // SET PACKET TIME |
|
930 | // SET PACKET TIME | |
929 | compute_acquisition_time( coarseTime, fineTime, sid, i, header->acquisitionTime ); |
|
931 | compute_acquisition_time( coarseTime, fineTime, sid, i, header->acquisitionTime ); | |
930 | // |
|
932 | // | |
931 | header->time[0] = header->acquisitionTime[0]; |
|
933 | header->time[0] = header->acquisitionTime[0]; | |
932 | header->time[1] = header->acquisitionTime[1]; |
|
934 | header->time[1] = header->acquisitionTime[1]; | |
933 | header->time[2] = header->acquisitionTime[2]; |
|
935 | header->time[2] = header->acquisitionTime[2]; | |
934 | header->time[3] = header->acquisitionTime[3]; |
|
936 | header->time[3] = header->acquisitionTime[3]; | |
935 | header->time[4] = header->acquisitionTime[4]; |
|
937 | header->time[4] = header->acquisitionTime[4]; | |
936 | header->time[5] = header->acquisitionTime[5]; |
|
938 | header->time[5] = header->acquisitionTime[5]; | |
937 |
|
939 | |||
938 | // SET SID |
|
940 | // SET SID | |
939 | header->sid = sid; |
|
941 | header->sid = sid; | |
940 |
|
942 | |||
941 | // SET PKTNR |
|
943 | // SET PKTNR | |
942 | header->pktNr = i+1; // PKT_NR |
|
944 | header->pktNr = i+1; // PKT_NR | |
943 |
|
945 | |||
944 | // SEND PACKET |
|
946 | // SEND PACKET | |
945 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, &spw_ioctl_send_SWF ); |
|
947 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, &spw_ioctl_send_SWF ); | |
946 | if (status != RTEMS_SUCCESSFUL) { |
|
948 | if (status != RTEMS_SUCCESSFUL) { | |
947 | printf("%d-%d, ERR %d\n", sid, i, (int) status); |
|
949 | printf("%d-%d, ERR %d\n", sid, i, (int) status); | |
948 | ret = LFR_DEFAULT; |
|
950 | ret = LFR_DEFAULT; | |
949 | } |
|
951 | } | |
950 | } |
|
952 | } | |
951 |
|
953 | |||
952 | return ret; |
|
954 | return ret; | |
953 | } |
|
955 | } | |
954 |
|
956 | |||
955 | int spw_send_waveform_CWF3_light( ring_node *ring_node_to_send, |
|
957 | int spw_send_waveform_CWF3_light( ring_node *ring_node_to_send, | |
956 | Header_TM_LFR_SCIENCE_CWF_t *header ) |
|
958 | Header_TM_LFR_SCIENCE_CWF_t *header ) | |
957 | { |
|
959 | { | |
958 | /** This function sends CWF_F3 CCSDS packets without the b1, b2 and b3 data. |
|
960 | /** This function sends CWF_F3 CCSDS packets without the b1, b2 and b3 data. | |
959 | * |
|
961 | * | |
960 | * @param waveform points to the buffer containing the data that will be send. |
|
962 | * @param waveform points to the buffer containing the data that will be send. | |
961 | * @param headerCWF points to a table of headers that have been prepared for the data transmission. |
|
963 | * @param headerCWF points to a table of headers that have been prepared for the data transmission. | |
962 | * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures |
|
964 | * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures | |
963 | * contain information to setup the transmission of the data packets. |
|
965 | * contain information to setup the transmission of the data packets. | |
964 | * |
|
966 | * | |
965 | * By default, CWF_F3 packet are send without the b1, b2 and b3 data. This function rebuilds a data buffer |
|
967 | * By default, CWF_F3 packet are send without the b1, b2 and b3 data. This function rebuilds a data buffer | |
966 | * from the incoming data and sends it in 7 packets, 6 containing 340 blocks and 1 one containing 8 blocks. |
|
968 | * from the incoming data and sends it in 7 packets, 6 containing 340 blocks and 1 one containing 8 blocks. | |
967 | * |
|
969 | * | |
968 | */ |
|
970 | */ | |
969 |
|
971 | |||
970 | unsigned int i; |
|
972 | unsigned int i; | |
971 | int ret; |
|
973 | int ret; | |
972 | unsigned int coarseTime; |
|
974 | unsigned int coarseTime; | |
973 | unsigned int fineTime; |
|
975 | unsigned int fineTime; | |
974 | rtems_status_code status; |
|
976 | rtems_status_code status; | |
975 | spw_ioctl_pkt_send spw_ioctl_send_CWF; |
|
977 | spw_ioctl_pkt_send spw_ioctl_send_CWF; | |
976 | char *dataPtr; |
|
978 | char *dataPtr; | |
977 | unsigned char sid; |
|
979 | unsigned char sid; | |
978 |
|
980 | |||
979 | spw_ioctl_send_CWF.hlen = HEADER_LENGTH_TM_LFR_SCIENCE_CWF; |
|
981 | spw_ioctl_send_CWF.hlen = HEADER_LENGTH_TM_LFR_SCIENCE_CWF; | |
980 | spw_ioctl_send_CWF.options = 0; |
|
982 | spw_ioctl_send_CWF.options = 0; | |
981 |
|
983 | |||
982 | ret = LFR_DEFAULT; |
|
984 | ret = LFR_DEFAULT; | |
983 | sid = ring_node_to_send->sid; |
|
985 | sid = ring_node_to_send->sid; | |
984 |
|
986 | |||
985 | coarseTime = ring_node_to_send->coarseTime; |
|
987 | coarseTime = ring_node_to_send->coarseTime; | |
986 | fineTime = ring_node_to_send->fineTime; |
|
988 | fineTime = ring_node_to_send->fineTime; | |
987 | dataPtr = (char*) ring_node_to_send->buffer_address; |
|
989 | dataPtr = (char*) ring_node_to_send->buffer_address; | |
988 |
|
990 | |||
989 | header->packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF_672 >> 8); |
|
991 | header->packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF_672 >> 8); | |
990 | header->packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF_672 ); |
|
992 | header->packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF_672 ); | |
|
993 | header->hkBIA = pa_bia_status_info; | |||
991 | header->sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters; |
|
994 | header->sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters; | |
992 | header->blkNr[0] = (unsigned char) (BLK_NR_CWF_SHORT_F3 >> 8); |
|
995 | header->blkNr[0] = (unsigned char) (BLK_NR_CWF_SHORT_F3 >> 8); | |
993 | header->blkNr[1] = (unsigned char) (BLK_NR_CWF_SHORT_F3 ); |
|
996 | header->blkNr[1] = (unsigned char) (BLK_NR_CWF_SHORT_F3 ); | |
994 |
|
997 | |||
995 | //********************* |
|
998 | //********************* | |
996 | // SEND CWF3_light DATA |
|
999 | // SEND CWF3_light DATA | |
997 | for (i=0; i<NB_PACKETS_PER_GROUP_OF_CWF_LIGHT; i++) // send waveform |
|
1000 | for (i=0; i<NB_PACKETS_PER_GROUP_OF_CWF_LIGHT; i++) // send waveform | |
998 | { |
|
1001 | { | |
999 | spw_ioctl_send_CWF.data = (char*) &dataPtr[ (i * BLK_NR_CWF_SHORT_F3 * NB_BYTES_CWF3_LIGHT_BLK) ]; |
|
1002 | spw_ioctl_send_CWF.data = (char*) &dataPtr[ (i * BLK_NR_CWF_SHORT_F3 * NB_BYTES_CWF3_LIGHT_BLK) ]; | |
1000 | spw_ioctl_send_CWF.hdr = (char*) header; |
|
1003 | spw_ioctl_send_CWF.hdr = (char*) header; | |
1001 | // BUILD THE DATA |
|
1004 | // BUILD THE DATA | |
1002 | spw_ioctl_send_CWF.dlen = BLK_NR_CWF_SHORT_F3 * NB_BYTES_CWF3_LIGHT_BLK; |
|
1005 | spw_ioctl_send_CWF.dlen = BLK_NR_CWF_SHORT_F3 * NB_BYTES_CWF3_LIGHT_BLK; | |
1003 |
|
1006 | |||
1004 | // SET PACKET SEQUENCE COUNTER |
|
1007 | // SET PACKET SEQUENCE COUNTER | |
1005 | increment_seq_counter_source_id( header->packetSequenceControl, sid ); |
|
1008 | increment_seq_counter_source_id( header->packetSequenceControl, sid ); | |
1006 |
|
1009 | |||
1007 | // SET SID |
|
1010 | // SET SID | |
1008 | header->sid = sid; |
|
1011 | header->sid = sid; | |
1009 |
|
1012 | |||
1010 | // SET PACKET TIME |
|
1013 | // SET PACKET TIME | |
1011 | compute_acquisition_time( coarseTime, fineTime, SID_NORM_CWF_F3, i, header->acquisitionTime ); |
|
1014 | compute_acquisition_time( coarseTime, fineTime, SID_NORM_CWF_F3, i, header->acquisitionTime ); | |
1012 | // |
|
1015 | // | |
1013 | header->time[0] = header->acquisitionTime[0]; |
|
1016 | header->time[0] = header->acquisitionTime[0]; | |
1014 | header->time[1] = header->acquisitionTime[1]; |
|
1017 | header->time[1] = header->acquisitionTime[1]; | |
1015 | header->time[2] = header->acquisitionTime[2]; |
|
1018 | header->time[2] = header->acquisitionTime[2]; | |
1016 | header->time[3] = header->acquisitionTime[3]; |
|
1019 | header->time[3] = header->acquisitionTime[3]; | |
1017 | header->time[4] = header->acquisitionTime[4]; |
|
1020 | header->time[4] = header->acquisitionTime[4]; | |
1018 | header->time[5] = header->acquisitionTime[5]; |
|
1021 | header->time[5] = header->acquisitionTime[5]; | |
1019 |
|
1022 | |||
1020 | // SET PACKET ID |
|
1023 | // SET PACKET ID | |
1021 | header->packetID[0] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST >> 8); |
|
1024 | header->packetID[0] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST >> 8); | |
1022 | header->packetID[1] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST); |
|
1025 | header->packetID[1] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST); | |
1023 |
|
1026 | |||
1024 | // SEND PACKET |
|
1027 | // SEND PACKET | |
1025 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, &spw_ioctl_send_CWF ); |
|
1028 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, &spw_ioctl_send_CWF ); | |
1026 | if (status != RTEMS_SUCCESSFUL) { |
|
1029 | if (status != RTEMS_SUCCESSFUL) { | |
1027 | printf("%d-%d, ERR %d\n", sid, i, (int) status); |
|
1030 | printf("%d-%d, ERR %d\n", sid, i, (int) status); | |
1028 | ret = LFR_DEFAULT; |
|
1031 | ret = LFR_DEFAULT; | |
1029 | } |
|
1032 | } | |
1030 | } |
|
1033 | } | |
1031 |
|
1034 | |||
1032 | return ret; |
|
1035 | return ret; | |
1033 | } |
|
1036 | } | |
1034 |
|
1037 | |||
1035 | void spw_send_asm_f0( ring_node *ring_node_to_send, |
|
1038 | void spw_send_asm_f0( ring_node *ring_node_to_send, | |
1036 | Header_TM_LFR_SCIENCE_ASM_t *header ) |
|
1039 | Header_TM_LFR_SCIENCE_ASM_t *header ) | |
1037 | { |
|
1040 | { | |
1038 | unsigned int i; |
|
1041 | unsigned int i; | |
1039 | unsigned int length = 0; |
|
1042 | unsigned int length = 0; | |
1040 | rtems_status_code status; |
|
1043 | rtems_status_code status; | |
1041 | unsigned int sid; |
|
1044 | unsigned int sid; | |
1042 | float *spectral_matrix; |
|
1045 | float *spectral_matrix; | |
1043 | int coarseTime; |
|
1046 | int coarseTime; | |
1044 | int fineTime; |
|
1047 | int fineTime; | |
1045 | spw_ioctl_pkt_send spw_ioctl_send_ASM; |
|
1048 | spw_ioctl_pkt_send spw_ioctl_send_ASM; | |
1046 |
|
1049 | |||
1047 | sid = ring_node_to_send->sid; |
|
1050 | sid = ring_node_to_send->sid; | |
1048 | spectral_matrix = (float*) ring_node_to_send->buffer_address; |
|
1051 | spectral_matrix = (float*) ring_node_to_send->buffer_address; | |
1049 | coarseTime = ring_node_to_send->coarseTime; |
|
1052 | coarseTime = ring_node_to_send->coarseTime; | |
1050 | fineTime = ring_node_to_send->fineTime; |
|
1053 | fineTime = ring_node_to_send->fineTime; | |
1051 |
|
1054 | |||
|
1055 | header->biaStatusInfo = pa_bia_status_info; | |||
1052 | header->sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters; |
|
1056 | header->sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters; | |
1053 |
|
1057 | |||
1054 | for (i=0; i<3; i++) |
|
1058 | for (i=0; i<3; i++) | |
1055 | { |
|
1059 | { | |
1056 | if ((i==0) || (i==1)) |
|
1060 | if ((i==0) || (i==1)) | |
1057 | { |
|
1061 | { | |
1058 | spw_ioctl_send_ASM.dlen = DLEN_ASM_F0_PKT_1; |
|
1062 | spw_ioctl_send_ASM.dlen = DLEN_ASM_F0_PKT_1; | |
1059 | spw_ioctl_send_ASM.data = (char *) &spectral_matrix[ |
|
1063 | spw_ioctl_send_ASM.data = (char *) &spectral_matrix[ | |
1060 | ( (ASM_F0_INDICE_START + (i*NB_BINS_PER_PKT_ASM_F0_1) ) * NB_VALUES_PER_SM ) |
|
1064 | ( (ASM_F0_INDICE_START + (i*NB_BINS_PER_PKT_ASM_F0_1) ) * NB_VALUES_PER_SM ) | |
1061 | ]; |
|
1065 | ]; | |
1062 | length = PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F0_1; |
|
1066 | length = PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F0_1; | |
1063 | header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE_6; |
|
1067 | header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE_6; | |
1064 | header->pa_lfr_asm_blk_nr[0] = (unsigned char) ( (NB_BINS_PER_PKT_ASM_F0_1) >> 8 ); // BLK_NR MSB |
|
1068 | header->pa_lfr_asm_blk_nr[0] = (unsigned char) ( (NB_BINS_PER_PKT_ASM_F0_1) >> 8 ); // BLK_NR MSB | |
1065 | header->pa_lfr_asm_blk_nr[1] = (unsigned char) (NB_BINS_PER_PKT_ASM_F0_1); // BLK_NR LSB |
|
1069 | header->pa_lfr_asm_blk_nr[1] = (unsigned char) (NB_BINS_PER_PKT_ASM_F0_1); // BLK_NR LSB | |
1066 | } |
|
1070 | } | |
1067 | else |
|
1071 | else | |
1068 | { |
|
1072 | { | |
1069 | spw_ioctl_send_ASM.dlen = DLEN_ASM_F0_PKT_2; |
|
1073 | spw_ioctl_send_ASM.dlen = DLEN_ASM_F0_PKT_2; | |
1070 | spw_ioctl_send_ASM.data = (char*) &spectral_matrix[ |
|
1074 | spw_ioctl_send_ASM.data = (char*) &spectral_matrix[ | |
1071 | ( (ASM_F0_INDICE_START + (i*NB_BINS_PER_PKT_ASM_F0_1) ) * NB_VALUES_PER_SM ) |
|
1075 | ( (ASM_F0_INDICE_START + (i*NB_BINS_PER_PKT_ASM_F0_1) ) * NB_VALUES_PER_SM ) | |
1072 | ]; |
|
1076 | ]; | |
1073 | length = PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F0_2; |
|
1077 | length = PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F0_2; | |
1074 | header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE_6; |
|
1078 | header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE_6; | |
1075 | header->pa_lfr_asm_blk_nr[0] = (unsigned char) ( (NB_BINS_PER_PKT_ASM_F0_2) >> 8 ); // BLK_NR MSB |
|
1079 | header->pa_lfr_asm_blk_nr[0] = (unsigned char) ( (NB_BINS_PER_PKT_ASM_F0_2) >> 8 ); // BLK_NR MSB | |
1076 | header->pa_lfr_asm_blk_nr[1] = (unsigned char) (NB_BINS_PER_PKT_ASM_F0_2); // BLK_NR LSB |
|
1080 | header->pa_lfr_asm_blk_nr[1] = (unsigned char) (NB_BINS_PER_PKT_ASM_F0_2); // BLK_NR LSB | |
1077 | } |
|
1081 | } | |
1078 |
|
1082 | |||
1079 | spw_ioctl_send_ASM.hlen = HEADER_LENGTH_TM_LFR_SCIENCE_ASM; |
|
1083 | spw_ioctl_send_ASM.hlen = HEADER_LENGTH_TM_LFR_SCIENCE_ASM; | |
1080 | spw_ioctl_send_ASM.hdr = (char *) header; |
|
1084 | spw_ioctl_send_ASM.hdr = (char *) header; | |
1081 | spw_ioctl_send_ASM.options = 0; |
|
1085 | spw_ioctl_send_ASM.options = 0; | |
1082 |
|
1086 | |||
1083 | // (2) BUILD THE HEADER |
|
1087 | // (2) BUILD THE HEADER | |
1084 | increment_seq_counter_source_id( header->packetSequenceControl, sid ); |
|
1088 | increment_seq_counter_source_id( header->packetSequenceControl, sid ); | |
1085 | header->packetLength[0] = (unsigned char) (length>>8); |
|
1089 | header->packetLength[0] = (unsigned char) (length>>8); | |
1086 | header->packetLength[1] = (unsigned char) (length); |
|
1090 | header->packetLength[1] = (unsigned char) (length); | |
1087 | header->sid = (unsigned char) sid; // SID |
|
1091 | header->sid = (unsigned char) sid; // SID | |
1088 | header->pa_lfr_pkt_cnt_asm = 3; |
|
1092 | header->pa_lfr_pkt_cnt_asm = 3; | |
1089 | header->pa_lfr_pkt_nr_asm = (unsigned char) (i+1); |
|
1093 | header->pa_lfr_pkt_nr_asm = (unsigned char) (i+1); | |
1090 |
|
1094 | |||
1091 | // (3) SET PACKET TIME |
|
1095 | // (3) SET PACKET TIME | |
1092 | header->time[0] = (unsigned char) (coarseTime>>24); |
|
1096 | header->time[0] = (unsigned char) (coarseTime>>24); | |
1093 | header->time[1] = (unsigned char) (coarseTime>>16); |
|
1097 | header->time[1] = (unsigned char) (coarseTime>>16); | |
1094 | header->time[2] = (unsigned char) (coarseTime>>8); |
|
1098 | header->time[2] = (unsigned char) (coarseTime>>8); | |
1095 | header->time[3] = (unsigned char) (coarseTime); |
|
1099 | header->time[3] = (unsigned char) (coarseTime); | |
1096 | header->time[4] = (unsigned char) (fineTime>>8); |
|
1100 | header->time[4] = (unsigned char) (fineTime>>8); | |
1097 | header->time[5] = (unsigned char) (fineTime); |
|
1101 | header->time[5] = (unsigned char) (fineTime); | |
1098 | // |
|
1102 | // | |
1099 | header->acquisitionTime[0] = header->time[0]; |
|
1103 | header->acquisitionTime[0] = header->time[0]; | |
1100 | header->acquisitionTime[1] = header->time[1]; |
|
1104 | header->acquisitionTime[1] = header->time[1]; | |
1101 | header->acquisitionTime[2] = header->time[2]; |
|
1105 | header->acquisitionTime[2] = header->time[2]; | |
1102 | header->acquisitionTime[3] = header->time[3]; |
|
1106 | header->acquisitionTime[3] = header->time[3]; | |
1103 | header->acquisitionTime[4] = header->time[4]; |
|
1107 | header->acquisitionTime[4] = header->time[4]; | |
1104 | header->acquisitionTime[5] = header->time[5]; |
|
1108 | header->acquisitionTime[5] = header->time[5]; | |
1105 |
|
1109 | |||
1106 | // (4) SEND PACKET |
|
1110 | // (4) SEND PACKET | |
1107 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, &spw_ioctl_send_ASM ); |
|
1111 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, &spw_ioctl_send_ASM ); | |
1108 | if (status != RTEMS_SUCCESSFUL) { |
|
1112 | if (status != RTEMS_SUCCESSFUL) { | |
1109 | printf("in ASM_send *** ERR %d\n", (int) status); |
|
1113 | printf("in ASM_send *** ERR %d\n", (int) status); | |
1110 | } |
|
1114 | } | |
1111 | } |
|
1115 | } | |
1112 | } |
|
1116 | } | |
1113 |
|
1117 | |||
1114 | void spw_send_asm_f1( ring_node *ring_node_to_send, |
|
1118 | void spw_send_asm_f1( ring_node *ring_node_to_send, | |
1115 | Header_TM_LFR_SCIENCE_ASM_t *header ) |
|
1119 | Header_TM_LFR_SCIENCE_ASM_t *header ) | |
1116 | { |
|
1120 | { | |
1117 | unsigned int i; |
|
1121 | unsigned int i; | |
1118 | unsigned int length = 0; |
|
1122 | unsigned int length = 0; | |
1119 | rtems_status_code status; |
|
1123 | rtems_status_code status; | |
1120 | unsigned int sid; |
|
1124 | unsigned int sid; | |
1121 | float *spectral_matrix; |
|
1125 | float *spectral_matrix; | |
1122 | int coarseTime; |
|
1126 | int coarseTime; | |
1123 | int fineTime; |
|
1127 | int fineTime; | |
1124 | spw_ioctl_pkt_send spw_ioctl_send_ASM; |
|
1128 | spw_ioctl_pkt_send spw_ioctl_send_ASM; | |
1125 |
|
1129 | |||
1126 | sid = ring_node_to_send->sid; |
|
1130 | sid = ring_node_to_send->sid; | |
1127 | spectral_matrix = (float*) ring_node_to_send->buffer_address; |
|
1131 | spectral_matrix = (float*) ring_node_to_send->buffer_address; | |
1128 | coarseTime = ring_node_to_send->coarseTime; |
|
1132 | coarseTime = ring_node_to_send->coarseTime; | |
1129 | fineTime = ring_node_to_send->fineTime; |
|
1133 | fineTime = ring_node_to_send->fineTime; | |
1130 |
|
1134 | |||
|
1135 | header->biaStatusInfo = pa_bia_status_info; | |||
1131 | header->sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters; |
|
1136 | header->sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters; | |
1132 |
|
1137 | |||
1133 | for (i=0; i<3; i++) |
|
1138 | for (i=0; i<3; i++) | |
1134 | { |
|
1139 | { | |
1135 | if ((i==0) || (i==1)) |
|
1140 | if ((i==0) || (i==1)) | |
1136 | { |
|
1141 | { | |
1137 | spw_ioctl_send_ASM.dlen = DLEN_ASM_F1_PKT_1; |
|
1142 | spw_ioctl_send_ASM.dlen = DLEN_ASM_F1_PKT_1; | |
1138 | spw_ioctl_send_ASM.data = (char *) &spectral_matrix[ |
|
1143 | spw_ioctl_send_ASM.data = (char *) &spectral_matrix[ | |
1139 | ( (ASM_F1_INDICE_START + (i*NB_BINS_PER_PKT_ASM_F1_1) ) * NB_VALUES_PER_SM ) |
|
1144 | ( (ASM_F1_INDICE_START + (i*NB_BINS_PER_PKT_ASM_F1_1) ) * NB_VALUES_PER_SM ) | |
1140 | ]; |
|
1145 | ]; | |
1141 | length = PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F1_1; |
|
1146 | length = PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F1_1; | |
1142 | header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE_6; |
|
1147 | header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE_6; | |
1143 | header->pa_lfr_asm_blk_nr[0] = (unsigned char) ( (NB_BINS_PER_PKT_ASM_F1_1) >> 8 ); // BLK_NR MSB |
|
1148 | header->pa_lfr_asm_blk_nr[0] = (unsigned char) ( (NB_BINS_PER_PKT_ASM_F1_1) >> 8 ); // BLK_NR MSB | |
1144 | header->pa_lfr_asm_blk_nr[1] = (unsigned char) (NB_BINS_PER_PKT_ASM_F1_1); // BLK_NR LSB |
|
1149 | header->pa_lfr_asm_blk_nr[1] = (unsigned char) (NB_BINS_PER_PKT_ASM_F1_1); // BLK_NR LSB | |
1145 | } |
|
1150 | } | |
1146 | else |
|
1151 | else | |
1147 | { |
|
1152 | { | |
1148 | spw_ioctl_send_ASM.dlen = DLEN_ASM_F1_PKT_2; |
|
1153 | spw_ioctl_send_ASM.dlen = DLEN_ASM_F1_PKT_2; | |
1149 | spw_ioctl_send_ASM.data = (char*) &spectral_matrix[ |
|
1154 | spw_ioctl_send_ASM.data = (char*) &spectral_matrix[ | |
1150 | ( (ASM_F1_INDICE_START + (i*NB_BINS_PER_PKT_ASM_F1_1) ) * NB_VALUES_PER_SM ) |
|
1155 | ( (ASM_F1_INDICE_START + (i*NB_BINS_PER_PKT_ASM_F1_1) ) * NB_VALUES_PER_SM ) | |
1151 | ]; |
|
1156 | ]; | |
1152 | length = PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F1_2; |
|
1157 | length = PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F1_2; | |
1153 | header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE_6; |
|
1158 | header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE_6; | |
1154 | header->pa_lfr_asm_blk_nr[0] = (unsigned char) ( (NB_BINS_PER_PKT_ASM_F1_2) >> 8 ); // BLK_NR MSB |
|
1159 | header->pa_lfr_asm_blk_nr[0] = (unsigned char) ( (NB_BINS_PER_PKT_ASM_F1_2) >> 8 ); // BLK_NR MSB | |
1155 | header->pa_lfr_asm_blk_nr[1] = (unsigned char) (NB_BINS_PER_PKT_ASM_F1_2); // BLK_NR LSB |
|
1160 | header->pa_lfr_asm_blk_nr[1] = (unsigned char) (NB_BINS_PER_PKT_ASM_F1_2); // BLK_NR LSB | |
1156 | } |
|
1161 | } | |
1157 |
|
1162 | |||
1158 | spw_ioctl_send_ASM.hlen = HEADER_LENGTH_TM_LFR_SCIENCE_ASM; |
|
1163 | spw_ioctl_send_ASM.hlen = HEADER_LENGTH_TM_LFR_SCIENCE_ASM; | |
1159 | spw_ioctl_send_ASM.hdr = (char *) header; |
|
1164 | spw_ioctl_send_ASM.hdr = (char *) header; | |
1160 | spw_ioctl_send_ASM.options = 0; |
|
1165 | spw_ioctl_send_ASM.options = 0; | |
1161 |
|
1166 | |||
1162 | // (2) BUILD THE HEADER |
|
1167 | // (2) BUILD THE HEADER | |
1163 | increment_seq_counter_source_id( header->packetSequenceControl, sid ); |
|
1168 | increment_seq_counter_source_id( header->packetSequenceControl, sid ); | |
1164 | header->packetLength[0] = (unsigned char) (length>>8); |
|
1169 | header->packetLength[0] = (unsigned char) (length>>8); | |
1165 | header->packetLength[1] = (unsigned char) (length); |
|
1170 | header->packetLength[1] = (unsigned char) (length); | |
1166 | header->sid = (unsigned char) sid; // SID |
|
1171 | header->sid = (unsigned char) sid; // SID | |
1167 | header->pa_lfr_pkt_cnt_asm = 3; |
|
1172 | header->pa_lfr_pkt_cnt_asm = 3; | |
1168 | header->pa_lfr_pkt_nr_asm = (unsigned char) (i+1); |
|
1173 | header->pa_lfr_pkt_nr_asm = (unsigned char) (i+1); | |
1169 |
|
1174 | |||
1170 | // (3) SET PACKET TIME |
|
1175 | // (3) SET PACKET TIME | |
1171 | header->time[0] = (unsigned char) (coarseTime>>24); |
|
1176 | header->time[0] = (unsigned char) (coarseTime>>24); | |
1172 | header->time[1] = (unsigned char) (coarseTime>>16); |
|
1177 | header->time[1] = (unsigned char) (coarseTime>>16); | |
1173 | header->time[2] = (unsigned char) (coarseTime>>8); |
|
1178 | header->time[2] = (unsigned char) (coarseTime>>8); | |
1174 | header->time[3] = (unsigned char) (coarseTime); |
|
1179 | header->time[3] = (unsigned char) (coarseTime); | |
1175 | header->time[4] = (unsigned char) (fineTime>>8); |
|
1180 | header->time[4] = (unsigned char) (fineTime>>8); | |
1176 | header->time[5] = (unsigned char) (fineTime); |
|
1181 | header->time[5] = (unsigned char) (fineTime); | |
1177 | // |
|
1182 | // | |
1178 | header->acquisitionTime[0] = header->time[0]; |
|
1183 | header->acquisitionTime[0] = header->time[0]; | |
1179 | header->acquisitionTime[1] = header->time[1]; |
|
1184 | header->acquisitionTime[1] = header->time[1]; | |
1180 | header->acquisitionTime[2] = header->time[2]; |
|
1185 | header->acquisitionTime[2] = header->time[2]; | |
1181 | header->acquisitionTime[3] = header->time[3]; |
|
1186 | header->acquisitionTime[3] = header->time[3]; | |
1182 | header->acquisitionTime[4] = header->time[4]; |
|
1187 | header->acquisitionTime[4] = header->time[4]; | |
1183 | header->acquisitionTime[5] = header->time[5]; |
|
1188 | header->acquisitionTime[5] = header->time[5]; | |
1184 |
|
1189 | |||
1185 | // (4) SEND PACKET |
|
1190 | // (4) SEND PACKET | |
1186 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, &spw_ioctl_send_ASM ); |
|
1191 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, &spw_ioctl_send_ASM ); | |
1187 | if (status != RTEMS_SUCCESSFUL) { |
|
1192 | if (status != RTEMS_SUCCESSFUL) { | |
1188 | printf("in ASM_send *** ERR %d\n", (int) status); |
|
1193 | printf("in ASM_send *** ERR %d\n", (int) status); | |
1189 | } |
|
1194 | } | |
1190 | } |
|
1195 | } | |
1191 | } |
|
1196 | } | |
1192 |
|
1197 | |||
1193 | void spw_send_asm_f2( ring_node *ring_node_to_send, |
|
1198 | void spw_send_asm_f2( ring_node *ring_node_to_send, | |
1194 | Header_TM_LFR_SCIENCE_ASM_t *header ) |
|
1199 | Header_TM_LFR_SCIENCE_ASM_t *header ) | |
1195 | { |
|
1200 | { | |
1196 | unsigned int i; |
|
1201 | unsigned int i; | |
1197 | unsigned int length = 0; |
|
1202 | unsigned int length = 0; | |
1198 | rtems_status_code status; |
|
1203 | rtems_status_code status; | |
1199 | unsigned int sid; |
|
1204 | unsigned int sid; | |
1200 | float *spectral_matrix; |
|
1205 | float *spectral_matrix; | |
1201 | int coarseTime; |
|
1206 | int coarseTime; | |
1202 | int fineTime; |
|
1207 | int fineTime; | |
1203 | spw_ioctl_pkt_send spw_ioctl_send_ASM; |
|
1208 | spw_ioctl_pkt_send spw_ioctl_send_ASM; | |
1204 |
|
1209 | |||
1205 | sid = ring_node_to_send->sid; |
|
1210 | sid = ring_node_to_send->sid; | |
1206 | spectral_matrix = (float*) ring_node_to_send->buffer_address; |
|
1211 | spectral_matrix = (float*) ring_node_to_send->buffer_address; | |
1207 | coarseTime = ring_node_to_send->coarseTime; |
|
1212 | coarseTime = ring_node_to_send->coarseTime; | |
1208 | fineTime = ring_node_to_send->fineTime; |
|
1213 | fineTime = ring_node_to_send->fineTime; | |
1209 |
|
1214 | |||
|
1215 | header->biaStatusInfo = pa_bia_status_info; | |||
1210 | header->sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters; |
|
1216 | header->sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters; | |
1211 |
|
1217 | |||
1212 | for (i=0; i<3; i++) |
|
1218 | for (i=0; i<3; i++) | |
1213 | { |
|
1219 | { | |
1214 |
|
1220 | |||
1215 | spw_ioctl_send_ASM.dlen = DLEN_ASM_F2_PKT; |
|
1221 | spw_ioctl_send_ASM.dlen = DLEN_ASM_F2_PKT; | |
1216 | spw_ioctl_send_ASM.data = (char *) &spectral_matrix[ |
|
1222 | spw_ioctl_send_ASM.data = (char *) &spectral_matrix[ | |
1217 | ( (ASM_F2_INDICE_START + (i*NB_BINS_PER_PKT_ASM_F2) ) * NB_VALUES_PER_SM ) |
|
1223 | ( (ASM_F2_INDICE_START + (i*NB_BINS_PER_PKT_ASM_F2) ) * NB_VALUES_PER_SM ) | |
1218 | ]; |
|
1224 | ]; | |
1219 | length = PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F2; |
|
1225 | length = PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F2; | |
1220 | header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE_3; |
|
1226 | header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE_3; | |
1221 | header->pa_lfr_asm_blk_nr[0] = (unsigned char) ( (NB_BINS_PER_PKT_ASM_F2) >> 8 ); // BLK_NR MSB |
|
1227 | header->pa_lfr_asm_blk_nr[0] = (unsigned char) ( (NB_BINS_PER_PKT_ASM_F2) >> 8 ); // BLK_NR MSB | |
1222 | header->pa_lfr_asm_blk_nr[1] = (unsigned char) (NB_BINS_PER_PKT_ASM_F2); // BLK_NR LSB |
|
1228 | header->pa_lfr_asm_blk_nr[1] = (unsigned char) (NB_BINS_PER_PKT_ASM_F2); // BLK_NR LSB | |
1223 |
|
1229 | |||
1224 | spw_ioctl_send_ASM.hlen = HEADER_LENGTH_TM_LFR_SCIENCE_ASM; |
|
1230 | spw_ioctl_send_ASM.hlen = HEADER_LENGTH_TM_LFR_SCIENCE_ASM; | |
1225 | spw_ioctl_send_ASM.hdr = (char *) header; |
|
1231 | spw_ioctl_send_ASM.hdr = (char *) header; | |
1226 | spw_ioctl_send_ASM.options = 0; |
|
1232 | spw_ioctl_send_ASM.options = 0; | |
1227 |
|
1233 | |||
1228 | // (2) BUILD THE HEADER |
|
1234 | // (2) BUILD THE HEADER | |
1229 | increment_seq_counter_source_id( header->packetSequenceControl, sid ); |
|
1235 | increment_seq_counter_source_id( header->packetSequenceControl, sid ); | |
1230 | header->packetLength[0] = (unsigned char) (length>>8); |
|
1236 | header->packetLength[0] = (unsigned char) (length>>8); | |
1231 | header->packetLength[1] = (unsigned char) (length); |
|
1237 | header->packetLength[1] = (unsigned char) (length); | |
1232 | header->sid = (unsigned char) sid; // SID |
|
1238 | header->sid = (unsigned char) sid; // SID | |
1233 | header->pa_lfr_pkt_cnt_asm = 3; |
|
1239 | header->pa_lfr_pkt_cnt_asm = 3; | |
1234 | header->pa_lfr_pkt_nr_asm = (unsigned char) (i+1); |
|
1240 | header->pa_lfr_pkt_nr_asm = (unsigned char) (i+1); | |
1235 |
|
1241 | |||
1236 | // (3) SET PACKET TIME |
|
1242 | // (3) SET PACKET TIME | |
1237 | header->time[0] = (unsigned char) (coarseTime>>24); |
|
1243 | header->time[0] = (unsigned char) (coarseTime>>24); | |
1238 | header->time[1] = (unsigned char) (coarseTime>>16); |
|
1244 | header->time[1] = (unsigned char) (coarseTime>>16); | |
1239 | header->time[2] = (unsigned char) (coarseTime>>8); |
|
1245 | header->time[2] = (unsigned char) (coarseTime>>8); | |
1240 | header->time[3] = (unsigned char) (coarseTime); |
|
1246 | header->time[3] = (unsigned char) (coarseTime); | |
1241 | header->time[4] = (unsigned char) (fineTime>>8); |
|
1247 | header->time[4] = (unsigned char) (fineTime>>8); | |
1242 | header->time[5] = (unsigned char) (fineTime); |
|
1248 | header->time[5] = (unsigned char) (fineTime); | |
1243 | // |
|
1249 | // | |
1244 | header->acquisitionTime[0] = header->time[0]; |
|
1250 | header->acquisitionTime[0] = header->time[0]; | |
1245 | header->acquisitionTime[1] = header->time[1]; |
|
1251 | header->acquisitionTime[1] = header->time[1]; | |
1246 | header->acquisitionTime[2] = header->time[2]; |
|
1252 | header->acquisitionTime[2] = header->time[2]; | |
1247 | header->acquisitionTime[3] = header->time[3]; |
|
1253 | header->acquisitionTime[3] = header->time[3]; | |
1248 | header->acquisitionTime[4] = header->time[4]; |
|
1254 | header->acquisitionTime[4] = header->time[4]; | |
1249 | header->acquisitionTime[5] = header->time[5]; |
|
1255 | header->acquisitionTime[5] = header->time[5]; | |
1250 |
|
1256 | |||
1251 | // (4) SEND PACKET |
|
1257 | // (4) SEND PACKET | |
1252 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, &spw_ioctl_send_ASM ); |
|
1258 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, &spw_ioctl_send_ASM ); | |
1253 | if (status != RTEMS_SUCCESSFUL) { |
|
1259 | if (status != RTEMS_SUCCESSFUL) { | |
1254 | printf("in ASM_send *** ERR %d\n", (int) status); |
|
1260 | printf("in ASM_send *** ERR %d\n", (int) status); | |
1255 | } |
|
1261 | } | |
1256 | } |
|
1262 | } | |
1257 | } |
|
1263 | } | |
1258 |
|
1264 | |||
1259 | void spw_send_k_dump( ring_node *ring_node_to_send ) |
|
1265 | void spw_send_k_dump( ring_node *ring_node_to_send ) | |
1260 | { |
|
1266 | { | |
1261 | rtems_status_code status; |
|
1267 | rtems_status_code status; | |
1262 | Packet_TM_LFR_KCOEFFICIENTS_DUMP_t *kcoefficients_dump; |
|
1268 | Packet_TM_LFR_KCOEFFICIENTS_DUMP_t *kcoefficients_dump; | |
1263 | unsigned int packetLength; |
|
1269 | unsigned int packetLength; | |
1264 | unsigned int size; |
|
1270 | unsigned int size; | |
1265 |
|
1271 | |||
1266 | printf("spw_send_k_dump\n"); |
|
1272 | printf("spw_send_k_dump\n"); | |
1267 |
|
1273 | |||
1268 | kcoefficients_dump = (Packet_TM_LFR_KCOEFFICIENTS_DUMP_t *) ring_node_to_send->buffer_address; |
|
1274 | kcoefficients_dump = (Packet_TM_LFR_KCOEFFICIENTS_DUMP_t *) ring_node_to_send->buffer_address; | |
1269 |
|
1275 | |||
1270 | packetLength = kcoefficients_dump->packetLength[0] * 256 + kcoefficients_dump->packetLength[1]; |
|
1276 | packetLength = kcoefficients_dump->packetLength[0] * 256 + kcoefficients_dump->packetLength[1]; | |
1271 |
|
1277 | |||
1272 | size = packetLength + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES; |
|
1278 | size = packetLength + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES; | |
1273 |
|
1279 | |||
1274 | printf("packetLength %d, size %d\n", packetLength, size ); |
|
1280 | printf("packetLength %d, size %d\n", packetLength, size ); | |
1275 |
|
1281 | |||
1276 | status = write( fdSPW, (char *) ring_node_to_send->buffer_address, size ); |
|
1282 | status = write( fdSPW, (char *) ring_node_to_send->buffer_address, size ); | |
1277 |
|
1283 | |||
1278 | if (status == -1){ |
|
1284 | if (status == -1){ | |
1279 | PRINTF2("in SEND *** (2.a) ERRNO = %d, size = %d\n", errno, size) |
|
1285 | PRINTF2("in SEND *** (2.a) ERRNO = %d, size = %d\n", errno, size) | |
1280 | } |
|
1286 | } | |
1281 |
|
1287 | |||
1282 | ring_node_to_send->status = 0x00; |
|
1288 | ring_node_to_send->status = 0x00; | |
1283 | } |
|
1289 | } |
@@ -1,1169 +1,1180 | |||||
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 | status = enter_mode( requestedMode, transitionCoarseTime ); |
|
207 | status = enter_mode( requestedMode, transitionCoarseTime ); | |
208 | } |
|
208 | } | |
209 |
|
209 | |||
210 | return status; |
|
210 | return status; | |
211 | } |
|
211 | } | |
212 |
|
212 | |||
213 | int action_update_info(ccsdsTelecommandPacket_t *TC, rtems_id queue_id) |
|
213 | int action_update_info(ccsdsTelecommandPacket_t *TC, rtems_id queue_id) | |
214 | { |
|
214 | { | |
215 | /** This function executes specific actions when a TC_LFR_UPDATE_INFO TeleCommand has been received. |
|
215 | /** This function executes specific actions when a TC_LFR_UPDATE_INFO TeleCommand has been received. | |
216 | * |
|
216 | * | |
217 | * @param TC points to the TeleCommand packet that is being processed |
|
217 | * @param TC points to the TeleCommand packet that is being processed | |
218 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver |
|
218 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver | |
219 | * |
|
219 | * | |
220 | * @return LFR directive status code: |
|
220 | * @return LFR directive status code: | |
221 | * - LFR_DEFAULT |
|
221 | * - LFR_DEFAULT | |
222 | * - LFR_SUCCESSFUL |
|
222 | * - LFR_SUCCESSFUL | |
223 | * |
|
223 | * | |
224 | */ |
|
224 | */ | |
225 |
|
225 | |||
226 | unsigned int val; |
|
226 | unsigned int val; | |
227 | int result; |
|
227 | int result; | |
228 | unsigned int status; |
|
228 | unsigned int status; | |
229 | unsigned char mode; |
|
229 | unsigned char mode; | |
230 | unsigned char * bytePosPtr; |
|
230 | unsigned char * bytePosPtr; | |
231 |
|
231 | |||
232 | bytePosPtr = (unsigned char *) &TC->packetID; |
|
232 | bytePosPtr = (unsigned char *) &TC->packetID; | |
233 |
|
233 | |||
234 | // check LFR mode |
|
234 | // check LFR mode | |
235 | mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET5 ] & 0x1e) >> 1; |
|
235 | mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET5 ] & 0x1e) >> 1; | |
236 | status = check_update_info_hk_lfr_mode( mode ); |
|
236 | status = check_update_info_hk_lfr_mode( mode ); | |
237 | if (status == LFR_SUCCESSFUL) // check TDS mode |
|
237 | if (status == LFR_SUCCESSFUL) // check TDS mode | |
238 | { |
|
238 | { | |
239 | mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET6 ] & 0xf0) >> 4; |
|
239 | mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET6 ] & 0xf0) >> 4; | |
240 | status = check_update_info_hk_tds_mode( mode ); |
|
240 | status = check_update_info_hk_tds_mode( mode ); | |
241 | } |
|
241 | } | |
242 | if (status == LFR_SUCCESSFUL) // check THR mode |
|
242 | if (status == LFR_SUCCESSFUL) // check THR mode | |
243 | { |
|
243 | { | |
244 | mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET6 ] & 0x0f); |
|
244 | mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET6 ] & 0x0f); | |
245 | status = check_update_info_hk_thr_mode( mode ); |
|
245 | status = check_update_info_hk_thr_mode( mode ); | |
246 | } |
|
246 | } | |
247 | if (status == LFR_SUCCESSFUL) // if the parameter check is successful |
|
247 | if (status == LFR_SUCCESSFUL) // if the parameter check is successful | |
248 | { |
|
248 | { | |
249 | val = housekeeping_packet.hk_lfr_update_info_tc_cnt[0] * 256 |
|
249 | val = housekeeping_packet.hk_lfr_update_info_tc_cnt[0] * 256 | |
250 | + housekeeping_packet.hk_lfr_update_info_tc_cnt[1]; |
|
250 | + housekeeping_packet.hk_lfr_update_info_tc_cnt[1]; | |
251 | val++; |
|
251 | val++; | |
252 | housekeeping_packet.hk_lfr_update_info_tc_cnt[0] = (unsigned char) (val >> 8); |
|
252 | housekeeping_packet.hk_lfr_update_info_tc_cnt[0] = (unsigned char) (val >> 8); | |
253 | housekeeping_packet.hk_lfr_update_info_tc_cnt[1] = (unsigned char) (val); |
|
253 | housekeeping_packet.hk_lfr_update_info_tc_cnt[1] = (unsigned char) (val); | |
254 | } |
|
254 | } | |
255 |
|
255 | |||
|
256 | // pa_bia_status_info | |||
|
257 | // => pa_bia_mode_mux_set 3 bits | |||
|
258 | // => pa_bia_mode_hv_enabled 1 bit | |||
|
259 | // => pa_bia_mode_bias1_enabled 1 bit | |||
|
260 | // => pa_bia_mode_bias2_enabled 1 bit | |||
|
261 | // => pa_bia_mode_bias3_enabled 1 bit | |||
|
262 | // => pa_bia_on_off (cp_dpu_bias_on_off) | |||
|
263 | pa_bia_status_info = bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET2 ] & 0xfe; // [1111 1110] | |||
|
264 | pa_bia_status_info = pa_bia_status_info | |||
|
265 | | (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET1 ] & 0x1); | |||
|
266 | ||||
256 | result = status; |
|
267 | result = status; | |
257 |
|
268 | |||
258 | return result; |
|
269 | return result; | |
259 | } |
|
270 | } | |
260 |
|
271 | |||
261 | int action_enable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) |
|
272 | int action_enable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) | |
262 | { |
|
273 | { | |
263 | /** This function executes specific actions when a TC_LFR_ENABLE_CALIBRATION TeleCommand has been received. |
|
274 | /** This function executes specific actions when a TC_LFR_ENABLE_CALIBRATION TeleCommand has been received. | |
264 | * |
|
275 | * | |
265 | * @param TC points to the TeleCommand packet that is being processed |
|
276 | * @param TC points to the TeleCommand packet that is being processed | |
266 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver |
|
277 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver | |
267 | * |
|
278 | * | |
268 | */ |
|
279 | */ | |
269 |
|
280 | |||
270 | int result; |
|
281 | int result; | |
271 |
|
282 | |||
272 | result = LFR_DEFAULT; |
|
283 | result = LFR_DEFAULT; | |
273 |
|
284 | |||
274 | setCalibration( true ); |
|
285 | setCalibration( true ); | |
275 |
|
286 | |||
276 | result = LFR_SUCCESSFUL; |
|
287 | result = LFR_SUCCESSFUL; | |
277 |
|
288 | |||
278 | return result; |
|
289 | return result; | |
279 | } |
|
290 | } | |
280 |
|
291 | |||
281 | int action_disable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) |
|
292 | int action_disable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) | |
282 | { |
|
293 | { | |
283 | /** This function executes specific actions when a TC_LFR_DISABLE_CALIBRATION TeleCommand has been received. |
|
294 | /** This function executes specific actions when a TC_LFR_DISABLE_CALIBRATION TeleCommand has been received. | |
284 | * |
|
295 | * | |
285 | * @param TC points to the TeleCommand packet that is being processed |
|
296 | * @param TC points to the TeleCommand packet that is being processed | |
286 | * @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 | |
287 | * |
|
298 | * | |
288 | */ |
|
299 | */ | |
289 |
|
300 | |||
290 | int result; |
|
301 | int result; | |
291 |
|
302 | |||
292 | result = LFR_DEFAULT; |
|
303 | result = LFR_DEFAULT; | |
293 |
|
304 | |||
294 | setCalibration( false ); |
|
305 | setCalibration( false ); | |
295 |
|
306 | |||
296 | result = LFR_SUCCESSFUL; |
|
307 | result = LFR_SUCCESSFUL; | |
297 |
|
308 | |||
298 | return result; |
|
309 | return result; | |
299 | } |
|
310 | } | |
300 |
|
311 | |||
301 | int action_update_time(ccsdsTelecommandPacket_t *TC) |
|
312 | int action_update_time(ccsdsTelecommandPacket_t *TC) | |
302 | { |
|
313 | { | |
303 | /** This function executes specific actions when a TC_LFR_UPDATE_TIME TeleCommand has been received. |
|
314 | /** This function executes specific actions when a TC_LFR_UPDATE_TIME TeleCommand has been received. | |
304 | * |
|
315 | * | |
305 | * @param TC points to the TeleCommand packet that is being processed |
|
316 | * @param TC points to the TeleCommand packet that is being processed | |
306 | * @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 | |
307 | * |
|
318 | * | |
308 | * @return LFR_SUCCESSFUL |
|
319 | * @return LFR_SUCCESSFUL | |
309 | * |
|
320 | * | |
310 | */ |
|
321 | */ | |
311 |
|
322 | |||
312 | unsigned int val; |
|
323 | unsigned int val; | |
313 |
|
324 | |||
314 | time_management_regs->coarse_time_load = (TC->dataAndCRC[0] << 24) |
|
325 | time_management_regs->coarse_time_load = (TC->dataAndCRC[0] << 24) | |
315 | + (TC->dataAndCRC[1] << 16) |
|
326 | + (TC->dataAndCRC[1] << 16) | |
316 | + (TC->dataAndCRC[2] << 8) |
|
327 | + (TC->dataAndCRC[2] << 8) | |
317 | + TC->dataAndCRC[3]; |
|
328 | + TC->dataAndCRC[3]; | |
318 |
|
329 | |||
319 | val = housekeeping_packet.hk_lfr_update_time_tc_cnt[0] * 256 |
|
330 | val = housekeeping_packet.hk_lfr_update_time_tc_cnt[0] * 256 | |
320 | + housekeeping_packet.hk_lfr_update_time_tc_cnt[1]; |
|
331 | + housekeeping_packet.hk_lfr_update_time_tc_cnt[1]; | |
321 | val++; |
|
332 | val++; | |
322 | housekeeping_packet.hk_lfr_update_time_tc_cnt[0] = (unsigned char) (val >> 8); |
|
333 | housekeeping_packet.hk_lfr_update_time_tc_cnt[0] = (unsigned char) (val >> 8); | |
323 | housekeeping_packet.hk_lfr_update_time_tc_cnt[1] = (unsigned char) (val); |
|
334 | housekeeping_packet.hk_lfr_update_time_tc_cnt[1] = (unsigned char) (val); | |
324 |
|
335 | |||
325 | return LFR_SUCCESSFUL; |
|
336 | return LFR_SUCCESSFUL; | |
326 | } |
|
337 | } | |
327 |
|
338 | |||
328 | //******************* |
|
339 | //******************* | |
329 | // ENTERING THE MODES |
|
340 | // ENTERING THE MODES | |
330 | int check_mode_value( unsigned char requestedMode ) |
|
341 | int check_mode_value( unsigned char requestedMode ) | |
331 | { |
|
342 | { | |
332 | int status; |
|
343 | int status; | |
333 |
|
344 | |||
334 | if ( (requestedMode != LFR_MODE_STANDBY) |
|
345 | if ( (requestedMode != LFR_MODE_STANDBY) | |
335 | && (requestedMode != LFR_MODE_NORMAL) && (requestedMode != LFR_MODE_BURST) |
|
346 | && (requestedMode != LFR_MODE_NORMAL) && (requestedMode != LFR_MODE_BURST) | |
336 | && (requestedMode != LFR_MODE_SBM1) && (requestedMode != LFR_MODE_SBM2) ) |
|
347 | && (requestedMode != LFR_MODE_SBM1) && (requestedMode != LFR_MODE_SBM2) ) | |
337 | { |
|
348 | { | |
338 | status = LFR_DEFAULT; |
|
349 | status = LFR_DEFAULT; | |
339 | } |
|
350 | } | |
340 | else |
|
351 | else | |
341 | { |
|
352 | { | |
342 | status = LFR_SUCCESSFUL; |
|
353 | status = LFR_SUCCESSFUL; | |
343 | } |
|
354 | } | |
344 |
|
355 | |||
345 | return status; |
|
356 | return status; | |
346 | } |
|
357 | } | |
347 |
|
358 | |||
348 | int check_mode_transition( unsigned char requestedMode ) |
|
359 | int check_mode_transition( unsigned char requestedMode ) | |
349 | { |
|
360 | { | |
350 | /** This function checks the validity of the transition requested by the TC_LFR_ENTER_MODE. |
|
361 | /** This function checks the validity of the transition requested by the TC_LFR_ENTER_MODE. | |
351 | * |
|
362 | * | |
352 | * @param requestedMode is the mode requested by the TC_LFR_ENTER_MODE |
|
363 | * @param requestedMode is the mode requested by the TC_LFR_ENTER_MODE | |
353 | * |
|
364 | * | |
354 | * @return LFR directive status codes: |
|
365 | * @return LFR directive status codes: | |
355 | * - LFR_SUCCESSFUL - the transition is authorized |
|
366 | * - LFR_SUCCESSFUL - the transition is authorized | |
356 | * - LFR_DEFAULT - the transition is not authorized |
|
367 | * - LFR_DEFAULT - the transition is not authorized | |
357 | * |
|
368 | * | |
358 | */ |
|
369 | */ | |
359 |
|
370 | |||
360 | int status; |
|
371 | int status; | |
361 |
|
372 | |||
362 | switch (requestedMode) |
|
373 | switch (requestedMode) | |
363 | { |
|
374 | { | |
364 | case LFR_MODE_STANDBY: |
|
375 | case LFR_MODE_STANDBY: | |
365 | if ( lfrCurrentMode == LFR_MODE_STANDBY ) { |
|
376 | if ( lfrCurrentMode == LFR_MODE_STANDBY ) { | |
366 | status = LFR_DEFAULT; |
|
377 | status = LFR_DEFAULT; | |
367 | } |
|
378 | } | |
368 | else |
|
379 | else | |
369 | { |
|
380 | { | |
370 | status = LFR_SUCCESSFUL; |
|
381 | status = LFR_SUCCESSFUL; | |
371 | } |
|
382 | } | |
372 | break; |
|
383 | break; | |
373 | case LFR_MODE_NORMAL: |
|
384 | case LFR_MODE_NORMAL: | |
374 | if ( lfrCurrentMode == LFR_MODE_NORMAL ) { |
|
385 | if ( lfrCurrentMode == LFR_MODE_NORMAL ) { | |
375 | status = LFR_DEFAULT; |
|
386 | status = LFR_DEFAULT; | |
376 | } |
|
387 | } | |
377 | else { |
|
388 | else { | |
378 | status = LFR_SUCCESSFUL; |
|
389 | status = LFR_SUCCESSFUL; | |
379 | } |
|
390 | } | |
380 | break; |
|
391 | break; | |
381 | case LFR_MODE_BURST: |
|
392 | case LFR_MODE_BURST: | |
382 | if ( lfrCurrentMode == LFR_MODE_BURST ) { |
|
393 | if ( lfrCurrentMode == LFR_MODE_BURST ) { | |
383 | status = LFR_DEFAULT; |
|
394 | status = LFR_DEFAULT; | |
384 | } |
|
395 | } | |
385 | else { |
|
396 | else { | |
386 | status = LFR_SUCCESSFUL; |
|
397 | status = LFR_SUCCESSFUL; | |
387 | } |
|
398 | } | |
388 | break; |
|
399 | break; | |
389 | case LFR_MODE_SBM1: |
|
400 | case LFR_MODE_SBM1: | |
390 | if ( lfrCurrentMode == LFR_MODE_SBM1 ) { |
|
401 | if ( lfrCurrentMode == LFR_MODE_SBM1 ) { | |
391 | status = LFR_DEFAULT; |
|
402 | status = LFR_DEFAULT; | |
392 | } |
|
403 | } | |
393 | else { |
|
404 | else { | |
394 | status = LFR_SUCCESSFUL; |
|
405 | status = LFR_SUCCESSFUL; | |
395 | } |
|
406 | } | |
396 | break; |
|
407 | break; | |
397 | case LFR_MODE_SBM2: |
|
408 | case LFR_MODE_SBM2: | |
398 | if ( lfrCurrentMode == LFR_MODE_SBM2 ) { |
|
409 | if ( lfrCurrentMode == LFR_MODE_SBM2 ) { | |
399 | status = LFR_DEFAULT; |
|
410 | status = LFR_DEFAULT; | |
400 | } |
|
411 | } | |
401 | else { |
|
412 | else { | |
402 | status = LFR_SUCCESSFUL; |
|
413 | status = LFR_SUCCESSFUL; | |
403 | } |
|
414 | } | |
404 | break; |
|
415 | break; | |
405 | default: |
|
416 | default: | |
406 | status = LFR_DEFAULT; |
|
417 | status = LFR_DEFAULT; | |
407 | break; |
|
418 | break; | |
408 | } |
|
419 | } | |
409 |
|
420 | |||
410 | return status; |
|
421 | return status; | |
411 | } |
|
422 | } | |
412 |
|
423 | |||
413 | int check_transition_date( unsigned int transitionCoarseTime ) |
|
424 | int check_transition_date( unsigned int transitionCoarseTime ) | |
414 | { |
|
425 | { | |
415 | int status; |
|
426 | int status; | |
416 | unsigned int localCoarseTime; |
|
427 | unsigned int localCoarseTime; | |
417 | unsigned int deltaCoarseTime; |
|
428 | unsigned int deltaCoarseTime; | |
418 |
|
429 | |||
419 | status = LFR_SUCCESSFUL; |
|
430 | status = LFR_SUCCESSFUL; | |
420 |
|
431 | |||
421 | if (transitionCoarseTime == 0) // transition time = 0 means an instant transition |
|
432 | if (transitionCoarseTime == 0) // transition time = 0 means an instant transition | |
422 | { |
|
433 | { | |
423 | status = LFR_SUCCESSFUL; |
|
434 | status = LFR_SUCCESSFUL; | |
424 | } |
|
435 | } | |
425 | else |
|
436 | else | |
426 | { |
|
437 | { | |
427 | localCoarseTime = time_management_regs->coarse_time & 0x7fffffff; |
|
438 | localCoarseTime = time_management_regs->coarse_time & 0x7fffffff; | |
428 |
|
439 | |||
429 | PRINTF2("localTime = %x, transitionTime = %x\n", localCoarseTime, transitionCoarseTime) |
|
440 | PRINTF2("localTime = %x, transitionTime = %x\n", localCoarseTime, transitionCoarseTime) | |
430 |
|
441 | |||
431 | if ( transitionCoarseTime <= localCoarseTime ) // SSS-CP-EQS-322 |
|
442 | if ( transitionCoarseTime <= localCoarseTime ) // SSS-CP-EQS-322 | |
432 | { |
|
443 | { | |
433 | status = LFR_DEFAULT; |
|
444 | status = LFR_DEFAULT; | |
434 | PRINTF("ERR *** in check_transition_date *** transitionCoarseTime <= localCoarseTime\n") |
|
445 | PRINTF("ERR *** in check_transition_date *** transitionCoarseTime <= localCoarseTime\n") | |
435 | } |
|
446 | } | |
436 |
|
447 | |||
437 | if (status == LFR_SUCCESSFUL) |
|
448 | if (status == LFR_SUCCESSFUL) | |
438 | { |
|
449 | { | |
439 | deltaCoarseTime = transitionCoarseTime - localCoarseTime; |
|
450 | deltaCoarseTime = transitionCoarseTime - localCoarseTime; | |
440 | if ( deltaCoarseTime > 3 ) // SSS-CP-EQS-323 |
|
451 | if ( deltaCoarseTime > 3 ) // SSS-CP-EQS-323 | |
441 | { |
|
452 | { | |
442 | status = LFR_DEFAULT; |
|
453 | status = LFR_DEFAULT; | |
443 | PRINTF1("ERR *** in check_transition_date *** deltaCoarseTime = %x\n", deltaCoarseTime) |
|
454 | PRINTF1("ERR *** in check_transition_date *** deltaCoarseTime = %x\n", deltaCoarseTime) | |
444 | } |
|
455 | } | |
445 | } |
|
456 | } | |
446 | } |
|
457 | } | |
447 |
|
458 | |||
448 | return status; |
|
459 | return status; | |
449 | } |
|
460 | } | |
450 |
|
461 | |||
451 | int stop_current_mode( void ) |
|
462 | int stop_current_mode( void ) | |
452 | { |
|
463 | { | |
453 | /** This function stops the current mode by masking interrupt lines and suspending science tasks. |
|
464 | /** This function stops the current mode by masking interrupt lines and suspending science tasks. | |
454 | * |
|
465 | * | |
455 | * @return RTEMS directive status codes: |
|
466 | * @return RTEMS directive status codes: | |
456 | * - RTEMS_SUCCESSFUL - task restarted successfully |
|
467 | * - RTEMS_SUCCESSFUL - task restarted successfully | |
457 | * - RTEMS_INVALID_ID - task id invalid |
|
468 | * - RTEMS_INVALID_ID - task id invalid | |
458 | * - RTEMS_ALREADY_SUSPENDED - task already suspended |
|
469 | * - RTEMS_ALREADY_SUSPENDED - task already suspended | |
459 | * |
|
470 | * | |
460 | */ |
|
471 | */ | |
461 |
|
472 | |||
462 | rtems_status_code status; |
|
473 | rtems_status_code status; | |
463 |
|
474 | |||
464 | status = RTEMS_SUCCESSFUL; |
|
475 | status = RTEMS_SUCCESSFUL; | |
465 |
|
476 | |||
466 | // (1) mask interruptions |
|
477 | // (1) mask interruptions | |
467 | LEON_Mask_interrupt( IRQ_WAVEFORM_PICKER ); // mask waveform picker interrupt |
|
478 | LEON_Mask_interrupt( IRQ_WAVEFORM_PICKER ); // mask waveform picker interrupt | |
468 | LEON_Mask_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt |
|
479 | LEON_Mask_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt | |
469 |
|
480 | |||
470 | // (2) reset waveform picker registers |
|
481 | // (2) reset waveform picker registers | |
471 | reset_wfp_burst_enable(); // reset burst and enable bits |
|
482 | reset_wfp_burst_enable(); // reset burst and enable bits | |
472 | reset_wfp_status(); // reset all the status bits |
|
483 | reset_wfp_status(); // reset all the status bits | |
473 |
|
484 | |||
474 | // (3) reset spectral matrices registers |
|
485 | // (3) reset spectral matrices registers | |
475 | set_sm_irq_onNewMatrix( 0 ); // stop the spectral matrices |
|
486 | set_sm_irq_onNewMatrix( 0 ); // stop the spectral matrices | |
476 | reset_sm_status(); |
|
487 | reset_sm_status(); | |
477 |
|
488 | |||
478 | // reset lfr VHDL module |
|
489 | // reset lfr VHDL module | |
479 | reset_lfr(); |
|
490 | reset_lfr(); | |
480 |
|
491 | |||
481 | reset_extractSWF(); // reset the extractSWF flag to false |
|
492 | reset_extractSWF(); // reset the extractSWF flag to false | |
482 |
|
493 | |||
483 | // (4) clear interruptions |
|
494 | // (4) clear interruptions | |
484 | LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER ); // clear waveform picker interrupt |
|
495 | LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER ); // clear waveform picker interrupt | |
485 | LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt |
|
496 | LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt | |
486 |
|
497 | |||
487 | // <Spectral Matrices simulator> |
|
498 | // <Spectral Matrices simulator> | |
488 | LEON_Mask_interrupt( IRQ_SM_SIMULATOR ); // mask spectral matrix interrupt simulator |
|
499 | LEON_Mask_interrupt( IRQ_SM_SIMULATOR ); // mask spectral matrix interrupt simulator | |
489 | timer_stop( (gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR ); |
|
500 | timer_stop( (gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR ); | |
490 | LEON_Clear_interrupt( IRQ_SM_SIMULATOR ); // clear spectral matrix interrupt simulator |
|
501 | LEON_Clear_interrupt( IRQ_SM_SIMULATOR ); // clear spectral matrix interrupt simulator | |
491 | // </Spectral Matrices simulator> |
|
502 | // </Spectral Matrices simulator> | |
492 |
|
503 | |||
493 | // suspend several tasks |
|
504 | // suspend several tasks | |
494 | if (lfrCurrentMode != LFR_MODE_STANDBY) { |
|
505 | if (lfrCurrentMode != LFR_MODE_STANDBY) { | |
495 | status = suspend_science_tasks(); |
|
506 | status = suspend_science_tasks(); | |
496 | } |
|
507 | } | |
497 |
|
508 | |||
498 | if (status != RTEMS_SUCCESSFUL) |
|
509 | if (status != RTEMS_SUCCESSFUL) | |
499 | { |
|
510 | { | |
500 | PRINTF1("in stop_current_mode *** in suspend_science_tasks *** ERR code: %d\n", status) |
|
511 | PRINTF1("in stop_current_mode *** in suspend_science_tasks *** ERR code: %d\n", status) | |
501 | } |
|
512 | } | |
502 |
|
513 | |||
503 | return status; |
|
514 | return status; | |
504 | } |
|
515 | } | |
505 |
|
516 | |||
506 | int enter_mode( unsigned char mode, unsigned int transitionCoarseTime ) |
|
517 | int enter_mode( unsigned char mode, unsigned int transitionCoarseTime ) | |
507 | { |
|
518 | { | |
508 | /** This function is launched after a mode transition validation. |
|
519 | /** This function is launched after a mode transition validation. | |
509 | * |
|
520 | * | |
510 | * @param mode is the mode in which LFR will be put. |
|
521 | * @param mode is the mode in which LFR will be put. | |
511 | * |
|
522 | * | |
512 | * @return RTEMS directive status codes: |
|
523 | * @return RTEMS directive status codes: | |
513 | * - RTEMS_SUCCESSFUL - the mode has been entered successfully |
|
524 | * - RTEMS_SUCCESSFUL - the mode has been entered successfully | |
514 | * - RTEMS_NOT_SATISFIED - the mode has not been entered successfully |
|
525 | * - RTEMS_NOT_SATISFIED - the mode has not been entered successfully | |
515 | * |
|
526 | * | |
516 | */ |
|
527 | */ | |
517 |
|
528 | |||
518 | rtems_status_code status; |
|
529 | rtems_status_code status; | |
519 |
|
530 | |||
520 | //********************** |
|
531 | //********************** | |
521 | // STOP THE CURRENT MODE |
|
532 | // STOP THE CURRENT MODE | |
522 | status = stop_current_mode(); |
|
533 | status = stop_current_mode(); | |
523 | if (status != RTEMS_SUCCESSFUL) |
|
534 | if (status != RTEMS_SUCCESSFUL) | |
524 | { |
|
535 | { | |
525 | PRINTF1("ERR *** in enter_mode *** stop_current_mode with mode = %d\n", mode) |
|
536 | PRINTF1("ERR *** in enter_mode *** stop_current_mode with mode = %d\n", mode) | |
526 | } |
|
537 | } | |
527 |
|
538 | |||
528 | //************************* |
|
539 | //************************* | |
529 | // ENTER THE REQUESTED MODE |
|
540 | // ENTER THE REQUESTED MODE | |
530 | if (status == RTEMS_SUCCESSFUL) // if the current mode has been successfully stopped |
|
541 | if (status == RTEMS_SUCCESSFUL) // if the current mode has been successfully stopped | |
531 | { |
|
542 | { | |
532 | if ( (mode == LFR_MODE_NORMAL) || (mode == LFR_MODE_BURST) |
|
543 | if ( (mode == LFR_MODE_NORMAL) || (mode == LFR_MODE_BURST) | |
533 | || (mode == LFR_MODE_SBM1) || (mode == LFR_MODE_SBM2) ) |
|
544 | || (mode == LFR_MODE_SBM1) || (mode == LFR_MODE_SBM2) ) | |
534 | { |
|
545 | { | |
535 | #ifdef PRINT_TASK_STATISTICS |
|
546 | #ifdef PRINT_TASK_STATISTICS | |
536 | rtems_cpu_usage_reset(); |
|
547 | rtems_cpu_usage_reset(); | |
537 | #endif |
|
548 | #endif | |
538 | status = restart_science_tasks( mode ); |
|
549 | status = restart_science_tasks( mode ); | |
539 | if (status == RTEMS_SUCCESSFUL) |
|
550 | if (status == RTEMS_SUCCESSFUL) | |
540 | { |
|
551 | { | |
541 | launch_spectral_matrix( ); |
|
552 | launch_spectral_matrix( ); | |
542 | launch_waveform_picker( mode, transitionCoarseTime ); |
|
553 | launch_waveform_picker( mode, transitionCoarseTime ); | |
543 | } |
|
554 | } | |
544 | } |
|
555 | } | |
545 | else if ( mode == LFR_MODE_STANDBY ) |
|
556 | else if ( mode == LFR_MODE_STANDBY ) | |
546 | { |
|
557 | { | |
547 | #ifdef PRINT_TASK_STATISTICS |
|
558 | #ifdef PRINT_TASK_STATISTICS | |
548 | rtems_cpu_usage_report(); |
|
559 | rtems_cpu_usage_report(); | |
549 | #endif |
|
560 | #endif | |
550 |
|
561 | |||
551 | #ifdef PRINT_STACK_REPORT |
|
562 | #ifdef PRINT_STACK_REPORT | |
552 | PRINTF("stack report selected\n") |
|
563 | PRINTF("stack report selected\n") | |
553 | rtems_stack_checker_report_usage(); |
|
564 | rtems_stack_checker_report_usage(); | |
554 | #endif |
|
565 | #endif | |
555 | } |
|
566 | } | |
556 | else |
|
567 | else | |
557 | { |
|
568 | { | |
558 | status = RTEMS_UNSATISFIED; |
|
569 | status = RTEMS_UNSATISFIED; | |
559 | } |
|
570 | } | |
560 | } |
|
571 | } | |
561 |
|
572 | |||
562 | if (status != RTEMS_SUCCESSFUL) |
|
573 | if (status != RTEMS_SUCCESSFUL) | |
563 | { |
|
574 | { | |
564 | PRINTF1("ERR *** in enter_mode *** status = %d\n", status) |
|
575 | PRINTF1("ERR *** in enter_mode *** status = %d\n", status) | |
565 | status = RTEMS_UNSATISFIED; |
|
576 | status = RTEMS_UNSATISFIED; | |
566 | } |
|
577 | } | |
567 |
|
578 | |||
568 | return status; |
|
579 | return status; | |
569 | } |
|
580 | } | |
570 |
|
581 | |||
571 | int restart_science_tasks(unsigned char lfrRequestedMode ) |
|
582 | int restart_science_tasks(unsigned char lfrRequestedMode ) | |
572 | { |
|
583 | { | |
573 | /** This function is used to restart all science tasks. |
|
584 | /** This function is used to restart all science tasks. | |
574 | * |
|
585 | * | |
575 | * @return RTEMS directive status codes: |
|
586 | * @return RTEMS directive status codes: | |
576 | * - RTEMS_SUCCESSFUL - task restarted successfully |
|
587 | * - RTEMS_SUCCESSFUL - task restarted successfully | |
577 | * - RTEMS_INVALID_ID - task id invalid |
|
588 | * - RTEMS_INVALID_ID - task id invalid | |
578 | * - RTEMS_INCORRECT_STATE - task never started |
|
589 | * - RTEMS_INCORRECT_STATE - task never started | |
579 | * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task |
|
590 | * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task | |
580 | * |
|
591 | * | |
581 | * Science tasks are AVF0, PRC0, WFRM, CWF3, CW2, CWF1 |
|
592 | * Science tasks are AVF0, PRC0, WFRM, CWF3, CW2, CWF1 | |
582 | * |
|
593 | * | |
583 | */ |
|
594 | */ | |
584 |
|
595 | |||
585 | rtems_status_code status[10]; |
|
596 | rtems_status_code status[10]; | |
586 | rtems_status_code ret; |
|
597 | rtems_status_code ret; | |
587 |
|
598 | |||
588 | ret = RTEMS_SUCCESSFUL; |
|
599 | ret = RTEMS_SUCCESSFUL; | |
589 |
|
600 | |||
590 | status[0] = rtems_task_restart( Task_id[TASKID_AVF0], lfrRequestedMode ); |
|
601 | status[0] = rtems_task_restart( Task_id[TASKID_AVF0], lfrRequestedMode ); | |
591 | if (status[0] != RTEMS_SUCCESSFUL) |
|
602 | if (status[0] != RTEMS_SUCCESSFUL) | |
592 | { |
|
603 | { | |
593 | PRINTF1("in restart_science_task *** AVF0 ERR %d\n", status[0]) |
|
604 | PRINTF1("in restart_science_task *** AVF0 ERR %d\n", status[0]) | |
594 | } |
|
605 | } | |
595 |
|
606 | |||
596 | status[1] = rtems_task_restart( Task_id[TASKID_PRC0], lfrRequestedMode ); |
|
607 | status[1] = rtems_task_restart( Task_id[TASKID_PRC0], lfrRequestedMode ); | |
597 | if (status[1] != RTEMS_SUCCESSFUL) |
|
608 | if (status[1] != RTEMS_SUCCESSFUL) | |
598 | { |
|
609 | { | |
599 | PRINTF1("in restart_science_task *** PRC0 ERR %d\n", status[1]) |
|
610 | PRINTF1("in restart_science_task *** PRC0 ERR %d\n", status[1]) | |
600 | } |
|
611 | } | |
601 |
|
612 | |||
602 | status[2] = rtems_task_restart( Task_id[TASKID_WFRM],1 ); |
|
613 | status[2] = rtems_task_restart( Task_id[TASKID_WFRM],1 ); | |
603 | if (status[2] != RTEMS_SUCCESSFUL) |
|
614 | if (status[2] != RTEMS_SUCCESSFUL) | |
604 | { |
|
615 | { | |
605 | PRINTF1("in restart_science_task *** WFRM ERR %d\n", status[2]) |
|
616 | PRINTF1("in restart_science_task *** WFRM ERR %d\n", status[2]) | |
606 | } |
|
617 | } | |
607 |
|
618 | |||
608 | status[3] = rtems_task_restart( Task_id[TASKID_CWF3],1 ); |
|
619 | status[3] = rtems_task_restart( Task_id[TASKID_CWF3],1 ); | |
609 | if (status[3] != RTEMS_SUCCESSFUL) |
|
620 | if (status[3] != RTEMS_SUCCESSFUL) | |
610 | { |
|
621 | { | |
611 | PRINTF1("in restart_science_task *** CWF3 ERR %d\n", status[3]) |
|
622 | PRINTF1("in restart_science_task *** CWF3 ERR %d\n", status[3]) | |
612 | } |
|
623 | } | |
613 |
|
624 | |||
614 | status[4] = rtems_task_restart( Task_id[TASKID_CWF2],1 ); |
|
625 | status[4] = rtems_task_restart( Task_id[TASKID_CWF2],1 ); | |
615 | if (status[4] != RTEMS_SUCCESSFUL) |
|
626 | if (status[4] != RTEMS_SUCCESSFUL) | |
616 | { |
|
627 | { | |
617 | PRINTF1("in restart_science_task *** CWF2 ERR %d\n", status[4]) |
|
628 | PRINTF1("in restart_science_task *** CWF2 ERR %d\n", status[4]) | |
618 | } |
|
629 | } | |
619 |
|
630 | |||
620 | status[5] = rtems_task_restart( Task_id[TASKID_CWF1],1 ); |
|
631 | status[5] = rtems_task_restart( Task_id[TASKID_CWF1],1 ); | |
621 | if (status[5] != RTEMS_SUCCESSFUL) |
|
632 | if (status[5] != RTEMS_SUCCESSFUL) | |
622 | { |
|
633 | { | |
623 | PRINTF1("in restart_science_task *** CWF1 ERR %d\n", status[5]) |
|
634 | PRINTF1("in restart_science_task *** CWF1 ERR %d\n", status[5]) | |
624 | } |
|
635 | } | |
625 |
|
636 | |||
626 | status[6] = rtems_task_restart( Task_id[TASKID_AVF1], lfrRequestedMode ); |
|
637 | status[6] = rtems_task_restart( Task_id[TASKID_AVF1], lfrRequestedMode ); | |
627 | if (status[6] != RTEMS_SUCCESSFUL) |
|
638 | if (status[6] != RTEMS_SUCCESSFUL) | |
628 | { |
|
639 | { | |
629 | PRINTF1("in restart_science_task *** AVF1 ERR %d\n", status[6]) |
|
640 | PRINTF1("in restart_science_task *** AVF1 ERR %d\n", status[6]) | |
630 | } |
|
641 | } | |
631 |
|
642 | |||
632 | status[7] = rtems_task_restart( Task_id[TASKID_PRC1],lfrRequestedMode ); |
|
643 | status[7] = rtems_task_restart( Task_id[TASKID_PRC1],lfrRequestedMode ); | |
633 | if (status[7] != RTEMS_SUCCESSFUL) |
|
644 | if (status[7] != RTEMS_SUCCESSFUL) | |
634 | { |
|
645 | { | |
635 | PRINTF1("in restart_science_task *** PRC1 ERR %d\n", status[7]) |
|
646 | PRINTF1("in restart_science_task *** PRC1 ERR %d\n", status[7]) | |
636 | } |
|
647 | } | |
637 |
|
648 | |||
638 | status[8] = rtems_task_restart( Task_id[TASKID_AVF2], 1 ); |
|
649 | status[8] = rtems_task_restart( Task_id[TASKID_AVF2], 1 ); | |
639 | if (status[8] != RTEMS_SUCCESSFUL) |
|
650 | if (status[8] != RTEMS_SUCCESSFUL) | |
640 | { |
|
651 | { | |
641 | PRINTF1("in restart_science_task *** AVF2 ERR %d\n", status[8]) |
|
652 | PRINTF1("in restart_science_task *** AVF2 ERR %d\n", status[8]) | |
642 | } |
|
653 | } | |
643 |
|
654 | |||
644 | status[9] = rtems_task_restart( Task_id[TASKID_PRC2], 1 ); |
|
655 | status[9] = rtems_task_restart( Task_id[TASKID_PRC2], 1 ); | |
645 | if (status[9] != RTEMS_SUCCESSFUL) |
|
656 | if (status[9] != RTEMS_SUCCESSFUL) | |
646 | { |
|
657 | { | |
647 | PRINTF1("in restart_science_task *** PRC2 ERR %d\n", status[9]) |
|
658 | PRINTF1("in restart_science_task *** PRC2 ERR %d\n", status[9]) | |
648 | } |
|
659 | } | |
649 |
|
660 | |||
650 | if ( (status[0] != RTEMS_SUCCESSFUL) || (status[1] != RTEMS_SUCCESSFUL) || |
|
661 | if ( (status[0] != RTEMS_SUCCESSFUL) || (status[1] != RTEMS_SUCCESSFUL) || | |
651 | (status[2] != RTEMS_SUCCESSFUL) || (status[3] != RTEMS_SUCCESSFUL) || |
|
662 | (status[2] != RTEMS_SUCCESSFUL) || (status[3] != RTEMS_SUCCESSFUL) || | |
652 | (status[4] != RTEMS_SUCCESSFUL) || (status[5] != RTEMS_SUCCESSFUL) || |
|
663 | (status[4] != RTEMS_SUCCESSFUL) || (status[5] != RTEMS_SUCCESSFUL) || | |
653 | (status[6] != RTEMS_SUCCESSFUL) || (status[7] != RTEMS_SUCCESSFUL) || |
|
664 | (status[6] != RTEMS_SUCCESSFUL) || (status[7] != RTEMS_SUCCESSFUL) || | |
654 | (status[8] != RTEMS_SUCCESSFUL) || (status[9] != RTEMS_SUCCESSFUL) ) |
|
665 | (status[8] != RTEMS_SUCCESSFUL) || (status[9] != RTEMS_SUCCESSFUL) ) | |
655 | { |
|
666 | { | |
656 | ret = RTEMS_UNSATISFIED; |
|
667 | ret = RTEMS_UNSATISFIED; | |
657 | } |
|
668 | } | |
658 |
|
669 | |||
659 | return ret; |
|
670 | return ret; | |
660 | } |
|
671 | } | |
661 |
|
672 | |||
662 | int suspend_science_tasks() |
|
673 | int suspend_science_tasks() | |
663 | { |
|
674 | { | |
664 | /** This function suspends the science tasks. |
|
675 | /** This function suspends the science tasks. | |
665 | * |
|
676 | * | |
666 | * @return RTEMS directive status codes: |
|
677 | * @return RTEMS directive status codes: | |
667 | * - RTEMS_SUCCESSFUL - task restarted successfully |
|
678 | * - RTEMS_SUCCESSFUL - task restarted successfully | |
668 | * - RTEMS_INVALID_ID - task id invalid |
|
679 | * - RTEMS_INVALID_ID - task id invalid | |
669 | * - RTEMS_ALREADY_SUSPENDED - task already suspended |
|
680 | * - RTEMS_ALREADY_SUSPENDED - task already suspended | |
670 | * |
|
681 | * | |
671 | */ |
|
682 | */ | |
672 |
|
683 | |||
673 | rtems_status_code status; |
|
684 | rtems_status_code status; | |
674 |
|
685 | |||
675 | printf("in suspend_science_tasks\n"); |
|
686 | printf("in suspend_science_tasks\n"); | |
676 |
|
687 | |||
677 | status = rtems_task_suspend( Task_id[TASKID_AVF0] ); // suspend AVF0 |
|
688 | status = rtems_task_suspend( Task_id[TASKID_AVF0] ); // suspend AVF0 | |
678 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) |
|
689 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) | |
679 | { |
|
690 | { | |
680 | PRINTF1("in suspend_science_task *** AVF0 ERR %d\n", status) |
|
691 | PRINTF1("in suspend_science_task *** AVF0 ERR %d\n", status) | |
681 | } |
|
692 | } | |
682 | else |
|
693 | else | |
683 | { |
|
694 | { | |
684 | status = RTEMS_SUCCESSFUL; |
|
695 | status = RTEMS_SUCCESSFUL; | |
685 | } |
|
696 | } | |
686 | if (status == RTEMS_SUCCESSFUL) // suspend PRC0 |
|
697 | if (status == RTEMS_SUCCESSFUL) // suspend PRC0 | |
687 | { |
|
698 | { | |
688 | status = rtems_task_suspend( Task_id[TASKID_PRC0] ); |
|
699 | status = rtems_task_suspend( Task_id[TASKID_PRC0] ); | |
689 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) |
|
700 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) | |
690 | { |
|
701 | { | |
691 | PRINTF1("in suspend_science_task *** PRC0 ERR %d\n", status) |
|
702 | PRINTF1("in suspend_science_task *** PRC0 ERR %d\n", status) | |
692 | } |
|
703 | } | |
693 | else |
|
704 | else | |
694 | { |
|
705 | { | |
695 | status = RTEMS_SUCCESSFUL; |
|
706 | status = RTEMS_SUCCESSFUL; | |
696 | } |
|
707 | } | |
697 | } |
|
708 | } | |
698 | if (status == RTEMS_SUCCESSFUL) // suspend AVF1 |
|
709 | if (status == RTEMS_SUCCESSFUL) // suspend AVF1 | |
699 | { |
|
710 | { | |
700 | status = rtems_task_suspend( Task_id[TASKID_AVF1] ); |
|
711 | status = rtems_task_suspend( Task_id[TASKID_AVF1] ); | |
701 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) |
|
712 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) | |
702 | { |
|
713 | { | |
703 | PRINTF1("in suspend_science_task *** AVF1 ERR %d\n", status) |
|
714 | PRINTF1("in suspend_science_task *** AVF1 ERR %d\n", status) | |
704 | } |
|
715 | } | |
705 | else |
|
716 | else | |
706 | { |
|
717 | { | |
707 | status = RTEMS_SUCCESSFUL; |
|
718 | status = RTEMS_SUCCESSFUL; | |
708 | } |
|
719 | } | |
709 | } |
|
720 | } | |
710 | if (status == RTEMS_SUCCESSFUL) // suspend PRC1 |
|
721 | if (status == RTEMS_SUCCESSFUL) // suspend PRC1 | |
711 | { |
|
722 | { | |
712 | status = rtems_task_suspend( Task_id[TASKID_PRC1] ); |
|
723 | status = rtems_task_suspend( Task_id[TASKID_PRC1] ); | |
713 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) |
|
724 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) | |
714 | { |
|
725 | { | |
715 | PRINTF1("in suspend_science_task *** PRC1 ERR %d\n", status) |
|
726 | PRINTF1("in suspend_science_task *** PRC1 ERR %d\n", status) | |
716 | } |
|
727 | } | |
717 | else |
|
728 | else | |
718 | { |
|
729 | { | |
719 | status = RTEMS_SUCCESSFUL; |
|
730 | status = RTEMS_SUCCESSFUL; | |
720 | } |
|
731 | } | |
721 | } |
|
732 | } | |
722 | if (status == RTEMS_SUCCESSFUL) // suspend AVF2 |
|
733 | if (status == RTEMS_SUCCESSFUL) // suspend AVF2 | |
723 | { |
|
734 | { | |
724 | status = rtems_task_suspend( Task_id[TASKID_AVF2] ); |
|
735 | status = rtems_task_suspend( Task_id[TASKID_AVF2] ); | |
725 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) |
|
736 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) | |
726 | { |
|
737 | { | |
727 | PRINTF1("in suspend_science_task *** AVF2 ERR %d\n", status) |
|
738 | PRINTF1("in suspend_science_task *** AVF2 ERR %d\n", status) | |
728 | } |
|
739 | } | |
729 | else |
|
740 | else | |
730 | { |
|
741 | { | |
731 | status = RTEMS_SUCCESSFUL; |
|
742 | status = RTEMS_SUCCESSFUL; | |
732 | } |
|
743 | } | |
733 | } |
|
744 | } | |
734 | if (status == RTEMS_SUCCESSFUL) // suspend PRC2 |
|
745 | if (status == RTEMS_SUCCESSFUL) // suspend PRC2 | |
735 | { |
|
746 | { | |
736 | status = rtems_task_suspend( Task_id[TASKID_PRC2] ); |
|
747 | status = rtems_task_suspend( Task_id[TASKID_PRC2] ); | |
737 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) |
|
748 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) | |
738 | { |
|
749 | { | |
739 | PRINTF1("in suspend_science_task *** PRC2 ERR %d\n", status) |
|
750 | PRINTF1("in suspend_science_task *** PRC2 ERR %d\n", status) | |
740 | } |
|
751 | } | |
741 | else |
|
752 | else | |
742 | { |
|
753 | { | |
743 | status = RTEMS_SUCCESSFUL; |
|
754 | status = RTEMS_SUCCESSFUL; | |
744 | } |
|
755 | } | |
745 | } |
|
756 | } | |
746 | if (status == RTEMS_SUCCESSFUL) // suspend WFRM |
|
757 | if (status == RTEMS_SUCCESSFUL) // suspend WFRM | |
747 | { |
|
758 | { | |
748 | status = rtems_task_suspend( Task_id[TASKID_WFRM] ); |
|
759 | status = rtems_task_suspend( Task_id[TASKID_WFRM] ); | |
749 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) |
|
760 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) | |
750 | { |
|
761 | { | |
751 | PRINTF1("in suspend_science_task *** WFRM ERR %d\n", status) |
|
762 | PRINTF1("in suspend_science_task *** WFRM ERR %d\n", status) | |
752 | } |
|
763 | } | |
753 | else |
|
764 | else | |
754 | { |
|
765 | { | |
755 | status = RTEMS_SUCCESSFUL; |
|
766 | status = RTEMS_SUCCESSFUL; | |
756 | } |
|
767 | } | |
757 | } |
|
768 | } | |
758 | if (status == RTEMS_SUCCESSFUL) // suspend CWF3 |
|
769 | if (status == RTEMS_SUCCESSFUL) // suspend CWF3 | |
759 | { |
|
770 | { | |
760 | status = rtems_task_suspend( Task_id[TASKID_CWF3] ); |
|
771 | status = rtems_task_suspend( Task_id[TASKID_CWF3] ); | |
761 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) |
|
772 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) | |
762 | { |
|
773 | { | |
763 | PRINTF1("in suspend_science_task *** CWF3 ERR %d\n", status) |
|
774 | PRINTF1("in suspend_science_task *** CWF3 ERR %d\n", status) | |
764 | } |
|
775 | } | |
765 | else |
|
776 | else | |
766 | { |
|
777 | { | |
767 | status = RTEMS_SUCCESSFUL; |
|
778 | status = RTEMS_SUCCESSFUL; | |
768 | } |
|
779 | } | |
769 | } |
|
780 | } | |
770 | if (status == RTEMS_SUCCESSFUL) // suspend CWF2 |
|
781 | if (status == RTEMS_SUCCESSFUL) // suspend CWF2 | |
771 | { |
|
782 | { | |
772 | status = rtems_task_suspend( Task_id[TASKID_CWF2] ); |
|
783 | status = rtems_task_suspend( Task_id[TASKID_CWF2] ); | |
773 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) |
|
784 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) | |
774 | { |
|
785 | { | |
775 | PRINTF1("in suspend_science_task *** CWF2 ERR %d\n", status) |
|
786 | PRINTF1("in suspend_science_task *** CWF2 ERR %d\n", status) | |
776 | } |
|
787 | } | |
777 | else |
|
788 | else | |
778 | { |
|
789 | { | |
779 | status = RTEMS_SUCCESSFUL; |
|
790 | status = RTEMS_SUCCESSFUL; | |
780 | } |
|
791 | } | |
781 | } |
|
792 | } | |
782 | if (status == RTEMS_SUCCESSFUL) // suspend CWF1 |
|
793 | if (status == RTEMS_SUCCESSFUL) // suspend CWF1 | |
783 | { |
|
794 | { | |
784 | status = rtems_task_suspend( Task_id[TASKID_CWF1] ); |
|
795 | status = rtems_task_suspend( Task_id[TASKID_CWF1] ); | |
785 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) |
|
796 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) | |
786 | { |
|
797 | { | |
787 | PRINTF1("in suspend_science_task *** CWF1 ERR %d\n", status) |
|
798 | PRINTF1("in suspend_science_task *** CWF1 ERR %d\n", status) | |
788 | } |
|
799 | } | |
789 | else |
|
800 | else | |
790 | { |
|
801 | { | |
791 | status = RTEMS_SUCCESSFUL; |
|
802 | status = RTEMS_SUCCESSFUL; | |
792 | } |
|
803 | } | |
793 | } |
|
804 | } | |
794 |
|
805 | |||
795 | return status; |
|
806 | return status; | |
796 | } |
|
807 | } | |
797 |
|
808 | |||
798 | void launch_waveform_picker( unsigned char mode, unsigned int transitionCoarseTime ) |
|
809 | void launch_waveform_picker( unsigned char mode, unsigned int transitionCoarseTime ) | |
799 | { |
|
810 | { | |
800 | WFP_reset_current_ring_nodes(); |
|
811 | WFP_reset_current_ring_nodes(); | |
801 |
|
812 | |||
802 | reset_waveform_picker_regs(); |
|
813 | reset_waveform_picker_regs(); | |
803 |
|
814 | |||
804 | set_wfp_burst_enable_register( mode ); |
|
815 | set_wfp_burst_enable_register( mode ); | |
805 |
|
816 | |||
806 | LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER ); |
|
817 | LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER ); | |
807 | LEON_Unmask_interrupt( IRQ_WAVEFORM_PICKER ); |
|
818 | LEON_Unmask_interrupt( IRQ_WAVEFORM_PICKER ); | |
808 |
|
819 | |||
809 | if (transitionCoarseTime == 0) |
|
820 | if (transitionCoarseTime == 0) | |
810 | { |
|
821 | { | |
811 | waveform_picker_regs->start_date = time_management_regs->coarse_time; |
|
822 | waveform_picker_regs->start_date = time_management_regs->coarse_time; | |
812 | } |
|
823 | } | |
813 | else |
|
824 | else | |
814 | { |
|
825 | { | |
815 | waveform_picker_regs->start_date = transitionCoarseTime; |
|
826 | waveform_picker_regs->start_date = transitionCoarseTime; | |
816 | } |
|
827 | } | |
817 |
|
828 | |||
818 | } |
|
829 | } | |
819 |
|
830 | |||
820 | void launch_spectral_matrix( void ) |
|
831 | void launch_spectral_matrix( void ) | |
821 | { |
|
832 | { | |
822 | SM_reset_current_ring_nodes(); |
|
833 | SM_reset_current_ring_nodes(); | |
823 |
|
834 | |||
824 | reset_spectral_matrix_regs(); |
|
835 | reset_spectral_matrix_regs(); | |
825 |
|
836 | |||
826 | reset_nb_sm(); |
|
837 | reset_nb_sm(); | |
827 |
|
838 | |||
828 | set_sm_irq_onNewMatrix( 1 ); |
|
839 | set_sm_irq_onNewMatrix( 1 ); | |
829 |
|
840 | |||
830 | LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX ); |
|
841 | LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX ); | |
831 | LEON_Unmask_interrupt( IRQ_SPECTRAL_MATRIX ); |
|
842 | LEON_Unmask_interrupt( IRQ_SPECTRAL_MATRIX ); | |
832 |
|
843 | |||
833 | } |
|
844 | } | |
834 |
|
845 | |||
835 | void launch_spectral_matrix_simu( void ) |
|
846 | void launch_spectral_matrix_simu( void ) | |
836 | { |
|
847 | { | |
837 | SM_reset_current_ring_nodes(); |
|
848 | SM_reset_current_ring_nodes(); | |
838 | reset_spectral_matrix_regs(); |
|
849 | reset_spectral_matrix_regs(); | |
839 | reset_nb_sm(); |
|
850 | reset_nb_sm(); | |
840 |
|
851 | |||
841 | // Spectral Matrices simulator |
|
852 | // Spectral Matrices simulator | |
842 | timer_start( (gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR ); |
|
853 | timer_start( (gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR ); | |
843 | LEON_Clear_interrupt( IRQ_SM_SIMULATOR ); |
|
854 | LEON_Clear_interrupt( IRQ_SM_SIMULATOR ); | |
844 | LEON_Unmask_interrupt( IRQ_SM_SIMULATOR ); |
|
855 | LEON_Unmask_interrupt( IRQ_SM_SIMULATOR ); | |
845 | } |
|
856 | } | |
846 |
|
857 | |||
847 | void set_sm_irq_onNewMatrix( unsigned char value ) |
|
858 | void set_sm_irq_onNewMatrix( unsigned char value ) | |
848 | { |
|
859 | { | |
849 | if (value == 1) |
|
860 | if (value == 1) | |
850 | { |
|
861 | { | |
851 | spectral_matrix_regs->config = spectral_matrix_regs->config | 0x01; |
|
862 | spectral_matrix_regs->config = spectral_matrix_regs->config | 0x01; | |
852 | } |
|
863 | } | |
853 | else |
|
864 | else | |
854 | { |
|
865 | { | |
855 | spectral_matrix_regs->config = spectral_matrix_regs->config & 0xfffffffe; // 1110 |
|
866 | spectral_matrix_regs->config = spectral_matrix_regs->config & 0xfffffffe; // 1110 | |
856 | } |
|
867 | } | |
857 | } |
|
868 | } | |
858 |
|
869 | |||
859 | void set_sm_irq_onError( unsigned char value ) |
|
870 | void set_sm_irq_onError( unsigned char value ) | |
860 | { |
|
871 | { | |
861 | if (value == 1) |
|
872 | if (value == 1) | |
862 | { |
|
873 | { | |
863 | spectral_matrix_regs->config = spectral_matrix_regs->config | 0x02; |
|
874 | spectral_matrix_regs->config = spectral_matrix_regs->config | 0x02; | |
864 | } |
|
875 | } | |
865 | else |
|
876 | else | |
866 | { |
|
877 | { | |
867 | spectral_matrix_regs->config = spectral_matrix_regs->config & 0xfffffffd; // 1101 |
|
878 | spectral_matrix_regs->config = spectral_matrix_regs->config & 0xfffffffd; // 1101 | |
868 | } |
|
879 | } | |
869 | } |
|
880 | } | |
870 |
|
881 | |||
871 | //***************************** |
|
882 | //***************************** | |
872 | // CONFIGURE CALIBRATION SIGNAL |
|
883 | // CONFIGURE CALIBRATION SIGNAL | |
873 | void setCalibrationPrescaler( unsigned int prescaler ) |
|
884 | void setCalibrationPrescaler( unsigned int prescaler ) | |
874 | { |
|
885 | { | |
875 | // prescaling of the master clock (25 MHz) |
|
886 | // prescaling of the master clock (25 MHz) | |
876 | // master clock is divided by 2^prescaler |
|
887 | // master clock is divided by 2^prescaler | |
877 | time_management_regs->calPrescaler = prescaler; |
|
888 | time_management_regs->calPrescaler = prescaler; | |
878 | } |
|
889 | } | |
879 |
|
890 | |||
880 | void setCalibrationDivisor( unsigned int divisionFactor ) |
|
891 | void setCalibrationDivisor( unsigned int divisionFactor ) | |
881 | { |
|
892 | { | |
882 | // division of the prescaled clock by the division factor |
|
893 | // division of the prescaled clock by the division factor | |
883 | time_management_regs->calDivisor = divisionFactor; |
|
894 | time_management_regs->calDivisor = divisionFactor; | |
884 | } |
|
895 | } | |
885 |
|
896 | |||
886 | void setCalibrationData( void ){ |
|
897 | void setCalibrationData( void ){ | |
887 | unsigned int k; |
|
898 | unsigned int k; | |
888 | unsigned short data; |
|
899 | unsigned short data; | |
889 | float val; |
|
900 | float val; | |
890 | float f0; |
|
901 | float f0; | |
891 | float f1; |
|
902 | float f1; | |
892 | float fs; |
|
903 | float fs; | |
893 | float Ts; |
|
904 | float Ts; | |
894 | float scaleFactor; |
|
905 | float scaleFactor; | |
895 |
|
906 | |||
896 | f0 = 625; |
|
907 | f0 = 625; | |
897 | f1 = 10000; |
|
908 | f1 = 10000; | |
898 | fs = 160256.410; |
|
909 | fs = 160256.410; | |
899 | Ts = 1. / fs; |
|
910 | Ts = 1. / fs; | |
900 | scaleFactor = 0.250 / 0.000654; // 191, 500 mVpp, 2 sinus waves => 500 mVpp each, amplitude = 250 mV |
|
911 | scaleFactor = 0.250 / 0.000654; // 191, 500 mVpp, 2 sinus waves => 500 mVpp each, amplitude = 250 mV | |
901 |
|
912 | |||
902 | time_management_regs->calDataPtr = 0x00; |
|
913 | time_management_regs->calDataPtr = 0x00; | |
903 |
|
914 | |||
904 | // build the signal for the SCM calibration |
|
915 | // build the signal for the SCM calibration | |
905 | for (k=0; k<256; k++) |
|
916 | for (k=0; k<256; k++) | |
906 | { |
|
917 | { | |
907 | val = sin( 2 * pi * f0 * k * Ts ) |
|
918 | val = sin( 2 * pi * f0 * k * Ts ) | |
908 | + sin( 2 * pi * f1 * k * Ts ); |
|
919 | + sin( 2 * pi * f1 * k * Ts ); | |
909 | data = (unsigned short) ((val * scaleFactor) + 2048); |
|
920 | data = (unsigned short) ((val * scaleFactor) + 2048); | |
910 | time_management_regs->calData = data & 0xfff; |
|
921 | time_management_regs->calData = data & 0xfff; | |
911 | } |
|
922 | } | |
912 | } |
|
923 | } | |
913 |
|
924 | |||
914 | void setCalibrationDataInterleaved( void ){ |
|
925 | void setCalibrationDataInterleaved( void ){ | |
915 | unsigned int k; |
|
926 | unsigned int k; | |
916 | float val; |
|
927 | float val; | |
917 | float f0; |
|
928 | float f0; | |
918 | float f1; |
|
929 | float f1; | |
919 | float fs; |
|
930 | float fs; | |
920 | float Ts; |
|
931 | float Ts; | |
921 | unsigned short data[384]; |
|
932 | unsigned short data[384]; | |
922 | unsigned char *dataPtr; |
|
933 | unsigned char *dataPtr; | |
923 |
|
934 | |||
924 | f0 = 625; |
|
935 | f0 = 625; | |
925 | f1 = 10000; |
|
936 | f1 = 10000; | |
926 | fs = 240384.615; |
|
937 | fs = 240384.615; | |
927 | Ts = 1. / fs; |
|
938 | Ts = 1. / fs; | |
928 |
|
939 | |||
929 | time_management_regs->calDataPtr = 0x00; |
|
940 | time_management_regs->calDataPtr = 0x00; | |
930 |
|
941 | |||
931 | // build the signal for the SCM calibration |
|
942 | // build the signal for the SCM calibration | |
932 | for (k=0; k<384; k++) |
|
943 | for (k=0; k<384; k++) | |
933 | { |
|
944 | { | |
934 | val = sin( 2 * pi * f0 * k * Ts ) |
|
945 | val = sin( 2 * pi * f0 * k * Ts ) | |
935 | + sin( 2 * pi * f1 * k * Ts ); |
|
946 | + sin( 2 * pi * f1 * k * Ts ); | |
936 | data[k] = (unsigned short) (val * 512 + 2048); |
|
947 | data[k] = (unsigned short) (val * 512 + 2048); | |
937 | } |
|
948 | } | |
938 |
|
949 | |||
939 | // write the signal in interleaved mode |
|
950 | // write the signal in interleaved mode | |
940 | for (k=0; k<128; k++) |
|
951 | for (k=0; k<128; k++) | |
941 | { |
|
952 | { | |
942 | dataPtr = (unsigned char*) &data[k*3 + 2]; |
|
953 | dataPtr = (unsigned char*) &data[k*3 + 2]; | |
943 | time_management_regs->calData = (data[k*3] & 0xfff) |
|
954 | time_management_regs->calData = (data[k*3] & 0xfff) | |
944 | + ( (dataPtr[0] & 0x3f) << 12); |
|
955 | + ( (dataPtr[0] & 0x3f) << 12); | |
945 | time_management_regs->calData = (data[k*3 + 1] & 0xfff) |
|
956 | time_management_regs->calData = (data[k*3 + 1] & 0xfff) | |
946 | + ( (dataPtr[1] & 0x3f) << 12); |
|
957 | + ( (dataPtr[1] & 0x3f) << 12); | |
947 | } |
|
958 | } | |
948 | } |
|
959 | } | |
949 |
|
960 | |||
950 | void setCalibrationReload( bool state) |
|
961 | void setCalibrationReload( bool state) | |
951 | { |
|
962 | { | |
952 | if (state == true) |
|
963 | if (state == true) | |
953 | { |
|
964 | { | |
954 | time_management_regs->calDACCtrl = time_management_regs->calDACCtrl | 0x00000010; // [0001 0000] |
|
965 | time_management_regs->calDACCtrl = time_management_regs->calDACCtrl | 0x00000010; // [0001 0000] | |
955 | } |
|
966 | } | |
956 | else |
|
967 | else | |
957 | { |
|
968 | { | |
958 | time_management_regs->calDACCtrl = time_management_regs->calDACCtrl & 0xffffffef; // [1110 1111] |
|
969 | time_management_regs->calDACCtrl = time_management_regs->calDACCtrl & 0xffffffef; // [1110 1111] | |
959 | } |
|
970 | } | |
960 | } |
|
971 | } | |
961 |
|
972 | |||
962 | void setCalibrationEnable( bool state ) |
|
973 | void setCalibrationEnable( bool state ) | |
963 | { |
|
974 | { | |
964 | // this bit drives the multiplexer |
|
975 | // this bit drives the multiplexer | |
965 | if (state == true) |
|
976 | if (state == true) | |
966 | { |
|
977 | { | |
967 | time_management_regs->calDACCtrl = time_management_regs->calDACCtrl | 0x00000040; // [0100 0000] |
|
978 | time_management_regs->calDACCtrl = time_management_regs->calDACCtrl | 0x00000040; // [0100 0000] | |
968 | } |
|
979 | } | |
969 | else |
|
980 | else | |
970 | { |
|
981 | { | |
971 | time_management_regs->calDACCtrl = time_management_regs->calDACCtrl & 0xffffffbf; // [1011 1111] |
|
982 | time_management_regs->calDACCtrl = time_management_regs->calDACCtrl & 0xffffffbf; // [1011 1111] | |
972 | } |
|
983 | } | |
973 | } |
|
984 | } | |
974 |
|
985 | |||
975 | void setCalibrationInterleaved( bool state ) |
|
986 | void setCalibrationInterleaved( bool state ) | |
976 | { |
|
987 | { | |
977 | // this bit drives the multiplexer |
|
988 | // this bit drives the multiplexer | |
978 | if (state == true) |
|
989 | if (state == true) | |
979 | { |
|
990 | { | |
980 | time_management_regs->calDACCtrl = time_management_regs->calDACCtrl | 0x00000020; // [0010 0000] |
|
991 | time_management_regs->calDACCtrl = time_management_regs->calDACCtrl | 0x00000020; // [0010 0000] | |
981 | } |
|
992 | } | |
982 | else |
|
993 | else | |
983 | { |
|
994 | { | |
984 | time_management_regs->calDACCtrl = time_management_regs->calDACCtrl & 0xffffffdf; // [1101 1111] |
|
995 | time_management_regs->calDACCtrl = time_management_regs->calDACCtrl & 0xffffffdf; // [1101 1111] | |
985 | } |
|
996 | } | |
986 | } |
|
997 | } | |
987 |
|
998 | |||
988 | void setCalibration( bool state ) |
|
999 | void setCalibration( bool state ) | |
989 | { |
|
1000 | { | |
990 | if (state == true) |
|
1001 | if (state == true) | |
991 | { |
|
1002 | { | |
992 | setCalibrationEnable( true ); |
|
1003 | setCalibrationEnable( true ); | |
993 | setCalibrationReload( false ); |
|
1004 | setCalibrationReload( false ); | |
994 | set_hk_lfr_calib_enable( true ); |
|
1005 | set_hk_lfr_calib_enable( true ); | |
995 | } |
|
1006 | } | |
996 | else |
|
1007 | else | |
997 | { |
|
1008 | { | |
998 | setCalibrationEnable( false ); |
|
1009 | setCalibrationEnable( false ); | |
999 | setCalibrationReload( true ); |
|
1010 | setCalibrationReload( true ); | |
1000 | set_hk_lfr_calib_enable( false ); |
|
1011 | set_hk_lfr_calib_enable( false ); | |
1001 | } |
|
1012 | } | |
1002 | } |
|
1013 | } | |
1003 |
|
1014 | |||
1004 | void configureCalibration( bool interleaved ) |
|
1015 | void configureCalibration( bool interleaved ) | |
1005 | { |
|
1016 | { | |
1006 | setCalibration( false ); |
|
1017 | setCalibration( false ); | |
1007 | if ( interleaved == true ) |
|
1018 | if ( interleaved == true ) | |
1008 | { |
|
1019 | { | |
1009 | setCalibrationInterleaved( true ); |
|
1020 | setCalibrationInterleaved( true ); | |
1010 | setCalibrationPrescaler( 0 ); // 25 MHz => 25 000 000 |
|
1021 | setCalibrationPrescaler( 0 ); // 25 MHz => 25 000 000 | |
1011 | setCalibrationDivisor( 26 ); // => 240 384 |
|
1022 | setCalibrationDivisor( 26 ); // => 240 384 | |
1012 | setCalibrationDataInterleaved(); |
|
1023 | setCalibrationDataInterleaved(); | |
1013 | } |
|
1024 | } | |
1014 | else |
|
1025 | else | |
1015 | { |
|
1026 | { | |
1016 | setCalibrationPrescaler( 0 ); // 25 MHz => 25 000 000 |
|
1027 | setCalibrationPrescaler( 0 ); // 25 MHz => 25 000 000 | |
1017 | setCalibrationDivisor( 38 ); // => 160 256 (39 - 1) |
|
1028 | setCalibrationDivisor( 38 ); // => 160 256 (39 - 1) | |
1018 | setCalibrationData(); |
|
1029 | setCalibrationData(); | |
1019 | } |
|
1030 | } | |
1020 | } |
|
1031 | } | |
1021 |
|
1032 | |||
1022 | //**************** |
|
1033 | //**************** | |
1023 | // CLOSING ACTIONS |
|
1034 | // CLOSING ACTIONS | |
1024 | void update_last_TC_exe( ccsdsTelecommandPacket_t *TC, unsigned char * time ) |
|
1035 | void update_last_TC_exe( ccsdsTelecommandPacket_t *TC, unsigned char * time ) | |
1025 | { |
|
1036 | { | |
1026 | /** This function is used to update the HK packets statistics after a successful TC execution. |
|
1037 | /** This function is used to update the HK packets statistics after a successful TC execution. | |
1027 | * |
|
1038 | * | |
1028 | * @param TC points to the TC being processed |
|
1039 | * @param TC points to the TC being processed | |
1029 | * @param time is the time used to date the TC execution |
|
1040 | * @param time is the time used to date the TC execution | |
1030 | * |
|
1041 | * | |
1031 | */ |
|
1042 | */ | |
1032 |
|
1043 | |||
1033 | unsigned int val; |
|
1044 | unsigned int val; | |
1034 |
|
1045 | |||
1035 | housekeeping_packet.hk_lfr_last_exe_tc_id[0] = TC->packetID[0]; |
|
1046 | housekeeping_packet.hk_lfr_last_exe_tc_id[0] = TC->packetID[0]; | |
1036 | housekeeping_packet.hk_lfr_last_exe_tc_id[1] = TC->packetID[1]; |
|
1047 | housekeeping_packet.hk_lfr_last_exe_tc_id[1] = TC->packetID[1]; | |
1037 | housekeeping_packet.hk_lfr_last_exe_tc_type[0] = 0x00; |
|
1048 | housekeeping_packet.hk_lfr_last_exe_tc_type[0] = 0x00; | |
1038 | housekeeping_packet.hk_lfr_last_exe_tc_type[1] = TC->serviceType; |
|
1049 | housekeeping_packet.hk_lfr_last_exe_tc_type[1] = TC->serviceType; | |
1039 | housekeeping_packet.hk_lfr_last_exe_tc_subtype[0] = 0x00; |
|
1050 | housekeeping_packet.hk_lfr_last_exe_tc_subtype[0] = 0x00; | |
1040 | housekeeping_packet.hk_lfr_last_exe_tc_subtype[1] = TC->serviceSubType; |
|
1051 | housekeeping_packet.hk_lfr_last_exe_tc_subtype[1] = TC->serviceSubType; | |
1041 | housekeeping_packet.hk_lfr_last_exe_tc_time[0] = time[0]; |
|
1052 | housekeeping_packet.hk_lfr_last_exe_tc_time[0] = time[0]; | |
1042 | housekeeping_packet.hk_lfr_last_exe_tc_time[1] = time[1]; |
|
1053 | housekeeping_packet.hk_lfr_last_exe_tc_time[1] = time[1]; | |
1043 | housekeeping_packet.hk_lfr_last_exe_tc_time[2] = time[2]; |
|
1054 | housekeeping_packet.hk_lfr_last_exe_tc_time[2] = time[2]; | |
1044 | housekeeping_packet.hk_lfr_last_exe_tc_time[3] = time[3]; |
|
1055 | housekeeping_packet.hk_lfr_last_exe_tc_time[3] = time[3]; | |
1045 | housekeeping_packet.hk_lfr_last_exe_tc_time[4] = time[4]; |
|
1056 | housekeeping_packet.hk_lfr_last_exe_tc_time[4] = time[4]; | |
1046 | housekeeping_packet.hk_lfr_last_exe_tc_time[5] = time[5]; |
|
1057 | housekeeping_packet.hk_lfr_last_exe_tc_time[5] = time[5]; | |
1047 |
|
1058 | |||
1048 | val = housekeeping_packet.hk_lfr_exe_tc_cnt[0] * 256 + housekeeping_packet.hk_lfr_exe_tc_cnt[1]; |
|
1059 | val = housekeeping_packet.hk_lfr_exe_tc_cnt[0] * 256 + housekeeping_packet.hk_lfr_exe_tc_cnt[1]; | |
1049 | val++; |
|
1060 | val++; | |
1050 | housekeeping_packet.hk_lfr_exe_tc_cnt[0] = (unsigned char) (val >> 8); |
|
1061 | housekeeping_packet.hk_lfr_exe_tc_cnt[0] = (unsigned char) (val >> 8); | |
1051 | housekeeping_packet.hk_lfr_exe_tc_cnt[1] = (unsigned char) (val); |
|
1062 | housekeeping_packet.hk_lfr_exe_tc_cnt[1] = (unsigned char) (val); | |
1052 | } |
|
1063 | } | |
1053 |
|
1064 | |||
1054 | void update_last_TC_rej(ccsdsTelecommandPacket_t *TC, unsigned char * time ) |
|
1065 | void update_last_TC_rej(ccsdsTelecommandPacket_t *TC, unsigned char * time ) | |
1055 | { |
|
1066 | { | |
1056 | /** This function is used to update the HK packets statistics after a TC rejection. |
|
1067 | /** This function is used to update the HK packets statistics after a TC rejection. | |
1057 | * |
|
1068 | * | |
1058 | * @param TC points to the TC being processed |
|
1069 | * @param TC points to the TC being processed | |
1059 | * @param time is the time used to date the TC rejection |
|
1070 | * @param time is the time used to date the TC rejection | |
1060 | * |
|
1071 | * | |
1061 | */ |
|
1072 | */ | |
1062 |
|
1073 | |||
1063 | unsigned int val; |
|
1074 | unsigned int val; | |
1064 |
|
1075 | |||
1065 | housekeeping_packet.hk_lfr_last_rej_tc_id[0] = TC->packetID[0]; |
|
1076 | housekeeping_packet.hk_lfr_last_rej_tc_id[0] = TC->packetID[0]; | |
1066 | housekeeping_packet.hk_lfr_last_rej_tc_id[1] = TC->packetID[1]; |
|
1077 | housekeeping_packet.hk_lfr_last_rej_tc_id[1] = TC->packetID[1]; | |
1067 | housekeeping_packet.hk_lfr_last_rej_tc_type[0] = 0x00; |
|
1078 | housekeeping_packet.hk_lfr_last_rej_tc_type[0] = 0x00; | |
1068 | housekeeping_packet.hk_lfr_last_rej_tc_type[1] = TC->serviceType; |
|
1079 | housekeeping_packet.hk_lfr_last_rej_tc_type[1] = TC->serviceType; | |
1069 | housekeeping_packet.hk_lfr_last_rej_tc_subtype[0] = 0x00; |
|
1080 | housekeeping_packet.hk_lfr_last_rej_tc_subtype[0] = 0x00; | |
1070 | housekeeping_packet.hk_lfr_last_rej_tc_subtype[1] = TC->serviceSubType; |
|
1081 | housekeeping_packet.hk_lfr_last_rej_tc_subtype[1] = TC->serviceSubType; | |
1071 | housekeeping_packet.hk_lfr_last_rej_tc_time[0] = time[0]; |
|
1082 | housekeeping_packet.hk_lfr_last_rej_tc_time[0] = time[0]; | |
1072 | housekeeping_packet.hk_lfr_last_rej_tc_time[1] = time[1]; |
|
1083 | housekeeping_packet.hk_lfr_last_rej_tc_time[1] = time[1]; | |
1073 | housekeeping_packet.hk_lfr_last_rej_tc_time[2] = time[2]; |
|
1084 | housekeeping_packet.hk_lfr_last_rej_tc_time[2] = time[2]; | |
1074 | housekeeping_packet.hk_lfr_last_rej_tc_time[3] = time[3]; |
|
1085 | housekeeping_packet.hk_lfr_last_rej_tc_time[3] = time[3]; | |
1075 | housekeeping_packet.hk_lfr_last_rej_tc_time[4] = time[4]; |
|
1086 | housekeeping_packet.hk_lfr_last_rej_tc_time[4] = time[4]; | |
1076 | housekeeping_packet.hk_lfr_last_rej_tc_time[5] = time[5]; |
|
1087 | housekeeping_packet.hk_lfr_last_rej_tc_time[5] = time[5]; | |
1077 |
|
1088 | |||
1078 | val = housekeeping_packet.hk_lfr_rej_tc_cnt[0] * 256 + housekeeping_packet.hk_lfr_rej_tc_cnt[1]; |
|
1089 | val = housekeeping_packet.hk_lfr_rej_tc_cnt[0] * 256 + housekeeping_packet.hk_lfr_rej_tc_cnt[1]; | |
1079 | val++; |
|
1090 | val++; | |
1080 | housekeeping_packet.hk_lfr_rej_tc_cnt[0] = (unsigned char) (val >> 8); |
|
1091 | housekeeping_packet.hk_lfr_rej_tc_cnt[0] = (unsigned char) (val >> 8); | |
1081 | housekeeping_packet.hk_lfr_rej_tc_cnt[1] = (unsigned char) (val); |
|
1092 | housekeeping_packet.hk_lfr_rej_tc_cnt[1] = (unsigned char) (val); | |
1082 | } |
|
1093 | } | |
1083 |
|
1094 | |||
1084 | void close_action(ccsdsTelecommandPacket_t *TC, int result, rtems_id queue_id ) |
|
1095 | void close_action(ccsdsTelecommandPacket_t *TC, int result, rtems_id queue_id ) | |
1085 | { |
|
1096 | { | |
1086 | /** This function is the last step of the TC execution workflow. |
|
1097 | /** This function is the last step of the TC execution workflow. | |
1087 | * |
|
1098 | * | |
1088 | * @param TC points to the TC being processed |
|
1099 | * @param TC points to the TC being processed | |
1089 | * @param result is the result of the TC execution (LFR_SUCCESSFUL / LFR_DEFAULT) |
|
1100 | * @param result is the result of the TC execution (LFR_SUCCESSFUL / LFR_DEFAULT) | |
1090 | * @param queue_id is the id of the RTEMS message queue used to send TM packets |
|
1101 | * @param queue_id is the id of the RTEMS message queue used to send TM packets | |
1091 | * @param time is the time used to date the TC execution |
|
1102 | * @param time is the time used to date the TC execution | |
1092 | * |
|
1103 | * | |
1093 | */ |
|
1104 | */ | |
1094 |
|
1105 | |||
1095 | unsigned char requestedMode; |
|
1106 | unsigned char requestedMode; | |
1096 |
|
1107 | |||
1097 | if (result == LFR_SUCCESSFUL) |
|
1108 | if (result == LFR_SUCCESSFUL) | |
1098 | { |
|
1109 | { | |
1099 | if ( !( (TC->serviceType==TC_TYPE_TIME) & (TC->serviceSubType==TC_SUBTYPE_UPDT_TIME) ) |
|
1110 | if ( !( (TC->serviceType==TC_TYPE_TIME) & (TC->serviceSubType==TC_SUBTYPE_UPDT_TIME) ) | |
1100 | & |
|
1111 | & | |
1101 | !( (TC->serviceType==TC_TYPE_GEN) & (TC->serviceSubType==TC_SUBTYPE_UPDT_INFO)) |
|
1112 | !( (TC->serviceType==TC_TYPE_GEN) & (TC->serviceSubType==TC_SUBTYPE_UPDT_INFO)) | |
1102 | ) |
|
1113 | ) | |
1103 | { |
|
1114 | { | |
1104 | send_tm_lfr_tc_exe_success( TC, queue_id ); |
|
1115 | send_tm_lfr_tc_exe_success( TC, queue_id ); | |
1105 | } |
|
1116 | } | |
1106 | if ( (TC->serviceType == TC_TYPE_GEN) & (TC->serviceSubType == TC_SUBTYPE_ENTER) ) |
|
1117 | if ( (TC->serviceType == TC_TYPE_GEN) & (TC->serviceSubType == TC_SUBTYPE_ENTER) ) | |
1107 | { |
|
1118 | { | |
1108 | //********************************** |
|
1119 | //********************************** | |
1109 | // UPDATE THE LFRMODE LOCAL VARIABLE |
|
1120 | // UPDATE THE LFRMODE LOCAL VARIABLE | |
1110 | requestedMode = TC->dataAndCRC[1]; |
|
1121 | requestedMode = TC->dataAndCRC[1]; | |
1111 | housekeeping_packet.lfr_status_word[0] = (unsigned char) ((requestedMode << 4) + 0x0d); |
|
1122 | housekeeping_packet.lfr_status_word[0] = (unsigned char) ((requestedMode << 4) + 0x0d); | |
1112 | updateLFRCurrentMode(); |
|
1123 | updateLFRCurrentMode(); | |
1113 | } |
|
1124 | } | |
1114 | } |
|
1125 | } | |
1115 | else if (result == LFR_EXE_ERROR) |
|
1126 | else if (result == LFR_EXE_ERROR) | |
1116 | { |
|
1127 | { | |
1117 | send_tm_lfr_tc_exe_error( TC, queue_id ); |
|
1128 | send_tm_lfr_tc_exe_error( TC, queue_id ); | |
1118 | } |
|
1129 | } | |
1119 | } |
|
1130 | } | |
1120 |
|
1131 | |||
1121 | //*************************** |
|
1132 | //*************************** | |
1122 | // Interrupt Service Routines |
|
1133 | // Interrupt Service Routines | |
1123 | rtems_isr commutation_isr1( rtems_vector_number vector ) |
|
1134 | rtems_isr commutation_isr1( rtems_vector_number vector ) | |
1124 | { |
|
1135 | { | |
1125 | if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) { |
|
1136 | if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) { | |
1126 | printf("In commutation_isr1 *** Error sending event to DUMB\n"); |
|
1137 | printf("In commutation_isr1 *** Error sending event to DUMB\n"); | |
1127 | } |
|
1138 | } | |
1128 | } |
|
1139 | } | |
1129 |
|
1140 | |||
1130 | rtems_isr commutation_isr2( rtems_vector_number vector ) |
|
1141 | rtems_isr commutation_isr2( rtems_vector_number vector ) | |
1131 | { |
|
1142 | { | |
1132 | if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) { |
|
1143 | if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) { | |
1133 | printf("In commutation_isr2 *** Error sending event to DUMB\n"); |
|
1144 | printf("In commutation_isr2 *** Error sending event to DUMB\n"); | |
1134 | } |
|
1145 | } | |
1135 | } |
|
1146 | } | |
1136 |
|
1147 | |||
1137 | //**************** |
|
1148 | //**************** | |
1138 | // OTHER FUNCTIONS |
|
1149 | // OTHER FUNCTIONS | |
1139 | void updateLFRCurrentMode() |
|
1150 | void updateLFRCurrentMode() | |
1140 | { |
|
1151 | { | |
1141 | /** This function updates the value of the global variable lfrCurrentMode. |
|
1152 | /** This function updates the value of the global variable lfrCurrentMode. | |
1142 | * |
|
1153 | * | |
1143 | * lfrCurrentMode is a parameter used by several functions to know in which mode LFR is running. |
|
1154 | * lfrCurrentMode is a parameter used by several functions to know in which mode LFR is running. | |
1144 | * |
|
1155 | * | |
1145 | */ |
|
1156 | */ | |
1146 | // update the local value of lfrCurrentMode with the value contained in the housekeeping_packet structure |
|
1157 | // update the local value of lfrCurrentMode with the value contained in the housekeeping_packet structure | |
1147 | lfrCurrentMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4; |
|
1158 | lfrCurrentMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4; | |
1148 | } |
|
1159 | } | |
1149 |
|
1160 | |||
1150 | void set_lfr_soft_reset( unsigned char value ) |
|
1161 | void set_lfr_soft_reset( unsigned char value ) | |
1151 | { |
|
1162 | { | |
1152 | if (value == 1) |
|
1163 | if (value == 1) | |
1153 | { |
|
1164 | { | |
1154 | time_management_regs->ctrl = time_management_regs->ctrl | 0x00000004; // [0100] |
|
1165 | time_management_regs->ctrl = time_management_regs->ctrl | 0x00000004; // [0100] | |
1155 | } |
|
1166 | } | |
1156 | else |
|
1167 | else | |
1157 | { |
|
1168 | { | |
1158 | time_management_regs->ctrl = time_management_regs->ctrl & 0xfffffffb; // [1011] |
|
1169 | time_management_regs->ctrl = time_management_regs->ctrl & 0xfffffffb; // [1011] | |
1159 | } |
|
1170 | } | |
1160 | } |
|
1171 | } | |
1161 |
|
1172 | |||
1162 | void reset_lfr( void ) |
|
1173 | void reset_lfr( void ) | |
1163 | { |
|
1174 | { | |
1164 | set_lfr_soft_reset( 1 ); |
|
1175 | set_lfr_soft_reset( 1 ); | |
1165 |
|
1176 | |||
1166 | set_lfr_soft_reset( 0 ); |
|
1177 | set_lfr_soft_reset( 0 ); | |
1167 |
|
1178 | |||
1168 | set_hk_lfr_sc_potential_flag( true ); |
|
1179 | set_hk_lfr_sc_potential_flag( true ); | |
1169 | } |
|
1180 | } |
General Comments 0
You need to be logged in to leave comments.
Login now