@@ -1,2 +1,2 | |||||
1 | 3081d1f9bb20b2b64a192585337a292a9804e0c5 LFR_basic-parameters |
|
1 | 3081d1f9bb20b2b64a192585337a292a9804e0c5 LFR_basic-parameters | |
2 | a0ca246cc2057880086d028aab3cf35be244efbc header/lfr_common_headers |
|
2 | 6a30b7a924d9c3824f432332ed79bcee25954455 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 cpu_usage_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,1296 +1,1312 | |||||
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 | unsigned char sidAsUnsignedChar; | |||
219 |
|
220 | |||
220 | incomingRingNodePtr = NULL; |
|
221 | incomingRingNodePtr = NULL; | |
221 | ring_node_address = 0; |
|
222 | ring_node_address = 0; | |
222 | charPtr = (char *) &ring_node_address; |
|
223 | charPtr = (char *) &ring_node_address; | |
223 | sid = 0; |
|
224 | sid = 0; | |
|
225 | sidAsUnsignedChar = 0; | |||
224 |
|
226 | |||
225 | init_header_cwf( &headerCWF ); |
|
227 | init_header_cwf( &headerCWF ); | |
226 | init_header_swf( &headerSWF ); |
|
228 | init_header_swf( &headerSWF ); | |
227 | init_header_asm( &headerASM ); |
|
229 | init_header_asm( &headerASM ); | |
228 |
|
230 | |||
229 | status = get_message_queue_id_send( &queue_send_id ); |
|
231 | status = get_message_queue_id_send( &queue_send_id ); | |
230 | if (status != RTEMS_SUCCESSFUL) |
|
232 | if (status != RTEMS_SUCCESSFUL) | |
231 | { |
|
233 | { | |
232 | PRINTF1("in HOUS *** ERR get_message_queue_id_send %d\n", status) |
|
234 | PRINTF1("in HOUS *** ERR get_message_queue_id_send %d\n", status) | |
233 | } |
|
235 | } | |
234 |
|
236 | |||
235 | BOOT_PRINTF("in SEND *** \n") |
|
237 | BOOT_PRINTF("in SEND *** \n") | |
236 |
|
238 | |||
237 | while(1) |
|
239 | while(1) | |
238 | { |
|
240 | { | |
239 | status = rtems_message_queue_receive( queue_send_id, incomingData, &size, |
|
241 | status = rtems_message_queue_receive( queue_send_id, incomingData, &size, | |
240 | RTEMS_WAIT, RTEMS_NO_TIMEOUT ); |
|
242 | RTEMS_WAIT, RTEMS_NO_TIMEOUT ); | |
241 |
|
243 | |||
242 | if (status!=RTEMS_SUCCESSFUL) |
|
244 | if (status!=RTEMS_SUCCESSFUL) | |
243 | { |
|
245 | { | |
244 | PRINTF1("in SEND *** (1) ERR = %d\n", status) |
|
246 | PRINTF1("in SEND *** (1) ERR = %d\n", status) | |
245 | } |
|
247 | } | |
246 | else |
|
248 | else | |
247 | { |
|
249 | { | |
248 | if ( size == sizeof(ring_node*) ) |
|
250 | if ( size == sizeof(ring_node*) ) | |
249 | { |
|
251 | { | |
250 | charPtr[0] = incomingData[0]; |
|
252 | charPtr[0] = incomingData[0]; | |
251 | charPtr[1] = incomingData[1]; |
|
253 | charPtr[1] = incomingData[1]; | |
252 | charPtr[2] = incomingData[2]; |
|
254 | charPtr[2] = incomingData[2]; | |
253 | charPtr[3] = incomingData[3]; |
|
255 | charPtr[3] = incomingData[3]; | |
254 | incomingRingNodePtr = (ring_node*) ring_node_address; |
|
256 | incomingRingNodePtr = (ring_node*) ring_node_address; | |
255 | sid = incomingRingNodePtr->sid; |
|
257 | sid = incomingRingNodePtr->sid; | |
256 | if ( (sid==SID_NORM_CWF_LONG_F3) |
|
258 | if ( (sid==SID_NORM_CWF_LONG_F3) | |
257 | || (sid==SID_BURST_CWF_F2 ) |
|
259 | || (sid==SID_BURST_CWF_F2 ) | |
258 | || (sid==SID_SBM1_CWF_F1 ) |
|
260 | || (sid==SID_SBM1_CWF_F1 ) | |
259 | || (sid==SID_SBM2_CWF_F2 )) |
|
261 | || (sid==SID_SBM2_CWF_F2 )) | |
260 | { |
|
262 | { | |
261 | spw_send_waveform_CWF( incomingRingNodePtr, &headerCWF ); |
|
263 | spw_send_waveform_CWF( incomingRingNodePtr, &headerCWF ); | |
262 | } |
|
264 | } | |
263 | else if ( (sid==SID_NORM_SWF_F0) || (sid== SID_NORM_SWF_F1) || (sid==SID_NORM_SWF_F2) ) |
|
265 | else if ( (sid==SID_NORM_SWF_F0) || (sid== SID_NORM_SWF_F1) || (sid==SID_NORM_SWF_F2) ) | |
264 | { |
|
266 | { | |
265 | spw_send_waveform_SWF( incomingRingNodePtr, &headerSWF ); |
|
267 | spw_send_waveform_SWF( incomingRingNodePtr, &headerSWF ); | |
266 | } |
|
268 | } | |
267 | else if ( (sid==SID_NORM_CWF_F3) ) |
|
269 | else if ( (sid==SID_NORM_CWF_F3) ) | |
268 | { |
|
270 | { | |
269 | spw_send_waveform_CWF3_light( incomingRingNodePtr, &headerCWF ); |
|
271 | spw_send_waveform_CWF3_light( incomingRingNodePtr, &headerCWF ); | |
270 | } |
|
272 | } | |
271 | else if (sid==SID_NORM_ASM_F0) |
|
273 | else if (sid==SID_NORM_ASM_F0) | |
272 | { |
|
274 | { | |
273 | spw_send_asm_f0( incomingRingNodePtr, &headerASM ); |
|
275 | spw_send_asm_f0( incomingRingNodePtr, &headerASM ); | |
274 | } |
|
276 | } | |
275 | else if (sid==SID_NORM_ASM_F1) |
|
277 | else if (sid==SID_NORM_ASM_F1) | |
276 | { |
|
278 | { | |
277 | spw_send_asm_f1( incomingRingNodePtr, &headerASM ); |
|
279 | spw_send_asm_f1( incomingRingNodePtr, &headerASM ); | |
278 | } |
|
280 | } | |
279 | else if (sid==SID_NORM_ASM_F2) |
|
281 | else if (sid==SID_NORM_ASM_F2) | |
280 | { |
|
282 | { | |
281 | spw_send_asm_f2( incomingRingNodePtr, &headerASM ); |
|
283 | spw_send_asm_f2( incomingRingNodePtr, &headerASM ); | |
282 | } |
|
284 | } | |
283 | else if ( sid==TM_CODE_K_DUMP ) |
|
285 | else if ( sid==TM_CODE_K_DUMP ) | |
284 | { |
|
286 | { | |
285 | spw_send_k_dump( incomingRingNodePtr ); |
|
287 | spw_send_k_dump( incomingRingNodePtr ); | |
286 | } |
|
288 | } | |
287 | else |
|
289 | else | |
288 | { |
|
290 | { | |
289 | PRINTF1("unexpected sid = %d\n", sid); |
|
291 | PRINTF1("unexpected sid = %d\n", sid); | |
290 | } |
|
292 | } | |
291 | } |
|
293 | } | |
292 | else if ( incomingData[0] == CCSDS_DESTINATION_ID ) // the incoming message is a ccsds packet |
|
294 | else if ( incomingData[0] == CCSDS_DESTINATION_ID ) // the incoming message is a ccsds packet | |
293 | { |
|
295 | { | |
|
296 | sidAsUnsignedChar = (unsigned char) incomingData[ PACKET_POS_PA_LFR_SID_PKT ]; | |||
|
297 | sid = sidAsUnsignedChar; | |||
|
298 | // SET THE SEQUENCE_CNT PARAMETER IN CASE OF BP0 OR BP1 PACKETS | |||
|
299 | if ( (sid == SID_NORM_BP1_F0) || (sid == SID_NORM_BP1_F1) || (sid == SID_NORM_BP1_F2) | |||
|
300 | || (sid == SID_NORM_BP2_F0) || (sid == SID_NORM_BP2_F1) || (sid == SID_NORM_BP2_F2) | |||
|
301 | || (sid == SID_BURST_BP1_F0) || (sid == SID_BURST_BP1_F1) | |||
|
302 | || (sid == SID_BURST_BP2_F0) || (sid == SID_BURST_BP2_F1) | |||
|
303 | || (sid == SID_SBM1_BP1_F0) || (sid == SID_SBM1_BP2_F0) | |||
|
304 | || (sid == SID_SBM2_BP1_F0) || (sid == SID_SBM2_BP1_F1) | |||
|
305 | || (sid == SID_SBM2_BP2_F0) || (sid == SID_SBM2_BP2_F1)) | |||
|
306 | { | |||
|
307 | increment_seq_counter_source_id( (unsigned char*) &incomingData[ PACKET_POS_SEQUENCE_CNT ], sid ); | |||
|
308 | } | |||
|
309 | ||||
294 | status = write( fdSPW, incomingData, size ); |
|
310 | status = write( fdSPW, incomingData, size ); | |
295 | if (status == -1){ |
|
311 | if (status == -1){ | |
296 | PRINTF2("in SEND *** (2.a) ERRNO = %d, size = %d\n", errno, size) |
|
312 | PRINTF2("in SEND *** (2.a) ERRNO = %d, size = %d\n", errno, size) | |
297 | } |
|
313 | } | |
298 | } |
|
314 | } | |
299 | else // the incoming message is a spw_ioctl_pkt_send structure |
|
315 | else // the incoming message is a spw_ioctl_pkt_send structure | |
300 | { |
|
316 | { | |
301 | spw_ioctl_send = (spw_ioctl_pkt_send*) incomingData; |
|
317 | spw_ioctl_send = (spw_ioctl_pkt_send*) incomingData; | |
302 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, spw_ioctl_send ); |
|
318 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, spw_ioctl_send ); | |
303 | if (status == -1){ |
|
319 | if (status == -1){ | |
304 | PRINTF2("in SEND *** (2.b) ERRNO = %d, RTEMS = %d\n", errno, status) |
|
320 | PRINTF2("in SEND *** (2.b) ERRNO = %d, RTEMS = %d\n", errno, status) | |
305 | } |
|
321 | } | |
306 | } |
|
322 | } | |
307 | } |
|
323 | } | |
308 |
|
324 | |||
309 | update_queue_max_count( queue_send_id, &hk_lfr_q_sd_fifo_size_max ); |
|
325 | update_queue_max_count( queue_send_id, &hk_lfr_q_sd_fifo_size_max ); | |
310 |
|
326 | |||
311 | } |
|
327 | } | |
312 | } |
|
328 | } | |
313 |
|
329 | |||
314 | rtems_task wtdg_task( rtems_task_argument argument ) |
|
330 | rtems_task wtdg_task( rtems_task_argument argument ) | |
315 | { |
|
331 | { | |
316 | rtems_event_set event_out; |
|
332 | rtems_event_set event_out; | |
317 | rtems_status_code status; |
|
333 | rtems_status_code status; | |
318 | int linkStatus; |
|
334 | int linkStatus; | |
319 |
|
335 | |||
320 | BOOT_PRINTF("in WTDG ***\n") |
|
336 | BOOT_PRINTF("in WTDG ***\n") | |
321 |
|
337 | |||
322 | while(1) |
|
338 | while(1) | |
323 | { |
|
339 | { | |
324 | // wait for an RTEMS_EVENT |
|
340 | // wait for an RTEMS_EVENT | |
325 | rtems_event_receive( RTEMS_EVENT_0, |
|
341 | rtems_event_receive( RTEMS_EVENT_0, | |
326 | RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); |
|
342 | RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); | |
327 | PRINTF("in WTDG *** wait for the link\n") |
|
343 | PRINTF("in WTDG *** wait for the link\n") | |
328 | status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status |
|
344 | status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status | |
329 | while( linkStatus != 5) // wait for the link |
|
345 | while( linkStatus != 5) // wait for the link | |
330 | { |
|
346 | { | |
331 | status = rtems_task_wake_after( 10 ); // monitor the link each 100ms |
|
347 | status = rtems_task_wake_after( 10 ); // monitor the link each 100ms | |
332 | status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status |
|
348 | status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status | |
333 | } |
|
349 | } | |
334 |
|
350 | |||
335 | status = spacewire_stop_and_start_link( fdSPW ); |
|
351 | status = spacewire_stop_and_start_link( fdSPW ); | |
336 |
|
352 | |||
337 | if (status != RTEMS_SUCCESSFUL) |
|
353 | if (status != RTEMS_SUCCESSFUL) | |
338 | { |
|
354 | { | |
339 | PRINTF1("in WTDG *** ERR link not started %d\n", status) |
|
355 | PRINTF1("in WTDG *** ERR link not started %d\n", status) | |
340 | } |
|
356 | } | |
341 | else |
|
357 | else | |
342 | { |
|
358 | { | |
343 | PRINTF("in WTDG *** OK link started\n") |
|
359 | PRINTF("in WTDG *** OK link started\n") | |
344 | } |
|
360 | } | |
345 |
|
361 | |||
346 | // restart the SPIQ task |
|
362 | // restart the SPIQ task | |
347 | status = rtems_task_restart( Task_id[TASKID_SPIQ], 1 ); |
|
363 | status = rtems_task_restart( Task_id[TASKID_SPIQ], 1 ); | |
348 | if ( status != RTEMS_SUCCESSFUL ) { |
|
364 | if ( status != RTEMS_SUCCESSFUL ) { | |
349 | PRINTF("in SPIQ *** ERR restarting SPIQ Task\n") |
|
365 | PRINTF("in SPIQ *** ERR restarting SPIQ Task\n") | |
350 | } |
|
366 | } | |
351 |
|
367 | |||
352 | // restart RECV and SEND |
|
368 | // restart RECV and SEND | |
353 | status = rtems_task_restart( Task_id[ TASKID_SEND ], 1 ); |
|
369 | status = rtems_task_restart( Task_id[ TASKID_SEND ], 1 ); | |
354 | if ( status != RTEMS_SUCCESSFUL ) { |
|
370 | if ( status != RTEMS_SUCCESSFUL ) { | |
355 | PRINTF("in SPIQ *** ERR restarting SEND Task\n") |
|
371 | PRINTF("in SPIQ *** ERR restarting SEND Task\n") | |
356 | } |
|
372 | } | |
357 | status = rtems_task_restart( Task_id[ TASKID_RECV ], 1 ); |
|
373 | status = rtems_task_restart( Task_id[ TASKID_RECV ], 1 ); | |
358 | if ( status != RTEMS_SUCCESSFUL ) { |
|
374 | if ( status != RTEMS_SUCCESSFUL ) { | |
359 | PRINTF("in SPIQ *** ERR restarting RECV Task\n") |
|
375 | PRINTF("in SPIQ *** ERR restarting RECV Task\n") | |
360 | } |
|
376 | } | |
361 | } |
|
377 | } | |
362 | } |
|
378 | } | |
363 |
|
379 | |||
364 | //**************** |
|
380 | //**************** | |
365 | // OTHER FUNCTIONS |
|
381 | // OTHER FUNCTIONS | |
366 | int spacewire_open_link( void ) // by default, the driver resets the core: [SPW_CTRL_WRITE(pDev, SPW_CTRL_RESET);] |
|
382 | int spacewire_open_link( void ) // by default, the driver resets the core: [SPW_CTRL_WRITE(pDev, SPW_CTRL_RESET);] | |
367 | { |
|
383 | { | |
368 | /** This function opens the SpaceWire link. |
|
384 | /** This function opens the SpaceWire link. | |
369 | * |
|
385 | * | |
370 | * @return a valid file descriptor in case of success, -1 in case of a failure |
|
386 | * @return a valid file descriptor in case of success, -1 in case of a failure | |
371 | * |
|
387 | * | |
372 | */ |
|
388 | */ | |
373 | rtems_status_code status; |
|
389 | rtems_status_code status; | |
374 |
|
390 | |||
375 | fdSPW = open(GRSPW_DEVICE_NAME, O_RDWR); // open the device. the open call resets the hardware |
|
391 | fdSPW = open(GRSPW_DEVICE_NAME, O_RDWR); // open the device. the open call resets the hardware | |
376 | if ( fdSPW < 0 ) { |
|
392 | if ( fdSPW < 0 ) { | |
377 | PRINTF1("ERR *** in configure_spw_link *** error opening "GRSPW_DEVICE_NAME" with ERR %d\n", errno) |
|
393 | PRINTF1("ERR *** in configure_spw_link *** error opening "GRSPW_DEVICE_NAME" with ERR %d\n", errno) | |
378 | } |
|
394 | } | |
379 | else |
|
395 | else | |
380 | { |
|
396 | { | |
381 | status = RTEMS_SUCCESSFUL; |
|
397 | status = RTEMS_SUCCESSFUL; | |
382 | } |
|
398 | } | |
383 |
|
399 | |||
384 | return status; |
|
400 | return status; | |
385 | } |
|
401 | } | |
386 |
|
402 | |||
387 | int spacewire_start_link( int fd ) |
|
403 | int spacewire_start_link( int fd ) | |
388 | { |
|
404 | { | |
389 | rtems_status_code status; |
|
405 | rtems_status_code status; | |
390 |
|
406 | |||
391 | status = ioctl( fd, SPACEWIRE_IOCTRL_START, -1); // returns successfuly if the link is started |
|
407 | status = ioctl( fd, SPACEWIRE_IOCTRL_START, -1); // returns successfuly if the link is started | |
392 | // -1 default hardcoded driver timeout |
|
408 | // -1 default hardcoded driver timeout | |
393 |
|
409 | |||
394 | return status; |
|
410 | return status; | |
395 | } |
|
411 | } | |
396 |
|
412 | |||
397 | int spacewire_stop_and_start_link( int fd ) |
|
413 | int spacewire_stop_and_start_link( int fd ) | |
398 | { |
|
414 | { | |
399 | rtems_status_code status; |
|
415 | rtems_status_code status; | |
400 |
|
416 | |||
401 | status = ioctl( fd, SPACEWIRE_IOCTRL_STOP); // start fails if link pDev->running != 0 |
|
417 | status = ioctl( fd, SPACEWIRE_IOCTRL_STOP); // start fails if link pDev->running != 0 | |
402 | status = ioctl( fd, SPACEWIRE_IOCTRL_START, -1); // returns successfuly if the link is started |
|
418 | status = ioctl( fd, SPACEWIRE_IOCTRL_START, -1); // returns successfuly if the link is started | |
403 | // -1 default hardcoded driver timeout |
|
419 | // -1 default hardcoded driver timeout | |
404 |
|
420 | |||
405 | return status; |
|
421 | return status; | |
406 | } |
|
422 | } | |
407 |
|
423 | |||
408 | int spacewire_configure_link( int fd ) |
|
424 | int spacewire_configure_link( int fd ) | |
409 | { |
|
425 | { | |
410 | /** This function configures the SpaceWire link. |
|
426 | /** This function configures the SpaceWire link. | |
411 | * |
|
427 | * | |
412 | * @return GR-RTEMS-DRIVER directive status codes: |
|
428 | * @return GR-RTEMS-DRIVER directive status codes: | |
413 | * - 22 EINVAL - Null pointer or an out of range value was given as the argument. |
|
429 | * - 22 EINVAL - Null pointer or an out of range value was given as the argument. | |
414 | * - 16 EBUSY - Only used for SEND. Returned when no descriptors are avialble in non-blocking mode. |
|
430 | * - 16 EBUSY - Only used for SEND. Returned when no descriptors are avialble in non-blocking mode. | |
415 | * - 88 ENOSYS - Returned for SET_DESTKEY if RMAP command handler is not available or if a non-implemented call is used. |
|
431 | * - 88 ENOSYS - Returned for SET_DESTKEY if RMAP command handler is not available or if a non-implemented call is used. | |
416 | * - 116 ETIMEDOUT - REturned for SET_PACKET_SIZE and START if the link could not be brought up. |
|
432 | * - 116 ETIMEDOUT - REturned for SET_PACKET_SIZE and START if the link could not be brought up. | |
417 | * - 12 ENOMEM - Returned for SET_PACKETSIZE if it was unable to allocate the new buffers. |
|
433 | * - 12 ENOMEM - Returned for SET_PACKETSIZE if it was unable to allocate the new buffers. | |
418 | * - 5 EIO - Error when writing to grswp hardware registers. |
|
434 | * - 5 EIO - Error when writing to grswp hardware registers. | |
419 | * - 2 ENOENT - No such file or directory |
|
435 | * - 2 ENOENT - No such file or directory | |
420 | */ |
|
436 | */ | |
421 |
|
437 | |||
422 | rtems_status_code status; |
|
438 | rtems_status_code status; | |
423 |
|
439 | |||
424 | spacewire_set_NP(1, REGS_ADDR_GRSPW); // [N]o [P]ort force |
|
440 | spacewire_set_NP(1, REGS_ADDR_GRSPW); // [N]o [P]ort force | |
425 | spacewire_set_RE(1, REGS_ADDR_GRSPW); // [R]MAP [E]nable, the dedicated call seems to break the no port force configuration |
|
441 | spacewire_set_RE(1, REGS_ADDR_GRSPW); // [R]MAP [E]nable, the dedicated call seems to break the no port force configuration | |
426 |
|
442 | |||
427 | status = ioctl(fd, SPACEWIRE_IOCTRL_SET_RXBLOCK, 1); // sets the blocking mode for reception |
|
443 | status = ioctl(fd, SPACEWIRE_IOCTRL_SET_RXBLOCK, 1); // sets the blocking mode for reception | |
428 | if (status!=RTEMS_SUCCESSFUL) { |
|
444 | if (status!=RTEMS_SUCCESSFUL) { | |
429 | PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_RXBLOCK\n") |
|
445 | PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_RXBLOCK\n") | |
430 | } |
|
446 | } | |
431 | // |
|
447 | // | |
432 | status = ioctl(fd, SPACEWIRE_IOCTRL_SET_EVENT_ID, Task_id[TASKID_SPIQ]); // sets the task ID to which an event is sent when a |
|
448 | status = ioctl(fd, SPACEWIRE_IOCTRL_SET_EVENT_ID, Task_id[TASKID_SPIQ]); // sets the task ID to which an event is sent when a | |
433 | if (status!=RTEMS_SUCCESSFUL) { |
|
449 | if (status!=RTEMS_SUCCESSFUL) { | |
434 | PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_EVENT_ID\n") // link-error interrupt occurs |
|
450 | PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_EVENT_ID\n") // link-error interrupt occurs | |
435 | } |
|
451 | } | |
436 | // |
|
452 | // | |
437 | status = ioctl(fd, SPACEWIRE_IOCTRL_SET_DISABLE_ERR, 0); // automatic link-disabling due to link-error interrupts |
|
453 | status = ioctl(fd, SPACEWIRE_IOCTRL_SET_DISABLE_ERR, 0); // automatic link-disabling due to link-error interrupts | |
438 | if (status!=RTEMS_SUCCESSFUL) { |
|
454 | if (status!=RTEMS_SUCCESSFUL) { | |
439 | PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_DISABLE_ERR\n") |
|
455 | PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_DISABLE_ERR\n") | |
440 | } |
|
456 | } | |
441 | // |
|
457 | // | |
442 | status = ioctl(fd, SPACEWIRE_IOCTRL_SET_LINK_ERR_IRQ, 1); // sets the link-error interrupt bit |
|
458 | status = ioctl(fd, SPACEWIRE_IOCTRL_SET_LINK_ERR_IRQ, 1); // sets the link-error interrupt bit | |
443 | if (status!=RTEMS_SUCCESSFUL) { |
|
459 | if (status!=RTEMS_SUCCESSFUL) { | |
444 | PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_LINK_ERR_IRQ\n") |
|
460 | PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_LINK_ERR_IRQ\n") | |
445 | } |
|
461 | } | |
446 | // |
|
462 | // | |
447 | status = ioctl(fd, SPACEWIRE_IOCTRL_SET_TXBLOCK, 1); // transmission blocks |
|
463 | status = ioctl(fd, SPACEWIRE_IOCTRL_SET_TXBLOCK, 1); // transmission blocks | |
448 | if (status!=RTEMS_SUCCESSFUL) { |
|
464 | if (status!=RTEMS_SUCCESSFUL) { | |
449 | PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_TXBLOCK\n") |
|
465 | PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_TXBLOCK\n") | |
450 | } |
|
466 | } | |
451 | // |
|
467 | // | |
452 | status = ioctl(fd, SPACEWIRE_IOCTRL_SET_TXBLOCK_ON_FULL, 1); // transmission blocks when no transmission descriptor is available |
|
468 | status = ioctl(fd, SPACEWIRE_IOCTRL_SET_TXBLOCK_ON_FULL, 1); // transmission blocks when no transmission descriptor is available | |
453 | if (status!=RTEMS_SUCCESSFUL) { |
|
469 | if (status!=RTEMS_SUCCESSFUL) { | |
454 | PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_TXBLOCK_ON_FULL\n") |
|
470 | PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_TXBLOCK_ON_FULL\n") | |
455 | } |
|
471 | } | |
456 | // |
|
472 | // | |
457 | status = ioctl(fd, SPACEWIRE_IOCTRL_SET_TCODE_CTRL, 0x0909); // [Time Rx : Time Tx : Link error : Tick-out IRQ] |
|
473 | status = ioctl(fd, SPACEWIRE_IOCTRL_SET_TCODE_CTRL, 0x0909); // [Time Rx : Time Tx : Link error : Tick-out IRQ] | |
458 | if (status!=RTEMS_SUCCESSFUL) { |
|
474 | if (status!=RTEMS_SUCCESSFUL) { | |
459 | PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_TCODE_CTRL,\n") |
|
475 | PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_TCODE_CTRL,\n") | |
460 | } |
|
476 | } | |
461 |
|
477 | |||
462 | return status; |
|
478 | return status; | |
463 | } |
|
479 | } | |
464 |
|
480 | |||
465 | int spacewire_reset_link( void ) |
|
481 | int spacewire_reset_link( void ) | |
466 | { |
|
482 | { | |
467 | /** This function is executed by the SPIQ rtems_task wehn it has been awaken by an interruption raised by the SpaceWire driver. |
|
483 | /** This function is executed by the SPIQ rtems_task wehn it has been awaken by an interruption raised by the SpaceWire driver. | |
468 | * |
|
484 | * | |
469 | * @return RTEMS directive status code: |
|
485 | * @return RTEMS directive status code: | |
470 | * - RTEMS_UNSATISFIED is returned is the link is not in the running state after 10 s. |
|
486 | * - RTEMS_UNSATISFIED is returned is the link is not in the running state after 10 s. | |
471 | * - RTEMS_SUCCESSFUL is returned if the link is up before the timeout. |
|
487 | * - RTEMS_SUCCESSFUL is returned if the link is up before the timeout. | |
472 | * |
|
488 | * | |
473 | */ |
|
489 | */ | |
474 |
|
490 | |||
475 | rtems_status_code status_spw; |
|
491 | rtems_status_code status_spw; | |
476 | rtems_status_code status; |
|
492 | rtems_status_code status; | |
477 | int i; |
|
493 | int i; | |
478 |
|
494 | |||
479 | for ( i=0; i<SY_LFR_DPU_CONNECT_ATTEMPT; i++ ) |
|
495 | for ( i=0; i<SY_LFR_DPU_CONNECT_ATTEMPT; i++ ) | |
480 | { |
|
496 | { | |
481 | PRINTF1("in spacewire_reset_link *** link recovery, try %d\n", i); |
|
497 | PRINTF1("in spacewire_reset_link *** link recovery, try %d\n", i); | |
482 |
|
498 | |||
483 | // CLOSING THE DRIVER AT THIS POINT WILL MAKE THE SEND TASK BLOCK THE SYSTEM |
|
499 | // CLOSING THE DRIVER AT THIS POINT WILL MAKE THE SEND TASK BLOCK THE SYSTEM | |
484 |
|
500 | |||
485 | status = rtems_task_wake_after( SY_LFR_DPU_CONNECT_TIMEOUT ); // wait SY_LFR_DPU_CONNECT_TIMEOUT 1000 ms |
|
501 | status = rtems_task_wake_after( SY_LFR_DPU_CONNECT_TIMEOUT ); // wait SY_LFR_DPU_CONNECT_TIMEOUT 1000 ms | |
486 |
|
502 | |||
487 | status_spw = spacewire_stop_and_start_link( fdSPW ); |
|
503 | status_spw = spacewire_stop_and_start_link( fdSPW ); | |
488 | if ( status_spw != RTEMS_SUCCESSFUL ) |
|
504 | if ( status_spw != RTEMS_SUCCESSFUL ) | |
489 | { |
|
505 | { | |
490 | PRINTF1("in spacewire_reset_link *** ERR spacewire_start_link code %d\n", status_spw) |
|
506 | PRINTF1("in spacewire_reset_link *** ERR spacewire_start_link code %d\n", status_spw) | |
491 | } |
|
507 | } | |
492 |
|
508 | |||
493 | if ( status_spw == RTEMS_SUCCESSFUL) |
|
509 | if ( status_spw == RTEMS_SUCCESSFUL) | |
494 | { |
|
510 | { | |
495 | break; |
|
511 | break; | |
496 | } |
|
512 | } | |
497 | } |
|
513 | } | |
498 |
|
514 | |||
499 | return status_spw; |
|
515 | return status_spw; | |
500 | } |
|
516 | } | |
501 |
|
517 | |||
502 | void spacewire_set_NP( unsigned char val, unsigned int regAddr ) // [N]o [P]ort force |
|
518 | void spacewire_set_NP( unsigned char val, unsigned int regAddr ) // [N]o [P]ort force | |
503 | { |
|
519 | { | |
504 | /** This function sets the [N]o [P]ort force bit of the GRSPW control register. |
|
520 | /** This function sets the [N]o [P]ort force bit of the GRSPW control register. | |
505 | * |
|
521 | * | |
506 | * @param val is the value, 0 or 1, used to set the value of the NP bit. |
|
522 | * @param val is the value, 0 or 1, used to set the value of the NP bit. | |
507 | * @param regAddr is the address of the GRSPW control register. |
|
523 | * @param regAddr is the address of the GRSPW control register. | |
508 | * |
|
524 | * | |
509 | * NP is the bit 20 of the GRSPW control register. |
|
525 | * NP is the bit 20 of the GRSPW control register. | |
510 | * |
|
526 | * | |
511 | */ |
|
527 | */ | |
512 |
|
528 | |||
513 | unsigned int *spwptr = (unsigned int*) regAddr; |
|
529 | unsigned int *spwptr = (unsigned int*) regAddr; | |
514 |
|
530 | |||
515 | if (val == 1) { |
|
531 | if (val == 1) { | |
516 | *spwptr = *spwptr | 0x00100000; // [NP] set the No port force bit |
|
532 | *spwptr = *spwptr | 0x00100000; // [NP] set the No port force bit | |
517 | } |
|
533 | } | |
518 | if (val== 0) { |
|
534 | if (val== 0) { | |
519 | *spwptr = *spwptr & 0xffdfffff; |
|
535 | *spwptr = *spwptr & 0xffdfffff; | |
520 | } |
|
536 | } | |
521 | } |
|
537 | } | |
522 |
|
538 | |||
523 | void spacewire_set_RE( unsigned char val, unsigned int regAddr ) // [R]MAP [E]nable |
|
539 | void spacewire_set_RE( unsigned char val, unsigned int regAddr ) // [R]MAP [E]nable | |
524 | { |
|
540 | { | |
525 | /** This function sets the [R]MAP [E]nable bit of the GRSPW control register. |
|
541 | /** This function sets the [R]MAP [E]nable bit of the GRSPW control register. | |
526 | * |
|
542 | * | |
527 | * @param val is the value, 0 or 1, used to set the value of the RE bit. |
|
543 | * @param val is the value, 0 or 1, used to set the value of the RE bit. | |
528 | * @param regAddr is the address of the GRSPW control register. |
|
544 | * @param regAddr is the address of the GRSPW control register. | |
529 | * |
|
545 | * | |
530 | * RE is the bit 16 of the GRSPW control register. |
|
546 | * RE is the bit 16 of the GRSPW control register. | |
531 | * |
|
547 | * | |
532 | */ |
|
548 | */ | |
533 |
|
549 | |||
534 | unsigned int *spwptr = (unsigned int*) regAddr; |
|
550 | unsigned int *spwptr = (unsigned int*) regAddr; | |
535 |
|
551 | |||
536 | if (val == 1) |
|
552 | if (val == 1) | |
537 | { |
|
553 | { | |
538 | *spwptr = *spwptr | 0x00010000; // [RE] set the RMAP Enable bit |
|
554 | *spwptr = *spwptr | 0x00010000; // [RE] set the RMAP Enable bit | |
539 | } |
|
555 | } | |
540 | if (val== 0) |
|
556 | if (val== 0) | |
541 | { |
|
557 | { | |
542 | *spwptr = *spwptr & 0xfffdffff; |
|
558 | *spwptr = *spwptr & 0xfffdffff; | |
543 | } |
|
559 | } | |
544 | } |
|
560 | } | |
545 |
|
561 | |||
546 | void spacewire_compute_stats_offsets( void ) |
|
562 | void spacewire_compute_stats_offsets( void ) | |
547 | { |
|
563 | { | |
548 | /** This function computes the SpaceWire statistics offsets in case of a SpaceWire related interruption raising. |
|
564 | /** This function computes the SpaceWire statistics offsets in case of a SpaceWire related interruption raising. | |
549 | * |
|
565 | * | |
550 | * The offsets keep a record of the statistics in case of a reset of the statistics. They are added to the current statistics |
|
566 | * The offsets keep a record of the statistics in case of a reset of the statistics. They are added to the current statistics | |
551 | * to keep the counters consistent even after a reset of the SpaceWire driver (the counter are set to zero by the driver when it |
|
567 | * to keep the counters consistent even after a reset of the SpaceWire driver (the counter are set to zero by the driver when it | |
552 | * during the open systel call). |
|
568 | * during the open systel call). | |
553 | * |
|
569 | * | |
554 | */ |
|
570 | */ | |
555 |
|
571 | |||
556 | spw_stats spacewire_stats_grspw; |
|
572 | spw_stats spacewire_stats_grspw; | |
557 | rtems_status_code status; |
|
573 | rtems_status_code status; | |
558 |
|
574 | |||
559 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_GET_STATISTICS, &spacewire_stats_grspw ); |
|
575 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_GET_STATISTICS, &spacewire_stats_grspw ); | |
560 |
|
576 | |||
561 | spacewire_stats_backup.packets_received = spacewire_stats_grspw.packets_received |
|
577 | spacewire_stats_backup.packets_received = spacewire_stats_grspw.packets_received | |
562 | + spacewire_stats.packets_received; |
|
578 | + spacewire_stats.packets_received; | |
563 | spacewire_stats_backup.packets_sent = spacewire_stats_grspw.packets_sent |
|
579 | spacewire_stats_backup.packets_sent = spacewire_stats_grspw.packets_sent | |
564 | + spacewire_stats.packets_sent; |
|
580 | + spacewire_stats.packets_sent; | |
565 | spacewire_stats_backup.parity_err = spacewire_stats_grspw.parity_err |
|
581 | spacewire_stats_backup.parity_err = spacewire_stats_grspw.parity_err | |
566 | + spacewire_stats.parity_err; |
|
582 | + spacewire_stats.parity_err; | |
567 | spacewire_stats_backup.disconnect_err = spacewire_stats_grspw.disconnect_err |
|
583 | spacewire_stats_backup.disconnect_err = spacewire_stats_grspw.disconnect_err | |
568 | + spacewire_stats.disconnect_err; |
|
584 | + spacewire_stats.disconnect_err; | |
569 | spacewire_stats_backup.escape_err = spacewire_stats_grspw.escape_err |
|
585 | spacewire_stats_backup.escape_err = spacewire_stats_grspw.escape_err | |
570 | + spacewire_stats.escape_err; |
|
586 | + spacewire_stats.escape_err; | |
571 | spacewire_stats_backup.credit_err = spacewire_stats_grspw.credit_err |
|
587 | spacewire_stats_backup.credit_err = spacewire_stats_grspw.credit_err | |
572 | + spacewire_stats.credit_err; |
|
588 | + spacewire_stats.credit_err; | |
573 | spacewire_stats_backup.write_sync_err = spacewire_stats_grspw.write_sync_err |
|
589 | spacewire_stats_backup.write_sync_err = spacewire_stats_grspw.write_sync_err | |
574 | + spacewire_stats.write_sync_err; |
|
590 | + spacewire_stats.write_sync_err; | |
575 | spacewire_stats_backup.rx_rmap_header_crc_err = spacewire_stats_grspw.rx_rmap_header_crc_err |
|
591 | spacewire_stats_backup.rx_rmap_header_crc_err = spacewire_stats_grspw.rx_rmap_header_crc_err | |
576 | + spacewire_stats.rx_rmap_header_crc_err; |
|
592 | + spacewire_stats.rx_rmap_header_crc_err; | |
577 | spacewire_stats_backup.rx_rmap_data_crc_err = spacewire_stats_grspw.rx_rmap_data_crc_err |
|
593 | spacewire_stats_backup.rx_rmap_data_crc_err = spacewire_stats_grspw.rx_rmap_data_crc_err | |
578 | + spacewire_stats.rx_rmap_data_crc_err; |
|
594 | + spacewire_stats.rx_rmap_data_crc_err; | |
579 | spacewire_stats_backup.early_ep = spacewire_stats_grspw.early_ep |
|
595 | spacewire_stats_backup.early_ep = spacewire_stats_grspw.early_ep | |
580 | + spacewire_stats.early_ep; |
|
596 | + spacewire_stats.early_ep; | |
581 | spacewire_stats_backup.invalid_address = spacewire_stats_grspw.invalid_address |
|
597 | spacewire_stats_backup.invalid_address = spacewire_stats_grspw.invalid_address | |
582 | + spacewire_stats.invalid_address; |
|
598 | + spacewire_stats.invalid_address; | |
583 | spacewire_stats_backup.rx_eep_err = spacewire_stats_grspw.rx_eep_err |
|
599 | spacewire_stats_backup.rx_eep_err = spacewire_stats_grspw.rx_eep_err | |
584 | + spacewire_stats.rx_eep_err; |
|
600 | + spacewire_stats.rx_eep_err; | |
585 | spacewire_stats_backup.rx_truncated = spacewire_stats_grspw.rx_truncated |
|
601 | spacewire_stats_backup.rx_truncated = spacewire_stats_grspw.rx_truncated | |
586 | + spacewire_stats.rx_truncated; |
|
602 | + spacewire_stats.rx_truncated; | |
587 | } |
|
603 | } | |
588 |
|
604 | |||
589 | void spacewire_update_statistics( void ) |
|
605 | void spacewire_update_statistics( void ) | |
590 | { |
|
606 | { | |
591 | rtems_status_code status; |
|
607 | rtems_status_code status; | |
592 | spw_stats spacewire_stats_grspw; |
|
608 | spw_stats spacewire_stats_grspw; | |
593 |
|
609 | |||
594 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_GET_STATISTICS, &spacewire_stats_grspw ); |
|
610 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_GET_STATISTICS, &spacewire_stats_grspw ); | |
595 |
|
611 | |||
596 | spacewire_stats.packets_received = spacewire_stats_backup.packets_received |
|
612 | spacewire_stats.packets_received = spacewire_stats_backup.packets_received | |
597 | + spacewire_stats_grspw.packets_received; |
|
613 | + spacewire_stats_grspw.packets_received; | |
598 | spacewire_stats.packets_sent = spacewire_stats_backup.packets_sent |
|
614 | spacewire_stats.packets_sent = spacewire_stats_backup.packets_sent | |
599 | + spacewire_stats_grspw.packets_sent; |
|
615 | + spacewire_stats_grspw.packets_sent; | |
600 | spacewire_stats.parity_err = spacewire_stats_backup.parity_err |
|
616 | spacewire_stats.parity_err = spacewire_stats_backup.parity_err | |
601 | + spacewire_stats_grspw.parity_err; |
|
617 | + spacewire_stats_grspw.parity_err; | |
602 | spacewire_stats.disconnect_err = spacewire_stats_backup.disconnect_err |
|
618 | spacewire_stats.disconnect_err = spacewire_stats_backup.disconnect_err | |
603 | + spacewire_stats_grspw.disconnect_err; |
|
619 | + spacewire_stats_grspw.disconnect_err; | |
604 | spacewire_stats.escape_err = spacewire_stats_backup.escape_err |
|
620 | spacewire_stats.escape_err = spacewire_stats_backup.escape_err | |
605 | + spacewire_stats_grspw.escape_err; |
|
621 | + spacewire_stats_grspw.escape_err; | |
606 | spacewire_stats.credit_err = spacewire_stats_backup.credit_err |
|
622 | spacewire_stats.credit_err = spacewire_stats_backup.credit_err | |
607 | + spacewire_stats_grspw.credit_err; |
|
623 | + spacewire_stats_grspw.credit_err; | |
608 | spacewire_stats.write_sync_err = spacewire_stats_backup.write_sync_err |
|
624 | spacewire_stats.write_sync_err = spacewire_stats_backup.write_sync_err | |
609 | + spacewire_stats_grspw.write_sync_err; |
|
625 | + spacewire_stats_grspw.write_sync_err; | |
610 | spacewire_stats.rx_rmap_header_crc_err = spacewire_stats_backup.rx_rmap_header_crc_err |
|
626 | spacewire_stats.rx_rmap_header_crc_err = spacewire_stats_backup.rx_rmap_header_crc_err | |
611 | + spacewire_stats_grspw.rx_rmap_header_crc_err; |
|
627 | + spacewire_stats_grspw.rx_rmap_header_crc_err; | |
612 | spacewire_stats.rx_rmap_data_crc_err = spacewire_stats_backup.rx_rmap_data_crc_err |
|
628 | spacewire_stats.rx_rmap_data_crc_err = spacewire_stats_backup.rx_rmap_data_crc_err | |
613 | + spacewire_stats_grspw.rx_rmap_data_crc_err; |
|
629 | + spacewire_stats_grspw.rx_rmap_data_crc_err; | |
614 | spacewire_stats.early_ep = spacewire_stats_backup.early_ep |
|
630 | spacewire_stats.early_ep = spacewire_stats_backup.early_ep | |
615 | + spacewire_stats_grspw.early_ep; |
|
631 | + spacewire_stats_grspw.early_ep; | |
616 | spacewire_stats.invalid_address = spacewire_stats_backup.invalid_address |
|
632 | spacewire_stats.invalid_address = spacewire_stats_backup.invalid_address | |
617 | + spacewire_stats_grspw.invalid_address; |
|
633 | + spacewire_stats_grspw.invalid_address; | |
618 | spacewire_stats.rx_eep_err = spacewire_stats_backup.rx_eep_err |
|
634 | spacewire_stats.rx_eep_err = spacewire_stats_backup.rx_eep_err | |
619 | + spacewire_stats_grspw.rx_eep_err; |
|
635 | + spacewire_stats_grspw.rx_eep_err; | |
620 | spacewire_stats.rx_truncated = spacewire_stats_backup.rx_truncated |
|
636 | spacewire_stats.rx_truncated = spacewire_stats_backup.rx_truncated | |
621 | + spacewire_stats_grspw.rx_truncated; |
|
637 | + spacewire_stats_grspw.rx_truncated; | |
622 | //spacewire_stats.tx_link_err; |
|
638 | //spacewire_stats.tx_link_err; | |
623 |
|
639 | |||
624 | //**************************** |
|
640 | //**************************** | |
625 | // DPU_SPACEWIRE_IF_STATISTICS |
|
641 | // DPU_SPACEWIRE_IF_STATISTICS | |
626 | housekeeping_packet.hk_lfr_dpu_spw_pkt_rcv_cnt[0] = (unsigned char) (spacewire_stats.packets_received >> 8); |
|
642 | housekeeping_packet.hk_lfr_dpu_spw_pkt_rcv_cnt[0] = (unsigned char) (spacewire_stats.packets_received >> 8); | |
627 | housekeeping_packet.hk_lfr_dpu_spw_pkt_rcv_cnt[1] = (unsigned char) (spacewire_stats.packets_received); |
|
643 | housekeeping_packet.hk_lfr_dpu_spw_pkt_rcv_cnt[1] = (unsigned char) (spacewire_stats.packets_received); | |
628 | housekeeping_packet.hk_lfr_dpu_spw_pkt_sent_cnt[0] = (unsigned char) (spacewire_stats.packets_sent >> 8); |
|
644 | housekeeping_packet.hk_lfr_dpu_spw_pkt_sent_cnt[0] = (unsigned char) (spacewire_stats.packets_sent >> 8); | |
629 | housekeeping_packet.hk_lfr_dpu_spw_pkt_sent_cnt[1] = (unsigned char) (spacewire_stats.packets_sent); |
|
645 | housekeeping_packet.hk_lfr_dpu_spw_pkt_sent_cnt[1] = (unsigned char) (spacewire_stats.packets_sent); | |
630 | //housekeeping_packet.hk_lfr_dpu_spw_tick_out_cnt; |
|
646 | //housekeeping_packet.hk_lfr_dpu_spw_tick_out_cnt; | |
631 | //housekeeping_packet.hk_lfr_dpu_spw_last_timc; |
|
647 | //housekeeping_packet.hk_lfr_dpu_spw_last_timc; | |
632 |
|
648 | |||
633 | //****************************************** |
|
649 | //****************************************** | |
634 | // ERROR COUNTERS / SPACEWIRE / LOW SEVERITY |
|
650 | // ERROR COUNTERS / SPACEWIRE / LOW SEVERITY | |
635 | housekeeping_packet.hk_lfr_dpu_spw_parity = (unsigned char) spacewire_stats.parity_err; |
|
651 | housekeeping_packet.hk_lfr_dpu_spw_parity = (unsigned char) spacewire_stats.parity_err; | |
636 | housekeeping_packet.hk_lfr_dpu_spw_disconnect = (unsigned char) spacewire_stats.disconnect_err; |
|
652 | housekeeping_packet.hk_lfr_dpu_spw_disconnect = (unsigned char) spacewire_stats.disconnect_err; | |
637 | housekeeping_packet.hk_lfr_dpu_spw_escape = (unsigned char) spacewire_stats.escape_err; |
|
653 | housekeeping_packet.hk_lfr_dpu_spw_escape = (unsigned char) spacewire_stats.escape_err; | |
638 | housekeeping_packet.hk_lfr_dpu_spw_credit = (unsigned char) spacewire_stats.credit_err; |
|
654 | housekeeping_packet.hk_lfr_dpu_spw_credit = (unsigned char) spacewire_stats.credit_err; | |
639 | housekeeping_packet.hk_lfr_dpu_spw_write_sync = (unsigned char) spacewire_stats.write_sync_err; |
|
655 | housekeeping_packet.hk_lfr_dpu_spw_write_sync = (unsigned char) spacewire_stats.write_sync_err; | |
640 |
|
656 | |||
641 | //********************************************* |
|
657 | //********************************************* | |
642 | // ERROR COUNTERS / SPACEWIRE / MEDIUM SEVERITY |
|
658 | // ERROR COUNTERS / SPACEWIRE / MEDIUM SEVERITY | |
643 | housekeeping_packet.hk_lfr_dpu_spw_early_eop = (unsigned char) spacewire_stats.early_ep; |
|
659 | housekeeping_packet.hk_lfr_dpu_spw_early_eop = (unsigned char) spacewire_stats.early_ep; | |
644 | housekeeping_packet.hk_lfr_dpu_spw_invalid_addr = (unsigned char) spacewire_stats.invalid_address; |
|
660 | housekeeping_packet.hk_lfr_dpu_spw_invalid_addr = (unsigned char) spacewire_stats.invalid_address; | |
645 | housekeeping_packet.hk_lfr_dpu_spw_eep = (unsigned char) spacewire_stats.rx_eep_err; |
|
661 | housekeeping_packet.hk_lfr_dpu_spw_eep = (unsigned char) spacewire_stats.rx_eep_err; | |
646 | housekeeping_packet.hk_lfr_dpu_spw_rx_too_big = (unsigned char) spacewire_stats.rx_truncated; |
|
662 | housekeeping_packet.hk_lfr_dpu_spw_rx_too_big = (unsigned char) spacewire_stats.rx_truncated; | |
647 | } |
|
663 | } | |
648 |
|
664 | |||
649 | void timecode_irq_handler( void *pDev, void *regs, int minor, unsigned int tc ) |
|
665 | void timecode_irq_handler( void *pDev, void *regs, int minor, unsigned int tc ) | |
650 | { |
|
666 | { | |
651 | // a valid timecode has been received, write it in the HK report |
|
667 | // a valid timecode has been received, write it in the HK report | |
652 | unsigned int *grspwPtr; |
|
668 | unsigned int *grspwPtr; | |
653 | unsigned char timecodeCtr; |
|
669 | unsigned char timecodeCtr; | |
654 | unsigned char updateTimeCtr; |
|
670 | unsigned char updateTimeCtr; | |
655 |
|
671 | |||
656 | grspwPtr = (unsigned int *) (REGS_ADDR_GRSPW + APB_OFFSET_GRSPW_TIME_REGISTER); |
|
672 | grspwPtr = (unsigned int *) (REGS_ADDR_GRSPW + APB_OFFSET_GRSPW_TIME_REGISTER); | |
657 |
|
673 | |||
658 | housekeeping_packet.hk_lfr_dpu_spw_last_timc = (unsigned char) (grspwPtr[0] & 0xff); // [1111 1111] |
|
674 | housekeeping_packet.hk_lfr_dpu_spw_last_timc = (unsigned char) (grspwPtr[0] & 0xff); // [1111 1111] | |
659 | timecodeCtr = (unsigned char) (grspwPtr[0] & 0x3f); // [0011 1111] |
|
675 | timecodeCtr = (unsigned char) (grspwPtr[0] & 0x3f); // [0011 1111] | |
660 | updateTimeCtr = time_management_regs->coarse_time_load & 0x3f; // [0011 1111] |
|
676 | updateTimeCtr = time_management_regs->coarse_time_load & 0x3f; // [0011 1111] | |
661 |
|
677 | |||
662 | // update the number of valid timecodes that have been received |
|
678 | // update the number of valid timecodes that have been received | |
663 | if (housekeeping_packet.hk_lfr_dpu_spw_tick_out_cnt == 255) |
|
679 | if (housekeeping_packet.hk_lfr_dpu_spw_tick_out_cnt == 255) | |
664 | { |
|
680 | { | |
665 | housekeeping_packet.hk_lfr_dpu_spw_tick_out_cnt = 0; |
|
681 | housekeeping_packet.hk_lfr_dpu_spw_tick_out_cnt = 0; | |
666 | } |
|
682 | } | |
667 | else |
|
683 | else | |
668 | { |
|
684 | { | |
669 | housekeeping_packet.hk_lfr_dpu_spw_tick_out_cnt = housekeeping_packet.hk_lfr_dpu_spw_tick_out_cnt + 1; |
|
685 | housekeeping_packet.hk_lfr_dpu_spw_tick_out_cnt = housekeeping_packet.hk_lfr_dpu_spw_tick_out_cnt + 1; | |
670 | } |
|
686 | } | |
671 |
|
687 | |||
672 | // check the value of the timecode with respect to the last TC_LFR_UPDATE_TIME => SSS-CP-FS-370 |
|
688 | // check the value of the timecode with respect to the last TC_LFR_UPDATE_TIME => SSS-CP-FS-370 | |
673 | if (timecodeCtr != updateTimeCtr) |
|
689 | if (timecodeCtr != updateTimeCtr) | |
674 | { |
|
690 | { | |
675 | if (housekeeping_packet.hk_lfr_time_timecode_ctr == 255) |
|
691 | if (housekeeping_packet.hk_lfr_time_timecode_ctr == 255) | |
676 | { |
|
692 | { | |
677 | housekeeping_packet.hk_lfr_time_timecode_ctr = 0; |
|
693 | housekeeping_packet.hk_lfr_time_timecode_ctr = 0; | |
678 | } |
|
694 | } | |
679 | else |
|
695 | else | |
680 | { |
|
696 | { | |
681 | housekeeping_packet.hk_lfr_time_timecode_ctr = housekeeping_packet.hk_lfr_time_timecode_ctr + 1; |
|
697 | housekeeping_packet.hk_lfr_time_timecode_ctr = housekeeping_packet.hk_lfr_time_timecode_ctr + 1; | |
682 | } |
|
698 | } | |
683 | } |
|
699 | } | |
684 | } |
|
700 | } | |
685 |
|
701 | |||
686 | rtems_timer_service_routine user_routine( rtems_id timer_id, void *user_data ) |
|
702 | rtems_timer_service_routine user_routine( rtems_id timer_id, void *user_data ) | |
687 | { |
|
703 | { | |
688 | int linkStatus; |
|
704 | int linkStatus; | |
689 | rtems_status_code status; |
|
705 | rtems_status_code status; | |
690 |
|
706 | |||
691 | status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status |
|
707 | status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status | |
692 |
|
708 | |||
693 | if ( linkStatus == 5) { |
|
709 | if ( linkStatus == 5) { | |
694 | PRINTF("in spacewire_reset_link *** link is running\n") |
|
710 | PRINTF("in spacewire_reset_link *** link is running\n") | |
695 | status = RTEMS_SUCCESSFUL; |
|
711 | status = RTEMS_SUCCESSFUL; | |
696 | } |
|
712 | } | |
697 | } |
|
713 | } | |
698 |
|
714 | |||
699 | void init_header_cwf( Header_TM_LFR_SCIENCE_CWF_t *header ) |
|
715 | void init_header_cwf( Header_TM_LFR_SCIENCE_CWF_t *header ) | |
700 | { |
|
716 | { | |
701 | header->targetLogicalAddress = CCSDS_DESTINATION_ID; |
|
717 | header->targetLogicalAddress = CCSDS_DESTINATION_ID; | |
702 | header->protocolIdentifier = CCSDS_PROTOCOLE_ID; |
|
718 | header->protocolIdentifier = CCSDS_PROTOCOLE_ID; | |
703 | header->reserved = DEFAULT_RESERVED; |
|
719 | header->reserved = DEFAULT_RESERVED; | |
704 | header->userApplication = CCSDS_USER_APP; |
|
720 | header->userApplication = CCSDS_USER_APP; | |
705 | header->packetSequenceControl[0]= TM_PACKET_SEQ_CTRL_STANDALONE; |
|
721 | header->packetSequenceControl[0]= TM_PACKET_SEQ_CTRL_STANDALONE; | |
706 | header->packetSequenceControl[1]= TM_PACKET_SEQ_CNT_DEFAULT; |
|
722 | header->packetSequenceControl[1]= TM_PACKET_SEQ_CNT_DEFAULT; | |
707 | header->packetLength[0] = 0x00; |
|
723 | header->packetLength[0] = 0x00; | |
708 | header->packetLength[1] = 0x00; |
|
724 | header->packetLength[1] = 0x00; | |
709 | // DATA FIELD HEADER |
|
725 | // DATA FIELD HEADER | |
710 | header->spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2; |
|
726 | header->spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2; | |
711 | header->serviceType = TM_TYPE_LFR_SCIENCE; // service type |
|
727 | header->serviceType = TM_TYPE_LFR_SCIENCE; // service type | |
712 | header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE_6; // service subtype |
|
728 | header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE_6; // service subtype | |
713 | header->destinationID = TM_DESTINATION_ID_GROUND; |
|
729 | header->destinationID = TM_DESTINATION_ID_GROUND; | |
714 | header->time[0] = 0x00; |
|
730 | header->time[0] = 0x00; | |
715 | header->time[0] = 0x00; |
|
731 | header->time[0] = 0x00; | |
716 | header->time[0] = 0x00; |
|
732 | header->time[0] = 0x00; | |
717 | header->time[0] = 0x00; |
|
733 | header->time[0] = 0x00; | |
718 | header->time[0] = 0x00; |
|
734 | header->time[0] = 0x00; | |
719 | header->time[0] = 0x00; |
|
735 | header->time[0] = 0x00; | |
720 | // AUXILIARY DATA HEADER |
|
736 | // AUXILIARY DATA HEADER | |
721 | header->sid = 0x00; |
|
737 | header->sid = 0x00; | |
722 | header->hkBIA = DEFAULT_HKBIA; |
|
738 | header->hkBIA = DEFAULT_HKBIA; | |
723 | header->blkNr[0] = 0x00; |
|
739 | header->blkNr[0] = 0x00; | |
724 | header->blkNr[1] = 0x00; |
|
740 | header->blkNr[1] = 0x00; | |
725 | } |
|
741 | } | |
726 |
|
742 | |||
727 | void init_header_swf( Header_TM_LFR_SCIENCE_SWF_t *header ) |
|
743 | void init_header_swf( Header_TM_LFR_SCIENCE_SWF_t *header ) | |
728 | { |
|
744 | { | |
729 | header->targetLogicalAddress = CCSDS_DESTINATION_ID; |
|
745 | header->targetLogicalAddress = CCSDS_DESTINATION_ID; | |
730 | header->protocolIdentifier = CCSDS_PROTOCOLE_ID; |
|
746 | header->protocolIdentifier = CCSDS_PROTOCOLE_ID; | |
731 | header->reserved = DEFAULT_RESERVED; |
|
747 | header->reserved = DEFAULT_RESERVED; | |
732 | header->userApplication = CCSDS_USER_APP; |
|
748 | header->userApplication = CCSDS_USER_APP; | |
733 | header->packetID[0] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST >> 8); |
|
749 | header->packetID[0] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST >> 8); | |
734 | header->packetID[1] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST); |
|
750 | header->packetID[1] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST); | |
735 | header->packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; |
|
751 | header->packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; | |
736 | header->packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT; |
|
752 | header->packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT; | |
737 | header->packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF_336 >> 8); |
|
753 | header->packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF_336 >> 8); | |
738 | header->packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF_336 ); |
|
754 | header->packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF_336 ); | |
739 | // DATA FIELD HEADER |
|
755 | // DATA FIELD HEADER | |
740 | header->spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2; |
|
756 | header->spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2; | |
741 | header->serviceType = TM_TYPE_LFR_SCIENCE; // service type |
|
757 | header->serviceType = TM_TYPE_LFR_SCIENCE; // service type | |
742 | header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE_6; // service subtype |
|
758 | header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE_6; // service subtype | |
743 | header->destinationID = TM_DESTINATION_ID_GROUND; |
|
759 | header->destinationID = TM_DESTINATION_ID_GROUND; | |
744 | header->time[0] = 0x00; |
|
760 | header->time[0] = 0x00; | |
745 | header->time[0] = 0x00; |
|
761 | header->time[0] = 0x00; | |
746 | header->time[0] = 0x00; |
|
762 | header->time[0] = 0x00; | |
747 | header->time[0] = 0x00; |
|
763 | header->time[0] = 0x00; | |
748 | header->time[0] = 0x00; |
|
764 | header->time[0] = 0x00; | |
749 | header->time[0] = 0x00; |
|
765 | header->time[0] = 0x00; | |
750 | // AUXILIARY DATA HEADER |
|
766 | // AUXILIARY DATA HEADER | |
751 | header->sid = 0x00; |
|
767 | header->sid = 0x00; | |
752 | header->hkBIA = DEFAULT_HKBIA; |
|
768 | header->hkBIA = DEFAULT_HKBIA; | |
753 | header->pktCnt = DEFAULT_PKTCNT; // PKT_CNT |
|
769 | header->pktCnt = DEFAULT_PKTCNT; // PKT_CNT | |
754 | header->pktNr = 0x00; |
|
770 | header->pktNr = 0x00; | |
755 | header->blkNr[0] = (unsigned char) (BLK_NR_CWF >> 8); |
|
771 | header->blkNr[0] = (unsigned char) (BLK_NR_CWF >> 8); | |
756 | header->blkNr[1] = (unsigned char) (BLK_NR_CWF ); |
|
772 | header->blkNr[1] = (unsigned char) (BLK_NR_CWF ); | |
757 | } |
|
773 | } | |
758 |
|
774 | |||
759 | void init_header_asm( Header_TM_LFR_SCIENCE_ASM_t *header ) |
|
775 | void init_header_asm( Header_TM_LFR_SCIENCE_ASM_t *header ) | |
760 | { |
|
776 | { | |
761 | header->targetLogicalAddress = CCSDS_DESTINATION_ID; |
|
777 | header->targetLogicalAddress = CCSDS_DESTINATION_ID; | |
762 | header->protocolIdentifier = CCSDS_PROTOCOLE_ID; |
|
778 | header->protocolIdentifier = CCSDS_PROTOCOLE_ID; | |
763 | header->reserved = DEFAULT_RESERVED; |
|
779 | header->reserved = DEFAULT_RESERVED; | |
764 | header->userApplication = CCSDS_USER_APP; |
|
780 | header->userApplication = CCSDS_USER_APP; | |
765 | header->packetID[0] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST >> 8); |
|
781 | header->packetID[0] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST >> 8); | |
766 | header->packetID[1] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST); |
|
782 | header->packetID[1] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST); | |
767 | header->packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; |
|
783 | header->packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; | |
768 | header->packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT; |
|
784 | header->packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT; | |
769 | header->packetLength[0] = 0x00; |
|
785 | header->packetLength[0] = 0x00; | |
770 | header->packetLength[1] = 0x00; |
|
786 | header->packetLength[1] = 0x00; | |
771 | // DATA FIELD HEADER |
|
787 | // DATA FIELD HEADER | |
772 | header->spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2; |
|
788 | header->spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2; | |
773 | header->serviceType = TM_TYPE_LFR_SCIENCE; // service type |
|
789 | header->serviceType = TM_TYPE_LFR_SCIENCE; // service type | |
774 | header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE_3; // service subtype |
|
790 | header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE_3; // service subtype | |
775 | header->destinationID = TM_DESTINATION_ID_GROUND; |
|
791 | header->destinationID = TM_DESTINATION_ID_GROUND; | |
776 | header->time[0] = 0x00; |
|
792 | header->time[0] = 0x00; | |
777 | header->time[0] = 0x00; |
|
793 | header->time[0] = 0x00; | |
778 | header->time[0] = 0x00; |
|
794 | header->time[0] = 0x00; | |
779 | header->time[0] = 0x00; |
|
795 | header->time[0] = 0x00; | |
780 | header->time[0] = 0x00; |
|
796 | header->time[0] = 0x00; | |
781 | header->time[0] = 0x00; |
|
797 | header->time[0] = 0x00; | |
782 | // AUXILIARY DATA HEADER |
|
798 | // AUXILIARY DATA HEADER | |
783 | header->sid = 0x00; |
|
799 | header->sid = 0x00; | |
784 | header->biaStatusInfo = 0x00; |
|
800 | header->biaStatusInfo = 0x00; | |
785 | header->pa_lfr_pkt_cnt_asm = 0x00; |
|
801 | header->pa_lfr_pkt_cnt_asm = 0x00; | |
786 | header->pa_lfr_pkt_nr_asm = 0x00; |
|
802 | header->pa_lfr_pkt_nr_asm = 0x00; | |
787 | header->pa_lfr_asm_blk_nr[0] = 0x00; |
|
803 | header->pa_lfr_asm_blk_nr[0] = 0x00; | |
788 | header->pa_lfr_asm_blk_nr[1] = 0x00; |
|
804 | header->pa_lfr_asm_blk_nr[1] = 0x00; | |
789 | } |
|
805 | } | |
790 |
|
806 | |||
791 | int spw_send_waveform_CWF( ring_node *ring_node_to_send, |
|
807 | int spw_send_waveform_CWF( ring_node *ring_node_to_send, | |
792 | Header_TM_LFR_SCIENCE_CWF_t *header ) |
|
808 | Header_TM_LFR_SCIENCE_CWF_t *header ) | |
793 | { |
|
809 | { | |
794 | /** This function sends CWF CCSDS packets (F2, F1 or F0). |
|
810 | /** This function sends CWF CCSDS packets (F2, F1 or F0). | |
795 | * |
|
811 | * | |
796 | * @param waveform points to the buffer containing the data that will be send. |
|
812 | * @param waveform points to the buffer containing the data that will be send. | |
797 | * @param sid is the source identifier of the data that will be sent. |
|
813 | * @param sid is the source identifier of the data that will be sent. | |
798 | * @param headerCWF points to a table of headers that have been prepared for the data transmission. |
|
814 | * @param headerCWF points to a table of headers that have been prepared for the data transmission. | |
799 | * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures |
|
815 | * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures | |
800 | * contain information to setup the transmission of the data packets. |
|
816 | * contain information to setup the transmission of the data packets. | |
801 | * |
|
817 | * | |
802 | * One group of 2048 samples is sent as 7 consecutive packets, 6 packets containing 340 blocks and 8 packets containing 8 blocks. |
|
818 | * One group of 2048 samples is sent as 7 consecutive packets, 6 packets containing 340 blocks and 8 packets containing 8 blocks. | |
803 | * |
|
819 | * | |
804 | */ |
|
820 | */ | |
805 |
|
821 | |||
806 | unsigned int i; |
|
822 | unsigned int i; | |
807 | int ret; |
|
823 | int ret; | |
808 | unsigned int coarseTime; |
|
824 | unsigned int coarseTime; | |
809 | unsigned int fineTime; |
|
825 | unsigned int fineTime; | |
810 | rtems_status_code status; |
|
826 | rtems_status_code status; | |
811 | spw_ioctl_pkt_send spw_ioctl_send_CWF; |
|
827 | spw_ioctl_pkt_send spw_ioctl_send_CWF; | |
812 | int *dataPtr; |
|
828 | int *dataPtr; | |
813 | unsigned char sid; |
|
829 | unsigned char sid; | |
814 |
|
830 | |||
815 | spw_ioctl_send_CWF.hlen = HEADER_LENGTH_TM_LFR_SCIENCE_CWF; |
|
831 | spw_ioctl_send_CWF.hlen = HEADER_LENGTH_TM_LFR_SCIENCE_CWF; | |
816 | spw_ioctl_send_CWF.options = 0; |
|
832 | spw_ioctl_send_CWF.options = 0; | |
817 |
|
833 | |||
818 | ret = LFR_DEFAULT; |
|
834 | ret = LFR_DEFAULT; | |
819 | sid = (unsigned char) ring_node_to_send->sid; |
|
835 | sid = (unsigned char) ring_node_to_send->sid; | |
820 |
|
836 | |||
821 | coarseTime = ring_node_to_send->coarseTime; |
|
837 | coarseTime = ring_node_to_send->coarseTime; | |
822 | fineTime = ring_node_to_send->fineTime; |
|
838 | fineTime = ring_node_to_send->fineTime; | |
823 | dataPtr = (int*) ring_node_to_send->buffer_address; |
|
839 | dataPtr = (int*) ring_node_to_send->buffer_address; | |
824 |
|
840 | |||
825 | header->packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF_336 >> 8); |
|
841 | header->packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF_336 >> 8); | |
826 | header->packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF_336 ); |
|
842 | header->packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF_336 ); | |
827 | header->hkBIA = pa_bia_status_info; |
|
843 | header->hkBIA = pa_bia_status_info; | |
828 | header->sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters; |
|
844 | header->sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters; | |
829 | header->blkNr[0] = (unsigned char) (BLK_NR_CWF >> 8); |
|
845 | header->blkNr[0] = (unsigned char) (BLK_NR_CWF >> 8); | |
830 | header->blkNr[1] = (unsigned char) (BLK_NR_CWF ); |
|
846 | header->blkNr[1] = (unsigned char) (BLK_NR_CWF ); | |
831 |
|
847 | |||
832 | for (i=0; i<NB_PACKETS_PER_GROUP_OF_CWF; i++) // send waveform |
|
848 | for (i=0; i<NB_PACKETS_PER_GROUP_OF_CWF; i++) // send waveform | |
833 | { |
|
849 | { | |
834 | spw_ioctl_send_CWF.data = (char*) &dataPtr[ (i * BLK_NR_CWF * NB_WORDS_SWF_BLK) ]; |
|
850 | spw_ioctl_send_CWF.data = (char*) &dataPtr[ (i * BLK_NR_CWF * NB_WORDS_SWF_BLK) ]; | |
835 | spw_ioctl_send_CWF.hdr = (char*) header; |
|
851 | spw_ioctl_send_CWF.hdr = (char*) header; | |
836 | // BUILD THE DATA |
|
852 | // BUILD THE DATA | |
837 | spw_ioctl_send_CWF.dlen = BLK_NR_CWF * NB_BYTES_SWF_BLK; |
|
853 | spw_ioctl_send_CWF.dlen = BLK_NR_CWF * NB_BYTES_SWF_BLK; | |
838 |
|
854 | |||
839 | // SET PACKET SEQUENCE CONTROL |
|
855 | // SET PACKET SEQUENCE CONTROL | |
840 | increment_seq_counter_source_id( header->packetSequenceControl, sid ); |
|
856 | increment_seq_counter_source_id( header->packetSequenceControl, sid ); | |
841 |
|
857 | |||
842 | // SET SID |
|
858 | // SET SID | |
843 | header->sid = sid; |
|
859 | header->sid = sid; | |
844 |
|
860 | |||
845 | // SET PACKET TIME |
|
861 | // SET PACKET TIME | |
846 | compute_acquisition_time( coarseTime, fineTime, sid, i, header->acquisitionTime); |
|
862 | compute_acquisition_time( coarseTime, fineTime, sid, i, header->acquisitionTime); | |
847 | // |
|
863 | // | |
848 | header->time[0] = header->acquisitionTime[0]; |
|
864 | header->time[0] = header->acquisitionTime[0]; | |
849 | header->time[1] = header->acquisitionTime[1]; |
|
865 | header->time[1] = header->acquisitionTime[1]; | |
850 | header->time[2] = header->acquisitionTime[2]; |
|
866 | header->time[2] = header->acquisitionTime[2]; | |
851 | header->time[3] = header->acquisitionTime[3]; |
|
867 | header->time[3] = header->acquisitionTime[3]; | |
852 | header->time[4] = header->acquisitionTime[4]; |
|
868 | header->time[4] = header->acquisitionTime[4]; | |
853 | header->time[5] = header->acquisitionTime[5]; |
|
869 | header->time[5] = header->acquisitionTime[5]; | |
854 |
|
870 | |||
855 | // SET PACKET ID |
|
871 | // SET PACKET ID | |
856 | if ( (sid == SID_SBM1_CWF_F1) || (sid == SID_SBM2_CWF_F2) ) |
|
872 | if ( (sid == SID_SBM1_CWF_F1) || (sid == SID_SBM2_CWF_F2) ) | |
857 | { |
|
873 | { | |
858 | header->packetID[0] = (unsigned char) (APID_TM_SCIENCE_SBM1_SBM2 >> 8); |
|
874 | header->packetID[0] = (unsigned char) (APID_TM_SCIENCE_SBM1_SBM2 >> 8); | |
859 | header->packetID[1] = (unsigned char) (APID_TM_SCIENCE_SBM1_SBM2); |
|
875 | header->packetID[1] = (unsigned char) (APID_TM_SCIENCE_SBM1_SBM2); | |
860 | } |
|
876 | } | |
861 | else |
|
877 | else | |
862 | { |
|
878 | { | |
863 | header->packetID[0] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST >> 8); |
|
879 | header->packetID[0] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST >> 8); | |
864 | header->packetID[1] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST); |
|
880 | header->packetID[1] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST); | |
865 | } |
|
881 | } | |
866 |
|
882 | |||
867 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, &spw_ioctl_send_CWF ); |
|
883 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, &spw_ioctl_send_CWF ); | |
868 | if (status != RTEMS_SUCCESSFUL) { |
|
884 | if (status != RTEMS_SUCCESSFUL) { | |
869 | ret = LFR_DEFAULT; |
|
885 | ret = LFR_DEFAULT; | |
870 | } |
|
886 | } | |
871 | } |
|
887 | } | |
872 |
|
888 | |||
873 | return ret; |
|
889 | return ret; | |
874 | } |
|
890 | } | |
875 |
|
891 | |||
876 | int spw_send_waveform_SWF( ring_node *ring_node_to_send, |
|
892 | int spw_send_waveform_SWF( ring_node *ring_node_to_send, | |
877 | Header_TM_LFR_SCIENCE_SWF_t *header ) |
|
893 | Header_TM_LFR_SCIENCE_SWF_t *header ) | |
878 | { |
|
894 | { | |
879 | /** This function sends SWF CCSDS packets (F2, F1 or F0). |
|
895 | /** This function sends SWF CCSDS packets (F2, F1 or F0). | |
880 | * |
|
896 | * | |
881 | * @param waveform points to the buffer containing the data that will be send. |
|
897 | * @param waveform points to the buffer containing the data that will be send. | |
882 | * @param sid is the source identifier of the data that will be sent. |
|
898 | * @param sid is the source identifier of the data that will be sent. | |
883 | * @param headerSWF points to a table of headers that have been prepared for the data transmission. |
|
899 | * @param headerSWF points to a table of headers that have been prepared for the data transmission. | |
884 | * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures |
|
900 | * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures | |
885 | * contain information to setup the transmission of the data packets. |
|
901 | * contain information to setup the transmission of the data packets. | |
886 | * |
|
902 | * | |
887 | * One group of 2048 samples is sent as 7 consecutive packets, 6 packets containing 340 blocks and 8 packets containing 8 blocks. |
|
903 | * One group of 2048 samples is sent as 7 consecutive packets, 6 packets containing 340 blocks and 8 packets containing 8 blocks. | |
888 | * |
|
904 | * | |
889 | */ |
|
905 | */ | |
890 |
|
906 | |||
891 | unsigned int i; |
|
907 | unsigned int i; | |
892 | int ret; |
|
908 | int ret; | |
893 | unsigned int coarseTime; |
|
909 | unsigned int coarseTime; | |
894 | unsigned int fineTime; |
|
910 | unsigned int fineTime; | |
895 | rtems_status_code status; |
|
911 | rtems_status_code status; | |
896 | spw_ioctl_pkt_send spw_ioctl_send_SWF; |
|
912 | spw_ioctl_pkt_send spw_ioctl_send_SWF; | |
897 | int *dataPtr; |
|
913 | int *dataPtr; | |
898 | unsigned char sid; |
|
914 | unsigned char sid; | |
899 |
|
915 | |||
900 | spw_ioctl_send_SWF.hlen = HEADER_LENGTH_TM_LFR_SCIENCE_SWF; |
|
916 | spw_ioctl_send_SWF.hlen = HEADER_LENGTH_TM_LFR_SCIENCE_SWF; | |
901 | spw_ioctl_send_SWF.options = 0; |
|
917 | spw_ioctl_send_SWF.options = 0; | |
902 |
|
918 | |||
903 | ret = LFR_DEFAULT; |
|
919 | ret = LFR_DEFAULT; | |
904 |
|
920 | |||
905 | coarseTime = ring_node_to_send->coarseTime; |
|
921 | coarseTime = ring_node_to_send->coarseTime; | |
906 | fineTime = ring_node_to_send->fineTime; |
|
922 | fineTime = ring_node_to_send->fineTime; | |
907 | dataPtr = (int*) ring_node_to_send->buffer_address; |
|
923 | dataPtr = (int*) ring_node_to_send->buffer_address; | |
908 | sid = ring_node_to_send->sid; |
|
924 | sid = ring_node_to_send->sid; | |
909 |
|
925 | |||
910 | header->hkBIA = pa_bia_status_info; |
|
926 | header->hkBIA = pa_bia_status_info; | |
911 | header->sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters; |
|
927 | header->sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters; | |
912 |
|
928 | |||
913 | for (i=0; i<7; i++) // send waveform |
|
929 | for (i=0; i<7; i++) // send waveform | |
914 | { |
|
930 | { | |
915 | spw_ioctl_send_SWF.data = (char*) &dataPtr[ (i * BLK_NR_304 * NB_WORDS_SWF_BLK) ]; |
|
931 | spw_ioctl_send_SWF.data = (char*) &dataPtr[ (i * BLK_NR_304 * NB_WORDS_SWF_BLK) ]; | |
916 | spw_ioctl_send_SWF.hdr = (char*) header; |
|
932 | spw_ioctl_send_SWF.hdr = (char*) header; | |
917 |
|
933 | |||
918 | // SET PACKET SEQUENCE CONTROL |
|
934 | // SET PACKET SEQUENCE CONTROL | |
919 | increment_seq_counter_source_id( header->packetSequenceControl, sid ); |
|
935 | increment_seq_counter_source_id( header->packetSequenceControl, sid ); | |
920 |
|
936 | |||
921 | // SET PACKET LENGTH AND BLKNR |
|
937 | // SET PACKET LENGTH AND BLKNR | |
922 | if (i == 6) |
|
938 | if (i == 6) | |
923 | { |
|
939 | { | |
924 | spw_ioctl_send_SWF.dlen = BLK_NR_224 * NB_BYTES_SWF_BLK; |
|
940 | spw_ioctl_send_SWF.dlen = BLK_NR_224 * NB_BYTES_SWF_BLK; | |
925 | header->packetLength[0] = (unsigned char) (TM_LEN_SCI_SWF_224 >> 8); |
|
941 | header->packetLength[0] = (unsigned char) (TM_LEN_SCI_SWF_224 >> 8); | |
926 | header->packetLength[1] = (unsigned char) (TM_LEN_SCI_SWF_224 ); |
|
942 | header->packetLength[1] = (unsigned char) (TM_LEN_SCI_SWF_224 ); | |
927 | header->blkNr[0] = (unsigned char) (BLK_NR_224 >> 8); |
|
943 | header->blkNr[0] = (unsigned char) (BLK_NR_224 >> 8); | |
928 | header->blkNr[1] = (unsigned char) (BLK_NR_224 ); |
|
944 | header->blkNr[1] = (unsigned char) (BLK_NR_224 ); | |
929 | } |
|
945 | } | |
930 | else |
|
946 | else | |
931 | { |
|
947 | { | |
932 | spw_ioctl_send_SWF.dlen = BLK_NR_304 * NB_BYTES_SWF_BLK; |
|
948 | spw_ioctl_send_SWF.dlen = BLK_NR_304 * NB_BYTES_SWF_BLK; | |
933 | header->packetLength[0] = (unsigned char) (TM_LEN_SCI_SWF_304 >> 8); |
|
949 | header->packetLength[0] = (unsigned char) (TM_LEN_SCI_SWF_304 >> 8); | |
934 | header->packetLength[1] = (unsigned char) (TM_LEN_SCI_SWF_304 ); |
|
950 | header->packetLength[1] = (unsigned char) (TM_LEN_SCI_SWF_304 ); | |
935 | header->blkNr[0] = (unsigned char) (BLK_NR_304 >> 8); |
|
951 | header->blkNr[0] = (unsigned char) (BLK_NR_304 >> 8); | |
936 | header->blkNr[1] = (unsigned char) (BLK_NR_304 ); |
|
952 | header->blkNr[1] = (unsigned char) (BLK_NR_304 ); | |
937 | } |
|
953 | } | |
938 |
|
954 | |||
939 | // SET PACKET TIME |
|
955 | // SET PACKET TIME | |
940 | compute_acquisition_time( coarseTime, fineTime, sid, i, header->acquisitionTime ); |
|
956 | compute_acquisition_time( coarseTime, fineTime, sid, i, header->acquisitionTime ); | |
941 | // |
|
957 | // | |
942 | header->time[0] = header->acquisitionTime[0]; |
|
958 | header->time[0] = header->acquisitionTime[0]; | |
943 | header->time[1] = header->acquisitionTime[1]; |
|
959 | header->time[1] = header->acquisitionTime[1]; | |
944 | header->time[2] = header->acquisitionTime[2]; |
|
960 | header->time[2] = header->acquisitionTime[2]; | |
945 | header->time[3] = header->acquisitionTime[3]; |
|
961 | header->time[3] = header->acquisitionTime[3]; | |
946 | header->time[4] = header->acquisitionTime[4]; |
|
962 | header->time[4] = header->acquisitionTime[4]; | |
947 | header->time[5] = header->acquisitionTime[5]; |
|
963 | header->time[5] = header->acquisitionTime[5]; | |
948 |
|
964 | |||
949 | // SET SID |
|
965 | // SET SID | |
950 | header->sid = sid; |
|
966 | header->sid = sid; | |
951 |
|
967 | |||
952 | // SET PKTNR |
|
968 | // SET PKTNR | |
953 | header->pktNr = i+1; // PKT_NR |
|
969 | header->pktNr = i+1; // PKT_NR | |
954 |
|
970 | |||
955 | // SEND PACKET |
|
971 | // SEND PACKET | |
956 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, &spw_ioctl_send_SWF ); |
|
972 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, &spw_ioctl_send_SWF ); | |
957 | if (status != RTEMS_SUCCESSFUL) { |
|
973 | if (status != RTEMS_SUCCESSFUL) { | |
958 | ret = LFR_DEFAULT; |
|
974 | ret = LFR_DEFAULT; | |
959 | } |
|
975 | } | |
960 | } |
|
976 | } | |
961 |
|
977 | |||
962 | return ret; |
|
978 | return ret; | |
963 | } |
|
979 | } | |
964 |
|
980 | |||
965 | int spw_send_waveform_CWF3_light( ring_node *ring_node_to_send, |
|
981 | int spw_send_waveform_CWF3_light( ring_node *ring_node_to_send, | |
966 | Header_TM_LFR_SCIENCE_CWF_t *header ) |
|
982 | Header_TM_LFR_SCIENCE_CWF_t *header ) | |
967 | { |
|
983 | { | |
968 | /** This function sends CWF_F3 CCSDS packets without the b1, b2 and b3 data. |
|
984 | /** This function sends CWF_F3 CCSDS packets without the b1, b2 and b3 data. | |
969 | * |
|
985 | * | |
970 | * @param waveform points to the buffer containing the data that will be send. |
|
986 | * @param waveform points to the buffer containing the data that will be send. | |
971 | * @param headerCWF points to a table of headers that have been prepared for the data transmission. |
|
987 | * @param headerCWF points to a table of headers that have been prepared for the data transmission. | |
972 | * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures |
|
988 | * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures | |
973 | * contain information to setup the transmission of the data packets. |
|
989 | * contain information to setup the transmission of the data packets. | |
974 | * |
|
990 | * | |
975 | * By default, CWF_F3 packet are send without the b1, b2 and b3 data. This function rebuilds a data buffer |
|
991 | * By default, CWF_F3 packet are send without the b1, b2 and b3 data. This function rebuilds a data buffer | |
976 | * from the incoming data and sends it in 7 packets, 6 containing 340 blocks and 1 one containing 8 blocks. |
|
992 | * from the incoming data and sends it in 7 packets, 6 containing 340 blocks and 1 one containing 8 blocks. | |
977 | * |
|
993 | * | |
978 | */ |
|
994 | */ | |
979 |
|
995 | |||
980 | unsigned int i; |
|
996 | unsigned int i; | |
981 | int ret; |
|
997 | int ret; | |
982 | unsigned int coarseTime; |
|
998 | unsigned int coarseTime; | |
983 | unsigned int fineTime; |
|
999 | unsigned int fineTime; | |
984 | rtems_status_code status; |
|
1000 | rtems_status_code status; | |
985 | spw_ioctl_pkt_send spw_ioctl_send_CWF; |
|
1001 | spw_ioctl_pkt_send spw_ioctl_send_CWF; | |
986 | char *dataPtr; |
|
1002 | char *dataPtr; | |
987 | unsigned char sid; |
|
1003 | unsigned char sid; | |
988 |
|
1004 | |||
989 | spw_ioctl_send_CWF.hlen = HEADER_LENGTH_TM_LFR_SCIENCE_CWF; |
|
1005 | spw_ioctl_send_CWF.hlen = HEADER_LENGTH_TM_LFR_SCIENCE_CWF; | |
990 | spw_ioctl_send_CWF.options = 0; |
|
1006 | spw_ioctl_send_CWF.options = 0; | |
991 |
|
1007 | |||
992 | ret = LFR_DEFAULT; |
|
1008 | ret = LFR_DEFAULT; | |
993 | sid = ring_node_to_send->sid; |
|
1009 | sid = ring_node_to_send->sid; | |
994 |
|
1010 | |||
995 | coarseTime = ring_node_to_send->coarseTime; |
|
1011 | coarseTime = ring_node_to_send->coarseTime; | |
996 | fineTime = ring_node_to_send->fineTime; |
|
1012 | fineTime = ring_node_to_send->fineTime; | |
997 | dataPtr = (char*) ring_node_to_send->buffer_address; |
|
1013 | dataPtr = (char*) ring_node_to_send->buffer_address; | |
998 |
|
1014 | |||
999 | header->packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF_672 >> 8); |
|
1015 | header->packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF_672 >> 8); | |
1000 | header->packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF_672 ); |
|
1016 | header->packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF_672 ); | |
1001 | header->hkBIA = pa_bia_status_info; |
|
1017 | header->hkBIA = pa_bia_status_info; | |
1002 | header->sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters; |
|
1018 | header->sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters; | |
1003 | header->blkNr[0] = (unsigned char) (BLK_NR_CWF_SHORT_F3 >> 8); |
|
1019 | header->blkNr[0] = (unsigned char) (BLK_NR_CWF_SHORT_F3 >> 8); | |
1004 | header->blkNr[1] = (unsigned char) (BLK_NR_CWF_SHORT_F3 ); |
|
1020 | header->blkNr[1] = (unsigned char) (BLK_NR_CWF_SHORT_F3 ); | |
1005 |
|
1021 | |||
1006 | //********************* |
|
1022 | //********************* | |
1007 | // SEND CWF3_light DATA |
|
1023 | // SEND CWF3_light DATA | |
1008 | for (i=0; i<NB_PACKETS_PER_GROUP_OF_CWF_LIGHT; i++) // send waveform |
|
1024 | for (i=0; i<NB_PACKETS_PER_GROUP_OF_CWF_LIGHT; i++) // send waveform | |
1009 | { |
|
1025 | { | |
1010 | spw_ioctl_send_CWF.data = (char*) &dataPtr[ (i * BLK_NR_CWF_SHORT_F3 * NB_BYTES_CWF3_LIGHT_BLK) ]; |
|
1026 | spw_ioctl_send_CWF.data = (char*) &dataPtr[ (i * BLK_NR_CWF_SHORT_F3 * NB_BYTES_CWF3_LIGHT_BLK) ]; | |
1011 | spw_ioctl_send_CWF.hdr = (char*) header; |
|
1027 | spw_ioctl_send_CWF.hdr = (char*) header; | |
1012 | // BUILD THE DATA |
|
1028 | // BUILD THE DATA | |
1013 | spw_ioctl_send_CWF.dlen = BLK_NR_CWF_SHORT_F3 * NB_BYTES_CWF3_LIGHT_BLK; |
|
1029 | spw_ioctl_send_CWF.dlen = BLK_NR_CWF_SHORT_F3 * NB_BYTES_CWF3_LIGHT_BLK; | |
1014 |
|
1030 | |||
1015 | // SET PACKET SEQUENCE COUNTER |
|
1031 | // SET PACKET SEQUENCE COUNTER | |
1016 | increment_seq_counter_source_id( header->packetSequenceControl, sid ); |
|
1032 | increment_seq_counter_source_id( header->packetSequenceControl, sid ); | |
1017 |
|
1033 | |||
1018 | // SET SID |
|
1034 | // SET SID | |
1019 | header->sid = sid; |
|
1035 | header->sid = sid; | |
1020 |
|
1036 | |||
1021 | // SET PACKET TIME |
|
1037 | // SET PACKET TIME | |
1022 | compute_acquisition_time( coarseTime, fineTime, SID_NORM_CWF_F3, i, header->acquisitionTime ); |
|
1038 | compute_acquisition_time( coarseTime, fineTime, SID_NORM_CWF_F3, i, header->acquisitionTime ); | |
1023 | // |
|
1039 | // | |
1024 | header->time[0] = header->acquisitionTime[0]; |
|
1040 | header->time[0] = header->acquisitionTime[0]; | |
1025 | header->time[1] = header->acquisitionTime[1]; |
|
1041 | header->time[1] = header->acquisitionTime[1]; | |
1026 | header->time[2] = header->acquisitionTime[2]; |
|
1042 | header->time[2] = header->acquisitionTime[2]; | |
1027 | header->time[3] = header->acquisitionTime[3]; |
|
1043 | header->time[3] = header->acquisitionTime[3]; | |
1028 | header->time[4] = header->acquisitionTime[4]; |
|
1044 | header->time[4] = header->acquisitionTime[4]; | |
1029 | header->time[5] = header->acquisitionTime[5]; |
|
1045 | header->time[5] = header->acquisitionTime[5]; | |
1030 |
|
1046 | |||
1031 | // SET PACKET ID |
|
1047 | // SET PACKET ID | |
1032 | header->packetID[0] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST >> 8); |
|
1048 | header->packetID[0] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST >> 8); | |
1033 | header->packetID[1] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST); |
|
1049 | header->packetID[1] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST); | |
1034 |
|
1050 | |||
1035 | // SEND PACKET |
|
1051 | // SEND PACKET | |
1036 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, &spw_ioctl_send_CWF ); |
|
1052 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, &spw_ioctl_send_CWF ); | |
1037 | if (status != RTEMS_SUCCESSFUL) { |
|
1053 | if (status != RTEMS_SUCCESSFUL) { | |
1038 | ret = LFR_DEFAULT; |
|
1054 | ret = LFR_DEFAULT; | |
1039 | } |
|
1055 | } | |
1040 | } |
|
1056 | } | |
1041 |
|
1057 | |||
1042 | return ret; |
|
1058 | return ret; | |
1043 | } |
|
1059 | } | |
1044 |
|
1060 | |||
1045 | void spw_send_asm_f0( ring_node *ring_node_to_send, |
|
1061 | void spw_send_asm_f0( ring_node *ring_node_to_send, | |
1046 | Header_TM_LFR_SCIENCE_ASM_t *header ) |
|
1062 | Header_TM_LFR_SCIENCE_ASM_t *header ) | |
1047 | { |
|
1063 | { | |
1048 | unsigned int i; |
|
1064 | unsigned int i; | |
1049 | unsigned int length = 0; |
|
1065 | unsigned int length = 0; | |
1050 | rtems_status_code status; |
|
1066 | rtems_status_code status; | |
1051 | unsigned int sid; |
|
1067 | unsigned int sid; | |
1052 | float *spectral_matrix; |
|
1068 | float *spectral_matrix; | |
1053 | int coarseTime; |
|
1069 | int coarseTime; | |
1054 | int fineTime; |
|
1070 | int fineTime; | |
1055 | spw_ioctl_pkt_send spw_ioctl_send_ASM; |
|
1071 | spw_ioctl_pkt_send spw_ioctl_send_ASM; | |
1056 |
|
1072 | |||
1057 | sid = ring_node_to_send->sid; |
|
1073 | sid = ring_node_to_send->sid; | |
1058 | spectral_matrix = (float*) ring_node_to_send->buffer_address; |
|
1074 | spectral_matrix = (float*) ring_node_to_send->buffer_address; | |
1059 | coarseTime = ring_node_to_send->coarseTime; |
|
1075 | coarseTime = ring_node_to_send->coarseTime; | |
1060 | fineTime = ring_node_to_send->fineTime; |
|
1076 | fineTime = ring_node_to_send->fineTime; | |
1061 |
|
1077 | |||
1062 | header->biaStatusInfo = pa_bia_status_info; |
|
1078 | header->biaStatusInfo = pa_bia_status_info; | |
1063 | header->sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters; |
|
1079 | header->sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters; | |
1064 |
|
1080 | |||
1065 | for (i=0; i<3; i++) |
|
1081 | for (i=0; i<3; i++) | |
1066 | { |
|
1082 | { | |
1067 | if ((i==0) || (i==1)) |
|
1083 | if ((i==0) || (i==1)) | |
1068 | { |
|
1084 | { | |
1069 | spw_ioctl_send_ASM.dlen = DLEN_ASM_F0_PKT_1; |
|
1085 | spw_ioctl_send_ASM.dlen = DLEN_ASM_F0_PKT_1; | |
1070 | spw_ioctl_send_ASM.data = (char *) &spectral_matrix[ |
|
1086 | 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 ) |
|
1087 | ( (ASM_F0_INDICE_START + (i*NB_BINS_PER_PKT_ASM_F0_1) ) * NB_VALUES_PER_SM ) | |
1072 | ]; |
|
1088 | ]; | |
1073 | length = PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F0_1; |
|
1089 | length = PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F0_1; | |
1074 | header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE_6; |
|
1090 | header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE_6; | |
1075 | header->pa_lfr_asm_blk_nr[0] = (unsigned char) ( (NB_BINS_PER_PKT_ASM_F0_1) >> 8 ); // BLK_NR MSB |
|
1091 | header->pa_lfr_asm_blk_nr[0] = (unsigned char) ( (NB_BINS_PER_PKT_ASM_F0_1) >> 8 ); // BLK_NR MSB | |
1076 | header->pa_lfr_asm_blk_nr[1] = (unsigned char) (NB_BINS_PER_PKT_ASM_F0_1); // BLK_NR LSB |
|
1092 | header->pa_lfr_asm_blk_nr[1] = (unsigned char) (NB_BINS_PER_PKT_ASM_F0_1); // BLK_NR LSB | |
1077 | } |
|
1093 | } | |
1078 | else |
|
1094 | else | |
1079 | { |
|
1095 | { | |
1080 | spw_ioctl_send_ASM.dlen = DLEN_ASM_F0_PKT_2; |
|
1096 | spw_ioctl_send_ASM.dlen = DLEN_ASM_F0_PKT_2; | |
1081 | spw_ioctl_send_ASM.data = (char*) &spectral_matrix[ |
|
1097 | spw_ioctl_send_ASM.data = (char*) &spectral_matrix[ | |
1082 | ( (ASM_F0_INDICE_START + (i*NB_BINS_PER_PKT_ASM_F0_1) ) * NB_VALUES_PER_SM ) |
|
1098 | ( (ASM_F0_INDICE_START + (i*NB_BINS_PER_PKT_ASM_F0_1) ) * NB_VALUES_PER_SM ) | |
1083 | ]; |
|
1099 | ]; | |
1084 | length = PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F0_2; |
|
1100 | length = PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F0_2; | |
1085 | header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE_6; |
|
1101 | header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE_6; | |
1086 | header->pa_lfr_asm_blk_nr[0] = (unsigned char) ( (NB_BINS_PER_PKT_ASM_F0_2) >> 8 ); // BLK_NR MSB |
|
1102 | header->pa_lfr_asm_blk_nr[0] = (unsigned char) ( (NB_BINS_PER_PKT_ASM_F0_2) >> 8 ); // BLK_NR MSB | |
1087 | header->pa_lfr_asm_blk_nr[1] = (unsigned char) (NB_BINS_PER_PKT_ASM_F0_2); // BLK_NR LSB |
|
1103 | header->pa_lfr_asm_blk_nr[1] = (unsigned char) (NB_BINS_PER_PKT_ASM_F0_2); // BLK_NR LSB | |
1088 | } |
|
1104 | } | |
1089 |
|
1105 | |||
1090 | spw_ioctl_send_ASM.hlen = HEADER_LENGTH_TM_LFR_SCIENCE_ASM; |
|
1106 | spw_ioctl_send_ASM.hlen = HEADER_LENGTH_TM_LFR_SCIENCE_ASM; | |
1091 | spw_ioctl_send_ASM.hdr = (char *) header; |
|
1107 | spw_ioctl_send_ASM.hdr = (char *) header; | |
1092 | spw_ioctl_send_ASM.options = 0; |
|
1108 | spw_ioctl_send_ASM.options = 0; | |
1093 |
|
1109 | |||
1094 | // (2) BUILD THE HEADER |
|
1110 | // (2) BUILD THE HEADER | |
1095 | increment_seq_counter_source_id( header->packetSequenceControl, sid ); |
|
1111 | increment_seq_counter_source_id( header->packetSequenceControl, sid ); | |
1096 | header->packetLength[0] = (unsigned char) (length>>8); |
|
1112 | header->packetLength[0] = (unsigned char) (length>>8); | |
1097 | header->packetLength[1] = (unsigned char) (length); |
|
1113 | header->packetLength[1] = (unsigned char) (length); | |
1098 | header->sid = (unsigned char) sid; // SID |
|
1114 | header->sid = (unsigned char) sid; // SID | |
1099 | header->pa_lfr_pkt_cnt_asm = 3; |
|
1115 | header->pa_lfr_pkt_cnt_asm = 3; | |
1100 | header->pa_lfr_pkt_nr_asm = (unsigned char) (i+1); |
|
1116 | header->pa_lfr_pkt_nr_asm = (unsigned char) (i+1); | |
1101 |
|
1117 | |||
1102 | // (3) SET PACKET TIME |
|
1118 | // (3) SET PACKET TIME | |
1103 | header->time[0] = (unsigned char) (coarseTime>>24); |
|
1119 | header->time[0] = (unsigned char) (coarseTime>>24); | |
1104 | header->time[1] = (unsigned char) (coarseTime>>16); |
|
1120 | header->time[1] = (unsigned char) (coarseTime>>16); | |
1105 | header->time[2] = (unsigned char) (coarseTime>>8); |
|
1121 | header->time[2] = (unsigned char) (coarseTime>>8); | |
1106 | header->time[3] = (unsigned char) (coarseTime); |
|
1122 | header->time[3] = (unsigned char) (coarseTime); | |
1107 | header->time[4] = (unsigned char) (fineTime>>8); |
|
1123 | header->time[4] = (unsigned char) (fineTime>>8); | |
1108 | header->time[5] = (unsigned char) (fineTime); |
|
1124 | header->time[5] = (unsigned char) (fineTime); | |
1109 | // |
|
1125 | // | |
1110 | header->acquisitionTime[0] = header->time[0]; |
|
1126 | header->acquisitionTime[0] = header->time[0]; | |
1111 | header->acquisitionTime[1] = header->time[1]; |
|
1127 | header->acquisitionTime[1] = header->time[1]; | |
1112 | header->acquisitionTime[2] = header->time[2]; |
|
1128 | header->acquisitionTime[2] = header->time[2]; | |
1113 | header->acquisitionTime[3] = header->time[3]; |
|
1129 | header->acquisitionTime[3] = header->time[3]; | |
1114 | header->acquisitionTime[4] = header->time[4]; |
|
1130 | header->acquisitionTime[4] = header->time[4]; | |
1115 | header->acquisitionTime[5] = header->time[5]; |
|
1131 | header->acquisitionTime[5] = header->time[5]; | |
1116 |
|
1132 | |||
1117 | // (4) SEND PACKET |
|
1133 | // (4) SEND PACKET | |
1118 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, &spw_ioctl_send_ASM ); |
|
1134 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, &spw_ioctl_send_ASM ); | |
1119 | if (status != RTEMS_SUCCESSFUL) { |
|
1135 | if (status != RTEMS_SUCCESSFUL) { | |
1120 | PRINTF1("in ASM_send *** ERR %d\n", (int) status) |
|
1136 | PRINTF1("in ASM_send *** ERR %d\n", (int) status) | |
1121 | } |
|
1137 | } | |
1122 | } |
|
1138 | } | |
1123 | } |
|
1139 | } | |
1124 |
|
1140 | |||
1125 | void spw_send_asm_f1( ring_node *ring_node_to_send, |
|
1141 | void spw_send_asm_f1( ring_node *ring_node_to_send, | |
1126 | Header_TM_LFR_SCIENCE_ASM_t *header ) |
|
1142 | Header_TM_LFR_SCIENCE_ASM_t *header ) | |
1127 | { |
|
1143 | { | |
1128 | unsigned int i; |
|
1144 | unsigned int i; | |
1129 | unsigned int length = 0; |
|
1145 | unsigned int length = 0; | |
1130 | rtems_status_code status; |
|
1146 | rtems_status_code status; | |
1131 | unsigned int sid; |
|
1147 | unsigned int sid; | |
1132 | float *spectral_matrix; |
|
1148 | float *spectral_matrix; | |
1133 | int coarseTime; |
|
1149 | int coarseTime; | |
1134 | int fineTime; |
|
1150 | int fineTime; | |
1135 | spw_ioctl_pkt_send spw_ioctl_send_ASM; |
|
1151 | spw_ioctl_pkt_send spw_ioctl_send_ASM; | |
1136 |
|
1152 | |||
1137 | sid = ring_node_to_send->sid; |
|
1153 | sid = ring_node_to_send->sid; | |
1138 | spectral_matrix = (float*) ring_node_to_send->buffer_address; |
|
1154 | spectral_matrix = (float*) ring_node_to_send->buffer_address; | |
1139 | coarseTime = ring_node_to_send->coarseTime; |
|
1155 | coarseTime = ring_node_to_send->coarseTime; | |
1140 | fineTime = ring_node_to_send->fineTime; |
|
1156 | fineTime = ring_node_to_send->fineTime; | |
1141 |
|
1157 | |||
1142 | header->biaStatusInfo = pa_bia_status_info; |
|
1158 | header->biaStatusInfo = pa_bia_status_info; | |
1143 | header->sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters; |
|
1159 | header->sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters; | |
1144 |
|
1160 | |||
1145 | for (i=0; i<3; i++) |
|
1161 | for (i=0; i<3; i++) | |
1146 | { |
|
1162 | { | |
1147 | if ((i==0) || (i==1)) |
|
1163 | if ((i==0) || (i==1)) | |
1148 | { |
|
1164 | { | |
1149 | spw_ioctl_send_ASM.dlen = DLEN_ASM_F1_PKT_1; |
|
1165 | spw_ioctl_send_ASM.dlen = DLEN_ASM_F1_PKT_1; | |
1150 | spw_ioctl_send_ASM.data = (char *) &spectral_matrix[ |
|
1166 | spw_ioctl_send_ASM.data = (char *) &spectral_matrix[ | |
1151 | ( (ASM_F1_INDICE_START + (i*NB_BINS_PER_PKT_ASM_F1_1) ) * NB_VALUES_PER_SM ) |
|
1167 | ( (ASM_F1_INDICE_START + (i*NB_BINS_PER_PKT_ASM_F1_1) ) * NB_VALUES_PER_SM ) | |
1152 | ]; |
|
1168 | ]; | |
1153 | length = PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F1_1; |
|
1169 | length = PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F1_1; | |
1154 | header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE_6; |
|
1170 | header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE_6; | |
1155 | header->pa_lfr_asm_blk_nr[0] = (unsigned char) ( (NB_BINS_PER_PKT_ASM_F1_1) >> 8 ); // BLK_NR MSB |
|
1171 | header->pa_lfr_asm_blk_nr[0] = (unsigned char) ( (NB_BINS_PER_PKT_ASM_F1_1) >> 8 ); // BLK_NR MSB | |
1156 | header->pa_lfr_asm_blk_nr[1] = (unsigned char) (NB_BINS_PER_PKT_ASM_F1_1); // BLK_NR LSB |
|
1172 | header->pa_lfr_asm_blk_nr[1] = (unsigned char) (NB_BINS_PER_PKT_ASM_F1_1); // BLK_NR LSB | |
1157 | } |
|
1173 | } | |
1158 | else |
|
1174 | else | |
1159 | { |
|
1175 | { | |
1160 | spw_ioctl_send_ASM.dlen = DLEN_ASM_F1_PKT_2; |
|
1176 | spw_ioctl_send_ASM.dlen = DLEN_ASM_F1_PKT_2; | |
1161 | spw_ioctl_send_ASM.data = (char*) &spectral_matrix[ |
|
1177 | spw_ioctl_send_ASM.data = (char*) &spectral_matrix[ | |
1162 | ( (ASM_F1_INDICE_START + (i*NB_BINS_PER_PKT_ASM_F1_1) ) * NB_VALUES_PER_SM ) |
|
1178 | ( (ASM_F1_INDICE_START + (i*NB_BINS_PER_PKT_ASM_F1_1) ) * NB_VALUES_PER_SM ) | |
1163 | ]; |
|
1179 | ]; | |
1164 | length = PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F1_2; |
|
1180 | length = PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F1_2; | |
1165 | header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE_6; |
|
1181 | header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE_6; | |
1166 | header->pa_lfr_asm_blk_nr[0] = (unsigned char) ( (NB_BINS_PER_PKT_ASM_F1_2) >> 8 ); // BLK_NR MSB |
|
1182 | header->pa_lfr_asm_blk_nr[0] = (unsigned char) ( (NB_BINS_PER_PKT_ASM_F1_2) >> 8 ); // BLK_NR MSB | |
1167 | header->pa_lfr_asm_blk_nr[1] = (unsigned char) (NB_BINS_PER_PKT_ASM_F1_2); // BLK_NR LSB |
|
1183 | header->pa_lfr_asm_blk_nr[1] = (unsigned char) (NB_BINS_PER_PKT_ASM_F1_2); // BLK_NR LSB | |
1168 | } |
|
1184 | } | |
1169 |
|
1185 | |||
1170 | spw_ioctl_send_ASM.hlen = HEADER_LENGTH_TM_LFR_SCIENCE_ASM; |
|
1186 | spw_ioctl_send_ASM.hlen = HEADER_LENGTH_TM_LFR_SCIENCE_ASM; | |
1171 | spw_ioctl_send_ASM.hdr = (char *) header; |
|
1187 | spw_ioctl_send_ASM.hdr = (char *) header; | |
1172 | spw_ioctl_send_ASM.options = 0; |
|
1188 | spw_ioctl_send_ASM.options = 0; | |
1173 |
|
1189 | |||
1174 | // (2) BUILD THE HEADER |
|
1190 | // (2) BUILD THE HEADER | |
1175 | increment_seq_counter_source_id( header->packetSequenceControl, sid ); |
|
1191 | increment_seq_counter_source_id( header->packetSequenceControl, sid ); | |
1176 | header->packetLength[0] = (unsigned char) (length>>8); |
|
1192 | header->packetLength[0] = (unsigned char) (length>>8); | |
1177 | header->packetLength[1] = (unsigned char) (length); |
|
1193 | header->packetLength[1] = (unsigned char) (length); | |
1178 | header->sid = (unsigned char) sid; // SID |
|
1194 | header->sid = (unsigned char) sid; // SID | |
1179 | header->pa_lfr_pkt_cnt_asm = 3; |
|
1195 | header->pa_lfr_pkt_cnt_asm = 3; | |
1180 | header->pa_lfr_pkt_nr_asm = (unsigned char) (i+1); |
|
1196 | header->pa_lfr_pkt_nr_asm = (unsigned char) (i+1); | |
1181 |
|
1197 | |||
1182 | // (3) SET PACKET TIME |
|
1198 | // (3) SET PACKET TIME | |
1183 | header->time[0] = (unsigned char) (coarseTime>>24); |
|
1199 | header->time[0] = (unsigned char) (coarseTime>>24); | |
1184 | header->time[1] = (unsigned char) (coarseTime>>16); |
|
1200 | header->time[1] = (unsigned char) (coarseTime>>16); | |
1185 | header->time[2] = (unsigned char) (coarseTime>>8); |
|
1201 | header->time[2] = (unsigned char) (coarseTime>>8); | |
1186 | header->time[3] = (unsigned char) (coarseTime); |
|
1202 | header->time[3] = (unsigned char) (coarseTime); | |
1187 | header->time[4] = (unsigned char) (fineTime>>8); |
|
1203 | header->time[4] = (unsigned char) (fineTime>>8); | |
1188 | header->time[5] = (unsigned char) (fineTime); |
|
1204 | header->time[5] = (unsigned char) (fineTime); | |
1189 | // |
|
1205 | // | |
1190 | header->acquisitionTime[0] = header->time[0]; |
|
1206 | header->acquisitionTime[0] = header->time[0]; | |
1191 | header->acquisitionTime[1] = header->time[1]; |
|
1207 | header->acquisitionTime[1] = header->time[1]; | |
1192 | header->acquisitionTime[2] = header->time[2]; |
|
1208 | header->acquisitionTime[2] = header->time[2]; | |
1193 | header->acquisitionTime[3] = header->time[3]; |
|
1209 | header->acquisitionTime[3] = header->time[3]; | |
1194 | header->acquisitionTime[4] = header->time[4]; |
|
1210 | header->acquisitionTime[4] = header->time[4]; | |
1195 | header->acquisitionTime[5] = header->time[5]; |
|
1211 | header->acquisitionTime[5] = header->time[5]; | |
1196 |
|
1212 | |||
1197 | // (4) SEND PACKET |
|
1213 | // (4) SEND PACKET | |
1198 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, &spw_ioctl_send_ASM ); |
|
1214 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, &spw_ioctl_send_ASM ); | |
1199 | if (status != RTEMS_SUCCESSFUL) { |
|
1215 | if (status != RTEMS_SUCCESSFUL) { | |
1200 | PRINTF1("in ASM_send *** ERR %d\n", (int) status) |
|
1216 | PRINTF1("in ASM_send *** ERR %d\n", (int) status) | |
1201 | } |
|
1217 | } | |
1202 | } |
|
1218 | } | |
1203 | } |
|
1219 | } | |
1204 |
|
1220 | |||
1205 | void spw_send_asm_f2( ring_node *ring_node_to_send, |
|
1221 | void spw_send_asm_f2( ring_node *ring_node_to_send, | |
1206 | Header_TM_LFR_SCIENCE_ASM_t *header ) |
|
1222 | Header_TM_LFR_SCIENCE_ASM_t *header ) | |
1207 | { |
|
1223 | { | |
1208 | unsigned int i; |
|
1224 | unsigned int i; | |
1209 | unsigned int length = 0; |
|
1225 | unsigned int length = 0; | |
1210 | rtems_status_code status; |
|
1226 | rtems_status_code status; | |
1211 | unsigned int sid; |
|
1227 | unsigned int sid; | |
1212 | float *spectral_matrix; |
|
1228 | float *spectral_matrix; | |
1213 | int coarseTime; |
|
1229 | int coarseTime; | |
1214 | int fineTime; |
|
1230 | int fineTime; | |
1215 | spw_ioctl_pkt_send spw_ioctl_send_ASM; |
|
1231 | spw_ioctl_pkt_send spw_ioctl_send_ASM; | |
1216 |
|
1232 | |||
1217 | sid = ring_node_to_send->sid; |
|
1233 | sid = ring_node_to_send->sid; | |
1218 | spectral_matrix = (float*) ring_node_to_send->buffer_address; |
|
1234 | spectral_matrix = (float*) ring_node_to_send->buffer_address; | |
1219 | coarseTime = ring_node_to_send->coarseTime; |
|
1235 | coarseTime = ring_node_to_send->coarseTime; | |
1220 | fineTime = ring_node_to_send->fineTime; |
|
1236 | fineTime = ring_node_to_send->fineTime; | |
1221 |
|
1237 | |||
1222 | header->biaStatusInfo = pa_bia_status_info; |
|
1238 | header->biaStatusInfo = pa_bia_status_info; | |
1223 | header->sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters; |
|
1239 | header->sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters; | |
1224 |
|
1240 | |||
1225 | for (i=0; i<3; i++) |
|
1241 | for (i=0; i<3; i++) | |
1226 | { |
|
1242 | { | |
1227 |
|
1243 | |||
1228 | spw_ioctl_send_ASM.dlen = DLEN_ASM_F2_PKT; |
|
1244 | spw_ioctl_send_ASM.dlen = DLEN_ASM_F2_PKT; | |
1229 | spw_ioctl_send_ASM.data = (char *) &spectral_matrix[ |
|
1245 | spw_ioctl_send_ASM.data = (char *) &spectral_matrix[ | |
1230 | ( (ASM_F2_INDICE_START + (i*NB_BINS_PER_PKT_ASM_F2) ) * NB_VALUES_PER_SM ) |
|
1246 | ( (ASM_F2_INDICE_START + (i*NB_BINS_PER_PKT_ASM_F2) ) * NB_VALUES_PER_SM ) | |
1231 | ]; |
|
1247 | ]; | |
1232 | length = PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F2; |
|
1248 | length = PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F2; | |
1233 | header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE_3; |
|
1249 | header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE_3; | |
1234 | header->pa_lfr_asm_blk_nr[0] = (unsigned char) ( (NB_BINS_PER_PKT_ASM_F2) >> 8 ); // BLK_NR MSB |
|
1250 | header->pa_lfr_asm_blk_nr[0] = (unsigned char) ( (NB_BINS_PER_PKT_ASM_F2) >> 8 ); // BLK_NR MSB | |
1235 | header->pa_lfr_asm_blk_nr[1] = (unsigned char) (NB_BINS_PER_PKT_ASM_F2); // BLK_NR LSB |
|
1251 | header->pa_lfr_asm_blk_nr[1] = (unsigned char) (NB_BINS_PER_PKT_ASM_F2); // BLK_NR LSB | |
1236 |
|
1252 | |||
1237 | spw_ioctl_send_ASM.hlen = HEADER_LENGTH_TM_LFR_SCIENCE_ASM; |
|
1253 | spw_ioctl_send_ASM.hlen = HEADER_LENGTH_TM_LFR_SCIENCE_ASM; | |
1238 | spw_ioctl_send_ASM.hdr = (char *) header; |
|
1254 | spw_ioctl_send_ASM.hdr = (char *) header; | |
1239 | spw_ioctl_send_ASM.options = 0; |
|
1255 | spw_ioctl_send_ASM.options = 0; | |
1240 |
|
1256 | |||
1241 | // (2) BUILD THE HEADER |
|
1257 | // (2) BUILD THE HEADER | |
1242 | increment_seq_counter_source_id( header->packetSequenceControl, sid ); |
|
1258 | increment_seq_counter_source_id( header->packetSequenceControl, sid ); | |
1243 | header->packetLength[0] = (unsigned char) (length>>8); |
|
1259 | header->packetLength[0] = (unsigned char) (length>>8); | |
1244 | header->packetLength[1] = (unsigned char) (length); |
|
1260 | header->packetLength[1] = (unsigned char) (length); | |
1245 | header->sid = (unsigned char) sid; // SID |
|
1261 | header->sid = (unsigned char) sid; // SID | |
1246 | header->pa_lfr_pkt_cnt_asm = 3; |
|
1262 | header->pa_lfr_pkt_cnt_asm = 3; | |
1247 | header->pa_lfr_pkt_nr_asm = (unsigned char) (i+1); |
|
1263 | header->pa_lfr_pkt_nr_asm = (unsigned char) (i+1); | |
1248 |
|
1264 | |||
1249 | // (3) SET PACKET TIME |
|
1265 | // (3) SET PACKET TIME | |
1250 | header->time[0] = (unsigned char) (coarseTime>>24); |
|
1266 | header->time[0] = (unsigned char) (coarseTime>>24); | |
1251 | header->time[1] = (unsigned char) (coarseTime>>16); |
|
1267 | header->time[1] = (unsigned char) (coarseTime>>16); | |
1252 | header->time[2] = (unsigned char) (coarseTime>>8); |
|
1268 | header->time[2] = (unsigned char) (coarseTime>>8); | |
1253 | header->time[3] = (unsigned char) (coarseTime); |
|
1269 | header->time[3] = (unsigned char) (coarseTime); | |
1254 | header->time[4] = (unsigned char) (fineTime>>8); |
|
1270 | header->time[4] = (unsigned char) (fineTime>>8); | |
1255 | header->time[5] = (unsigned char) (fineTime); |
|
1271 | header->time[5] = (unsigned char) (fineTime); | |
1256 | // |
|
1272 | // | |
1257 | header->acquisitionTime[0] = header->time[0]; |
|
1273 | header->acquisitionTime[0] = header->time[0]; | |
1258 | header->acquisitionTime[1] = header->time[1]; |
|
1274 | header->acquisitionTime[1] = header->time[1]; | |
1259 | header->acquisitionTime[2] = header->time[2]; |
|
1275 | header->acquisitionTime[2] = header->time[2]; | |
1260 | header->acquisitionTime[3] = header->time[3]; |
|
1276 | header->acquisitionTime[3] = header->time[3]; | |
1261 | header->acquisitionTime[4] = header->time[4]; |
|
1277 | header->acquisitionTime[4] = header->time[4]; | |
1262 | header->acquisitionTime[5] = header->time[5]; |
|
1278 | header->acquisitionTime[5] = header->time[5]; | |
1263 |
|
1279 | |||
1264 | // (4) SEND PACKET |
|
1280 | // (4) SEND PACKET | |
1265 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, &spw_ioctl_send_ASM ); |
|
1281 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, &spw_ioctl_send_ASM ); | |
1266 | if (status != RTEMS_SUCCESSFUL) { |
|
1282 | if (status != RTEMS_SUCCESSFUL) { | |
1267 | PRINTF1("in ASM_send *** ERR %d\n", (int) status) |
|
1283 | PRINTF1("in ASM_send *** ERR %d\n", (int) status) | |
1268 | } |
|
1284 | } | |
1269 | } |
|
1285 | } | |
1270 | } |
|
1286 | } | |
1271 |
|
1287 | |||
1272 | void spw_send_k_dump( ring_node *ring_node_to_send ) |
|
1288 | void spw_send_k_dump( ring_node *ring_node_to_send ) | |
1273 | { |
|
1289 | { | |
1274 | rtems_status_code status; |
|
1290 | rtems_status_code status; | |
1275 | Packet_TM_LFR_KCOEFFICIENTS_DUMP_t *kcoefficients_dump; |
|
1291 | Packet_TM_LFR_KCOEFFICIENTS_DUMP_t *kcoefficients_dump; | |
1276 | unsigned int packetLength; |
|
1292 | unsigned int packetLength; | |
1277 | unsigned int size; |
|
1293 | unsigned int size; | |
1278 |
|
1294 | |||
1279 | PRINTF("spw_send_k_dump\n") |
|
1295 | PRINTF("spw_send_k_dump\n") | |
1280 |
|
1296 | |||
1281 | kcoefficients_dump = (Packet_TM_LFR_KCOEFFICIENTS_DUMP_t *) ring_node_to_send->buffer_address; |
|
1297 | kcoefficients_dump = (Packet_TM_LFR_KCOEFFICIENTS_DUMP_t *) ring_node_to_send->buffer_address; | |
1282 |
|
1298 | |||
1283 | packetLength = kcoefficients_dump->packetLength[0] * 256 + kcoefficients_dump->packetLength[1]; |
|
1299 | packetLength = kcoefficients_dump->packetLength[0] * 256 + kcoefficients_dump->packetLength[1]; | |
1284 |
|
1300 | |||
1285 | size = packetLength + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES; |
|
1301 | size = packetLength + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES; | |
1286 |
|
1302 | |||
1287 | PRINTF2("packetLength %d, size %d\n", packetLength, size ) |
|
1303 | PRINTF2("packetLength %d, size %d\n", packetLength, size ) | |
1288 |
|
1304 | |||
1289 | status = write( fdSPW, (char *) ring_node_to_send->buffer_address, size ); |
|
1305 | status = write( fdSPW, (char *) ring_node_to_send->buffer_address, size ); | |
1290 |
|
1306 | |||
1291 | if (status == -1){ |
|
1307 | if (status == -1){ | |
1292 | PRINTF2("in SEND *** (2.a) ERRNO = %d, size = %d\n", errno, size) |
|
1308 | PRINTF2("in SEND *** (2.a) ERRNO = %d, size = %d\n", errno, size) | |
1293 | } |
|
1309 | } | |
1294 |
|
1310 | |||
1295 | ring_node_to_send->status = 0x00; |
|
1311 | ring_node_to_send->status = 0x00; | |
1296 | } |
|
1312 | } |
@@ -1,671 +1,669 | |||||
1 | /** Functions related to data processing. |
|
1 | /** Functions related to data processing. | |
2 | * |
|
2 | * | |
3 | * @file |
|
3 | * @file | |
4 | * @author P. LEROY |
|
4 | * @author P. LEROY | |
5 | * |
|
5 | * | |
6 | * These function are related to data processing, i.e. spectral matrices averaging and basic parameters computation. |
|
6 | * These function are related to data processing, i.e. spectral matrices averaging and basic parameters computation. | |
7 | * |
|
7 | * | |
8 | */ |
|
8 | */ | |
9 |
|
9 | |||
10 | #include "fsw_processing.h" |
|
10 | #include "fsw_processing.h" | |
11 | #include "fsw_processing_globals.c" |
|
11 | #include "fsw_processing_globals.c" | |
12 | #include "fsw_init.h" |
|
12 | #include "fsw_init.h" | |
13 |
|
13 | |||
14 | unsigned int nb_sm_f0; |
|
14 | unsigned int nb_sm_f0; | |
15 | unsigned int nb_sm_f0_aux_f1; |
|
15 | unsigned int nb_sm_f0_aux_f1; | |
16 | unsigned int nb_sm_f1; |
|
16 | unsigned int nb_sm_f1; | |
17 | unsigned int nb_sm_f0_aux_f2; |
|
17 | unsigned int nb_sm_f0_aux_f2; | |
18 |
|
18 | |||
19 | //************************ |
|
19 | //************************ | |
20 | // spectral matrices rings |
|
20 | // spectral matrices rings | |
21 | ring_node sm_ring_f0[ NB_RING_NODES_SM_F0 ]; |
|
21 | ring_node sm_ring_f0[ NB_RING_NODES_SM_F0 ]; | |
22 | ring_node sm_ring_f1[ NB_RING_NODES_SM_F1 ]; |
|
22 | ring_node sm_ring_f1[ NB_RING_NODES_SM_F1 ]; | |
23 | ring_node sm_ring_f2[ NB_RING_NODES_SM_F2 ]; |
|
23 | ring_node sm_ring_f2[ NB_RING_NODES_SM_F2 ]; | |
24 | ring_node *current_ring_node_sm_f0; |
|
24 | ring_node *current_ring_node_sm_f0; | |
25 | ring_node *current_ring_node_sm_f1; |
|
25 | ring_node *current_ring_node_sm_f1; | |
26 | ring_node *current_ring_node_sm_f2; |
|
26 | ring_node *current_ring_node_sm_f2; | |
27 | ring_node *ring_node_for_averaging_sm_f0; |
|
27 | ring_node *ring_node_for_averaging_sm_f0; | |
28 | ring_node *ring_node_for_averaging_sm_f1; |
|
28 | ring_node *ring_node_for_averaging_sm_f1; | |
29 | ring_node *ring_node_for_averaging_sm_f2; |
|
29 | ring_node *ring_node_for_averaging_sm_f2; | |
30 |
|
30 | |||
31 | // |
|
31 | // | |
32 | ring_node * getRingNodeForAveraging( unsigned char frequencyChannel) |
|
32 | ring_node * getRingNodeForAveraging( unsigned char frequencyChannel) | |
33 | { |
|
33 | { | |
34 | ring_node *node; |
|
34 | ring_node *node; | |
35 |
|
35 | |||
36 | node = NULL; |
|
36 | node = NULL; | |
37 | switch ( frequencyChannel ) { |
|
37 | switch ( frequencyChannel ) { | |
38 | case 0: |
|
38 | case 0: | |
39 | node = ring_node_for_averaging_sm_f0; |
|
39 | node = ring_node_for_averaging_sm_f0; | |
40 | break; |
|
40 | break; | |
41 | case 1: |
|
41 | case 1: | |
42 | node = ring_node_for_averaging_sm_f1; |
|
42 | node = ring_node_for_averaging_sm_f1; | |
43 | break; |
|
43 | break; | |
44 | case 2: |
|
44 | case 2: | |
45 | node = ring_node_for_averaging_sm_f2; |
|
45 | node = ring_node_for_averaging_sm_f2; | |
46 | break; |
|
46 | break; | |
47 | default: |
|
47 | default: | |
48 | break; |
|
48 | break; | |
49 | } |
|
49 | } | |
50 |
|
50 | |||
51 | return node; |
|
51 | return node; | |
52 | } |
|
52 | } | |
53 |
|
53 | |||
54 | //*********************************************************** |
|
54 | //*********************************************************** | |
55 | // Interrupt Service Routine for spectral matrices processing |
|
55 | // Interrupt Service Routine for spectral matrices processing | |
56 |
|
56 | |||
57 | void spectral_matrices_isr_f0( unsigned char statusReg ) |
|
57 | void spectral_matrices_isr_f0( unsigned char statusReg ) | |
58 | { |
|
58 | { | |
59 | unsigned char status; |
|
59 | unsigned char status; | |
60 | rtems_status_code status_code; |
|
60 | rtems_status_code status_code; | |
61 | ring_node *full_ring_node; |
|
61 | ring_node *full_ring_node; | |
62 |
|
62 | |||
63 | status = statusReg & 0x03; // [0011] get the status_ready_matrix_f0_x bits |
|
63 | status = statusReg & 0x03; // [0011] get the status_ready_matrix_f0_x bits | |
64 |
|
64 | |||
65 | switch(status) |
|
65 | switch(status) | |
66 | { |
|
66 | { | |
67 | case 0: |
|
67 | case 0: | |
68 | break; |
|
68 | break; | |
69 | case 3: |
|
69 | case 3: | |
70 | // UNEXPECTED VALUE |
|
70 | // UNEXPECTED VALUE | |
71 | spectral_matrix_regs->status = 0x03; // [0011] |
|
71 | spectral_matrix_regs->status = 0x03; // [0011] | |
72 | status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_11 ); |
|
72 | status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_11 ); | |
73 | break; |
|
73 | break; | |
74 | case 1: |
|
74 | case 1: | |
75 | full_ring_node = current_ring_node_sm_f0->previous; |
|
75 | full_ring_node = current_ring_node_sm_f0->previous; | |
76 | full_ring_node->coarseTime = spectral_matrix_regs->f0_0_coarse_time; |
|
76 | full_ring_node->coarseTime = spectral_matrix_regs->f0_0_coarse_time; | |
77 | full_ring_node->fineTime = spectral_matrix_regs->f0_0_fine_time; |
|
77 | full_ring_node->fineTime = spectral_matrix_regs->f0_0_fine_time; | |
78 | current_ring_node_sm_f0 = current_ring_node_sm_f0->next; |
|
78 | current_ring_node_sm_f0 = current_ring_node_sm_f0->next; | |
79 | spectral_matrix_regs->f0_0_address = current_ring_node_sm_f0->buffer_address; |
|
79 | spectral_matrix_regs->f0_0_address = current_ring_node_sm_f0->buffer_address; | |
80 | // if there are enough ring nodes ready, wake up an AVFx task |
|
80 | // if there are enough ring nodes ready, wake up an AVFx task | |
81 | nb_sm_f0 = nb_sm_f0 + 1; |
|
81 | nb_sm_f0 = nb_sm_f0 + 1; | |
82 | if (nb_sm_f0 == NB_SM_BEFORE_AVF0) |
|
82 | if (nb_sm_f0 == NB_SM_BEFORE_AVF0) | |
83 | { |
|
83 | { | |
84 | ring_node_for_averaging_sm_f0 = full_ring_node; |
|
84 | ring_node_for_averaging_sm_f0 = full_ring_node; | |
85 | if (rtems_event_send( Task_id[TASKID_AVF0], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) |
|
85 | if (rtems_event_send( Task_id[TASKID_AVF0], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) | |
86 | { |
|
86 | { | |
87 | status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 ); |
|
87 | status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 ); | |
88 | } |
|
88 | } | |
89 | nb_sm_f0 = 0; |
|
89 | nb_sm_f0 = 0; | |
90 | } |
|
90 | } | |
91 | spectral_matrix_regs->status = 0x01; // [0000 0001] |
|
91 | spectral_matrix_regs->status = 0x01; // [0000 0001] | |
92 | break; |
|
92 | break; | |
93 | case 2: |
|
93 | case 2: | |
94 | full_ring_node = current_ring_node_sm_f0->previous; |
|
94 | full_ring_node = current_ring_node_sm_f0->previous; | |
95 | full_ring_node->coarseTime = spectral_matrix_regs->f0_1_coarse_time; |
|
95 | full_ring_node->coarseTime = spectral_matrix_regs->f0_1_coarse_time; | |
96 | full_ring_node->fineTime = spectral_matrix_regs->f0_1_fine_time; |
|
96 | full_ring_node->fineTime = spectral_matrix_regs->f0_1_fine_time; | |
97 | current_ring_node_sm_f0 = current_ring_node_sm_f0->next; |
|
97 | current_ring_node_sm_f0 = current_ring_node_sm_f0->next; | |
98 | spectral_matrix_regs->f0_1_address = current_ring_node_sm_f0->buffer_address; |
|
98 | spectral_matrix_regs->f0_1_address = current_ring_node_sm_f0->buffer_address; | |
99 | // if there are enough ring nodes ready, wake up an AVFx task |
|
99 | // if there are enough ring nodes ready, wake up an AVFx task | |
100 | nb_sm_f0 = nb_sm_f0 + 1; |
|
100 | nb_sm_f0 = nb_sm_f0 + 1; | |
101 | if (nb_sm_f0 == NB_SM_BEFORE_AVF0) |
|
101 | if (nb_sm_f0 == NB_SM_BEFORE_AVF0) | |
102 | { |
|
102 | { | |
103 | ring_node_for_averaging_sm_f0 = full_ring_node; |
|
103 | ring_node_for_averaging_sm_f0 = full_ring_node; | |
104 | if (rtems_event_send( Task_id[TASKID_AVF0], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) |
|
104 | if (rtems_event_send( Task_id[TASKID_AVF0], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) | |
105 | { |
|
105 | { | |
106 | status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 ); |
|
106 | status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 ); | |
107 | } |
|
107 | } | |
108 | nb_sm_f0 = 0; |
|
108 | nb_sm_f0 = 0; | |
109 | } |
|
109 | } | |
110 | spectral_matrix_regs->status = 0x02; // [0000 0010] |
|
110 | spectral_matrix_regs->status = 0x02; // [0000 0010] | |
111 | break; |
|
111 | break; | |
112 | } |
|
112 | } | |
113 | } |
|
113 | } | |
114 |
|
114 | |||
115 | void spectral_matrices_isr_f1( unsigned char statusReg ) |
|
115 | void spectral_matrices_isr_f1( unsigned char statusReg ) | |
116 | { |
|
116 | { | |
117 | rtems_status_code status_code; |
|
117 | rtems_status_code status_code; | |
118 | unsigned char status; |
|
118 | unsigned char status; | |
119 | ring_node *full_ring_node; |
|
119 | ring_node *full_ring_node; | |
120 |
|
120 | |||
121 | status = (statusReg & 0x0c) >> 2; // [1100] get the status_ready_matrix_f0_x bits |
|
121 | status = (statusReg & 0x0c) >> 2; // [1100] get the status_ready_matrix_f0_x bits | |
122 |
|
122 | |||
123 | switch(status) |
|
123 | switch(status) | |
124 | { |
|
124 | { | |
125 | case 0: |
|
125 | case 0: | |
126 | break; |
|
126 | break; | |
127 | case 3: |
|
127 | case 3: | |
128 | // UNEXPECTED VALUE |
|
128 | // UNEXPECTED VALUE | |
129 | spectral_matrix_regs->status = 0xc0; // [1100] |
|
129 | spectral_matrix_regs->status = 0xc0; // [1100] | |
130 | status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_11 ); |
|
130 | status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_11 ); | |
131 | break; |
|
131 | break; | |
132 | case 1: |
|
132 | case 1: | |
133 | full_ring_node = current_ring_node_sm_f1->previous; |
|
133 | full_ring_node = current_ring_node_sm_f1->previous; | |
134 | full_ring_node->coarseTime = spectral_matrix_regs->f1_0_coarse_time; |
|
134 | full_ring_node->coarseTime = spectral_matrix_regs->f1_0_coarse_time; | |
135 | full_ring_node->fineTime = spectral_matrix_regs->f1_0_fine_time; |
|
135 | full_ring_node->fineTime = spectral_matrix_regs->f1_0_fine_time; | |
136 | current_ring_node_sm_f1 = current_ring_node_sm_f1->next; |
|
136 | current_ring_node_sm_f1 = current_ring_node_sm_f1->next; | |
137 | spectral_matrix_regs->f1_0_address = current_ring_node_sm_f1->buffer_address; |
|
137 | spectral_matrix_regs->f1_0_address = current_ring_node_sm_f1->buffer_address; | |
138 | // if there are enough ring nodes ready, wake up an AVFx task |
|
138 | // if there are enough ring nodes ready, wake up an AVFx task | |
139 | nb_sm_f1 = nb_sm_f1 + 1; |
|
139 | nb_sm_f1 = nb_sm_f1 + 1; | |
140 | if (nb_sm_f1 == NB_SM_BEFORE_AVF1) |
|
140 | if (nb_sm_f1 == NB_SM_BEFORE_AVF1) | |
141 | { |
|
141 | { | |
142 | ring_node_for_averaging_sm_f1 = full_ring_node; |
|
142 | ring_node_for_averaging_sm_f1 = full_ring_node; | |
143 | if (rtems_event_send( Task_id[TASKID_AVF1], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) |
|
143 | if (rtems_event_send( Task_id[TASKID_AVF1], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) | |
144 | { |
|
144 | { | |
145 | status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 ); |
|
145 | status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 ); | |
146 | } |
|
146 | } | |
147 | nb_sm_f1 = 0; |
|
147 | nb_sm_f1 = 0; | |
148 | } |
|
148 | } | |
149 | spectral_matrix_regs->status = 0x04; // [0000 0100] |
|
149 | spectral_matrix_regs->status = 0x04; // [0000 0100] | |
150 | break; |
|
150 | break; | |
151 | case 2: |
|
151 | case 2: | |
152 | full_ring_node = current_ring_node_sm_f1->previous; |
|
152 | full_ring_node = current_ring_node_sm_f1->previous; | |
153 | full_ring_node->coarseTime = spectral_matrix_regs->f1_1_coarse_time; |
|
153 | full_ring_node->coarseTime = spectral_matrix_regs->f1_1_coarse_time; | |
154 | full_ring_node->fineTime = spectral_matrix_regs->f1_1_fine_time; |
|
154 | full_ring_node->fineTime = spectral_matrix_regs->f1_1_fine_time; | |
155 | current_ring_node_sm_f1 = current_ring_node_sm_f1->next; |
|
155 | current_ring_node_sm_f1 = current_ring_node_sm_f1->next; | |
156 | spectral_matrix_regs->f1_1_address = current_ring_node_sm_f1->buffer_address; |
|
156 | spectral_matrix_regs->f1_1_address = current_ring_node_sm_f1->buffer_address; | |
157 | // if there are enough ring nodes ready, wake up an AVFx task |
|
157 | // if there are enough ring nodes ready, wake up an AVFx task | |
158 | nb_sm_f1 = nb_sm_f1 + 1; |
|
158 | nb_sm_f1 = nb_sm_f1 + 1; | |
159 | if (nb_sm_f1 == NB_SM_BEFORE_AVF1) |
|
159 | if (nb_sm_f1 == NB_SM_BEFORE_AVF1) | |
160 | { |
|
160 | { | |
161 | ring_node_for_averaging_sm_f1 = full_ring_node; |
|
161 | ring_node_for_averaging_sm_f1 = full_ring_node; | |
162 | if (rtems_event_send( Task_id[TASKID_AVF1], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) |
|
162 | if (rtems_event_send( Task_id[TASKID_AVF1], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) | |
163 | { |
|
163 | { | |
164 | status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 ); |
|
164 | status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 ); | |
165 | } |
|
165 | } | |
166 | nb_sm_f1 = 0; |
|
166 | nb_sm_f1 = 0; | |
167 | } |
|
167 | } | |
168 | spectral_matrix_regs->status = 0x08; // [1000 0000] |
|
168 | spectral_matrix_regs->status = 0x08; // [1000 0000] | |
169 | break; |
|
169 | break; | |
170 | } |
|
170 | } | |
171 | } |
|
171 | } | |
172 |
|
172 | |||
173 | void spectral_matrices_isr_f2( unsigned char statusReg ) |
|
173 | void spectral_matrices_isr_f2( unsigned char statusReg ) | |
174 | { |
|
174 | { | |
175 | unsigned char status; |
|
175 | unsigned char status; | |
176 | rtems_status_code status_code; |
|
176 | rtems_status_code status_code; | |
177 |
|
177 | |||
178 | status = (statusReg & 0x30) >> 4; // [0011 0000] get the status_ready_matrix_f0_x bits |
|
178 | status = (statusReg & 0x30) >> 4; // [0011 0000] get the status_ready_matrix_f0_x bits | |
179 |
|
179 | |||
180 | switch(status) |
|
180 | switch(status) | |
181 | { |
|
181 | { | |
182 | case 0: |
|
182 | case 0: | |
183 | break; |
|
183 | break; | |
184 | case 3: |
|
184 | case 3: | |
185 | // UNEXPECTED VALUE |
|
185 | // UNEXPECTED VALUE | |
186 | spectral_matrix_regs->status = 0x30; // [0011 0000] |
|
186 | spectral_matrix_regs->status = 0x30; // [0011 0000] | |
187 | status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_11 ); |
|
187 | status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_11 ); | |
188 | break; |
|
188 | break; | |
189 | case 1: |
|
189 | case 1: | |
190 | ring_node_for_averaging_sm_f2 = current_ring_node_sm_f2->previous; |
|
190 | ring_node_for_averaging_sm_f2 = current_ring_node_sm_f2->previous; | |
191 | current_ring_node_sm_f2 = current_ring_node_sm_f2->next; |
|
191 | current_ring_node_sm_f2 = current_ring_node_sm_f2->next; | |
192 | ring_node_for_averaging_sm_f2->coarseTime = spectral_matrix_regs->f2_0_coarse_time; |
|
192 | ring_node_for_averaging_sm_f2->coarseTime = spectral_matrix_regs->f2_0_coarse_time; | |
193 | ring_node_for_averaging_sm_f2->fineTime = spectral_matrix_regs->f2_0_fine_time; |
|
193 | ring_node_for_averaging_sm_f2->fineTime = spectral_matrix_regs->f2_0_fine_time; | |
194 | spectral_matrix_regs->f2_0_address = current_ring_node_sm_f2->buffer_address; |
|
194 | spectral_matrix_regs->f2_0_address = current_ring_node_sm_f2->buffer_address; | |
195 | spectral_matrix_regs->status = 0x10; // [0001 0000] |
|
195 | spectral_matrix_regs->status = 0x10; // [0001 0000] | |
196 | if (rtems_event_send( Task_id[TASKID_AVF2], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) |
|
196 | if (rtems_event_send( Task_id[TASKID_AVF2], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) | |
197 | { |
|
197 | { | |
198 | status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 ); |
|
198 | status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 ); | |
199 | } |
|
199 | } | |
200 | break; |
|
200 | break; | |
201 | case 2: |
|
201 | case 2: | |
202 | ring_node_for_averaging_sm_f2 = current_ring_node_sm_f2->previous; |
|
202 | ring_node_for_averaging_sm_f2 = current_ring_node_sm_f2->previous; | |
203 | current_ring_node_sm_f2 = current_ring_node_sm_f2->next; |
|
203 | current_ring_node_sm_f2 = current_ring_node_sm_f2->next; | |
204 | ring_node_for_averaging_sm_f2->coarseTime = spectral_matrix_regs->f2_1_coarse_time; |
|
204 | ring_node_for_averaging_sm_f2->coarseTime = spectral_matrix_regs->f2_1_coarse_time; | |
205 | ring_node_for_averaging_sm_f2->fineTime = spectral_matrix_regs->f2_1_fine_time; |
|
205 | ring_node_for_averaging_sm_f2->fineTime = spectral_matrix_regs->f2_1_fine_time; | |
206 | spectral_matrix_regs->f2_1_address = current_ring_node_sm_f2->buffer_address; |
|
206 | spectral_matrix_regs->f2_1_address = current_ring_node_sm_f2->buffer_address; | |
207 | spectral_matrix_regs->status = 0x20; // [0010 0000] |
|
207 | spectral_matrix_regs->status = 0x20; // [0010 0000] | |
208 | if (rtems_event_send( Task_id[TASKID_AVF2], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) |
|
208 | if (rtems_event_send( Task_id[TASKID_AVF2], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) | |
209 | { |
|
209 | { | |
210 | status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 ); |
|
210 | status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 ); | |
211 | } |
|
211 | } | |
212 | break; |
|
212 | break; | |
213 | } |
|
213 | } | |
214 | } |
|
214 | } | |
215 |
|
215 | |||
216 | void spectral_matrix_isr_error_handler( unsigned char statusReg ) |
|
216 | void spectral_matrix_isr_error_handler( unsigned char statusReg ) | |
217 | { |
|
217 | { | |
218 | rtems_status_code status_code; |
|
218 | rtems_status_code status_code; | |
219 |
|
219 | |||
220 | if (statusReg & 0x7c0) // [0111 1100 0000] |
|
220 | if (statusReg & 0x7c0) // [0111 1100 0000] | |
221 | { |
|
221 | { | |
222 | status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_8 ); |
|
222 | status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_8 ); | |
223 | } |
|
223 | } | |
224 |
|
224 | |||
225 | spectral_matrix_regs->status = spectral_matrix_regs->status & 0x7c0; |
|
225 | spectral_matrix_regs->status = spectral_matrix_regs->status & 0x7c0; | |
226 | } |
|
226 | } | |
227 |
|
227 | |||
228 | rtems_isr spectral_matrices_isr( rtems_vector_number vector ) |
|
228 | rtems_isr spectral_matrices_isr( rtems_vector_number vector ) | |
229 | { |
|
229 | { | |
230 | // STATUS REGISTER |
|
230 | // STATUS REGISTER | |
231 | // input_fifo_write(2) *** input_fifo_write(1) *** input_fifo_write(0) |
|
231 | // input_fifo_write(2) *** input_fifo_write(1) *** input_fifo_write(0) | |
232 | // 10 9 8 |
|
232 | // 10 9 8 | |
233 | // buffer_full ** bad_component_err ** f2_1 ** f2_0 ** f1_1 ** f1_0 ** f0_1 ** f0_0 |
|
233 | // buffer_full ** bad_component_err ** f2_1 ** f2_0 ** f1_1 ** f1_0 ** f0_1 ** f0_0 | |
234 | // 7 6 5 4 3 2 1 0 |
|
234 | // 7 6 5 4 3 2 1 0 | |
235 |
|
235 | |||
236 | unsigned char statusReg; |
|
236 | unsigned char statusReg; | |
237 |
|
237 | |||
238 | statusReg = spectral_matrix_regs->status; |
|
238 | statusReg = spectral_matrix_regs->status; | |
239 |
|
239 | |||
240 | spectral_matrices_isr_f0( statusReg ); |
|
240 | spectral_matrices_isr_f0( statusReg ); | |
241 |
|
241 | |||
242 | spectral_matrices_isr_f1( statusReg ); |
|
242 | spectral_matrices_isr_f1( statusReg ); | |
243 |
|
243 | |||
244 | spectral_matrices_isr_f2( statusReg ); |
|
244 | spectral_matrices_isr_f2( statusReg ); | |
245 |
|
245 | |||
246 | spectral_matrix_isr_error_handler( statusReg ); |
|
246 | spectral_matrix_isr_error_handler( statusReg ); | |
247 | } |
|
247 | } | |
248 |
|
248 | |||
249 | rtems_isr spectral_matrices_isr_simu( rtems_vector_number vector ) |
|
249 | rtems_isr spectral_matrices_isr_simu( rtems_vector_number vector ) | |
250 | { |
|
250 | { | |
251 | rtems_status_code status_code; |
|
251 | rtems_status_code status_code; | |
252 |
|
252 | |||
253 | //*** |
|
253 | //*** | |
254 | // F0 |
|
254 | // F0 | |
255 | nb_sm_f0 = nb_sm_f0 + 1; |
|
255 | nb_sm_f0 = nb_sm_f0 + 1; | |
256 | if (nb_sm_f0 == NB_SM_BEFORE_AVF0 ) |
|
256 | if (nb_sm_f0 == NB_SM_BEFORE_AVF0 ) | |
257 | { |
|
257 | { | |
258 | ring_node_for_averaging_sm_f0 = current_ring_node_sm_f0; |
|
258 | ring_node_for_averaging_sm_f0 = current_ring_node_sm_f0; | |
259 | if (rtems_event_send( Task_id[TASKID_AVF0], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) |
|
259 | if (rtems_event_send( Task_id[TASKID_AVF0], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) | |
260 | { |
|
260 | { | |
261 | status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 ); |
|
261 | status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 ); | |
262 | } |
|
262 | } | |
263 | nb_sm_f0 = 0; |
|
263 | nb_sm_f0 = 0; | |
264 | } |
|
264 | } | |
265 |
|
265 | |||
266 | //*** |
|
266 | //*** | |
267 | // F1 |
|
267 | // F1 | |
268 | nb_sm_f0_aux_f1 = nb_sm_f0_aux_f1 + 1; |
|
268 | nb_sm_f0_aux_f1 = nb_sm_f0_aux_f1 + 1; | |
269 | if (nb_sm_f0_aux_f1 == 6) |
|
269 | if (nb_sm_f0_aux_f1 == 6) | |
270 | { |
|
270 | { | |
271 | nb_sm_f0_aux_f1 = 0; |
|
271 | nb_sm_f0_aux_f1 = 0; | |
272 | nb_sm_f1 = nb_sm_f1 + 1; |
|
272 | nb_sm_f1 = nb_sm_f1 + 1; | |
273 | } |
|
273 | } | |
274 | if (nb_sm_f1 == NB_SM_BEFORE_AVF1 ) |
|
274 | if (nb_sm_f1 == NB_SM_BEFORE_AVF1 ) | |
275 | { |
|
275 | { | |
276 | ring_node_for_averaging_sm_f1 = current_ring_node_sm_f1; |
|
276 | ring_node_for_averaging_sm_f1 = current_ring_node_sm_f1; | |
277 | if (rtems_event_send( Task_id[TASKID_AVF1], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) |
|
277 | if (rtems_event_send( Task_id[TASKID_AVF1], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) | |
278 | { |
|
278 | { | |
279 | status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 ); |
|
279 | status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 ); | |
280 | } |
|
280 | } | |
281 | nb_sm_f1 = 0; |
|
281 | nb_sm_f1 = 0; | |
282 | } |
|
282 | } | |
283 |
|
283 | |||
284 | //*** |
|
284 | //*** | |
285 | // F2 |
|
285 | // F2 | |
286 | nb_sm_f0_aux_f2 = nb_sm_f0_aux_f2 + 1; |
|
286 | nb_sm_f0_aux_f2 = nb_sm_f0_aux_f2 + 1; | |
287 | if (nb_sm_f0_aux_f2 == 96) |
|
287 | if (nb_sm_f0_aux_f2 == 96) | |
288 | { |
|
288 | { | |
289 | nb_sm_f0_aux_f2 = 0; |
|
289 | nb_sm_f0_aux_f2 = 0; | |
290 | ring_node_for_averaging_sm_f2 = current_ring_node_sm_f2; |
|
290 | ring_node_for_averaging_sm_f2 = current_ring_node_sm_f2; | |
291 | if (rtems_event_send( Task_id[TASKID_AVF2], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) |
|
291 | if (rtems_event_send( Task_id[TASKID_AVF2], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) | |
292 | { |
|
292 | { | |
293 | status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 ); |
|
293 | status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 ); | |
294 | } |
|
294 | } | |
295 | } |
|
295 | } | |
296 | } |
|
296 | } | |
297 |
|
297 | |||
298 | //****************** |
|
298 | //****************** | |
299 | // Spectral Matrices |
|
299 | // Spectral Matrices | |
300 |
|
300 | |||
301 | void reset_nb_sm( void ) |
|
301 | void reset_nb_sm( void ) | |
302 | { |
|
302 | { | |
303 | nb_sm_f0 = 0; |
|
303 | nb_sm_f0 = 0; | |
304 | nb_sm_f0_aux_f1 = 0; |
|
304 | nb_sm_f0_aux_f1 = 0; | |
305 | nb_sm_f0_aux_f2 = 0; |
|
305 | nb_sm_f0_aux_f2 = 0; | |
306 |
|
306 | |||
307 | nb_sm_f1 = 0; |
|
307 | nb_sm_f1 = 0; | |
308 | } |
|
308 | } | |
309 |
|
309 | |||
310 | void SM_init_rings( void ) |
|
310 | void SM_init_rings( void ) | |
311 | { |
|
311 | { | |
312 | init_ring( sm_ring_f0, NB_RING_NODES_SM_F0, sm_f0, TOTAL_SIZE_SM ); |
|
312 | init_ring( sm_ring_f0, NB_RING_NODES_SM_F0, sm_f0, TOTAL_SIZE_SM ); | |
313 | init_ring( sm_ring_f1, NB_RING_NODES_SM_F1, sm_f1, TOTAL_SIZE_SM ); |
|
313 | init_ring( sm_ring_f1, NB_RING_NODES_SM_F1, sm_f1, TOTAL_SIZE_SM ); | |
314 | init_ring( sm_ring_f2, NB_RING_NODES_SM_F2, sm_f2, TOTAL_SIZE_SM ); |
|
314 | init_ring( sm_ring_f2, NB_RING_NODES_SM_F2, sm_f2, TOTAL_SIZE_SM ); | |
315 |
|
315 | |||
316 | DEBUG_PRINTF1("sm_ring_f0 @%x\n", (unsigned int) sm_ring_f0) |
|
316 | DEBUG_PRINTF1("sm_ring_f0 @%x\n", (unsigned int) sm_ring_f0) | |
317 | DEBUG_PRINTF1("sm_ring_f1 @%x\n", (unsigned int) sm_ring_f1) |
|
317 | DEBUG_PRINTF1("sm_ring_f1 @%x\n", (unsigned int) sm_ring_f1) | |
318 | DEBUG_PRINTF1("sm_ring_f2 @%x\n", (unsigned int) sm_ring_f2) |
|
318 | DEBUG_PRINTF1("sm_ring_f2 @%x\n", (unsigned int) sm_ring_f2) | |
319 | DEBUG_PRINTF1("sm_f0 @%x\n", (unsigned int) sm_f0) |
|
319 | DEBUG_PRINTF1("sm_f0 @%x\n", (unsigned int) sm_f0) | |
320 | DEBUG_PRINTF1("sm_f1 @%x\n", (unsigned int) sm_f1) |
|
320 | DEBUG_PRINTF1("sm_f1 @%x\n", (unsigned int) sm_f1) | |
321 | DEBUG_PRINTF1("sm_f2 @%x\n", (unsigned int) sm_f2) |
|
321 | DEBUG_PRINTF1("sm_f2 @%x\n", (unsigned int) sm_f2) | |
322 | } |
|
322 | } | |
323 |
|
323 | |||
324 | void ASM_generic_init_ring( ring_node_asm *ring, unsigned char nbNodes ) |
|
324 | void ASM_generic_init_ring( ring_node_asm *ring, unsigned char nbNodes ) | |
325 | { |
|
325 | { | |
326 | unsigned char i; |
|
326 | unsigned char i; | |
327 |
|
327 | |||
328 | ring[ nbNodes - 1 ].next |
|
328 | ring[ nbNodes - 1 ].next | |
329 | = (ring_node_asm*) &ring[ 0 ]; |
|
329 | = (ring_node_asm*) &ring[ 0 ]; | |
330 |
|
330 | |||
331 | for(i=0; i<nbNodes-1; i++) |
|
331 | for(i=0; i<nbNodes-1; i++) | |
332 | { |
|
332 | { | |
333 | ring[ i ].next = (ring_node_asm*) &ring[ i + 1 ]; |
|
333 | ring[ i ].next = (ring_node_asm*) &ring[ i + 1 ]; | |
334 | } |
|
334 | } | |
335 | } |
|
335 | } | |
336 |
|
336 | |||
337 | void SM_reset_current_ring_nodes( void ) |
|
337 | void SM_reset_current_ring_nodes( void ) | |
338 | { |
|
338 | { | |
339 | current_ring_node_sm_f0 = sm_ring_f0[0].next; |
|
339 | current_ring_node_sm_f0 = sm_ring_f0[0].next; | |
340 | current_ring_node_sm_f1 = sm_ring_f1[0].next; |
|
340 | current_ring_node_sm_f1 = sm_ring_f1[0].next; | |
341 | current_ring_node_sm_f2 = sm_ring_f2[0].next; |
|
341 | current_ring_node_sm_f2 = sm_ring_f2[0].next; | |
342 |
|
342 | |||
343 | ring_node_for_averaging_sm_f0 = NULL; |
|
343 | ring_node_for_averaging_sm_f0 = NULL; | |
344 | ring_node_for_averaging_sm_f1 = NULL; |
|
344 | ring_node_for_averaging_sm_f1 = NULL; | |
345 | ring_node_for_averaging_sm_f2 = NULL; |
|
345 | ring_node_for_averaging_sm_f2 = NULL; | |
346 | } |
|
346 | } | |
347 |
|
347 | |||
348 | //***************** |
|
348 | //***************** | |
349 | // Basic Parameters |
|
349 | // Basic Parameters | |
350 |
|
350 | |||
351 | void BP_init_header( bp_packet *packet, |
|
351 | void BP_init_header( bp_packet *packet, | |
352 | unsigned int apid, unsigned char sid, |
|
352 | unsigned int apid, unsigned char sid, | |
353 | unsigned int packetLength, unsigned char blkNr ) |
|
353 | unsigned int packetLength, unsigned char blkNr ) | |
354 | { |
|
354 | { | |
355 | packet->targetLogicalAddress = CCSDS_DESTINATION_ID; |
|
355 | packet->targetLogicalAddress = CCSDS_DESTINATION_ID; | |
356 | packet->protocolIdentifier = CCSDS_PROTOCOLE_ID; |
|
356 | packet->protocolIdentifier = CCSDS_PROTOCOLE_ID; | |
357 | packet->reserved = 0x00; |
|
357 | packet->reserved = 0x00; | |
358 | packet->userApplication = CCSDS_USER_APP; |
|
358 | packet->userApplication = CCSDS_USER_APP; | |
359 | packet->packetID[0] = (unsigned char) (apid >> 8); |
|
359 | packet->packetID[0] = (unsigned char) (apid >> 8); | |
360 | packet->packetID[1] = (unsigned char) (apid); |
|
360 | packet->packetID[1] = (unsigned char) (apid); | |
361 | packet->packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; |
|
361 | packet->packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; | |
362 | packet->packetSequenceControl[1] = 0x00; |
|
362 | packet->packetSequenceControl[1] = 0x00; | |
363 | packet->packetLength[0] = (unsigned char) (packetLength >> 8); |
|
363 | packet->packetLength[0] = (unsigned char) (packetLength >> 8); | |
364 | packet->packetLength[1] = (unsigned char) (packetLength); |
|
364 | packet->packetLength[1] = (unsigned char) (packetLength); | |
365 | // DATA FIELD HEADER |
|
365 | // DATA FIELD HEADER | |
366 | packet->spare1_pusVersion_spare2 = 0x10; |
|
366 | packet->spare1_pusVersion_spare2 = 0x10; | |
367 | packet->serviceType = TM_TYPE_LFR_SCIENCE; // service type |
|
367 | packet->serviceType = TM_TYPE_LFR_SCIENCE; // service type | |
368 | packet->serviceSubType = TM_SUBTYPE_LFR_SCIENCE_3; // service subtype |
|
368 | packet->serviceSubType = TM_SUBTYPE_LFR_SCIENCE_3; // service subtype | |
369 | packet->destinationID = TM_DESTINATION_ID_GROUND; |
|
369 | packet->destinationID = TM_DESTINATION_ID_GROUND; | |
370 | packet->time[0] = 0x00; |
|
370 | packet->time[0] = 0x00; | |
371 | packet->time[1] = 0x00; |
|
371 | packet->time[1] = 0x00; | |
372 | packet->time[2] = 0x00; |
|
372 | packet->time[2] = 0x00; | |
373 | packet->time[3] = 0x00; |
|
373 | packet->time[3] = 0x00; | |
374 | packet->time[4] = 0x00; |
|
374 | packet->time[4] = 0x00; | |
375 | packet->time[5] = 0x00; |
|
375 | packet->time[5] = 0x00; | |
376 | // AUXILIARY DATA HEADER |
|
376 | // AUXILIARY DATA HEADER | |
377 | packet->sid = sid; |
|
377 | packet->sid = sid; | |
378 | packet->biaStatusInfo = 0x00; |
|
378 | packet->biaStatusInfo = 0x00; | |
379 | packet->sy_lfr_common_parameters_spare = 0x00; |
|
379 | packet->sy_lfr_common_parameters_spare = 0x00; | |
380 | packet->sy_lfr_common_parameters = 0x00; |
|
380 | packet->sy_lfr_common_parameters = 0x00; | |
381 | packet->acquisitionTime[0] = 0x00; |
|
381 | packet->acquisitionTime[0] = 0x00; | |
382 | packet->acquisitionTime[1] = 0x00; |
|
382 | packet->acquisitionTime[1] = 0x00; | |
383 | packet->acquisitionTime[2] = 0x00; |
|
383 | packet->acquisitionTime[2] = 0x00; | |
384 | packet->acquisitionTime[3] = 0x00; |
|
384 | packet->acquisitionTime[3] = 0x00; | |
385 | packet->acquisitionTime[4] = 0x00; |
|
385 | packet->acquisitionTime[4] = 0x00; | |
386 | packet->acquisitionTime[5] = 0x00; |
|
386 | packet->acquisitionTime[5] = 0x00; | |
387 | packet->pa_lfr_bp_blk_nr[0] = 0x00; // BLK_NR MSB |
|
387 | packet->pa_lfr_bp_blk_nr[0] = 0x00; // BLK_NR MSB | |
388 | packet->pa_lfr_bp_blk_nr[1] = blkNr; // BLK_NR LSB |
|
388 | packet->pa_lfr_bp_blk_nr[1] = blkNr; // BLK_NR LSB | |
389 | } |
|
389 | } | |
390 |
|
390 | |||
391 | void BP_init_header_with_spare( bp_packet_with_spare *packet, |
|
391 | void BP_init_header_with_spare( bp_packet_with_spare *packet, | |
392 | unsigned int apid, unsigned char sid, |
|
392 | unsigned int apid, unsigned char sid, | |
393 | unsigned int packetLength , unsigned char blkNr) |
|
393 | unsigned int packetLength , unsigned char blkNr) | |
394 | { |
|
394 | { | |
395 | packet->targetLogicalAddress = CCSDS_DESTINATION_ID; |
|
395 | packet->targetLogicalAddress = CCSDS_DESTINATION_ID; | |
396 | packet->protocolIdentifier = CCSDS_PROTOCOLE_ID; |
|
396 | packet->protocolIdentifier = CCSDS_PROTOCOLE_ID; | |
397 | packet->reserved = 0x00; |
|
397 | packet->reserved = 0x00; | |
398 | packet->userApplication = CCSDS_USER_APP; |
|
398 | packet->userApplication = CCSDS_USER_APP; | |
399 | packet->packetID[0] = (unsigned char) (apid >> 8); |
|
399 | packet->packetID[0] = (unsigned char) (apid >> 8); | |
400 | packet->packetID[1] = (unsigned char) (apid); |
|
400 | packet->packetID[1] = (unsigned char) (apid); | |
401 | packet->packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; |
|
401 | packet->packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; | |
402 | packet->packetSequenceControl[1] = 0x00; |
|
402 | packet->packetSequenceControl[1] = 0x00; | |
403 | packet->packetLength[0] = (unsigned char) (packetLength >> 8); |
|
403 | packet->packetLength[0] = (unsigned char) (packetLength >> 8); | |
404 | packet->packetLength[1] = (unsigned char) (packetLength); |
|
404 | packet->packetLength[1] = (unsigned char) (packetLength); | |
405 | // DATA FIELD HEADER |
|
405 | // DATA FIELD HEADER | |
406 | packet->spare1_pusVersion_spare2 = 0x10; |
|
406 | packet->spare1_pusVersion_spare2 = 0x10; | |
407 | packet->serviceType = TM_TYPE_LFR_SCIENCE; // service type |
|
407 | packet->serviceType = TM_TYPE_LFR_SCIENCE; // service type | |
408 | packet->serviceSubType = TM_SUBTYPE_LFR_SCIENCE_3; // service subtype |
|
408 | packet->serviceSubType = TM_SUBTYPE_LFR_SCIENCE_3; // service subtype | |
409 | packet->destinationID = TM_DESTINATION_ID_GROUND; |
|
409 | packet->destinationID = TM_DESTINATION_ID_GROUND; | |
410 | // AUXILIARY DATA HEADER |
|
410 | // AUXILIARY DATA HEADER | |
411 | packet->sid = sid; |
|
411 | packet->sid = sid; | |
412 | packet->biaStatusInfo = 0x00; |
|
412 | packet->biaStatusInfo = 0x00; | |
413 | packet->sy_lfr_common_parameters_spare = 0x00; |
|
413 | packet->sy_lfr_common_parameters_spare = 0x00; | |
414 | packet->sy_lfr_common_parameters = 0x00; |
|
414 | packet->sy_lfr_common_parameters = 0x00; | |
415 | packet->time[0] = 0x00; |
|
415 | packet->time[0] = 0x00; | |
416 | packet->time[0] = 0x00; |
|
416 | packet->time[0] = 0x00; | |
417 | packet->time[0] = 0x00; |
|
417 | packet->time[0] = 0x00; | |
418 | packet->time[0] = 0x00; |
|
418 | packet->time[0] = 0x00; | |
419 | packet->time[0] = 0x00; |
|
419 | packet->time[0] = 0x00; | |
420 | packet->time[0] = 0x00; |
|
420 | packet->time[0] = 0x00; | |
421 | packet->source_data_spare = 0x00; |
|
421 | packet->source_data_spare = 0x00; | |
422 | packet->pa_lfr_bp_blk_nr[0] = 0x00; // BLK_NR MSB |
|
422 | packet->pa_lfr_bp_blk_nr[0] = 0x00; // BLK_NR MSB | |
423 | packet->pa_lfr_bp_blk_nr[1] = blkNr; // BLK_NR LSB |
|
423 | packet->pa_lfr_bp_blk_nr[1] = blkNr; // BLK_NR LSB | |
424 | } |
|
424 | } | |
425 |
|
425 | |||
426 | void BP_send(char *data, rtems_id queue_id, unsigned int nbBytesToSend, unsigned int sid ) |
|
426 | void BP_send(char *data, rtems_id queue_id, unsigned int nbBytesToSend, unsigned int sid ) | |
427 | { |
|
427 | { | |
428 | rtems_status_code status; |
|
428 | rtems_status_code status; | |
429 |
|
429 | |||
430 | // SET THE SEQUENCE_CNT PARAMETER |
|
|||
431 | increment_seq_counter_source_id( (unsigned char*) &data[ PACKET_POS_SEQUENCE_CNT ], sid ); |
|
|||
432 | // SEND PACKET |
|
430 | // SEND PACKET | |
433 | status = rtems_message_queue_send( queue_id, data, nbBytesToSend); |
|
431 | status = rtems_message_queue_send( queue_id, data, nbBytesToSend); | |
434 | if (status != RTEMS_SUCCESSFUL) |
|
432 | if (status != RTEMS_SUCCESSFUL) | |
435 | { |
|
433 | { | |
436 | PRINTF1("ERR *** in BP_send *** ERR %d\n", (int) status) |
|
434 | PRINTF1("ERR *** in BP_send *** ERR %d\n", (int) status) | |
437 | } |
|
435 | } | |
438 | } |
|
436 | } | |
439 |
|
437 | |||
440 | //****************** |
|
438 | //****************** | |
441 | // general functions |
|
439 | // general functions | |
442 |
|
440 | |||
443 | void reset_sm_status( void ) |
|
441 | void reset_sm_status( void ) | |
444 | { |
|
442 | { | |
445 | // error |
|
443 | // error | |
446 | // 10 --------------- 9 ---------------- 8 ---------------- 7 --------- |
|
444 | // 10 --------------- 9 ---------------- 8 ---------------- 7 --------- | |
447 | // input_fif0_write_2 input_fifo_write_1 input_fifo_write_0 buffer_full |
|
445 | // input_fif0_write_2 input_fifo_write_1 input_fifo_write_0 buffer_full | |
448 | // ---------- 5 -- 4 -- 3 -- 2 -- 1 -- 0 -- |
|
446 | // ---------- 5 -- 4 -- 3 -- 2 -- 1 -- 0 -- | |
449 | // ready bits f2_1 f2_0 f1_1 f1_1 f0_1 f0_0 |
|
447 | // ready bits f2_1 f2_0 f1_1 f1_1 f0_1 f0_0 | |
450 |
|
448 | |||
451 | spectral_matrix_regs->status = 0x7ff; // [0111 1111 1111] |
|
449 | spectral_matrix_regs->status = 0x7ff; // [0111 1111 1111] | |
452 | } |
|
450 | } | |
453 |
|
451 | |||
454 | void reset_spectral_matrix_regs( void ) |
|
452 | void reset_spectral_matrix_regs( void ) | |
455 | { |
|
453 | { | |
456 | /** This function resets the spectral matrices module registers. |
|
454 | /** This function resets the spectral matrices module registers. | |
457 | * |
|
455 | * | |
458 | * The registers affected by this function are located at the following offset addresses: |
|
456 | * The registers affected by this function are located at the following offset addresses: | |
459 | * |
|
457 | * | |
460 | * - 0x00 config |
|
458 | * - 0x00 config | |
461 | * - 0x04 status |
|
459 | * - 0x04 status | |
462 | * - 0x08 matrixF0_Address0 |
|
460 | * - 0x08 matrixF0_Address0 | |
463 | * - 0x10 matrixFO_Address1 |
|
461 | * - 0x10 matrixFO_Address1 | |
464 | * - 0x14 matrixF1_Address |
|
462 | * - 0x14 matrixF1_Address | |
465 | * - 0x18 matrixF2_Address |
|
463 | * - 0x18 matrixF2_Address | |
466 | * |
|
464 | * | |
467 | */ |
|
465 | */ | |
468 |
|
466 | |||
469 | set_sm_irq_onError( 0 ); |
|
467 | set_sm_irq_onError( 0 ); | |
470 |
|
468 | |||
471 | set_sm_irq_onNewMatrix( 0 ); |
|
469 | set_sm_irq_onNewMatrix( 0 ); | |
472 |
|
470 | |||
473 | reset_sm_status(); |
|
471 | reset_sm_status(); | |
474 |
|
472 | |||
475 | // F1 |
|
473 | // F1 | |
476 | spectral_matrix_regs->f0_0_address = current_ring_node_sm_f0->previous->buffer_address; |
|
474 | spectral_matrix_regs->f0_0_address = current_ring_node_sm_f0->previous->buffer_address; | |
477 | spectral_matrix_regs->f0_1_address = current_ring_node_sm_f0->buffer_address; |
|
475 | spectral_matrix_regs->f0_1_address = current_ring_node_sm_f0->buffer_address; | |
478 | // F2 |
|
476 | // F2 | |
479 | spectral_matrix_regs->f1_0_address = current_ring_node_sm_f1->previous->buffer_address; |
|
477 | spectral_matrix_regs->f1_0_address = current_ring_node_sm_f1->previous->buffer_address; | |
480 | spectral_matrix_regs->f1_1_address = current_ring_node_sm_f1->buffer_address; |
|
478 | spectral_matrix_regs->f1_1_address = current_ring_node_sm_f1->buffer_address; | |
481 | // F3 |
|
479 | // F3 | |
482 | spectral_matrix_regs->f2_0_address = current_ring_node_sm_f2->previous->buffer_address; |
|
480 | spectral_matrix_regs->f2_0_address = current_ring_node_sm_f2->previous->buffer_address; | |
483 | spectral_matrix_regs->f2_1_address = current_ring_node_sm_f2->buffer_address; |
|
481 | spectral_matrix_regs->f2_1_address = current_ring_node_sm_f2->buffer_address; | |
484 |
|
482 | |||
485 | spectral_matrix_regs->matrix_length = 0xc8; // 25 * 128 / 16 = 200 = 0xc8 |
|
483 | spectral_matrix_regs->matrix_length = 0xc8; // 25 * 128 / 16 = 200 = 0xc8 | |
486 | } |
|
484 | } | |
487 |
|
485 | |||
488 | void set_time( unsigned char *time, unsigned char * timeInBuffer ) |
|
486 | void set_time( unsigned char *time, unsigned char * timeInBuffer ) | |
489 | { |
|
487 | { | |
490 | time[0] = timeInBuffer[0]; |
|
488 | time[0] = timeInBuffer[0]; | |
491 | time[1] = timeInBuffer[1]; |
|
489 | time[1] = timeInBuffer[1]; | |
492 | time[2] = timeInBuffer[2]; |
|
490 | time[2] = timeInBuffer[2]; | |
493 | time[3] = timeInBuffer[3]; |
|
491 | time[3] = timeInBuffer[3]; | |
494 | time[4] = timeInBuffer[6]; |
|
492 | time[4] = timeInBuffer[6]; | |
495 | time[5] = timeInBuffer[7]; |
|
493 | time[5] = timeInBuffer[7]; | |
496 | } |
|
494 | } | |
497 |
|
495 | |||
498 | unsigned long long int get_acquisition_time( unsigned char *timePtr ) |
|
496 | unsigned long long int get_acquisition_time( unsigned char *timePtr ) | |
499 | { |
|
497 | { | |
500 | unsigned long long int acquisitionTimeAslong; |
|
498 | unsigned long long int acquisitionTimeAslong; | |
501 | acquisitionTimeAslong = 0x00; |
|
499 | acquisitionTimeAslong = 0x00; | |
502 | acquisitionTimeAslong = ( (unsigned long long int) (timePtr[0] & 0x7f) << 40 ) // [0111 1111] mask the synchronization bit |
|
500 | acquisitionTimeAslong = ( (unsigned long long int) (timePtr[0] & 0x7f) << 40 ) // [0111 1111] mask the synchronization bit | |
503 | + ( (unsigned long long int) timePtr[1] << 32 ) |
|
501 | + ( (unsigned long long int) timePtr[1] << 32 ) | |
504 | + ( (unsigned long long int) timePtr[2] << 24 ) |
|
502 | + ( (unsigned long long int) timePtr[2] << 24 ) | |
505 | + ( (unsigned long long int) timePtr[3] << 16 ) |
|
503 | + ( (unsigned long long int) timePtr[3] << 16 ) | |
506 | + ( (unsigned long long int) timePtr[6] << 8 ) |
|
504 | + ( (unsigned long long int) timePtr[6] << 8 ) | |
507 | + ( (unsigned long long int) timePtr[7] ); |
|
505 | + ( (unsigned long long int) timePtr[7] ); | |
508 | return acquisitionTimeAslong; |
|
506 | return acquisitionTimeAslong; | |
509 | } |
|
507 | } | |
510 |
|
508 | |||
511 | unsigned char getSID( rtems_event_set event ) |
|
509 | unsigned char getSID( rtems_event_set event ) | |
512 | { |
|
510 | { | |
513 | unsigned char sid; |
|
511 | unsigned char sid; | |
514 |
|
512 | |||
515 | rtems_event_set eventSetBURST; |
|
513 | rtems_event_set eventSetBURST; | |
516 | rtems_event_set eventSetSBM; |
|
514 | rtems_event_set eventSetSBM; | |
517 |
|
515 | |||
518 | //****** |
|
516 | //****** | |
519 | // BURST |
|
517 | // BURST | |
520 | eventSetBURST = RTEMS_EVENT_BURST_BP1_F0 |
|
518 | eventSetBURST = RTEMS_EVENT_BURST_BP1_F0 | |
521 | | RTEMS_EVENT_BURST_BP1_F1 |
|
519 | | RTEMS_EVENT_BURST_BP1_F1 | |
522 | | RTEMS_EVENT_BURST_BP2_F0 |
|
520 | | RTEMS_EVENT_BURST_BP2_F0 | |
523 | | RTEMS_EVENT_BURST_BP2_F1; |
|
521 | | RTEMS_EVENT_BURST_BP2_F1; | |
524 |
|
522 | |||
525 | //**** |
|
523 | //**** | |
526 | // SBM |
|
524 | // SBM | |
527 | eventSetSBM = RTEMS_EVENT_SBM_BP1_F0 |
|
525 | eventSetSBM = RTEMS_EVENT_SBM_BP1_F0 | |
528 | | RTEMS_EVENT_SBM_BP1_F1 |
|
526 | | RTEMS_EVENT_SBM_BP1_F1 | |
529 | | RTEMS_EVENT_SBM_BP2_F0 |
|
527 | | RTEMS_EVENT_SBM_BP2_F0 | |
530 | | RTEMS_EVENT_SBM_BP2_F1; |
|
528 | | RTEMS_EVENT_SBM_BP2_F1; | |
531 |
|
529 | |||
532 | if (event & eventSetBURST) |
|
530 | if (event & eventSetBURST) | |
533 | { |
|
531 | { | |
534 | sid = SID_BURST_BP1_F0; |
|
532 | sid = SID_BURST_BP1_F0; | |
535 | } |
|
533 | } | |
536 | else if (event & eventSetSBM) |
|
534 | else if (event & eventSetSBM) | |
537 | { |
|
535 | { | |
538 | sid = SID_SBM1_BP1_F0; |
|
536 | sid = SID_SBM1_BP1_F0; | |
539 | } |
|
537 | } | |
540 | else |
|
538 | else | |
541 | { |
|
539 | { | |
542 | sid = 0; |
|
540 | sid = 0; | |
543 | } |
|
541 | } | |
544 |
|
542 | |||
545 | return sid; |
|
543 | return sid; | |
546 | } |
|
544 | } | |
547 |
|
545 | |||
548 | void extractReImVectors( float *inputASM, float *outputASM, unsigned int asmComponent ) |
|
546 | void extractReImVectors( float *inputASM, float *outputASM, unsigned int asmComponent ) | |
549 | { |
|
547 | { | |
550 | unsigned int i; |
|
548 | unsigned int i; | |
551 | float re; |
|
549 | float re; | |
552 | float im; |
|
550 | float im; | |
553 |
|
551 | |||
554 | for (i=0; i<NB_BINS_PER_SM; i++){ |
|
552 | for (i=0; i<NB_BINS_PER_SM; i++){ | |
555 | re = inputASM[ (asmComponent*NB_BINS_PER_SM) + i * 2 ]; |
|
553 | re = inputASM[ (asmComponent*NB_BINS_PER_SM) + i * 2 ]; | |
556 | im = inputASM[ (asmComponent*NB_BINS_PER_SM) + i * 2 + 1]; |
|
554 | im = inputASM[ (asmComponent*NB_BINS_PER_SM) + i * 2 + 1]; | |
557 | outputASM[ (asmComponent *NB_BINS_PER_SM) + i] = re; |
|
555 | outputASM[ (asmComponent *NB_BINS_PER_SM) + i] = re; | |
558 | outputASM[ (asmComponent+1)*NB_BINS_PER_SM + i] = im; |
|
556 | outputASM[ (asmComponent+1)*NB_BINS_PER_SM + i] = im; | |
559 | } |
|
557 | } | |
560 | } |
|
558 | } | |
561 |
|
559 | |||
562 | void copyReVectors( float *inputASM, float *outputASM, unsigned int asmComponent ) |
|
560 | void copyReVectors( float *inputASM, float *outputASM, unsigned int asmComponent ) | |
563 | { |
|
561 | { | |
564 | unsigned int i; |
|
562 | unsigned int i; | |
565 | float re; |
|
563 | float re; | |
566 |
|
564 | |||
567 | for (i=0; i<NB_BINS_PER_SM; i++){ |
|
565 | for (i=0; i<NB_BINS_PER_SM; i++){ | |
568 | re = inputASM[ (asmComponent*NB_BINS_PER_SM) + i]; |
|
566 | re = inputASM[ (asmComponent*NB_BINS_PER_SM) + i]; | |
569 | outputASM[ (asmComponent*NB_BINS_PER_SM) + i] = re; |
|
567 | outputASM[ (asmComponent*NB_BINS_PER_SM) + i] = re; | |
570 | } |
|
568 | } | |
571 | } |
|
569 | } | |
572 |
|
570 | |||
573 | void ASM_patch( float *inputASM, float *outputASM ) |
|
571 | void ASM_patch( float *inputASM, float *outputASM ) | |
574 | { |
|
572 | { | |
575 | extractReImVectors( inputASM, outputASM, 1); // b1b2 |
|
573 | extractReImVectors( inputASM, outputASM, 1); // b1b2 | |
576 | extractReImVectors( inputASM, outputASM, 3 ); // b1b3 |
|
574 | extractReImVectors( inputASM, outputASM, 3 ); // b1b3 | |
577 | extractReImVectors( inputASM, outputASM, 5 ); // b1e1 |
|
575 | extractReImVectors( inputASM, outputASM, 5 ); // b1e1 | |
578 | extractReImVectors( inputASM, outputASM, 7 ); // b1e2 |
|
576 | extractReImVectors( inputASM, outputASM, 7 ); // b1e2 | |
579 | extractReImVectors( inputASM, outputASM, 10 ); // b2b3 |
|
577 | extractReImVectors( inputASM, outputASM, 10 ); // b2b3 | |
580 | extractReImVectors( inputASM, outputASM, 12 ); // b2e1 |
|
578 | extractReImVectors( inputASM, outputASM, 12 ); // b2e1 | |
581 | extractReImVectors( inputASM, outputASM, 14 ); // b2e2 |
|
579 | extractReImVectors( inputASM, outputASM, 14 ); // b2e2 | |
582 | extractReImVectors( inputASM, outputASM, 17 ); // b3e1 |
|
580 | extractReImVectors( inputASM, outputASM, 17 ); // b3e1 | |
583 | extractReImVectors( inputASM, outputASM, 19 ); // b3e2 |
|
581 | extractReImVectors( inputASM, outputASM, 19 ); // b3e2 | |
584 | extractReImVectors( inputASM, outputASM, 22 ); // e1e2 |
|
582 | extractReImVectors( inputASM, outputASM, 22 ); // e1e2 | |
585 |
|
583 | |||
586 | copyReVectors(inputASM, outputASM, 0 ); // b1b1 |
|
584 | copyReVectors(inputASM, outputASM, 0 ); // b1b1 | |
587 | copyReVectors(inputASM, outputASM, 9 ); // b2b2 |
|
585 | copyReVectors(inputASM, outputASM, 9 ); // b2b2 | |
588 | copyReVectors(inputASM, outputASM, 16); // b3b3 |
|
586 | copyReVectors(inputASM, outputASM, 16); // b3b3 | |
589 | copyReVectors(inputASM, outputASM, 21); // e1e1 |
|
587 | copyReVectors(inputASM, outputASM, 21); // e1e1 | |
590 | copyReVectors(inputASM, outputASM, 24); // e2e2 |
|
588 | copyReVectors(inputASM, outputASM, 24); // e2e2 | |
591 | } |
|
589 | } | |
592 |
|
590 | |||
593 | void ASM_compress_reorganize_and_divide_mask(float *averaged_spec_mat, float *compressed_spec_mat , float divider, |
|
591 | void ASM_compress_reorganize_and_divide_mask(float *averaged_spec_mat, float *compressed_spec_mat , float divider, | |
594 | unsigned char nbBinsCompressedMatrix, unsigned char nbBinsToAverage, unsigned char ASMIndexStart ) |
|
592 | unsigned char nbBinsCompressedMatrix, unsigned char nbBinsToAverage, unsigned char ASMIndexStart ) | |
595 | { |
|
593 | { | |
596 | //************* |
|
594 | //************* | |
597 | // input format |
|
595 | // input format | |
598 | // component0[0 .. 127] component1[0 .. 127] .. component24[0 .. 127] |
|
596 | // component0[0 .. 127] component1[0 .. 127] .. component24[0 .. 127] | |
599 | //************** |
|
597 | //************** | |
600 | // output format |
|
598 | // output format | |
601 | // matr0[0 .. 24] matr1[0 .. 24] .. matr127[0 .. 24] |
|
599 | // matr0[0 .. 24] matr1[0 .. 24] .. matr127[0 .. 24] | |
602 | //************ |
|
600 | //************ | |
603 | // compression |
|
601 | // compression | |
604 | // matr0[0 .. 24] matr1[0 .. 24] .. matr11[0 .. 24] => f0 NORM |
|
602 | // matr0[0 .. 24] matr1[0 .. 24] .. matr11[0 .. 24] => f0 NORM | |
605 | // matr0[0 .. 24] matr1[0 .. 24] .. matr22[0 .. 24] => f0 BURST, SBM |
|
603 | // matr0[0 .. 24] matr1[0 .. 24] .. matr22[0 .. 24] => f0 BURST, SBM | |
606 |
|
604 | |||
607 | int frequencyBin; |
|
605 | int frequencyBin; | |
608 | int asmComponent; |
|
606 | int asmComponent; | |
609 | int offsetASM; |
|
607 | int offsetASM; | |
610 | int offsetCompressed; |
|
608 | int offsetCompressed; | |
611 | int offsetFBin; |
|
609 | int offsetFBin; | |
612 | int fBinMask; |
|
610 | int fBinMask; | |
613 | int k; |
|
611 | int k; | |
614 |
|
612 | |||
615 | // BUILD DATA |
|
613 | // BUILD DATA | |
616 | for (asmComponent = 0; asmComponent < NB_VALUES_PER_SM; asmComponent++) |
|
614 | for (asmComponent = 0; asmComponent < NB_VALUES_PER_SM; asmComponent++) | |
617 | { |
|
615 | { | |
618 | for( frequencyBin = 0; frequencyBin < nbBinsCompressedMatrix; frequencyBin++ ) |
|
616 | for( frequencyBin = 0; frequencyBin < nbBinsCompressedMatrix; frequencyBin++ ) | |
619 | { |
|
617 | { | |
620 | offsetCompressed = // NO TIME OFFSET |
|
618 | offsetCompressed = // NO TIME OFFSET | |
621 | frequencyBin * NB_VALUES_PER_SM |
|
619 | frequencyBin * NB_VALUES_PER_SM | |
622 | + asmComponent; |
|
620 | + asmComponent; | |
623 | offsetASM = // NO TIME OFFSET |
|
621 | offsetASM = // NO TIME OFFSET | |
624 | asmComponent * NB_BINS_PER_SM |
|
622 | asmComponent * NB_BINS_PER_SM | |
625 | + ASMIndexStart |
|
623 | + ASMIndexStart | |
626 | + frequencyBin * nbBinsToAverage; |
|
624 | + frequencyBin * nbBinsToAverage; | |
627 | offsetFBin = ASMIndexStart |
|
625 | offsetFBin = ASMIndexStart | |
628 | + frequencyBin * nbBinsToAverage; |
|
626 | + frequencyBin * nbBinsToAverage; | |
629 | compressed_spec_mat[ offsetCompressed ] = 0; |
|
627 | compressed_spec_mat[ offsetCompressed ] = 0; | |
630 | for ( k = 0; k < nbBinsToAverage; k++ ) |
|
628 | for ( k = 0; k < nbBinsToAverage; k++ ) | |
631 | { |
|
629 | { | |
632 | fBinMask = getFBinMask( offsetFBin + k ); |
|
630 | fBinMask = getFBinMask( offsetFBin + k ); | |
633 | compressed_spec_mat[offsetCompressed ] = |
|
631 | compressed_spec_mat[offsetCompressed ] = | |
634 | ( compressed_spec_mat[ offsetCompressed ] |
|
632 | ( compressed_spec_mat[ offsetCompressed ] | |
635 | + averaged_spec_mat[ offsetASM + k ] * fBinMask ); |
|
633 | + averaged_spec_mat[ offsetASM + k ] * fBinMask ); | |
636 | } |
|
634 | } | |
637 | compressed_spec_mat[ offsetCompressed ] = |
|
635 | compressed_spec_mat[ offsetCompressed ] = | |
638 | compressed_spec_mat[ offsetCompressed ] / (divider * nbBinsToAverage); |
|
636 | compressed_spec_mat[ offsetCompressed ] / (divider * nbBinsToAverage); | |
639 | } |
|
637 | } | |
640 | } |
|
638 | } | |
641 |
|
639 | |||
642 | } |
|
640 | } | |
643 |
|
641 | |||
644 | int getFBinMask( int index ) |
|
642 | int getFBinMask( int index ) | |
645 | { |
|
643 | { | |
646 | unsigned int indexInChar; |
|
644 | unsigned int indexInChar; | |
647 | unsigned int indexInTheChar; |
|
645 | unsigned int indexInTheChar; | |
648 | int fbin; |
|
646 | int fbin; | |
649 |
|
647 | |||
650 | indexInChar = index >> 3; |
|
648 | indexInChar = index >> 3; | |
651 | indexInTheChar = index - indexInChar * 8; |
|
649 | indexInTheChar = index - indexInChar * 8; | |
652 |
|
650 | |||
653 | fbin = (int) ((parameter_dump_packet.sy_lfr_fbins_f0_word1[ NB_BYTES_PER_FREQ_MASK - 1 - indexInChar] >> indexInTheChar) & 0x1); |
|
651 | fbin = (int) ((parameter_dump_packet.sy_lfr_fbins_f0_word1[ NB_BYTES_PER_FREQ_MASK - 1 - indexInChar] >> indexInTheChar) & 0x1); | |
654 |
|
652 | |||
655 | return fbin; |
|
653 | return fbin; | |
656 | } |
|
654 | } | |
657 |
|
655 | |||
658 | void init_kcoeff_sbm_from_kcoeff_norm(float *input_kcoeff, float *output_kcoeff, unsigned char nb_bins_norm) |
|
656 | void init_kcoeff_sbm_from_kcoeff_norm(float *input_kcoeff, float *output_kcoeff, unsigned char nb_bins_norm) | |
659 | { |
|
657 | { | |
660 | unsigned char bin; |
|
658 | unsigned char bin; | |
661 | unsigned char kcoeff; |
|
659 | unsigned char kcoeff; | |
662 |
|
660 | |||
663 | for (bin=0; bin<nb_bins_norm; bin++) |
|
661 | for (bin=0; bin<nb_bins_norm; bin++) | |
664 | { |
|
662 | { | |
665 | for (kcoeff=0; kcoeff<NB_K_COEFF_PER_BIN; kcoeff++) |
|
663 | for (kcoeff=0; kcoeff<NB_K_COEFF_PER_BIN; kcoeff++) | |
666 | { |
|
664 | { | |
667 | output_kcoeff[ (bin*NB_K_COEFF_PER_BIN + kcoeff)*2 ] = input_kcoeff[ bin*NB_K_COEFF_PER_BIN + kcoeff ]; |
|
665 | output_kcoeff[ (bin*NB_K_COEFF_PER_BIN + kcoeff)*2 ] = input_kcoeff[ bin*NB_K_COEFF_PER_BIN + kcoeff ]; | |
668 | output_kcoeff[ (bin*NB_K_COEFF_PER_BIN + kcoeff)*2 + 1 ] = input_kcoeff[ bin*NB_K_COEFF_PER_BIN + kcoeff ]; |
|
666 | output_kcoeff[ (bin*NB_K_COEFF_PER_BIN + kcoeff)*2 + 1 ] = input_kcoeff[ bin*NB_K_COEFF_PER_BIN + kcoeff ]; | |
669 | } |
|
667 | } | |
670 | } |
|
668 | } | |
671 | } |
|
669 | } |
@@ -1,1373 +1,1373 | |||||
1 | /** Functions and tasks related to waveform packet generation. |
|
1 | /** Functions and tasks related to waveform packet generation. | |
2 | * |
|
2 | * | |
3 | * @file |
|
3 | * @file | |
4 | * @author P. LEROY |
|
4 | * @author P. LEROY | |
5 | * |
|
5 | * | |
6 | * A group of functions to handle waveforms, in snapshot or continuous format.\n |
|
6 | * A group of functions to handle waveforms, in snapshot or continuous format.\n | |
7 | * |
|
7 | * | |
8 | */ |
|
8 | */ | |
9 |
|
9 | |||
10 | #include "wf_handler.h" |
|
10 | #include "wf_handler.h" | |
11 |
|
11 | |||
12 | //*************** |
|
12 | //*************** | |
13 | // waveform rings |
|
13 | // waveform rings | |
14 | // F0 |
|
14 | // F0 | |
15 | ring_node waveform_ring_f0[NB_RING_NODES_F0]; |
|
15 | ring_node waveform_ring_f0[NB_RING_NODES_F0]; | |
16 | ring_node *current_ring_node_f0; |
|
16 | ring_node *current_ring_node_f0; | |
17 | ring_node *ring_node_to_send_swf_f0; |
|
17 | ring_node *ring_node_to_send_swf_f0; | |
18 | // F1 |
|
18 | // F1 | |
19 | ring_node waveform_ring_f1[NB_RING_NODES_F1]; |
|
19 | ring_node waveform_ring_f1[NB_RING_NODES_F1]; | |
20 | ring_node *current_ring_node_f1; |
|
20 | ring_node *current_ring_node_f1; | |
21 | ring_node *ring_node_to_send_swf_f1; |
|
21 | ring_node *ring_node_to_send_swf_f1; | |
22 | ring_node *ring_node_to_send_cwf_f1; |
|
22 | ring_node *ring_node_to_send_cwf_f1; | |
23 | // F2 |
|
23 | // F2 | |
24 | ring_node waveform_ring_f2[NB_RING_NODES_F2]; |
|
24 | ring_node waveform_ring_f2[NB_RING_NODES_F2]; | |
25 | ring_node *current_ring_node_f2; |
|
25 | ring_node *current_ring_node_f2; | |
26 | ring_node *ring_node_to_send_swf_f2; |
|
26 | ring_node *ring_node_to_send_swf_f2; | |
27 | ring_node *ring_node_to_send_cwf_f2; |
|
27 | ring_node *ring_node_to_send_cwf_f2; | |
28 | // F3 |
|
28 | // F3 | |
29 | ring_node waveform_ring_f3[NB_RING_NODES_F3]; |
|
29 | ring_node waveform_ring_f3[NB_RING_NODES_F3]; | |
30 | ring_node *current_ring_node_f3; |
|
30 | ring_node *current_ring_node_f3; | |
31 | ring_node *ring_node_to_send_cwf_f3; |
|
31 | ring_node *ring_node_to_send_cwf_f3; | |
32 | char wf_cont_f3_light[ (NB_SAMPLES_PER_SNAPSHOT) * NB_BYTES_CWF3_LIGHT_BLK ]; |
|
32 | char wf_cont_f3_light[ (NB_SAMPLES_PER_SNAPSHOT) * NB_BYTES_CWF3_LIGHT_BLK ]; | |
33 |
|
33 | |||
34 | bool extractSWF = false; |
|
34 | bool extractSWF = false; | |
35 | bool swf_f0_ready = false; |
|
35 | bool swf_f0_ready = false; | |
36 | bool swf_f1_ready = false; |
|
36 | bool swf_f1_ready = false; | |
37 | bool swf_f2_ready = false; |
|
37 | bool swf_f2_ready = false; | |
38 |
|
38 | |||
39 | int wf_snap_extracted[ (NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK) ]; |
|
39 | int wf_snap_extracted[ (NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK) ]; | |
40 | ring_node ring_node_wf_snap_extracted; |
|
40 | ring_node ring_node_wf_snap_extracted; | |
41 |
|
41 | |||
42 | //********************* |
|
42 | //********************* | |
43 | // Interrupt SubRoutine |
|
43 | // Interrupt SubRoutine | |
44 |
|
44 | |||
45 | ring_node * getRingNodeToSendCWF( unsigned char frequencyChannel) |
|
45 | ring_node * getRingNodeToSendCWF( unsigned char frequencyChannel) | |
46 | { |
|
46 | { | |
47 | ring_node *node; |
|
47 | ring_node *node; | |
48 |
|
48 | |||
49 | node = NULL; |
|
49 | node = NULL; | |
50 | switch ( frequencyChannel ) { |
|
50 | switch ( frequencyChannel ) { | |
51 | case 1: |
|
51 | case 1: | |
52 | node = ring_node_to_send_cwf_f1; |
|
52 | node = ring_node_to_send_cwf_f1; | |
53 | break; |
|
53 | break; | |
54 | case 2: |
|
54 | case 2: | |
55 | node = ring_node_to_send_cwf_f2; |
|
55 | node = ring_node_to_send_cwf_f2; | |
56 | break; |
|
56 | break; | |
57 | case 3: |
|
57 | case 3: | |
58 | node = ring_node_to_send_cwf_f3; |
|
58 | node = ring_node_to_send_cwf_f3; | |
59 | break; |
|
59 | break; | |
60 | default: |
|
60 | default: | |
61 | break; |
|
61 | break; | |
62 | } |
|
62 | } | |
63 |
|
63 | |||
64 | return node; |
|
64 | return node; | |
65 | } |
|
65 | } | |
66 |
|
66 | |||
67 | ring_node * getRingNodeToSendSWF( unsigned char frequencyChannel) |
|
67 | ring_node * getRingNodeToSendSWF( unsigned char frequencyChannel) | |
68 | { |
|
68 | { | |
69 | ring_node *node; |
|
69 | ring_node *node; | |
70 |
|
70 | |||
71 | node = NULL; |
|
71 | node = NULL; | |
72 | switch ( frequencyChannel ) { |
|
72 | switch ( frequencyChannel ) { | |
73 | case 0: |
|
73 | case 0: | |
74 | node = ring_node_to_send_swf_f0; |
|
74 | node = ring_node_to_send_swf_f0; | |
75 | break; |
|
75 | break; | |
76 | case 1: |
|
76 | case 1: | |
77 | node = ring_node_to_send_swf_f1; |
|
77 | node = ring_node_to_send_swf_f1; | |
78 | break; |
|
78 | break; | |
79 | case 2: |
|
79 | case 2: | |
80 | node = ring_node_to_send_swf_f2; |
|
80 | node = ring_node_to_send_swf_f2; | |
81 | break; |
|
81 | break; | |
82 | default: |
|
82 | default: | |
83 | break; |
|
83 | break; | |
84 | } |
|
84 | } | |
85 |
|
85 | |||
86 | return node; |
|
86 | return node; | |
87 | } |
|
87 | } | |
88 |
|
88 | |||
89 | void reset_extractSWF( void ) |
|
89 | void reset_extractSWF( void ) | |
90 | { |
|
90 | { | |
91 | extractSWF = false; |
|
91 | extractSWF = false; | |
92 | swf_f0_ready = false; |
|
92 | swf_f0_ready = false; | |
93 | swf_f1_ready = false; |
|
93 | swf_f1_ready = false; | |
94 | swf_f2_ready = false; |
|
94 | swf_f2_ready = false; | |
95 | } |
|
95 | } | |
96 |
|
96 | |||
97 | inline void waveforms_isr_f3( void ) |
|
97 | inline void waveforms_isr_f3( void ) | |
98 | { |
|
98 | { | |
99 | rtems_status_code spare_status; |
|
99 | rtems_status_code spare_status; | |
100 |
|
100 | |||
101 | if ( (lfrCurrentMode == LFR_MODE_NORMAL) || (lfrCurrentMode == LFR_MODE_BURST) // in BURST the data are used to place v, e1 and e2 in the HK packet |
|
101 | if ( (lfrCurrentMode == LFR_MODE_NORMAL) || (lfrCurrentMode == LFR_MODE_BURST) // in BURST the data are used to place v, e1 and e2 in the HK packet | |
102 | || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) ) |
|
102 | || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) ) | |
103 | { // in modes other than STANDBY and BURST, send the CWF_F3 data |
|
103 | { // in modes other than STANDBY and BURST, send the CWF_F3 data | |
104 | //*** |
|
104 | //*** | |
105 | // F3 |
|
105 | // F3 | |
106 | if ( (waveform_picker_regs->status & 0xc0) != 0x00 ) { // [1100 0000] check the f3 full bits |
|
106 | if ( (waveform_picker_regs->status & 0xc0) != 0x00 ) { // [1100 0000] check the f3 full bits | |
107 | ring_node_to_send_cwf_f3 = current_ring_node_f3->previous; |
|
107 | ring_node_to_send_cwf_f3 = current_ring_node_f3->previous; | |
108 | current_ring_node_f3 = current_ring_node_f3->next; |
|
108 | current_ring_node_f3 = current_ring_node_f3->next; | |
109 | if ((waveform_picker_regs->status & 0x40) == 0x40){ // [0100 0000] f3 buffer 0 is full |
|
109 | if ((waveform_picker_regs->status & 0x40) == 0x40){ // [0100 0000] f3 buffer 0 is full | |
110 | ring_node_to_send_cwf_f3->coarseTime = waveform_picker_regs->f3_0_coarse_time; |
|
110 | ring_node_to_send_cwf_f3->coarseTime = waveform_picker_regs->f3_0_coarse_time; | |
111 | ring_node_to_send_cwf_f3->fineTime = waveform_picker_regs->f3_0_fine_time; |
|
111 | ring_node_to_send_cwf_f3->fineTime = waveform_picker_regs->f3_0_fine_time; | |
112 | waveform_picker_regs->addr_data_f3_0 = current_ring_node_f3->buffer_address; |
|
112 | waveform_picker_regs->addr_data_f3_0 = current_ring_node_f3->buffer_address; | |
113 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00008840; // [1000 1000 0100 0000] |
|
113 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00008840; // [1000 1000 0100 0000] | |
114 | } |
|
114 | } | |
115 | else if ((waveform_picker_regs->status & 0x80) == 0x80){ // [1000 0000] f3 buffer 1 is full |
|
115 | else if ((waveform_picker_regs->status & 0x80) == 0x80){ // [1000 0000] f3 buffer 1 is full | |
116 | ring_node_to_send_cwf_f3->coarseTime = waveform_picker_regs->f3_1_coarse_time; |
|
116 | ring_node_to_send_cwf_f3->coarseTime = waveform_picker_regs->f3_1_coarse_time; | |
117 | ring_node_to_send_cwf_f3->fineTime = waveform_picker_regs->f3_1_fine_time; |
|
117 | ring_node_to_send_cwf_f3->fineTime = waveform_picker_regs->f3_1_fine_time; | |
118 | waveform_picker_regs->addr_data_f3_1 = current_ring_node_f3->buffer_address; |
|
118 | waveform_picker_regs->addr_data_f3_1 = current_ring_node_f3->buffer_address; | |
119 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00008880; // [1000 1000 1000 0000] |
|
119 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00008880; // [1000 1000 1000 0000] | |
120 | } |
|
120 | } | |
121 | if (rtems_event_send( Task_id[TASKID_CWF3], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) { |
|
121 | if (rtems_event_send( Task_id[TASKID_CWF3], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) { | |
122 | spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ); |
|
122 | spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ); | |
123 | } |
|
123 | } | |
124 | } |
|
124 | } | |
125 | } |
|
125 | } | |
126 | } |
|
126 | } | |
127 |
|
127 | |||
128 | inline void waveforms_isr_normal( void ) |
|
128 | inline void waveforms_isr_normal( void ) | |
129 | { |
|
129 | { | |
130 | rtems_status_code status; |
|
130 | rtems_status_code status; | |
131 |
|
131 | |||
132 | if ( ( (waveform_picker_regs->status & 0x30) != 0x00 ) // [0011 0000] check the f2 full bits |
|
132 | if ( ( (waveform_picker_regs->status & 0x30) != 0x00 ) // [0011 0000] check the f2 full bits | |
133 | && ( (waveform_picker_regs->status & 0x0c) != 0x00 ) // [0000 1100] check the f1 full bits |
|
133 | && ( (waveform_picker_regs->status & 0x0c) != 0x00 ) // [0000 1100] check the f1 full bits | |
134 | && ( (waveform_picker_regs->status & 0x03) != 0x00 )) // [0000 0011] check the f0 full bits |
|
134 | && ( (waveform_picker_regs->status & 0x03) != 0x00 )) // [0000 0011] check the f0 full bits | |
135 | { |
|
135 | { | |
136 | //*** |
|
136 | //*** | |
137 | // F0 |
|
137 | // F0 | |
138 | ring_node_to_send_swf_f0 = current_ring_node_f0->previous; |
|
138 | ring_node_to_send_swf_f0 = current_ring_node_f0->previous; | |
139 | current_ring_node_f0 = current_ring_node_f0->next; |
|
139 | current_ring_node_f0 = current_ring_node_f0->next; | |
140 | if ( (waveform_picker_regs->status & 0x01) == 0x01) |
|
140 | if ( (waveform_picker_regs->status & 0x01) == 0x01) | |
141 | { |
|
141 | { | |
142 |
|
142 | |||
143 | ring_node_to_send_swf_f0->coarseTime = waveform_picker_regs->f0_0_coarse_time; |
|
143 | ring_node_to_send_swf_f0->coarseTime = waveform_picker_regs->f0_0_coarse_time; | |
144 | ring_node_to_send_swf_f0->fineTime = waveform_picker_regs->f0_0_fine_time; |
|
144 | ring_node_to_send_swf_f0->fineTime = waveform_picker_regs->f0_0_fine_time; | |
145 | waveform_picker_regs->addr_data_f0_0 = current_ring_node_f0->buffer_address; |
|
145 | waveform_picker_regs->addr_data_f0_0 = current_ring_node_f0->buffer_address; | |
146 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00001101; // [0001 0001 0000 0001] |
|
146 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00001101; // [0001 0001 0000 0001] | |
147 | } |
|
147 | } | |
148 | else if ( (waveform_picker_regs->status & 0x02) == 0x02) |
|
148 | else if ( (waveform_picker_regs->status & 0x02) == 0x02) | |
149 | { |
|
149 | { | |
150 | ring_node_to_send_swf_f0->coarseTime = waveform_picker_regs->f0_1_coarse_time; |
|
150 | ring_node_to_send_swf_f0->coarseTime = waveform_picker_regs->f0_1_coarse_time; | |
151 | ring_node_to_send_swf_f0->fineTime = waveform_picker_regs->f0_1_fine_time; |
|
151 | ring_node_to_send_swf_f0->fineTime = waveform_picker_regs->f0_1_fine_time; | |
152 | waveform_picker_regs->addr_data_f0_1 = current_ring_node_f0->buffer_address; |
|
152 | waveform_picker_regs->addr_data_f0_1 = current_ring_node_f0->buffer_address; | |
153 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00001102; // [0001 0001 0000 0010] |
|
153 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00001102; // [0001 0001 0000 0010] | |
154 | } |
|
154 | } | |
155 |
|
155 | |||
156 | //*** |
|
156 | //*** | |
157 | // F1 |
|
157 | // F1 | |
158 | ring_node_to_send_swf_f1 = current_ring_node_f1->previous; |
|
158 | ring_node_to_send_swf_f1 = current_ring_node_f1->previous; | |
159 | current_ring_node_f1 = current_ring_node_f1->next; |
|
159 | current_ring_node_f1 = current_ring_node_f1->next; | |
160 | if ( (waveform_picker_regs->status & 0x04) == 0x04) |
|
160 | if ( (waveform_picker_regs->status & 0x04) == 0x04) | |
161 | { |
|
161 | { | |
162 | ring_node_to_send_swf_f1->coarseTime = waveform_picker_regs->f1_0_coarse_time; |
|
162 | ring_node_to_send_swf_f1->coarseTime = waveform_picker_regs->f1_0_coarse_time; | |
163 | ring_node_to_send_swf_f1->fineTime = waveform_picker_regs->f1_0_fine_time; |
|
163 | ring_node_to_send_swf_f1->fineTime = waveform_picker_regs->f1_0_fine_time; | |
164 | waveform_picker_regs->addr_data_f1_0 = current_ring_node_f1->buffer_address; |
|
164 | waveform_picker_regs->addr_data_f1_0 = current_ring_node_f1->buffer_address; | |
165 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00002204; // [0010 0010 0000 0100] f1 bits = 0 |
|
165 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00002204; // [0010 0010 0000 0100] f1 bits = 0 | |
166 | } |
|
166 | } | |
167 | else if ( (waveform_picker_regs->status & 0x08) == 0x08) |
|
167 | else if ( (waveform_picker_regs->status & 0x08) == 0x08) | |
168 | { |
|
168 | { | |
169 | ring_node_to_send_swf_f1->coarseTime = waveform_picker_regs->f1_1_coarse_time; |
|
169 | ring_node_to_send_swf_f1->coarseTime = waveform_picker_regs->f1_1_coarse_time; | |
170 | ring_node_to_send_swf_f1->fineTime = waveform_picker_regs->f1_1_fine_time; |
|
170 | ring_node_to_send_swf_f1->fineTime = waveform_picker_regs->f1_1_fine_time; | |
171 | waveform_picker_regs->addr_data_f1_1 = current_ring_node_f1->buffer_address; |
|
171 | waveform_picker_regs->addr_data_f1_1 = current_ring_node_f1->buffer_address; | |
172 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00002208; // [0010 0010 0000 1000] f1 bits = 0 |
|
172 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00002208; // [0010 0010 0000 1000] f1 bits = 0 | |
173 | } |
|
173 | } | |
174 |
|
174 | |||
175 | //*** |
|
175 | //*** | |
176 | // F2 |
|
176 | // F2 | |
177 | ring_node_to_send_swf_f2 = current_ring_node_f2->previous; |
|
177 | ring_node_to_send_swf_f2 = current_ring_node_f2->previous; | |
178 | current_ring_node_f2 = current_ring_node_f2->next; |
|
178 | current_ring_node_f2 = current_ring_node_f2->next; | |
179 | if ( (waveform_picker_regs->status & 0x10) == 0x10) |
|
179 | if ( (waveform_picker_regs->status & 0x10) == 0x10) | |
180 | { |
|
180 | { | |
181 | ring_node_to_send_swf_f2->coarseTime = waveform_picker_regs->f2_0_coarse_time; |
|
181 | ring_node_to_send_swf_f2->coarseTime = waveform_picker_regs->f2_0_coarse_time; | |
182 | ring_node_to_send_swf_f2->fineTime = waveform_picker_regs->f2_0_fine_time; |
|
182 | ring_node_to_send_swf_f2->fineTime = waveform_picker_regs->f2_0_fine_time; | |
183 | waveform_picker_regs->addr_data_f2_0 = current_ring_node_f2->buffer_address; |
|
183 | waveform_picker_regs->addr_data_f2_0 = current_ring_node_f2->buffer_address; | |
184 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00004410; // [0100 0100 0001 0000] |
|
184 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00004410; // [0100 0100 0001 0000] | |
185 | } |
|
185 | } | |
186 | else if ( (waveform_picker_regs->status & 0x20) == 0x20) |
|
186 | else if ( (waveform_picker_regs->status & 0x20) == 0x20) | |
187 | { |
|
187 | { | |
188 | ring_node_to_send_swf_f2->coarseTime = waveform_picker_regs->f2_1_coarse_time; |
|
188 | ring_node_to_send_swf_f2->coarseTime = waveform_picker_regs->f2_1_coarse_time; | |
189 | ring_node_to_send_swf_f2->fineTime = waveform_picker_regs->f2_1_fine_time; |
|
189 | ring_node_to_send_swf_f2->fineTime = waveform_picker_regs->f2_1_fine_time; | |
190 | waveform_picker_regs->addr_data_f2_1 = current_ring_node_f2->buffer_address; |
|
190 | waveform_picker_regs->addr_data_f2_1 = current_ring_node_f2->buffer_address; | |
191 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00004420; // [0100 0100 0010 0000] |
|
191 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00004420; // [0100 0100 0010 0000] | |
192 | } |
|
192 | } | |
193 | // |
|
193 | // | |
194 | status = rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_NORMAL ); |
|
194 | status = rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_NORMAL ); | |
195 | if ( status != RTEMS_SUCCESSFUL) |
|
195 | if ( status != RTEMS_SUCCESSFUL) | |
196 | { |
|
196 | { | |
197 | status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ); |
|
197 | status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ); | |
198 | } |
|
198 | } | |
199 | } |
|
199 | } | |
200 | } |
|
200 | } | |
201 |
|
201 | |||
202 | inline void waveforms_isr_burst( void ) |
|
202 | inline void waveforms_isr_burst( void ) | |
203 | { |
|
203 | { | |
204 | unsigned char status; |
|
204 | unsigned char status; | |
205 | rtems_status_code spare_status; |
|
205 | rtems_status_code spare_status; | |
206 |
|
206 | |||
207 | status = (waveform_picker_regs->status & 0x30) >> 4; // [0011 0000] get the status bits for f2 |
|
207 | status = (waveform_picker_regs->status & 0x30) >> 4; // [0011 0000] get the status bits for f2 | |
208 |
|
208 | |||
209 |
|
209 | |||
210 | switch(status) |
|
210 | switch(status) | |
211 | { |
|
211 | { | |
212 | case 1: |
|
212 | case 1: | |
213 | ring_node_to_send_cwf_f2 = current_ring_node_f2->previous; |
|
213 | ring_node_to_send_cwf_f2 = current_ring_node_f2->previous; | |
214 | ring_node_to_send_cwf_f2->sid = SID_BURST_CWF_F2; |
|
214 | ring_node_to_send_cwf_f2->sid = SID_BURST_CWF_F2; | |
215 | ring_node_to_send_cwf_f2->coarseTime = waveform_picker_regs->f2_0_coarse_time; |
|
215 | ring_node_to_send_cwf_f2->coarseTime = waveform_picker_regs->f2_0_coarse_time; | |
216 | ring_node_to_send_cwf_f2->fineTime = waveform_picker_regs->f2_0_fine_time; |
|
216 | ring_node_to_send_cwf_f2->fineTime = waveform_picker_regs->f2_0_fine_time; | |
217 | current_ring_node_f2 = current_ring_node_f2->next; |
|
217 | current_ring_node_f2 = current_ring_node_f2->next; | |
218 | waveform_picker_regs->addr_data_f2_0 = current_ring_node_f2->buffer_address; |
|
218 | waveform_picker_regs->addr_data_f2_0 = current_ring_node_f2->buffer_address; | |
219 | if (rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_BURST ) != RTEMS_SUCCESSFUL) { |
|
219 | if (rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_BURST ) != RTEMS_SUCCESSFUL) { | |
220 | spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ); |
|
220 | spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ); | |
221 | } |
|
221 | } | |
222 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00004410; // [0100 0100 0001 0000] |
|
222 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00004410; // [0100 0100 0001 0000] | |
223 | break; |
|
223 | break; | |
224 | case 2: |
|
224 | case 2: | |
225 | ring_node_to_send_cwf_f2 = current_ring_node_f2->previous; |
|
225 | ring_node_to_send_cwf_f2 = current_ring_node_f2->previous; | |
226 | ring_node_to_send_cwf_f2->sid = SID_BURST_CWF_F2; |
|
226 | ring_node_to_send_cwf_f2->sid = SID_BURST_CWF_F2; | |
227 | ring_node_to_send_cwf_f2->coarseTime = waveform_picker_regs->f2_1_coarse_time; |
|
227 | ring_node_to_send_cwf_f2->coarseTime = waveform_picker_regs->f2_1_coarse_time; | |
228 | ring_node_to_send_cwf_f2->fineTime = waveform_picker_regs->f2_1_fine_time; |
|
228 | ring_node_to_send_cwf_f2->fineTime = waveform_picker_regs->f2_1_fine_time; | |
229 | current_ring_node_f2 = current_ring_node_f2->next; |
|
229 | current_ring_node_f2 = current_ring_node_f2->next; | |
230 | waveform_picker_regs->addr_data_f2_1 = current_ring_node_f2->buffer_address; |
|
230 | waveform_picker_regs->addr_data_f2_1 = current_ring_node_f2->buffer_address; | |
231 | if (rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_BURST ) != RTEMS_SUCCESSFUL) { |
|
231 | if (rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_BURST ) != RTEMS_SUCCESSFUL) { | |
232 | spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ); |
|
232 | spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ); | |
233 | } |
|
233 | } | |
234 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00004420; // [0100 0100 0010 0000] |
|
234 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00004420; // [0100 0100 0010 0000] | |
235 | break; |
|
235 | break; | |
236 | default: |
|
236 | default: | |
237 | break; |
|
237 | break; | |
238 | } |
|
238 | } | |
239 | } |
|
239 | } | |
240 |
|
240 | |||
241 | inline void waveforms_isr_sbm1( void ) |
|
241 | inline void waveforms_isr_sbm1( void ) | |
242 | { |
|
242 | { | |
243 | rtems_status_code status; |
|
243 | rtems_status_code status; | |
244 |
|
244 | |||
245 | //*** |
|
245 | //*** | |
246 | // F1 |
|
246 | // F1 | |
247 | if ( (waveform_picker_regs->status & 0x0c) != 0x00 ) { // [0000 1100] check the f1 full bits |
|
247 | if ( (waveform_picker_regs->status & 0x0c) != 0x00 ) { // [0000 1100] check the f1 full bits | |
248 | // (1) change the receiving buffer for the waveform picker |
|
248 | // (1) change the receiving buffer for the waveform picker | |
249 | ring_node_to_send_cwf_f1 = current_ring_node_f1->previous; |
|
249 | ring_node_to_send_cwf_f1 = current_ring_node_f1->previous; | |
250 | current_ring_node_f1 = current_ring_node_f1->next; |
|
250 | current_ring_node_f1 = current_ring_node_f1->next; | |
251 | if ( (waveform_picker_regs->status & 0x04) == 0x04) |
|
251 | if ( (waveform_picker_regs->status & 0x04) == 0x04) | |
252 | { |
|
252 | { | |
253 | ring_node_to_send_cwf_f1->coarseTime = waveform_picker_regs->f1_0_coarse_time; |
|
253 | ring_node_to_send_cwf_f1->coarseTime = waveform_picker_regs->f1_0_coarse_time; | |
254 | ring_node_to_send_cwf_f1->fineTime = waveform_picker_regs->f1_0_fine_time; |
|
254 | ring_node_to_send_cwf_f1->fineTime = waveform_picker_regs->f1_0_fine_time; | |
255 | waveform_picker_regs->addr_data_f1_0 = current_ring_node_f1->buffer_address; |
|
255 | waveform_picker_regs->addr_data_f1_0 = current_ring_node_f1->buffer_address; | |
256 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00002204; // [0010 0010 0000 0100] f1 bits = 0 |
|
256 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00002204; // [0010 0010 0000 0100] f1 bits = 0 | |
257 | } |
|
257 | } | |
258 | else if ( (waveform_picker_regs->status & 0x08) == 0x08) |
|
258 | else if ( (waveform_picker_regs->status & 0x08) == 0x08) | |
259 | { |
|
259 | { | |
260 | ring_node_to_send_cwf_f1->coarseTime = waveform_picker_regs->f1_1_coarse_time; |
|
260 | ring_node_to_send_cwf_f1->coarseTime = waveform_picker_regs->f1_1_coarse_time; | |
261 | ring_node_to_send_cwf_f1->fineTime = waveform_picker_regs->f1_1_fine_time; |
|
261 | ring_node_to_send_cwf_f1->fineTime = waveform_picker_regs->f1_1_fine_time; | |
262 | waveform_picker_regs->addr_data_f1_1 = current_ring_node_f1->buffer_address; |
|
262 | waveform_picker_regs->addr_data_f1_1 = current_ring_node_f1->buffer_address; | |
263 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00002208; // [0010 0010 0000 1000] f1 bits = 0 |
|
263 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00002208; // [0010 0010 0000 1000] f1 bits = 0 | |
264 | } |
|
264 | } | |
265 | // (2) send an event for the the CWF1 task for transmission (and snapshot extraction if needed) |
|
265 | // (2) send an event for the the CWF1 task for transmission (and snapshot extraction if needed) | |
266 | status = rtems_event_send( Task_id[TASKID_CWF1], RTEMS_EVENT_MODE_SBM1 ); |
|
266 | status = rtems_event_send( Task_id[TASKID_CWF1], RTEMS_EVENT_MODE_SBM1 ); | |
267 | } |
|
267 | } | |
268 |
|
268 | |||
269 | //*** |
|
269 | //*** | |
270 | // F0 |
|
270 | // F0 | |
271 | if ( (waveform_picker_regs->status & 0x03) != 0x00 ) { // [0000 0011] check the f0 full bits |
|
271 | if ( (waveform_picker_regs->status & 0x03) != 0x00 ) { // [0000 0011] check the f0 full bits | |
272 | swf_f0_ready = true; |
|
272 | swf_f0_ready = true; | |
273 | // change f0 buffer |
|
273 | // change f0 buffer | |
274 | ring_node_to_send_swf_f0 = current_ring_node_f0->previous; |
|
274 | ring_node_to_send_swf_f0 = current_ring_node_f0->previous; | |
275 | current_ring_node_f0 = current_ring_node_f0->next; |
|
275 | current_ring_node_f0 = current_ring_node_f0->next; | |
276 | if ( (waveform_picker_regs->status & 0x01) == 0x01) |
|
276 | if ( (waveform_picker_regs->status & 0x01) == 0x01) | |
277 | { |
|
277 | { | |
278 |
|
278 | |||
279 | ring_node_to_send_swf_f0->coarseTime = waveform_picker_regs->f0_0_coarse_time; |
|
279 | ring_node_to_send_swf_f0->coarseTime = waveform_picker_regs->f0_0_coarse_time; | |
280 | ring_node_to_send_swf_f0->fineTime = waveform_picker_regs->f0_0_fine_time; |
|
280 | ring_node_to_send_swf_f0->fineTime = waveform_picker_regs->f0_0_fine_time; | |
281 | waveform_picker_regs->addr_data_f0_0 = current_ring_node_f0->buffer_address; |
|
281 | waveform_picker_regs->addr_data_f0_0 = current_ring_node_f0->buffer_address; | |
282 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00001101; // [0001 0001 0000 0001] |
|
282 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00001101; // [0001 0001 0000 0001] | |
283 | } |
|
283 | } | |
284 | else if ( (waveform_picker_regs->status & 0x02) == 0x02) |
|
284 | else if ( (waveform_picker_regs->status & 0x02) == 0x02) | |
285 | { |
|
285 | { | |
286 | ring_node_to_send_swf_f0->coarseTime = waveform_picker_regs->f0_1_coarse_time; |
|
286 | ring_node_to_send_swf_f0->coarseTime = waveform_picker_regs->f0_1_coarse_time; | |
287 | ring_node_to_send_swf_f0->fineTime = waveform_picker_regs->f0_1_fine_time; |
|
287 | ring_node_to_send_swf_f0->fineTime = waveform_picker_regs->f0_1_fine_time; | |
288 | waveform_picker_regs->addr_data_f0_1 = current_ring_node_f0->buffer_address; |
|
288 | waveform_picker_regs->addr_data_f0_1 = current_ring_node_f0->buffer_address; | |
289 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00001102; // [0001 0001 0000 0010] |
|
289 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00001102; // [0001 0001 0000 0010] | |
290 | } |
|
290 | } | |
291 | } |
|
291 | } | |
292 |
|
292 | |||
293 | //*** |
|
293 | //*** | |
294 | // F2 |
|
294 | // F2 | |
295 | if ( (waveform_picker_regs->status & 0x30) != 0x00 ) { // [0011 0000] check the f2 full bits |
|
295 | if ( (waveform_picker_regs->status & 0x30) != 0x00 ) { // [0011 0000] check the f2 full bits | |
296 | swf_f2_ready = true; |
|
296 | swf_f2_ready = true; | |
297 | // change f2 buffer |
|
297 | // change f2 buffer | |
298 | ring_node_to_send_swf_f2 = current_ring_node_f2->previous; |
|
298 | ring_node_to_send_swf_f2 = current_ring_node_f2->previous; | |
299 | current_ring_node_f2 = current_ring_node_f2->next; |
|
299 | current_ring_node_f2 = current_ring_node_f2->next; | |
300 | if ( (waveform_picker_regs->status & 0x10) == 0x10) |
|
300 | if ( (waveform_picker_regs->status & 0x10) == 0x10) | |
301 | { |
|
301 | { | |
302 | ring_node_to_send_swf_f2->coarseTime = waveform_picker_regs->f2_0_coarse_time; |
|
302 | ring_node_to_send_swf_f2->coarseTime = waveform_picker_regs->f2_0_coarse_time; | |
303 | ring_node_to_send_swf_f2->fineTime = waveform_picker_regs->f2_0_fine_time; |
|
303 | ring_node_to_send_swf_f2->fineTime = waveform_picker_regs->f2_0_fine_time; | |
304 | waveform_picker_regs->addr_data_f2_0 = current_ring_node_f2->buffer_address; |
|
304 | waveform_picker_regs->addr_data_f2_0 = current_ring_node_f2->buffer_address; | |
305 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00004410; // [0100 0100 0001 0000] |
|
305 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00004410; // [0100 0100 0001 0000] | |
306 | } |
|
306 | } | |
307 | else if ( (waveform_picker_regs->status & 0x20) == 0x20) |
|
307 | else if ( (waveform_picker_regs->status & 0x20) == 0x20) | |
308 | { |
|
308 | { | |
309 | ring_node_to_send_swf_f2->coarseTime = waveform_picker_regs->f2_1_coarse_time; |
|
309 | ring_node_to_send_swf_f2->coarseTime = waveform_picker_regs->f2_1_coarse_time; | |
310 | ring_node_to_send_swf_f2->fineTime = waveform_picker_regs->f2_1_fine_time; |
|
310 | ring_node_to_send_swf_f2->fineTime = waveform_picker_regs->f2_1_fine_time; | |
311 | waveform_picker_regs->addr_data_f2_1 = current_ring_node_f2->buffer_address; |
|
311 | waveform_picker_regs->addr_data_f2_1 = current_ring_node_f2->buffer_address; | |
312 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00004420; // [0100 0100 0010 0000] |
|
312 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00004420; // [0100 0100 0010 0000] | |
313 | } |
|
313 | } | |
314 | } |
|
314 | } | |
315 | } |
|
315 | } | |
316 |
|
316 | |||
317 | inline void waveforms_isr_sbm2( void ) |
|
317 | inline void waveforms_isr_sbm2( void ) | |
318 | { |
|
318 | { | |
319 | rtems_status_code status; |
|
319 | rtems_status_code status; | |
320 |
|
320 | |||
321 | //*** |
|
321 | //*** | |
322 | // F2 |
|
322 | // F2 | |
323 | if ( (waveform_picker_regs->status & 0x30) != 0x00 ) { // [0011 0000] check the f2 full bit |
|
323 | if ( (waveform_picker_regs->status & 0x30) != 0x00 ) { // [0011 0000] check the f2 full bit | |
324 | // (1) change the receiving buffer for the waveform picker |
|
324 | // (1) change the receiving buffer for the waveform picker | |
325 | ring_node_to_send_cwf_f2 = current_ring_node_f2->previous; |
|
325 | ring_node_to_send_cwf_f2 = current_ring_node_f2->previous; | |
326 | ring_node_to_send_cwf_f2->sid = SID_SBM2_CWF_F2; |
|
326 | ring_node_to_send_cwf_f2->sid = SID_SBM2_CWF_F2; | |
327 | current_ring_node_f2 = current_ring_node_f2->next; |
|
327 | current_ring_node_f2 = current_ring_node_f2->next; | |
328 | if ( (waveform_picker_regs->status & 0x10) == 0x10) |
|
328 | if ( (waveform_picker_regs->status & 0x10) == 0x10) | |
329 | { |
|
329 | { | |
330 | ring_node_to_send_cwf_f2->coarseTime = waveform_picker_regs->f2_0_coarse_time; |
|
330 | ring_node_to_send_cwf_f2->coarseTime = waveform_picker_regs->f2_0_coarse_time; | |
331 | ring_node_to_send_cwf_f2->fineTime = waveform_picker_regs->f2_0_fine_time; |
|
331 | ring_node_to_send_cwf_f2->fineTime = waveform_picker_regs->f2_0_fine_time; | |
332 | waveform_picker_regs->addr_data_f2_0 = current_ring_node_f2->buffer_address; |
|
332 | waveform_picker_regs->addr_data_f2_0 = current_ring_node_f2->buffer_address; | |
333 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00004410; // [0100 0100 0001 0000] |
|
333 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00004410; // [0100 0100 0001 0000] | |
334 | } |
|
334 | } | |
335 | else if ( (waveform_picker_regs->status & 0x20) == 0x20) |
|
335 | else if ( (waveform_picker_regs->status & 0x20) == 0x20) | |
336 | { |
|
336 | { | |
337 | ring_node_to_send_cwf_f2->coarseTime = waveform_picker_regs->f2_1_coarse_time; |
|
337 | ring_node_to_send_cwf_f2->coarseTime = waveform_picker_regs->f2_1_coarse_time; | |
338 | ring_node_to_send_cwf_f2->fineTime = waveform_picker_regs->f2_1_fine_time; |
|
338 | ring_node_to_send_cwf_f2->fineTime = waveform_picker_regs->f2_1_fine_time; | |
339 | waveform_picker_regs->addr_data_f2_1 = current_ring_node_f2->buffer_address; |
|
339 | waveform_picker_regs->addr_data_f2_1 = current_ring_node_f2->buffer_address; | |
340 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00004420; // [0100 0100 0010 0000] |
|
340 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00004420; // [0100 0100 0010 0000] | |
341 | } |
|
341 | } | |
342 | // (2) send an event for the waveforms transmission |
|
342 | // (2) send an event for the waveforms transmission | |
343 | status = rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_SBM2 ); |
|
343 | status = rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_SBM2 ); | |
344 | } |
|
344 | } | |
345 |
|
345 | |||
346 | //*** |
|
346 | //*** | |
347 | // F0 |
|
347 | // F0 | |
348 | if ( (waveform_picker_regs->status & 0x03) != 0x00 ) { // [0000 0011] check the f0 full bit |
|
348 | if ( (waveform_picker_regs->status & 0x03) != 0x00 ) { // [0000 0011] check the f0 full bit | |
349 | swf_f0_ready = true; |
|
349 | swf_f0_ready = true; | |
350 | // change f0 buffer |
|
350 | // change f0 buffer | |
351 | ring_node_to_send_swf_f0 = current_ring_node_f0->previous; |
|
351 | ring_node_to_send_swf_f0 = current_ring_node_f0->previous; | |
352 | current_ring_node_f0 = current_ring_node_f0->next; |
|
352 | current_ring_node_f0 = current_ring_node_f0->next; | |
353 | if ( (waveform_picker_regs->status & 0x01) == 0x01) |
|
353 | if ( (waveform_picker_regs->status & 0x01) == 0x01) | |
354 | { |
|
354 | { | |
355 |
|
355 | |||
356 | ring_node_to_send_swf_f0->coarseTime = waveform_picker_regs->f0_0_coarse_time; |
|
356 | ring_node_to_send_swf_f0->coarseTime = waveform_picker_regs->f0_0_coarse_time; | |
357 | ring_node_to_send_swf_f0->fineTime = waveform_picker_regs->f0_0_fine_time; |
|
357 | ring_node_to_send_swf_f0->fineTime = waveform_picker_regs->f0_0_fine_time; | |
358 | waveform_picker_regs->addr_data_f0_0 = current_ring_node_f0->buffer_address; |
|
358 | waveform_picker_regs->addr_data_f0_0 = current_ring_node_f0->buffer_address; | |
359 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00001101; // [0001 0001 0000 0001] |
|
359 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00001101; // [0001 0001 0000 0001] | |
360 | } |
|
360 | } | |
361 | else if ( (waveform_picker_regs->status & 0x02) == 0x02) |
|
361 | else if ( (waveform_picker_regs->status & 0x02) == 0x02) | |
362 | { |
|
362 | { | |
363 | ring_node_to_send_swf_f0->coarseTime = waveform_picker_regs->f0_1_coarse_time; |
|
363 | ring_node_to_send_swf_f0->coarseTime = waveform_picker_regs->f0_1_coarse_time; | |
364 | ring_node_to_send_swf_f0->fineTime = waveform_picker_regs->f0_1_fine_time; |
|
364 | ring_node_to_send_swf_f0->fineTime = waveform_picker_regs->f0_1_fine_time; | |
365 | waveform_picker_regs->addr_data_f0_1 = current_ring_node_f0->buffer_address; |
|
365 | waveform_picker_regs->addr_data_f0_1 = current_ring_node_f0->buffer_address; | |
366 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00001102; // [0001 0001 0000 0010] |
|
366 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00001102; // [0001 0001 0000 0010] | |
367 | } |
|
367 | } | |
368 | } |
|
368 | } | |
369 |
|
369 | |||
370 | //*** |
|
370 | //*** | |
371 | // F1 |
|
371 | // F1 | |
372 | if ( (waveform_picker_regs->status & 0x0c) != 0x00 ) { // [0000 1100] check the f1 full bit |
|
372 | if ( (waveform_picker_regs->status & 0x0c) != 0x00 ) { // [0000 1100] check the f1 full bit | |
373 | swf_f1_ready = true; |
|
373 | swf_f1_ready = true; | |
374 | ring_node_to_send_swf_f1 = current_ring_node_f1->previous; |
|
374 | ring_node_to_send_swf_f1 = current_ring_node_f1->previous; | |
375 | current_ring_node_f1 = current_ring_node_f1->next; |
|
375 | current_ring_node_f1 = current_ring_node_f1->next; | |
376 | if ( (waveform_picker_regs->status & 0x04) == 0x04) |
|
376 | if ( (waveform_picker_regs->status & 0x04) == 0x04) | |
377 | { |
|
377 | { | |
378 | ring_node_to_send_swf_f1->coarseTime = waveform_picker_regs->f1_0_coarse_time; |
|
378 | ring_node_to_send_swf_f1->coarseTime = waveform_picker_regs->f1_0_coarse_time; | |
379 | ring_node_to_send_swf_f1->fineTime = waveform_picker_regs->f1_0_fine_time; |
|
379 | ring_node_to_send_swf_f1->fineTime = waveform_picker_regs->f1_0_fine_time; | |
380 | waveform_picker_regs->addr_data_f1_0 = current_ring_node_f1->buffer_address; |
|
380 | waveform_picker_regs->addr_data_f1_0 = current_ring_node_f1->buffer_address; | |
381 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00002204; // [0010 0010 0000 0100] f1 bits = 0 |
|
381 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00002204; // [0010 0010 0000 0100] f1 bits = 0 | |
382 | } |
|
382 | } | |
383 | else if ( (waveform_picker_regs->status & 0x08) == 0x08) |
|
383 | else if ( (waveform_picker_regs->status & 0x08) == 0x08) | |
384 | { |
|
384 | { | |
385 | ring_node_to_send_swf_f1->coarseTime = waveform_picker_regs->f1_1_coarse_time; |
|
385 | ring_node_to_send_swf_f1->coarseTime = waveform_picker_regs->f1_1_coarse_time; | |
386 | ring_node_to_send_swf_f1->fineTime = waveform_picker_regs->f1_1_fine_time; |
|
386 | ring_node_to_send_swf_f1->fineTime = waveform_picker_regs->f1_1_fine_time; | |
387 | waveform_picker_regs->addr_data_f1_1 = current_ring_node_f1->buffer_address; |
|
387 | waveform_picker_regs->addr_data_f1_1 = current_ring_node_f1->buffer_address; | |
388 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00002208; // [0010 0010 0000 1000] f1 bits = 0 |
|
388 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00002208; // [0010 0010 0000 1000] f1 bits = 0 | |
389 | } |
|
389 | } | |
390 | } |
|
390 | } | |
391 | } |
|
391 | } | |
392 |
|
392 | |||
393 | rtems_isr waveforms_isr( rtems_vector_number vector ) |
|
393 | rtems_isr waveforms_isr( rtems_vector_number vector ) | |
394 | { |
|
394 | { | |
395 | /** This is the interrupt sub routine called by the waveform picker core. |
|
395 | /** This is the interrupt sub routine called by the waveform picker core. | |
396 | * |
|
396 | * | |
397 | * This ISR launch different actions depending mainly on two pieces of information: |
|
397 | * This ISR launch different actions depending mainly on two pieces of information: | |
398 | * 1. the values read in the registers of the waveform picker. |
|
398 | * 1. the values read in the registers of the waveform picker. | |
399 | * 2. the current LFR mode. |
|
399 | * 2. the current LFR mode. | |
400 | * |
|
400 | * | |
401 | */ |
|
401 | */ | |
402 |
|
402 | |||
403 | // STATUS |
|
403 | // STATUS | |
404 | // new error error buffer full |
|
404 | // new error error buffer full | |
405 | // 15 14 13 12 11 10 9 8 |
|
405 | // 15 14 13 12 11 10 9 8 | |
406 | // f3 f2 f1 f0 f3 f2 f1 f0 |
|
406 | // f3 f2 f1 f0 f3 f2 f1 f0 | |
407 | // |
|
407 | // | |
408 | // ready buffer |
|
408 | // ready buffer | |
409 | // 7 6 5 4 3 2 1 0 |
|
409 | // 7 6 5 4 3 2 1 0 | |
410 | // f3_1 f3_0 f2_1 f2_0 f1_1 f1_0 f0_1 f0_0 |
|
410 | // f3_1 f3_0 f2_1 f2_0 f1_1 f1_0 f0_1 f0_0 | |
411 |
|
411 | |||
412 | rtems_status_code spare_status; |
|
412 | rtems_status_code spare_status; | |
413 |
|
413 | |||
414 | waveforms_isr_f3(); |
|
414 | waveforms_isr_f3(); | |
415 |
|
415 | |||
416 | if ( (waveform_picker_regs->status & 0xff00) != 0x00) // [1111 1111 0000 0000] check the error bits |
|
416 | if ( (waveform_picker_regs->status & 0xff00) != 0x00) // [1111 1111 0000 0000] check the error bits | |
417 | { |
|
417 | { | |
418 | spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_10 ); |
|
418 | spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_10 ); | |
419 | } |
|
419 | } | |
420 |
|
420 | |||
421 | switch(lfrCurrentMode) |
|
421 | switch(lfrCurrentMode) | |
422 | { |
|
422 | { | |
423 | //******** |
|
423 | //******** | |
424 | // STANDBY |
|
424 | // STANDBY | |
425 | case(LFR_MODE_STANDBY): |
|
425 | case(LFR_MODE_STANDBY): | |
426 | break; |
|
426 | break; | |
427 |
|
427 | |||
428 | //****** |
|
428 | //****** | |
429 | // NORMAL |
|
429 | // NORMAL | |
430 | case(LFR_MODE_NORMAL): |
|
430 | case(LFR_MODE_NORMAL): | |
431 | waveforms_isr_normal(); |
|
431 | waveforms_isr_normal(); | |
432 | break; |
|
432 | break; | |
433 |
|
433 | |||
434 | //****** |
|
434 | //****** | |
435 | // BURST |
|
435 | // BURST | |
436 | case(LFR_MODE_BURST): |
|
436 | case(LFR_MODE_BURST): | |
437 | waveforms_isr_burst(); |
|
437 | waveforms_isr_burst(); | |
438 | break; |
|
438 | break; | |
439 |
|
439 | |||
440 | //***** |
|
440 | //***** | |
441 | // SBM1 |
|
441 | // SBM1 | |
442 | case(LFR_MODE_SBM1): |
|
442 | case(LFR_MODE_SBM1): | |
443 | waveforms_isr_sbm1(); |
|
443 | waveforms_isr_sbm1(); | |
444 | break; |
|
444 | break; | |
445 |
|
445 | |||
446 | //***** |
|
446 | //***** | |
447 | // SBM2 |
|
447 | // SBM2 | |
448 | case(LFR_MODE_SBM2): |
|
448 | case(LFR_MODE_SBM2): | |
449 | waveforms_isr_sbm2(); |
|
449 | waveforms_isr_sbm2(); | |
450 | break; |
|
450 | break; | |
451 |
|
451 | |||
452 | //******** |
|
452 | //******** | |
453 | // DEFAULT |
|
453 | // DEFAULT | |
454 | default: |
|
454 | default: | |
455 | break; |
|
455 | break; | |
456 | } |
|
456 | } | |
457 | } |
|
457 | } | |
458 |
|
458 | |||
459 | //************ |
|
459 | //************ | |
460 | // RTEMS TASKS |
|
460 | // RTEMS TASKS | |
461 |
|
461 | |||
462 | rtems_task wfrm_task(rtems_task_argument argument) //used with the waveform picker VHDL IP |
|
462 | rtems_task wfrm_task(rtems_task_argument argument) //used with the waveform picker VHDL IP | |
463 | { |
|
463 | { | |
464 | /** This RTEMS task is dedicated to the transmission of snapshots of the NORMAL mode. |
|
464 | /** This RTEMS task is dedicated to the transmission of snapshots of the NORMAL mode. | |
465 | * |
|
465 | * | |
466 | * @param unused is the starting argument of the RTEMS task |
|
466 | * @param unused is the starting argument of the RTEMS task | |
467 | * |
|
467 | * | |
468 | * The following data packets are sent by this task: |
|
468 | * The following data packets are sent by this task: | |
469 | * - TM_LFR_SCIENCE_NORMAL_SWF_F0 |
|
469 | * - TM_LFR_SCIENCE_NORMAL_SWF_F0 | |
470 | * - TM_LFR_SCIENCE_NORMAL_SWF_F1 |
|
470 | * - TM_LFR_SCIENCE_NORMAL_SWF_F1 | |
471 | * - TM_LFR_SCIENCE_NORMAL_SWF_F2 |
|
471 | * - TM_LFR_SCIENCE_NORMAL_SWF_F2 | |
472 | * |
|
472 | * | |
473 | */ |
|
473 | */ | |
474 |
|
474 | |||
475 | rtems_event_set event_out; |
|
475 | rtems_event_set event_out; | |
476 | rtems_id queue_id; |
|
476 | rtems_id queue_id; | |
477 | rtems_status_code status; |
|
477 | rtems_status_code status; | |
478 | bool resynchronisationEngaged; |
|
478 | bool resynchronisationEngaged; | |
479 | ring_node *ring_node_wf_snap_extracted_ptr; |
|
479 | ring_node *ring_node_wf_snap_extracted_ptr; | |
480 |
|
480 | |||
481 | ring_node_wf_snap_extracted_ptr = (ring_node *) &ring_node_wf_snap_extracted; |
|
481 | ring_node_wf_snap_extracted_ptr = (ring_node *) &ring_node_wf_snap_extracted; | |
482 |
|
482 | |||
483 | resynchronisationEngaged = false; |
|
483 | resynchronisationEngaged = false; | |
484 |
|
484 | |||
485 | status = get_message_queue_id_send( &queue_id ); |
|
485 | status = get_message_queue_id_send( &queue_id ); | |
486 | if (status != RTEMS_SUCCESSFUL) |
|
486 | if (status != RTEMS_SUCCESSFUL) | |
487 | { |
|
487 | { | |
488 | PRINTF1("in WFRM *** ERR get_message_queue_id_send %d\n", status) |
|
488 | PRINTF1("in WFRM *** ERR get_message_queue_id_send %d\n", status) | |
489 | } |
|
489 | } | |
490 |
|
490 | |||
491 | BOOT_PRINTF("in WFRM ***\n") |
|
491 | BOOT_PRINTF("in WFRM ***\n") | |
492 |
|
492 | |||
493 | while(1){ |
|
493 | while(1){ | |
494 | // wait for an RTEMS_EVENT |
|
494 | // wait for an RTEMS_EVENT | |
495 | rtems_event_receive(RTEMS_EVENT_MODE_NORMAL | RTEMS_EVENT_MODE_SBM1 |
|
495 | rtems_event_receive(RTEMS_EVENT_MODE_NORMAL | RTEMS_EVENT_MODE_SBM1 | |
496 | | RTEMS_EVENT_MODE_SBM2 | RTEMS_EVENT_MODE_SBM2_WFRM, |
|
496 | | RTEMS_EVENT_MODE_SBM2 | RTEMS_EVENT_MODE_SBM2_WFRM, | |
497 | RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); |
|
497 | RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); | |
498 | if(resynchronisationEngaged == false) |
|
498 | if(resynchronisationEngaged == false) | |
499 | { // engage resynchronisation |
|
499 | { // engage resynchronisation | |
500 | snapshot_resynchronization( (unsigned char *) &ring_node_to_send_swf_f0->coarseTime ); |
|
500 | snapshot_resynchronization( (unsigned char *) &ring_node_to_send_swf_f0->coarseTime ); | |
501 | resynchronisationEngaged = true; |
|
501 | resynchronisationEngaged = true; | |
502 | } |
|
502 | } | |
503 | else |
|
503 | else | |
504 | { // reset delta_snapshot to the nominal value |
|
504 | { // reset delta_snapshot to the nominal value | |
505 | PRINTF("no resynchronisation, reset delta_snapshot to the nominal value\n") |
|
505 | PRINTF("no resynchronisation, reset delta_snapshot to the nominal value\n") | |
506 | set_wfp_delta_snapshot(); |
|
506 | set_wfp_delta_snapshot(); | |
507 | resynchronisationEngaged = false; |
|
507 | resynchronisationEngaged = false; | |
508 | } |
|
508 | } | |
509 | // |
|
509 | // | |
510 |
|
510 | |||
511 | if (event_out == RTEMS_EVENT_MODE_NORMAL) |
|
511 | if (event_out == RTEMS_EVENT_MODE_NORMAL) | |
512 | { |
|
512 | { | |
513 | DEBUG_PRINTF("WFRM received RTEMS_EVENT_MODE_NORMAL\n") |
|
513 | DEBUG_PRINTF("WFRM received RTEMS_EVENT_MODE_NORMAL\n") | |
514 | ring_node_to_send_swf_f0->sid = SID_NORM_SWF_F0; |
|
514 | ring_node_to_send_swf_f0->sid = SID_NORM_SWF_F0; | |
515 | ring_node_to_send_swf_f1->sid = SID_NORM_SWF_F1; |
|
515 | ring_node_to_send_swf_f1->sid = SID_NORM_SWF_F1; | |
516 | ring_node_to_send_swf_f2->sid = SID_NORM_SWF_F2; |
|
516 | ring_node_to_send_swf_f2->sid = SID_NORM_SWF_F2; | |
517 | status = rtems_message_queue_send( queue_id, &ring_node_to_send_swf_f0, sizeof( ring_node* ) ); |
|
517 | status = rtems_message_queue_send( queue_id, &ring_node_to_send_swf_f0, sizeof( ring_node* ) ); | |
518 | status = rtems_message_queue_send( queue_id, &ring_node_to_send_swf_f1, sizeof( ring_node* ) ); |
|
518 | status = rtems_message_queue_send( queue_id, &ring_node_to_send_swf_f1, sizeof( ring_node* ) ); | |
519 | status = rtems_message_queue_send( queue_id, &ring_node_to_send_swf_f2, sizeof( ring_node* ) ); |
|
519 | status = rtems_message_queue_send( queue_id, &ring_node_to_send_swf_f2, sizeof( ring_node* ) ); | |
520 | } |
|
520 | } | |
521 | if (event_out == RTEMS_EVENT_MODE_SBM1) |
|
521 | if (event_out == RTEMS_EVENT_MODE_SBM1) | |
522 | { |
|
522 | { | |
523 | DEBUG_PRINTF("WFRM received RTEMS_EVENT_MODE_SBM1\n") |
|
523 | DEBUG_PRINTF("WFRM received RTEMS_EVENT_MODE_SBM1\n") | |
524 | ring_node_to_send_swf_f0->sid = SID_NORM_SWF_F0; |
|
524 | ring_node_to_send_swf_f0->sid = SID_NORM_SWF_F0; | |
525 | ring_node_wf_snap_extracted_ptr->sid = SID_NORM_SWF_F1; |
|
525 | ring_node_wf_snap_extracted_ptr->sid = SID_NORM_SWF_F1; | |
526 | ring_node_to_send_swf_f2->sid = SID_NORM_SWF_F2; |
|
526 | ring_node_to_send_swf_f2->sid = SID_NORM_SWF_F2; | |
527 | status = rtems_message_queue_send( queue_id, &ring_node_to_send_swf_f0, sizeof( ring_node* ) ); |
|
527 | status = rtems_message_queue_send( queue_id, &ring_node_to_send_swf_f0, sizeof( ring_node* ) ); | |
528 | status = rtems_message_queue_send( queue_id, &ring_node_wf_snap_extracted_ptr, sizeof( ring_node* ) ); |
|
528 | status = rtems_message_queue_send( queue_id, &ring_node_wf_snap_extracted_ptr, sizeof( ring_node* ) ); | |
529 | status = rtems_message_queue_send( queue_id, &ring_node_to_send_swf_f2, sizeof( ring_node* ) ); |
|
529 | status = rtems_message_queue_send( queue_id, &ring_node_to_send_swf_f2, sizeof( ring_node* ) ); | |
530 | } |
|
530 | } | |
531 | if (event_out == RTEMS_EVENT_MODE_SBM2) |
|
531 | if (event_out == RTEMS_EVENT_MODE_SBM2) | |
532 | { |
|
532 | { | |
533 | DEBUG_PRINTF("WFRM received RTEMS_EVENT_MODE_SBM2\n") |
|
533 | DEBUG_PRINTF("WFRM received RTEMS_EVENT_MODE_SBM2\n") | |
534 | ring_node_to_send_swf_f0->sid = SID_NORM_SWF_F0; |
|
534 | ring_node_to_send_swf_f0->sid = SID_NORM_SWF_F0; | |
535 | ring_node_to_send_swf_f1->sid = SID_NORM_SWF_F1; |
|
535 | ring_node_to_send_swf_f1->sid = SID_NORM_SWF_F1; | |
536 | ring_node_wf_snap_extracted_ptr->sid = SID_NORM_SWF_F2; |
|
536 | ring_node_wf_snap_extracted_ptr->sid = SID_NORM_SWF_F2; | |
537 | status = rtems_message_queue_send( queue_id, &ring_node_to_send_swf_f0, sizeof( ring_node* ) ); |
|
537 | status = rtems_message_queue_send( queue_id, &ring_node_to_send_swf_f0, sizeof( ring_node* ) ); | |
538 | status = rtems_message_queue_send( queue_id, &ring_node_to_send_swf_f1, sizeof( ring_node* ) ); |
|
538 | status = rtems_message_queue_send( queue_id, &ring_node_to_send_swf_f1, sizeof( ring_node* ) ); | |
539 | status = rtems_message_queue_send( queue_id, &ring_node_wf_snap_extracted_ptr, sizeof( ring_node* ) ); |
|
539 | status = rtems_message_queue_send( queue_id, &ring_node_wf_snap_extracted_ptr, sizeof( ring_node* ) ); | |
540 | } |
|
540 | } | |
541 | } |
|
541 | } | |
542 | } |
|
542 | } | |
543 |
|
543 | |||
544 | rtems_task cwf3_task(rtems_task_argument argument) //used with the waveform picker VHDL IP |
|
544 | rtems_task cwf3_task(rtems_task_argument argument) //used with the waveform picker VHDL IP | |
545 | { |
|
545 | { | |
546 | /** This RTEMS task is dedicated to the transmission of continuous waveforms at f3. |
|
546 | /** This RTEMS task is dedicated to the transmission of continuous waveforms at f3. | |
547 | * |
|
547 | * | |
548 | * @param unused is the starting argument of the RTEMS task |
|
548 | * @param unused is the starting argument of the RTEMS task | |
549 | * |
|
549 | * | |
550 | * The following data packet is sent by this task: |
|
550 | * The following data packet is sent by this task: | |
551 | * - TM_LFR_SCIENCE_NORMAL_CWF_F3 |
|
551 | * - TM_LFR_SCIENCE_NORMAL_CWF_F3 | |
552 | * |
|
552 | * | |
553 | */ |
|
553 | */ | |
554 |
|
554 | |||
555 | rtems_event_set event_out; |
|
555 | rtems_event_set event_out; | |
556 | rtems_id queue_id; |
|
556 | rtems_id queue_id; | |
557 | rtems_status_code status; |
|
557 | rtems_status_code status; | |
558 | ring_node ring_node_cwf3_light; |
|
558 | ring_node ring_node_cwf3_light; | |
559 | ring_node *ring_node_to_send_cwf; |
|
559 | ring_node *ring_node_to_send_cwf; | |
560 |
|
560 | |||
561 | status = get_message_queue_id_send( &queue_id ); |
|
561 | status = get_message_queue_id_send( &queue_id ); | |
562 | if (status != RTEMS_SUCCESSFUL) |
|
562 | if (status != RTEMS_SUCCESSFUL) | |
563 | { |
|
563 | { | |
564 | PRINTF1("in CWF3 *** ERR get_message_queue_id_send %d\n", status) |
|
564 | PRINTF1("in CWF3 *** ERR get_message_queue_id_send %d\n", status) | |
565 | } |
|
565 | } | |
566 |
|
566 | |||
567 | ring_node_to_send_cwf_f3->sid = SID_NORM_CWF_LONG_F3; |
|
567 | ring_node_to_send_cwf_f3->sid = SID_NORM_CWF_LONG_F3; | |
568 |
|
568 | |||
569 | // init the ring_node_cwf3_light structure |
|
569 | // init the ring_node_cwf3_light structure | |
570 | ring_node_cwf3_light.buffer_address = (int) wf_cont_f3_light; |
|
570 | ring_node_cwf3_light.buffer_address = (int) wf_cont_f3_light; | |
571 | ring_node_cwf3_light.coarseTime = 0x00; |
|
571 | ring_node_cwf3_light.coarseTime = 0x00; | |
572 | ring_node_cwf3_light.fineTime = 0x00; |
|
572 | ring_node_cwf3_light.fineTime = 0x00; | |
573 | ring_node_cwf3_light.next = NULL; |
|
573 | ring_node_cwf3_light.next = NULL; | |
574 | ring_node_cwf3_light.previous = NULL; |
|
574 | ring_node_cwf3_light.previous = NULL; | |
575 | ring_node_cwf3_light.sid = SID_NORM_CWF_F3; |
|
575 | ring_node_cwf3_light.sid = SID_NORM_CWF_F3; | |
576 | ring_node_cwf3_light.status = 0x00; |
|
576 | ring_node_cwf3_light.status = 0x00; | |
577 |
|
577 | |||
578 | BOOT_PRINTF("in CWF3 ***\n") |
|
578 | BOOT_PRINTF("in CWF3 ***\n") | |
579 |
|
579 | |||
580 | while(1){ |
|
580 | while(1){ | |
581 | // wait for an RTEMS_EVENT |
|
581 | // wait for an RTEMS_EVENT | |
582 | rtems_event_receive( RTEMS_EVENT_0, |
|
582 | rtems_event_receive( RTEMS_EVENT_0, | |
583 | RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); |
|
583 | RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); | |
584 | if ( (lfrCurrentMode == LFR_MODE_NORMAL) |
|
584 | if ( (lfrCurrentMode == LFR_MODE_NORMAL) | |
585 | || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode==LFR_MODE_SBM2) ) |
|
585 | || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode==LFR_MODE_SBM2) ) | |
586 | { |
|
586 | { | |
587 | ring_node_to_send_cwf = getRingNodeToSendCWF( 3 ); |
|
587 | ring_node_to_send_cwf = getRingNodeToSendCWF( 3 ); | |
588 | if ( (parameter_dump_packet.sy_lfr_n_cwf_long_f3 & 0x01) == 0x01) |
|
588 | if ( (parameter_dump_packet.sy_lfr_n_cwf_long_f3 & 0x01) == 0x01) | |
589 | { |
|
589 | { | |
590 | PRINTF("send CWF_LONG_F3\n") |
|
590 | PRINTF("send CWF_LONG_F3\n") | |
591 | ring_node_to_send_cwf_f3->sid = SID_NORM_CWF_LONG_F3; |
|
591 | ring_node_to_send_cwf_f3->sid = SID_NORM_CWF_LONG_F3; | |
592 | status = rtems_message_queue_send( queue_id, &ring_node_to_send_cwf, sizeof( ring_node* ) ); |
|
592 | status = rtems_message_queue_send( queue_id, &ring_node_to_send_cwf, sizeof( ring_node* ) ); | |
593 | } |
|
593 | } | |
594 | else |
|
594 | else | |
595 | { |
|
595 | { | |
596 | PRINTF("send CWF_F3 (light)\n") |
|
596 | PRINTF("send CWF_F3 (light)\n") | |
597 | send_waveform_CWF3_light( ring_node_to_send_cwf, &ring_node_cwf3_light, queue_id ); |
|
597 | send_waveform_CWF3_light( ring_node_to_send_cwf, &ring_node_cwf3_light, queue_id ); | |
598 | } |
|
598 | } | |
599 |
|
599 | |||
600 | } |
|
600 | } | |
601 | else |
|
601 | else | |
602 | { |
|
602 | { | |
603 | PRINTF1("in CWF3 *** lfrCurrentMode is %d, no data will be sent\n", lfrCurrentMode) |
|
603 | PRINTF1("in CWF3 *** lfrCurrentMode is %d, no data will be sent\n", lfrCurrentMode) | |
604 | } |
|
604 | } | |
605 | } |
|
605 | } | |
606 | } |
|
606 | } | |
607 |
|
607 | |||
608 | rtems_task cwf2_task(rtems_task_argument argument) // ONLY USED IN BURST AND SBM2 |
|
608 | rtems_task cwf2_task(rtems_task_argument argument) // ONLY USED IN BURST AND SBM2 | |
609 | { |
|
609 | { | |
610 | /** This RTEMS task is dedicated to the transmission of continuous waveforms at f2. |
|
610 | /** This RTEMS task is dedicated to the transmission of continuous waveforms at f2. | |
611 | * |
|
611 | * | |
612 | * @param unused is the starting argument of the RTEMS task |
|
612 | * @param unused is the starting argument of the RTEMS task | |
613 | * |
|
613 | * | |
614 | * The following data packet is sent by this function: |
|
614 | * The following data packet is sent by this function: | |
615 | * - TM_LFR_SCIENCE_BURST_CWF_F2 |
|
615 | * - TM_LFR_SCIENCE_BURST_CWF_F2 | |
616 | * - TM_LFR_SCIENCE_SBM2_CWF_F2 |
|
616 | * - TM_LFR_SCIENCE_SBM2_CWF_F2 | |
617 | * |
|
617 | * | |
618 | */ |
|
618 | */ | |
619 |
|
619 | |||
620 | rtems_event_set event_out; |
|
620 | rtems_event_set event_out; | |
621 | rtems_id queue_id; |
|
621 | rtems_id queue_id; | |
622 | rtems_status_code status; |
|
622 | rtems_status_code status; | |
623 | ring_node *ring_node_to_send; |
|
623 | ring_node *ring_node_to_send; | |
624 | unsigned long long int acquisitionTimeF0_asLong; |
|
624 | unsigned long long int acquisitionTimeF0_asLong; | |
625 |
|
625 | |||
626 | acquisitionTimeF0_asLong = 0x00; |
|
626 | acquisitionTimeF0_asLong = 0x00; | |
627 |
|
627 | |||
628 | status = get_message_queue_id_send( &queue_id ); |
|
628 | status = get_message_queue_id_send( &queue_id ); | |
629 | if (status != RTEMS_SUCCESSFUL) |
|
629 | if (status != RTEMS_SUCCESSFUL) | |
630 | { |
|
630 | { | |
631 | PRINTF1("in CWF2 *** ERR get_message_queue_id_send %d\n", status) |
|
631 | PRINTF1("in CWF2 *** ERR get_message_queue_id_send %d\n", status) | |
632 | } |
|
632 | } | |
633 |
|
633 | |||
634 | BOOT_PRINTF("in CWF2 ***\n") |
|
634 | BOOT_PRINTF("in CWF2 ***\n") | |
635 |
|
635 | |||
636 | while(1){ |
|
636 | while(1){ | |
637 | // wait for an RTEMS_EVENT |
|
637 | // wait for an RTEMS_EVENT | |
638 | rtems_event_receive( RTEMS_EVENT_MODE_BURST | RTEMS_EVENT_MODE_SBM2, |
|
638 | rtems_event_receive( RTEMS_EVENT_MODE_BURST | RTEMS_EVENT_MODE_SBM2, | |
639 | RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); |
|
639 | RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); | |
640 | ring_node_to_send = getRingNodeToSendCWF( 2 ); |
|
640 | ring_node_to_send = getRingNodeToSendCWF( 2 ); | |
641 | if (event_out == RTEMS_EVENT_MODE_BURST) |
|
641 | if (event_out == RTEMS_EVENT_MODE_BURST) | |
642 | { |
|
642 | { | |
643 | status = rtems_message_queue_send( queue_id, &ring_node_to_send, sizeof( ring_node* ) ); |
|
643 | status = rtems_message_queue_send( queue_id, &ring_node_to_send, sizeof( ring_node* ) ); | |
644 | } |
|
644 | } | |
645 | if (event_out == RTEMS_EVENT_MODE_SBM2) |
|
645 | if (event_out == RTEMS_EVENT_MODE_SBM2) | |
646 | { |
|
646 | { | |
647 | status = rtems_message_queue_send( queue_id, &ring_node_to_send, sizeof( ring_node* ) ); |
|
647 | status = rtems_message_queue_send( queue_id, &ring_node_to_send, sizeof( ring_node* ) ); | |
648 | // launch snapshot extraction if needed |
|
648 | // launch snapshot extraction if needed | |
649 | if (extractSWF == true) |
|
649 | if (extractSWF == true) | |
650 | { |
|
650 | { | |
651 | ring_node_to_send_swf_f2 = ring_node_to_send_cwf_f2; |
|
651 | ring_node_to_send_swf_f2 = ring_node_to_send_cwf_f2; | |
652 | // extract the snapshot |
|
652 | // extract the snapshot | |
653 | build_snapshot_from_ring( ring_node_to_send_swf_f2, 2, acquisitionTimeF0_asLong ); |
|
653 | build_snapshot_from_ring( ring_node_to_send_swf_f2, 2, acquisitionTimeF0_asLong ); | |
654 | // send the snapshot when built |
|
654 | // send the snapshot when built | |
655 | status = rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_SBM2 ); |
|
655 | status = rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_SBM2 ); | |
656 | extractSWF = false; |
|
656 | extractSWF = false; | |
657 | } |
|
657 | } | |
658 | if (swf_f0_ready && swf_f1_ready) |
|
658 | if (swf_f0_ready && swf_f1_ready) | |
659 | { |
|
659 | { | |
660 | extractSWF = true; |
|
660 | extractSWF = true; | |
661 | // record the acquition time of the fΓ snapshot to use to build the snapshot at f2 |
|
661 | // record the acquition time of the fΓ snapshot to use to build the snapshot at f2 | |
662 | acquisitionTimeF0_asLong = get_acquisition_time( (unsigned char *) &ring_node_to_send_swf_f0->coarseTime ); |
|
662 | acquisitionTimeF0_asLong = get_acquisition_time( (unsigned char *) &ring_node_to_send_swf_f0->coarseTime ); | |
663 | swf_f0_ready = false; |
|
663 | swf_f0_ready = false; | |
664 | swf_f1_ready = false; |
|
664 | swf_f1_ready = false; | |
665 | } |
|
665 | } | |
666 | } |
|
666 | } | |
667 | } |
|
667 | } | |
668 | } |
|
668 | } | |
669 |
|
669 | |||
670 | rtems_task cwf1_task(rtems_task_argument argument) // ONLY USED IN SBM1 |
|
670 | rtems_task cwf1_task(rtems_task_argument argument) // ONLY USED IN SBM1 | |
671 | { |
|
671 | { | |
672 | /** This RTEMS task is dedicated to the transmission of continuous waveforms at f1. |
|
672 | /** This RTEMS task is dedicated to the transmission of continuous waveforms at f1. | |
673 | * |
|
673 | * | |
674 | * @param unused is the starting argument of the RTEMS task |
|
674 | * @param unused is the starting argument of the RTEMS task | |
675 | * |
|
675 | * | |
676 | * The following data packet is sent by this function: |
|
676 | * The following data packet is sent by this function: | |
677 | * - TM_LFR_SCIENCE_SBM1_CWF_F1 |
|
677 | * - TM_LFR_SCIENCE_SBM1_CWF_F1 | |
678 | * |
|
678 | * | |
679 | */ |
|
679 | */ | |
680 |
|
680 | |||
681 | rtems_event_set event_out; |
|
681 | rtems_event_set event_out; | |
682 | rtems_id queue_id; |
|
682 | rtems_id queue_id; | |
683 | rtems_status_code status; |
|
683 | rtems_status_code status; | |
684 |
|
684 | |||
685 | ring_node *ring_node_to_send_cwf; |
|
685 | ring_node *ring_node_to_send_cwf; | |
686 |
|
686 | |||
687 | status = get_message_queue_id_send( &queue_id ); |
|
687 | status = get_message_queue_id_send( &queue_id ); | |
688 | if (status != RTEMS_SUCCESSFUL) |
|
688 | if (status != RTEMS_SUCCESSFUL) | |
689 | { |
|
689 | { | |
690 | PRINTF1("in CWF1 *** ERR get_message_queue_id_send %d\n", status) |
|
690 | PRINTF1("in CWF1 *** ERR get_message_queue_id_send %d\n", status) | |
691 | } |
|
691 | } | |
692 |
|
692 | |||
693 | BOOT_PRINTF("in CWF1 ***\n") |
|
693 | BOOT_PRINTF("in CWF1 ***\n") | |
694 |
|
694 | |||
695 | while(1){ |
|
695 | while(1){ | |
696 | // wait for an RTEMS_EVENT |
|
696 | // wait for an RTEMS_EVENT | |
697 | rtems_event_receive( RTEMS_EVENT_MODE_SBM1, |
|
697 | rtems_event_receive( RTEMS_EVENT_MODE_SBM1, | |
698 | RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); |
|
698 | RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); | |
699 | ring_node_to_send_cwf = getRingNodeToSendCWF( 1 ); |
|
699 | ring_node_to_send_cwf = getRingNodeToSendCWF( 1 ); | |
700 | ring_node_to_send_cwf_f1->sid = SID_SBM1_CWF_F1; |
|
700 | ring_node_to_send_cwf_f1->sid = SID_SBM1_CWF_F1; | |
701 | status = rtems_message_queue_send( queue_id, &ring_node_to_send_cwf, sizeof( ring_node* ) ); |
|
701 | status = rtems_message_queue_send( queue_id, &ring_node_to_send_cwf, sizeof( ring_node* ) ); | |
702 | if (status != 0) |
|
702 | if (status != 0) | |
703 | { |
|
703 | { | |
704 | PRINTF("cwf sending failed\n") |
|
704 | PRINTF("cwf sending failed\n") | |
705 | } |
|
705 | } | |
706 | // launch snapshot extraction if needed |
|
706 | // launch snapshot extraction if needed | |
707 | if (extractSWF == true) |
|
707 | if (extractSWF == true) | |
708 | { |
|
708 | { | |
709 | ring_node_to_send_swf_f1 = ring_node_to_send_cwf; |
|
709 | ring_node_to_send_swf_f1 = ring_node_to_send_cwf; | |
710 | // launch the snapshot extraction |
|
710 | // launch the snapshot extraction | |
711 | status = rtems_event_send( Task_id[TASKID_SWBD], RTEMS_EVENT_MODE_SBM1 ); |
|
711 | status = rtems_event_send( Task_id[TASKID_SWBD], RTEMS_EVENT_MODE_SBM1 ); | |
712 | extractSWF = false; |
|
712 | extractSWF = false; | |
713 | } |
|
713 | } | |
714 | if (swf_f0_ready == true) |
|
714 | if (swf_f0_ready == true) | |
715 | { |
|
715 | { | |
716 | extractSWF = true; |
|
716 | extractSWF = true; | |
717 | swf_f0_ready = false; // this step shall be executed only one time |
|
717 | swf_f0_ready = false; // this step shall be executed only one time | |
718 | } |
|
718 | } | |
719 | if ((swf_f1_ready == true) && (swf_f2_ready == true)) // swf_f1 is ready after the extraction |
|
719 | if ((swf_f1_ready == true) && (swf_f2_ready == true)) // swf_f1 is ready after the extraction | |
720 | { |
|
720 | { | |
721 | status = rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_SBM1 ); |
|
721 | status = rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_SBM1 ); | |
722 | swf_f1_ready = false; |
|
722 | swf_f1_ready = false; | |
723 | swf_f2_ready = false; |
|
723 | swf_f2_ready = false; | |
724 | } |
|
724 | } | |
725 | } |
|
725 | } | |
726 | } |
|
726 | } | |
727 |
|
727 | |||
728 | rtems_task swbd_task(rtems_task_argument argument) |
|
728 | rtems_task swbd_task(rtems_task_argument argument) | |
729 | { |
|
729 | { | |
730 | /** This RTEMS task is dedicated to the building of snapshots from different continuous waveforms buffers. |
|
730 | /** This RTEMS task is dedicated to the building of snapshots from different continuous waveforms buffers. | |
731 | * |
|
731 | * | |
732 | * @param unused is the starting argument of the RTEMS task |
|
732 | * @param unused is the starting argument of the RTEMS task | |
733 | * |
|
733 | * | |
734 | */ |
|
734 | */ | |
735 |
|
735 | |||
736 | rtems_event_set event_out; |
|
736 | rtems_event_set event_out; | |
737 | unsigned long long int acquisitionTimeF0_asLong; |
|
737 | unsigned long long int acquisitionTimeF0_asLong; | |
738 |
|
738 | |||
739 | acquisitionTimeF0_asLong = 0x00; |
|
739 | acquisitionTimeF0_asLong = 0x00; | |
740 |
|
740 | |||
741 | BOOT_PRINTF("in SWBD ***\n") |
|
741 | BOOT_PRINTF("in SWBD ***\n") | |
742 |
|
742 | |||
743 | while(1){ |
|
743 | while(1){ | |
744 | // wait for an RTEMS_EVENT |
|
744 | // wait for an RTEMS_EVENT | |
745 | rtems_event_receive( RTEMS_EVENT_MODE_SBM1 | RTEMS_EVENT_MODE_SBM2, |
|
745 | rtems_event_receive( RTEMS_EVENT_MODE_SBM1 | RTEMS_EVENT_MODE_SBM2, | |
746 | RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); |
|
746 | RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); | |
747 | if (event_out == RTEMS_EVENT_MODE_SBM1) |
|
747 | if (event_out == RTEMS_EVENT_MODE_SBM1) | |
748 | { |
|
748 | { | |
749 | acquisitionTimeF0_asLong = get_acquisition_time( (unsigned char *) &ring_node_to_send_swf_f0->coarseTime ); |
|
749 | acquisitionTimeF0_asLong = get_acquisition_time( (unsigned char *) &ring_node_to_send_swf_f0->coarseTime ); | |
750 | build_snapshot_from_ring( ring_node_to_send_swf_f1, 1, acquisitionTimeF0_asLong ); |
|
750 | build_snapshot_from_ring( ring_node_to_send_swf_f1, 1, acquisitionTimeF0_asLong ); | |
751 | swf_f1_ready = true; // the snapshot has been extracted and is ready to be sent |
|
751 | swf_f1_ready = true; // the snapshot has been extracted and is ready to be sent | |
752 | } |
|
752 | } | |
753 | else |
|
753 | else | |
754 | { |
|
754 | { | |
755 | PRINTF1("in SWBD *** unexpected rtems event received %x\n", (int) event_out) |
|
755 | PRINTF1("in SWBD *** unexpected rtems event received %x\n", (int) event_out) | |
756 | } |
|
756 | } | |
757 | } |
|
757 | } | |
758 | } |
|
758 | } | |
759 |
|
759 | |||
760 | //****************** |
|
760 | //****************** | |
761 | // general functions |
|
761 | // general functions | |
762 |
|
762 | |||
763 | void WFP_init_rings( void ) |
|
763 | void WFP_init_rings( void ) | |
764 | { |
|
764 | { | |
765 | // F0 RING |
|
765 | // F0 RING | |
766 | init_ring( waveform_ring_f0, NB_RING_NODES_F0, wf_buffer_f0, WFRM_BUFFER ); |
|
766 | init_ring( waveform_ring_f0, NB_RING_NODES_F0, wf_buffer_f0, WFRM_BUFFER ); | |
767 | // F1 RING |
|
767 | // F1 RING | |
768 | init_ring( waveform_ring_f1, NB_RING_NODES_F1, wf_buffer_f1, WFRM_BUFFER ); |
|
768 | init_ring( waveform_ring_f1, NB_RING_NODES_F1, wf_buffer_f1, WFRM_BUFFER ); | |
769 | // F2 RING |
|
769 | // F2 RING | |
770 | init_ring( waveform_ring_f2, NB_RING_NODES_F2, wf_buffer_f2, WFRM_BUFFER ); |
|
770 | init_ring( waveform_ring_f2, NB_RING_NODES_F2, wf_buffer_f2, WFRM_BUFFER ); | |
771 | // F3 RING |
|
771 | // F3 RING | |
772 | init_ring( waveform_ring_f3, NB_RING_NODES_F3, wf_buffer_f3, WFRM_BUFFER ); |
|
772 | init_ring( waveform_ring_f3, NB_RING_NODES_F3, wf_buffer_f3, WFRM_BUFFER ); | |
773 |
|
773 | |||
774 | ring_node_wf_snap_extracted.buffer_address = (int) wf_snap_extracted; |
|
774 | ring_node_wf_snap_extracted.buffer_address = (int) wf_snap_extracted; | |
775 |
|
775 | |||
776 | DEBUG_PRINTF1("waveform_ring_f0 @%x\n", (unsigned int) waveform_ring_f0) |
|
776 | DEBUG_PRINTF1("waveform_ring_f0 @%x\n", (unsigned int) waveform_ring_f0) | |
777 | DEBUG_PRINTF1("waveform_ring_f1 @%x\n", (unsigned int) waveform_ring_f1) |
|
777 | DEBUG_PRINTF1("waveform_ring_f1 @%x\n", (unsigned int) waveform_ring_f1) | |
778 | DEBUG_PRINTF1("waveform_ring_f2 @%x\n", (unsigned int) waveform_ring_f2) |
|
778 | DEBUG_PRINTF1("waveform_ring_f2 @%x\n", (unsigned int) waveform_ring_f2) | |
779 | DEBUG_PRINTF1("waveform_ring_f3 @%x\n", (unsigned int) waveform_ring_f3) |
|
779 | DEBUG_PRINTF1("waveform_ring_f3 @%x\n", (unsigned int) waveform_ring_f3) | |
780 | DEBUG_PRINTF1("wf_buffer_f0 @%x\n", (unsigned int) wf_buffer_f0) |
|
780 | DEBUG_PRINTF1("wf_buffer_f0 @%x\n", (unsigned int) wf_buffer_f0) | |
781 | DEBUG_PRINTF1("wf_buffer_f1 @%x\n", (unsigned int) wf_buffer_f1) |
|
781 | DEBUG_PRINTF1("wf_buffer_f1 @%x\n", (unsigned int) wf_buffer_f1) | |
782 | DEBUG_PRINTF1("wf_buffer_f2 @%x\n", (unsigned int) wf_buffer_f2) |
|
782 | DEBUG_PRINTF1("wf_buffer_f2 @%x\n", (unsigned int) wf_buffer_f2) | |
783 | DEBUG_PRINTF1("wf_buffer_f3 @%x\n", (unsigned int) wf_buffer_f3) |
|
783 | DEBUG_PRINTF1("wf_buffer_f3 @%x\n", (unsigned int) wf_buffer_f3) | |
784 |
|
784 | |||
785 | } |
|
785 | } | |
786 |
|
786 | |||
787 | void WFP_reset_current_ring_nodes( void ) |
|
787 | void WFP_reset_current_ring_nodes( void ) | |
788 | { |
|
788 | { | |
789 | current_ring_node_f0 = waveform_ring_f0[0].next; |
|
789 | current_ring_node_f0 = waveform_ring_f0[0].next; | |
790 | current_ring_node_f1 = waveform_ring_f1[0].next; |
|
790 | current_ring_node_f1 = waveform_ring_f1[0].next; | |
791 | current_ring_node_f2 = waveform_ring_f2[0].next; |
|
791 | current_ring_node_f2 = waveform_ring_f2[0].next; | |
792 | current_ring_node_f3 = waveform_ring_f3[0].next; |
|
792 | current_ring_node_f3 = waveform_ring_f3[0].next; | |
793 |
|
793 | |||
794 | ring_node_to_send_swf_f0 = waveform_ring_f0; |
|
794 | ring_node_to_send_swf_f0 = waveform_ring_f0; | |
795 | ring_node_to_send_swf_f1 = waveform_ring_f1; |
|
795 | ring_node_to_send_swf_f1 = waveform_ring_f1; | |
796 | ring_node_to_send_swf_f2 = waveform_ring_f2; |
|
796 | ring_node_to_send_swf_f2 = waveform_ring_f2; | |
797 |
|
797 | |||
798 | ring_node_to_send_cwf_f1 = waveform_ring_f1; |
|
798 | ring_node_to_send_cwf_f1 = waveform_ring_f1; | |
799 | ring_node_to_send_cwf_f2 = waveform_ring_f2; |
|
799 | ring_node_to_send_cwf_f2 = waveform_ring_f2; | |
800 | ring_node_to_send_cwf_f3 = waveform_ring_f3; |
|
800 | ring_node_to_send_cwf_f3 = waveform_ring_f3; | |
801 | } |
|
801 | } | |
802 |
|
802 | |||
803 | int send_waveform_CWF3_light( ring_node *ring_node_to_send, ring_node *ring_node_cwf3_light, rtems_id queue_id ) |
|
803 | int send_waveform_CWF3_light( ring_node *ring_node_to_send, ring_node *ring_node_cwf3_light, rtems_id queue_id ) | |
804 | { |
|
804 | { | |
805 | /** This function sends CWF_F3 CCSDS packets without the b1, b2 and b3 data. |
|
805 | /** This function sends CWF_F3 CCSDS packets without the b1, b2 and b3 data. | |
806 | * |
|
806 | * | |
807 | * @param waveform points to the buffer containing the data that will be send. |
|
807 | * @param waveform points to the buffer containing the data that will be send. | |
808 | * @param headerCWF points to a table of headers that have been prepared for the data transmission. |
|
808 | * @param headerCWF points to a table of headers that have been prepared for the data transmission. | |
809 | * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures |
|
809 | * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures | |
810 | * contain information to setup the transmission of the data packets. |
|
810 | * contain information to setup the transmission of the data packets. | |
811 | * |
|
811 | * | |
812 | * By default, CWF_F3 packet are send without the b1, b2 and b3 data. This function rebuilds a data buffer |
|
812 | * By default, CWF_F3 packet are send without the b1, b2 and b3 data. This function rebuilds a data buffer | |
813 | * from the incoming data and sends it in 7 packets, 6 containing 340 blocks and 1 one containing 8 blocks. |
|
813 | * from the incoming data and sends it in 7 packets, 6 containing 340 blocks and 1 one containing 8 blocks. | |
814 | * |
|
814 | * | |
815 | */ |
|
815 | */ | |
816 |
|
816 | |||
817 | unsigned int i; |
|
817 | unsigned int i; | |
818 | int ret; |
|
818 | int ret; | |
819 | rtems_status_code status; |
|
819 | rtems_status_code status; | |
820 |
|
820 | |||
821 | char *sample; |
|
821 | char *sample; | |
822 | int *dataPtr; |
|
822 | int *dataPtr; | |
823 |
|
823 | |||
824 | ret = LFR_DEFAULT; |
|
824 | ret = LFR_DEFAULT; | |
825 |
|
825 | |||
826 | dataPtr = (int*) ring_node_to_send->buffer_address; |
|
826 | dataPtr = (int*) ring_node_to_send->buffer_address; | |
827 |
|
827 | |||
828 | ring_node_cwf3_light->coarseTime = ring_node_to_send->coarseTime; |
|
828 | ring_node_cwf3_light->coarseTime = ring_node_to_send->coarseTime; | |
829 | ring_node_cwf3_light->fineTime = ring_node_to_send->fineTime; |
|
829 | ring_node_cwf3_light->fineTime = ring_node_to_send->fineTime; | |
830 |
|
830 | |||
831 | //********************** |
|
831 | //********************** | |
832 | // BUILD CWF3_light DATA |
|
832 | // BUILD CWF3_light DATA | |
833 | for ( i=0; i< NB_SAMPLES_PER_SNAPSHOT; i++) |
|
833 | for ( i=0; i< NB_SAMPLES_PER_SNAPSHOT; i++) | |
834 | { |
|
834 | { | |
835 | sample = (char*) &dataPtr[ (i * NB_WORDS_SWF_BLK) ]; |
|
835 | sample = (char*) &dataPtr[ (i * NB_WORDS_SWF_BLK) ]; | |
836 | wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) ] = sample[ 0 ]; |
|
836 | wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) ] = sample[ 0 ]; | |
837 | wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 1 ] = sample[ 1 ]; |
|
837 | wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 1 ] = sample[ 1 ]; | |
838 | wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 2 ] = sample[ 2 ]; |
|
838 | wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 2 ] = sample[ 2 ]; | |
839 | wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 3 ] = sample[ 3 ]; |
|
839 | wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 3 ] = sample[ 3 ]; | |
840 | wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 4 ] = sample[ 4 ]; |
|
840 | wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 4 ] = sample[ 4 ]; | |
841 | wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 5 ] = sample[ 5 ]; |
|
841 | wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 5 ] = sample[ 5 ]; | |
842 | } |
|
842 | } | |
843 |
|
843 | |||
844 | // SEND PACKET |
|
844 | // SEND PACKET | |
845 | status = rtems_message_queue_send( queue_id, &ring_node_cwf3_light, sizeof( ring_node* ) ); |
|
845 | status = rtems_message_queue_send( queue_id, &ring_node_cwf3_light, sizeof( ring_node* ) ); | |
846 | if (status != RTEMS_SUCCESSFUL) { |
|
846 | if (status != RTEMS_SUCCESSFUL) { | |
847 | ret = LFR_DEFAULT; |
|
847 | ret = LFR_DEFAULT; | |
848 | } |
|
848 | } | |
849 |
|
849 | |||
850 | return ret; |
|
850 | return ret; | |
851 | } |
|
851 | } | |
852 |
|
852 | |||
853 | void compute_acquisition_time( unsigned int coarseTime, unsigned int fineTime, |
|
853 | void compute_acquisition_time( unsigned int coarseTime, unsigned int fineTime, | |
854 | unsigned int sid, unsigned char pa_lfr_pkt_nr, unsigned char * acquisitionTime ) |
|
854 | unsigned int sid, unsigned char pa_lfr_pkt_nr, unsigned char * acquisitionTime ) | |
855 | { |
|
855 | { | |
856 | unsigned long long int acquisitionTimeAsLong; |
|
856 | unsigned long long int acquisitionTimeAsLong; | |
857 | unsigned char localAcquisitionTime[6]; |
|
857 | unsigned char localAcquisitionTime[6]; | |
858 | double deltaT; |
|
858 | double deltaT; | |
859 |
|
859 | |||
860 | deltaT = 0.; |
|
860 | deltaT = 0.; | |
861 |
|
861 | |||
862 | localAcquisitionTime[0] = (unsigned char) ( coarseTime >> 24 ); |
|
862 | localAcquisitionTime[0] = (unsigned char) ( coarseTime >> 24 ); | |
863 | localAcquisitionTime[1] = (unsigned char) ( coarseTime >> 16 ); |
|
863 | localAcquisitionTime[1] = (unsigned char) ( coarseTime >> 16 ); | |
864 | localAcquisitionTime[2] = (unsigned char) ( coarseTime >> 8 ); |
|
864 | localAcquisitionTime[2] = (unsigned char) ( coarseTime >> 8 ); | |
865 | localAcquisitionTime[3] = (unsigned char) ( coarseTime ); |
|
865 | localAcquisitionTime[3] = (unsigned char) ( coarseTime ); | |
866 | localAcquisitionTime[4] = (unsigned char) ( fineTime >> 8 ); |
|
866 | localAcquisitionTime[4] = (unsigned char) ( fineTime >> 8 ); | |
867 | localAcquisitionTime[5] = (unsigned char) ( fineTime ); |
|
867 | localAcquisitionTime[5] = (unsigned char) ( fineTime ); | |
868 |
|
868 | |||
869 | acquisitionTimeAsLong = ( (unsigned long long int) localAcquisitionTime[0] << 40 ) |
|
869 | acquisitionTimeAsLong = ( (unsigned long long int) localAcquisitionTime[0] << 40 ) | |
870 | + ( (unsigned long long int) localAcquisitionTime[1] << 32 ) |
|
870 | + ( (unsigned long long int) localAcquisitionTime[1] << 32 ) | |
871 | + ( (unsigned long long int) localAcquisitionTime[2] << 24 ) |
|
871 | + ( (unsigned long long int) localAcquisitionTime[2] << 24 ) | |
872 | + ( (unsigned long long int) localAcquisitionTime[3] << 16 ) |
|
872 | + ( (unsigned long long int) localAcquisitionTime[3] << 16 ) | |
873 | + ( (unsigned long long int) localAcquisitionTime[4] << 8 ) |
|
873 | + ( (unsigned long long int) localAcquisitionTime[4] << 8 ) | |
874 | + ( (unsigned long long int) localAcquisitionTime[5] ); |
|
874 | + ( (unsigned long long int) localAcquisitionTime[5] ); | |
875 |
|
875 | |||
876 | switch( sid ) |
|
876 | switch( sid ) | |
877 | { |
|
877 | { | |
878 | case SID_NORM_SWF_F0: |
|
878 | case SID_NORM_SWF_F0: | |
879 | deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_304 * 65536. / 24576. ; |
|
879 | deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_304 * 65536. / 24576. ; | |
880 | break; |
|
880 | break; | |
881 |
|
881 | |||
882 | case SID_NORM_SWF_F1: |
|
882 | case SID_NORM_SWF_F1: | |
883 | deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_304 * 65536. / 4096. ; |
|
883 | deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_304 * 65536. / 4096. ; | |
884 | break; |
|
884 | break; | |
885 |
|
885 | |||
886 | case SID_NORM_SWF_F2: |
|
886 | case SID_NORM_SWF_F2: | |
887 | deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_304 * 65536. / 256. ; |
|
887 | deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_304 * 65536. / 256. ; | |
888 | break; |
|
888 | break; | |
889 |
|
889 | |||
890 | case SID_SBM1_CWF_F1: |
|
890 | case SID_SBM1_CWF_F1: | |
891 | deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * 65536. / 4096. ; |
|
891 | deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * 65536. / 4096. ; | |
892 | break; |
|
892 | break; | |
893 |
|
893 | |||
894 | case SID_SBM2_CWF_F2: |
|
894 | case SID_SBM2_CWF_F2: | |
895 | deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * 65536. / 256. ; |
|
895 | deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * 65536. / 256. ; | |
896 | break; |
|
896 | break; | |
897 |
|
897 | |||
898 | case SID_BURST_CWF_F2: |
|
898 | case SID_BURST_CWF_F2: | |
899 | deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * 65536. / 256. ; |
|
899 | deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * 65536. / 256. ; | |
900 | break; |
|
900 | break; | |
901 |
|
901 | |||
902 | case SID_NORM_CWF_F3: |
|
902 | case SID_NORM_CWF_F3: | |
903 | deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF_SHORT_F3 * 65536. / 16. ; |
|
903 | deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF_SHORT_F3 * 65536. / 16. ; | |
904 | break; |
|
904 | break; | |
905 |
|
905 | |||
906 | case SID_NORM_CWF_LONG_F3: |
|
906 | case SID_NORM_CWF_LONG_F3: | |
907 | deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * 65536. / 16. ; |
|
907 | deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * 65536. / 16. ; | |
908 | break; |
|
908 | break; | |
909 |
|
909 | |||
910 | default: |
|
910 | default: | |
911 | PRINTF1("in compute_acquisition_time *** ERR unexpected sid %d\n", sid) |
|
911 | PRINTF1("in compute_acquisition_time *** ERR unexpected sid %d\n", sid) | |
912 | deltaT = 0.; |
|
912 | deltaT = 0.; | |
913 | break; |
|
913 | break; | |
914 | } |
|
914 | } | |
915 |
|
915 | |||
916 | acquisitionTimeAsLong = acquisitionTimeAsLong + (unsigned long long int) deltaT; |
|
916 | acquisitionTimeAsLong = acquisitionTimeAsLong + (unsigned long long int) deltaT; | |
917 | // |
|
917 | // | |
918 | acquisitionTime[0] = (unsigned char) (acquisitionTimeAsLong >> 40); |
|
918 | acquisitionTime[0] = (unsigned char) (acquisitionTimeAsLong >> 40); | |
919 | acquisitionTime[1] = (unsigned char) (acquisitionTimeAsLong >> 32); |
|
919 | acquisitionTime[1] = (unsigned char) (acquisitionTimeAsLong >> 32); | |
920 | acquisitionTime[2] = (unsigned char) (acquisitionTimeAsLong >> 24); |
|
920 | acquisitionTime[2] = (unsigned char) (acquisitionTimeAsLong >> 24); | |
921 | acquisitionTime[3] = (unsigned char) (acquisitionTimeAsLong >> 16); |
|
921 | acquisitionTime[3] = (unsigned char) (acquisitionTimeAsLong >> 16); | |
922 | acquisitionTime[4] = (unsigned char) (acquisitionTimeAsLong >> 8 ); |
|
922 | acquisitionTime[4] = (unsigned char) (acquisitionTimeAsLong >> 8 ); | |
923 | acquisitionTime[5] = (unsigned char) (acquisitionTimeAsLong ); |
|
923 | acquisitionTime[5] = (unsigned char) (acquisitionTimeAsLong ); | |
924 |
|
924 | |||
925 | } |
|
925 | } | |
926 |
|
926 | |||
927 | void build_snapshot_from_ring( ring_node *ring_node_to_send, unsigned char frequencyChannel, unsigned long long int acquisitionTimeF0_asLong ) |
|
927 | void build_snapshot_from_ring( ring_node *ring_node_to_send, unsigned char frequencyChannel, unsigned long long int acquisitionTimeF0_asLong ) | |
928 | { |
|
928 | { | |
929 | unsigned int i; |
|
929 | unsigned int i; | |
930 | unsigned long long int centerTime_asLong; |
|
930 | unsigned long long int centerTime_asLong; | |
931 | unsigned long long int acquisitionTime_asLong; |
|
931 | unsigned long long int acquisitionTime_asLong; | |
932 | unsigned long long int bufferAcquisitionTime_asLong; |
|
932 | unsigned long long int bufferAcquisitionTime_asLong; | |
933 | unsigned char *ptr1; |
|
933 | unsigned char *ptr1; | |
934 | unsigned char *ptr2; |
|
934 | unsigned char *ptr2; | |
935 | unsigned char *timeCharPtr; |
|
935 | unsigned char *timeCharPtr; | |
936 | unsigned char nb_ring_nodes; |
|
936 | unsigned char nb_ring_nodes; | |
937 | unsigned long long int frequency_asLong; |
|
937 | unsigned long long int frequency_asLong; | |
938 | unsigned long long int nbTicksPerSample_asLong; |
|
938 | unsigned long long int nbTicksPerSample_asLong; | |
939 | unsigned long long int nbSamplesPart1_asLong; |
|
939 | unsigned long long int nbSamplesPart1_asLong; | |
940 | unsigned long long int sampleOffset_asLong; |
|
940 | unsigned long long int sampleOffset_asLong; | |
941 |
|
941 | |||
942 | unsigned int deltaT_F0; |
|
942 | unsigned int deltaT_F0; | |
943 | unsigned int deltaT_F1; |
|
943 | unsigned int deltaT_F1; | |
944 | unsigned long long int deltaT_F2; |
|
944 | unsigned long long int deltaT_F2; | |
945 |
|
945 | |||
946 | deltaT_F0 = 2731; // (2048. / 24576. / 2.) * 65536. = 2730.667; |
|
946 | deltaT_F0 = 2731; // (2048. / 24576. / 2.) * 65536. = 2730.667; | |
947 | deltaT_F1 = 16384; // (2048. / 4096. / 2.) * 65536. = 16384; |
|
947 | deltaT_F1 = 16384; // (2048. / 4096. / 2.) * 65536. = 16384; | |
948 | deltaT_F2 = 262144; // (2048. / 256. / 2.) * 65536. = 262144; |
|
948 | deltaT_F2 = 262144; // (2048. / 256. / 2.) * 65536. = 262144; | |
949 | sampleOffset_asLong = 0x00; |
|
949 | sampleOffset_asLong = 0x00; | |
950 |
|
950 | |||
951 | // (1) get the f0 acquisition time => the value is passed in argument |
|
951 | // (1) get the f0 acquisition time => the value is passed in argument | |
952 |
|
952 | |||
953 | // (2) compute the central reference time |
|
953 | // (2) compute the central reference time | |
954 | centerTime_asLong = acquisitionTimeF0_asLong + deltaT_F0; |
|
954 | centerTime_asLong = acquisitionTimeF0_asLong + deltaT_F0; | |
955 |
|
955 | |||
956 | // (3) compute the acquisition time of the current snapshot |
|
956 | // (3) compute the acquisition time of the current snapshot | |
957 | switch(frequencyChannel) |
|
957 | switch(frequencyChannel) | |
958 | { |
|
958 | { | |
959 | case 1: // 1 is for F1 = 4096 Hz |
|
959 | case 1: // 1 is for F1 = 4096 Hz | |
960 | acquisitionTime_asLong = centerTime_asLong - deltaT_F1; |
|
960 | acquisitionTime_asLong = centerTime_asLong - deltaT_F1; | |
961 | nb_ring_nodes = NB_RING_NODES_F1; |
|
961 | nb_ring_nodes = NB_RING_NODES_F1; | |
962 | frequency_asLong = 4096; |
|
962 | frequency_asLong = 4096; | |
963 | nbTicksPerSample_asLong = 16; // 65536 / 4096; |
|
963 | nbTicksPerSample_asLong = 16; // 65536 / 4096; | |
964 | break; |
|
964 | break; | |
965 | case 2: // 2 is for F2 = 256 Hz |
|
965 | case 2: // 2 is for F2 = 256 Hz | |
966 | acquisitionTime_asLong = centerTime_asLong - deltaT_F2; |
|
966 | acquisitionTime_asLong = centerTime_asLong - deltaT_F2; | |
967 | nb_ring_nodes = NB_RING_NODES_F2; |
|
967 | nb_ring_nodes = NB_RING_NODES_F2; | |
968 | frequency_asLong = 256; |
|
968 | frequency_asLong = 256; | |
969 | nbTicksPerSample_asLong = 256; // 65536 / 256; |
|
969 | nbTicksPerSample_asLong = 256; // 65536 / 256; | |
970 | break; |
|
970 | break; | |
971 | default: |
|
971 | default: | |
972 | acquisitionTime_asLong = centerTime_asLong; |
|
972 | acquisitionTime_asLong = centerTime_asLong; | |
973 | frequency_asLong = 256; |
|
973 | frequency_asLong = 256; | |
974 | nbTicksPerSample_asLong = 256; |
|
974 | nbTicksPerSample_asLong = 256; | |
975 | break; |
|
975 | break; | |
976 | } |
|
976 | } | |
977 |
|
977 | |||
978 | //**************************************************************************** |
|
978 | //**************************************************************************** | |
979 | // (4) search the ring_node with the acquisition time <= acquisitionTime_asLong |
|
979 | // (4) search the ring_node with the acquisition time <= acquisitionTime_asLong | |
980 | for (i=0; i<nb_ring_nodes; i++) |
|
980 | for (i=0; i<nb_ring_nodes; i++) | |
981 | { |
|
981 | { | |
982 | PRINTF1("%d ... ", i) |
|
982 | PRINTF1("%d ... ", i) | |
983 | bufferAcquisitionTime_asLong = get_acquisition_time( (unsigned char *) &ring_node_to_send->coarseTime ); |
|
983 | bufferAcquisitionTime_asLong = get_acquisition_time( (unsigned char *) &ring_node_to_send->coarseTime ); | |
984 | if (bufferAcquisitionTime_asLong <= acquisitionTime_asLong) |
|
984 | if (bufferAcquisitionTime_asLong <= acquisitionTime_asLong) | |
985 | { |
|
985 | { | |
986 | PRINTF1("buffer found with acquisition time = %llx\n", bufferAcquisitionTime_asLong) |
|
986 | PRINTF1("buffer found with acquisition time = %llx\n", bufferAcquisitionTime_asLong) | |
987 | break; |
|
987 | break; | |
988 | } |
|
988 | } | |
989 | ring_node_to_send = ring_node_to_send->previous; |
|
989 | ring_node_to_send = ring_node_to_send->previous; | |
990 | } |
|
990 | } | |
991 |
|
991 | |||
992 | // (5) compute the number of samples to take in the current buffer |
|
992 | // (5) compute the number of samples to take in the current buffer | |
993 | sampleOffset_asLong = ((acquisitionTime_asLong - bufferAcquisitionTime_asLong) * frequency_asLong ) >> 16; |
|
993 | sampleOffset_asLong = ((acquisitionTime_asLong - bufferAcquisitionTime_asLong) * frequency_asLong ) >> 16; | |
994 | nbSamplesPart1_asLong = NB_SAMPLES_PER_SNAPSHOT - sampleOffset_asLong; |
|
994 | nbSamplesPart1_asLong = NB_SAMPLES_PER_SNAPSHOT - sampleOffset_asLong; | |
995 | PRINTF2("sampleOffset_asLong = %lld, nbSamplesPart1_asLong = %lld\n", sampleOffset_asLong, nbSamplesPart1_asLong) |
|
995 | PRINTF2("sampleOffset_asLong = %lld, nbSamplesPart1_asLong = %lld\n", sampleOffset_asLong, nbSamplesPart1_asLong) | |
996 |
|
996 | |||
997 | // (6) compute the final acquisition time |
|
997 | // (6) compute the final acquisition time | |
998 | acquisitionTime_asLong = bufferAcquisitionTime_asLong + |
|
998 | acquisitionTime_asLong = bufferAcquisitionTime_asLong + | |
999 | sampleOffset_asLong * nbTicksPerSample_asLong; |
|
999 | sampleOffset_asLong * nbTicksPerSample_asLong; | |
1000 |
|
1000 | |||
1001 | // (7) copy the acquisition time at the beginning of the extrated snapshot |
|
1001 | // (7) copy the acquisition time at the beginning of the extrated snapshot | |
1002 | ptr1 = (unsigned char*) &acquisitionTime_asLong; |
|
1002 | ptr1 = (unsigned char*) &acquisitionTime_asLong; | |
1003 | // fine time |
|
1003 | // fine time | |
1004 | ptr2 = (unsigned char*) &ring_node_wf_snap_extracted.fineTime; |
|
1004 | ptr2 = (unsigned char*) &ring_node_wf_snap_extracted.fineTime; | |
1005 | ptr2[2] = ptr1[ 4 + 2 ]; |
|
1005 | ptr2[2] = ptr1[ 4 + 2 ]; | |
1006 | ptr2[3] = ptr1[ 5 + 2 ]; |
|
1006 | ptr2[3] = ptr1[ 5 + 2 ]; | |
1007 | // coarse time |
|
1007 | // coarse time | |
1008 | ptr2 = (unsigned char*) &ring_node_wf_snap_extracted.coarseTime; |
|
1008 | ptr2 = (unsigned char*) &ring_node_wf_snap_extracted.coarseTime; | |
1009 | ptr2[0] = ptr1[ 0 + 2 ]; |
|
1009 | ptr2[0] = ptr1[ 0 + 2 ]; | |
1010 | ptr2[1] = ptr1[ 1 + 2 ]; |
|
1010 | ptr2[1] = ptr1[ 1 + 2 ]; | |
1011 | ptr2[2] = ptr1[ 2 + 2 ]; |
|
1011 | ptr2[2] = ptr1[ 2 + 2 ]; | |
1012 | ptr2[3] = ptr1[ 3 + 2 ]; |
|
1012 | ptr2[3] = ptr1[ 3 + 2 ]; | |
1013 |
|
1013 | |||
1014 | // re set the synchronization bit |
|
1014 | // re set the synchronization bit | |
1015 | timeCharPtr = (unsigned char*) &ring_node_to_send->coarseTime; |
|
1015 | timeCharPtr = (unsigned char*) &ring_node_to_send->coarseTime; | |
1016 | ptr2[0] = ptr2[0] | (timeCharPtr[0] & 0x80); // [1000 0000] |
|
1016 | ptr2[0] = ptr2[0] | (timeCharPtr[0] & 0x80); // [1000 0000] | |
1017 |
|
1017 | |||
1018 | if ( (nbSamplesPart1_asLong >= NB_SAMPLES_PER_SNAPSHOT) | (nbSamplesPart1_asLong < 0) ) |
|
1018 | if ( (nbSamplesPart1_asLong >= NB_SAMPLES_PER_SNAPSHOT) | (nbSamplesPart1_asLong < 0) ) | |
1019 | { |
|
1019 | { | |
1020 | nbSamplesPart1_asLong = 0; |
|
1020 | nbSamplesPart1_asLong = 0; | |
1021 | } |
|
1021 | } | |
1022 | // copy the part 1 of the snapshot in the extracted buffer |
|
1022 | // copy the part 1 of the snapshot in the extracted buffer | |
1023 | for ( i = 0; i < (nbSamplesPart1_asLong * NB_WORDS_SWF_BLK); i++ ) |
|
1023 | for ( i = 0; i < (nbSamplesPart1_asLong * NB_WORDS_SWF_BLK); i++ ) | |
1024 | { |
|
1024 | { | |
1025 | wf_snap_extracted[i] = |
|
1025 | wf_snap_extracted[i] = | |
1026 | ((int*) ring_node_to_send->buffer_address)[ i + (sampleOffset_asLong * NB_WORDS_SWF_BLK) ]; |
|
1026 | ((int*) ring_node_to_send->buffer_address)[ i + (sampleOffset_asLong * NB_WORDS_SWF_BLK) ]; | |
1027 | } |
|
1027 | } | |
1028 | // copy the part 2 of the snapshot in the extracted buffer |
|
1028 | // copy the part 2 of the snapshot in the extracted buffer | |
1029 | ring_node_to_send = ring_node_to_send->next; |
|
1029 | ring_node_to_send = ring_node_to_send->next; | |
1030 | for ( i = (nbSamplesPart1_asLong * NB_WORDS_SWF_BLK); i < (NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK); i++ ) |
|
1030 | for ( i = (nbSamplesPart1_asLong * NB_WORDS_SWF_BLK); i < (NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK); i++ ) | |
1031 | { |
|
1031 | { | |
1032 | wf_snap_extracted[i] = |
|
1032 | wf_snap_extracted[i] = | |
1033 | ((int*) ring_node_to_send->buffer_address)[ (i-(nbSamplesPart1_asLong * NB_WORDS_SWF_BLK)) ]; |
|
1033 | ((int*) ring_node_to_send->buffer_address)[ (i-(nbSamplesPart1_asLong * NB_WORDS_SWF_BLK)) ]; | |
1034 | } |
|
1034 | } | |
1035 | } |
|
1035 | } | |
1036 |
|
1036 | |||
1037 | void snapshot_resynchronization( unsigned char *timePtr ) |
|
1037 | void snapshot_resynchronization( unsigned char *timePtr ) | |
1038 | { |
|
1038 | { | |
1039 | unsigned long long int acquisitionTime; |
|
1039 | unsigned long long int acquisitionTime; | |
1040 | unsigned long long int centerTime; |
|
1040 | unsigned long long int centerTime; | |
1041 | unsigned long long int previousTick; |
|
1041 | unsigned long long int previousTick; | |
1042 | unsigned long long int nextTick; |
|
1042 | unsigned long long int nextTick; | |
1043 | unsigned long long int deltaPreviousTick; |
|
1043 | unsigned long long int deltaPreviousTick; | |
1044 | unsigned long long int deltaNextTick; |
|
1044 | unsigned long long int deltaNextTick; | |
1045 | unsigned int deltaTickInF2; |
|
1045 | unsigned int deltaTickInF2; | |
1046 | double deltaPrevious; |
|
1046 | double deltaPrevious; | |
1047 | double deltaNext; |
|
1047 | double deltaNext; | |
1048 |
|
1048 | |||
1049 | acquisitionTime = get_acquisition_time( timePtr ); |
|
1049 | acquisitionTime = get_acquisition_time( timePtr ); | |
1050 |
|
1050 | |||
1051 | // compute center time |
|
1051 | // compute center time | |
1052 | centerTime = acquisitionTime + 2731; // (2048. / 24576. / 2.) * 65536. = 2730.667; |
|
1052 | centerTime = acquisitionTime + 2731; // (2048. / 24576. / 2.) * 65536. = 2730.667; | |
1053 | previousTick = centerTime - (centerTime & 0xffff); |
|
1053 | previousTick = centerTime - (centerTime & 0xffff); | |
1054 | nextTick = previousTick + 65536; |
|
1054 | nextTick = previousTick + 65536; | |
1055 |
|
1055 | |||
1056 | deltaPreviousTick = centerTime - previousTick; |
|
1056 | deltaPreviousTick = centerTime - previousTick; | |
1057 | deltaNextTick = nextTick - centerTime; |
|
1057 | deltaNextTick = nextTick - centerTime; | |
1058 |
|
1058 | |||
1059 | deltaPrevious = ((double) deltaPreviousTick) / 65536. * 1000.; |
|
1059 | deltaPrevious = ((double) deltaPreviousTick) / 65536. * 1000.; | |
1060 | deltaNext = ((double) deltaNextTick) / 65536. * 1000.; |
|
1060 | deltaNext = ((double) deltaNextTick) / 65536. * 1000.; | |
1061 |
|
1061 | |||
1062 | PRINTF2("delta previous = %f ms, delta next = %f ms\n", deltaPrevious, deltaNext) |
|
1062 | PRINTF2("delta previous = %f ms, delta next = %f ms\n", deltaPrevious, deltaNext) | |
1063 | PRINTF2("delta previous = %llu, delta next = %llu\n", deltaPreviousTick, deltaNextTick) |
|
1063 | PRINTF2("delta previous = %llu, delta next = %llu\n", deltaPreviousTick, deltaNextTick) | |
1064 |
|
1064 | |||
1065 | // which tick is the closest |
|
1065 | // which tick is the closest | |
1066 | if (deltaPreviousTick > deltaNextTick) |
|
1066 | if (deltaPreviousTick > deltaNextTick) | |
1067 | { |
|
1067 | { | |
1068 | deltaTickInF2 = floor( (deltaNext * 256. / 1000.) ); // the division by 2 is important here |
|
1068 | deltaTickInF2 = floor( (deltaNext * 256. / 1000.) ); // the division by 2 is important here | |
1069 | waveform_picker_regs->delta_snapshot = waveform_picker_regs->delta_snapshot + deltaTickInF2; |
|
1069 | waveform_picker_regs->delta_snapshot = waveform_picker_regs->delta_snapshot + deltaTickInF2; | |
1070 | PRINTF1("correction of = + %u\n", deltaTickInF2) |
|
1070 | PRINTF1("correction of = + %u\n", deltaTickInF2) | |
1071 | } |
|
1071 | } | |
1072 | else |
|
1072 | else | |
1073 | { |
|
1073 | { | |
1074 | deltaTickInF2 = floor( (deltaPrevious * 256. / 1000.) ); // the division by 2 is important here |
|
1074 | deltaTickInF2 = floor( (deltaPrevious * 256. / 1000.) ); // the division by 2 is important here | |
1075 | waveform_picker_regs->delta_snapshot = waveform_picker_regs->delta_snapshot - deltaTickInF2; |
|
1075 | waveform_picker_regs->delta_snapshot = waveform_picker_regs->delta_snapshot - deltaTickInF2; | |
1076 | PRINTF1("correction of = - %u\n", deltaTickInF2) |
|
1076 | PRINTF1("correction of = - %u\n", deltaTickInF2) | |
1077 | } |
|
1077 | } | |
1078 | } |
|
1078 | } | |
1079 |
|
1079 | |||
1080 | //************** |
|
1080 | //************** | |
1081 | // wfp registers |
|
1081 | // wfp registers | |
1082 | void reset_wfp_burst_enable( void ) |
|
1082 | void reset_wfp_burst_enable( void ) | |
1083 | { |
|
1083 | { | |
1084 | /** This function resets the waveform picker burst_enable register. |
|
1084 | /** This function resets the waveform picker burst_enable register. | |
1085 | * |
|
1085 | * | |
1086 | * The burst bits [f2 f1 f0] and the enable bits [f3 f2 f1 f0] are set to 0. |
|
1086 | * The burst bits [f2 f1 f0] and the enable bits [f3 f2 f1 f0] are set to 0. | |
1087 | * |
|
1087 | * | |
1088 | */ |
|
1088 | */ | |
1089 |
|
1089 | |||
1090 | // [1000 000] burst f2, f1, f0 enable f3, f2, f1, f0 |
|
1090 | // [1000 000] burst f2, f1, f0 enable f3, f2, f1, f0 | |
1091 | waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable & 0x80; |
|
1091 | waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable & 0x80; | |
1092 | } |
|
1092 | } | |
1093 |
|
1093 | |||
1094 | void reset_wfp_status( void ) |
|
1094 | void reset_wfp_status( void ) | |
1095 | { |
|
1095 | { | |
1096 | /** This function resets the waveform picker status register. |
|
1096 | /** This function resets the waveform picker status register. | |
1097 | * |
|
1097 | * | |
1098 | * All status bits are set to 0 [new_err full_err full]. |
|
1098 | * All status bits are set to 0 [new_err full_err full]. | |
1099 | * |
|
1099 | * | |
1100 | */ |
|
1100 | */ | |
1101 |
|
1101 | |||
1102 | waveform_picker_regs->status = 0xffff; |
|
1102 | waveform_picker_regs->status = 0xffff; | |
1103 | } |
|
1103 | } | |
1104 |
|
1104 | |||
1105 | void reset_wfp_buffer_addresses( void ) |
|
1105 | void reset_wfp_buffer_addresses( void ) | |
1106 | { |
|
1106 | { | |
1107 | // F0 |
|
1107 | // F0 | |
1108 | waveform_picker_regs->addr_data_f0_0 = current_ring_node_f0->previous->buffer_address; // 0x08 |
|
1108 | waveform_picker_regs->addr_data_f0_0 = current_ring_node_f0->previous->buffer_address; // 0x08 | |
1109 | waveform_picker_regs->addr_data_f0_1 = current_ring_node_f0->buffer_address; // 0x0c |
|
1109 | waveform_picker_regs->addr_data_f0_1 = current_ring_node_f0->buffer_address; // 0x0c | |
1110 | // F1 |
|
1110 | // F1 | |
1111 | waveform_picker_regs->addr_data_f1_0 = current_ring_node_f1->previous->buffer_address; // 0x10 |
|
1111 | waveform_picker_regs->addr_data_f1_0 = current_ring_node_f1->previous->buffer_address; // 0x10 | |
1112 | waveform_picker_regs->addr_data_f1_1 = current_ring_node_f1->buffer_address; // 0x14 |
|
1112 | waveform_picker_regs->addr_data_f1_1 = current_ring_node_f1->buffer_address; // 0x14 | |
1113 | // F2 |
|
1113 | // F2 | |
1114 | waveform_picker_regs->addr_data_f2_0 = current_ring_node_f2->previous->buffer_address; // 0x18 |
|
1114 | waveform_picker_regs->addr_data_f2_0 = current_ring_node_f2->previous->buffer_address; // 0x18 | |
1115 | waveform_picker_regs->addr_data_f2_1 = current_ring_node_f2->buffer_address; // 0x1c |
|
1115 | waveform_picker_regs->addr_data_f2_1 = current_ring_node_f2->buffer_address; // 0x1c | |
1116 | // F3 |
|
1116 | // F3 | |
1117 | waveform_picker_regs->addr_data_f3_0 = current_ring_node_f3->previous->buffer_address; // 0x20 |
|
1117 | waveform_picker_regs->addr_data_f3_0 = current_ring_node_f3->previous->buffer_address; // 0x20 | |
1118 | waveform_picker_regs->addr_data_f3_1 = current_ring_node_f3->buffer_address; // 0x24 |
|
1118 | waveform_picker_regs->addr_data_f3_1 = current_ring_node_f3->buffer_address; // 0x24 | |
1119 | } |
|
1119 | } | |
1120 |
|
1120 | |||
1121 | void reset_waveform_picker_regs( void ) |
|
1121 | void reset_waveform_picker_regs( void ) | |
1122 | { |
|
1122 | { | |
1123 | /** This function resets the waveform picker module registers. |
|
1123 | /** This function resets the waveform picker module registers. | |
1124 | * |
|
1124 | * | |
1125 | * The registers affected by this function are located at the following offset addresses: |
|
1125 | * The registers affected by this function are located at the following offset addresses: | |
1126 | * - 0x00 data_shaping |
|
1126 | * - 0x00 data_shaping | |
1127 | * - 0x04 run_burst_enable |
|
1127 | * - 0x04 run_burst_enable | |
1128 | * - 0x08 addr_data_f0 |
|
1128 | * - 0x08 addr_data_f0 | |
1129 | * - 0x0C addr_data_f1 |
|
1129 | * - 0x0C addr_data_f1 | |
1130 | * - 0x10 addr_data_f2 |
|
1130 | * - 0x10 addr_data_f2 | |
1131 | * - 0x14 addr_data_f3 |
|
1131 | * - 0x14 addr_data_f3 | |
1132 | * - 0x18 status |
|
1132 | * - 0x18 status | |
1133 | * - 0x1C delta_snapshot |
|
1133 | * - 0x1C delta_snapshot | |
1134 | * - 0x20 delta_f0 |
|
1134 | * - 0x20 delta_f0 | |
1135 | * - 0x24 delta_f0_2 |
|
1135 | * - 0x24 delta_f0_2 | |
1136 | * - 0x28 delta_f1 |
|
1136 | * - 0x28 delta_f1 | |
1137 | * - 0x2c delta_f2 |
|
1137 | * - 0x2c delta_f2 | |
1138 | * - 0x30 nb_data_by_buffer |
|
1138 | * - 0x30 nb_data_by_buffer | |
1139 | * - 0x34 nb_snapshot_param |
|
1139 | * - 0x34 nb_snapshot_param | |
1140 | * - 0x38 start_date |
|
1140 | * - 0x38 start_date | |
1141 | * - 0x3c nb_word_in_buffer |
|
1141 | * - 0x3c nb_word_in_buffer | |
1142 | * |
|
1142 | * | |
1143 | */ |
|
1143 | */ | |
1144 |
|
1144 | |||
1145 | set_wfp_data_shaping(); // 0x00 *** R1 R0 SP1 SP0 BW |
|
1145 | set_wfp_data_shaping(); // 0x00 *** R1 R0 SP1 SP0 BW | |
1146 |
|
1146 | |||
1147 | reset_wfp_burst_enable(); // 0x04 *** [run *** burst f2, f1, f0 *** enable f3, f2, f1, f0 ] |
|
1147 | reset_wfp_burst_enable(); // 0x04 *** [run *** burst f2, f1, f0 *** enable f3, f2, f1, f0 ] | |
1148 |
|
1148 | |||
1149 | reset_wfp_buffer_addresses(); |
|
1149 | reset_wfp_buffer_addresses(); | |
1150 |
|
1150 | |||
1151 | reset_wfp_status(); // 0x18 |
|
1151 | reset_wfp_status(); // 0x18 | |
1152 |
|
1152 | |||
1153 | set_wfp_delta_snapshot(); // 0x1c *** 300 s => 0x12bff |
|
1153 | set_wfp_delta_snapshot(); // 0x1c *** 300 s => 0x12bff | |
1154 |
|
1154 | |||
1155 | set_wfp_delta_f0_f0_2(); // 0x20, 0x24 |
|
1155 | set_wfp_delta_f0_f0_2(); // 0x20, 0x24 | |
1156 |
|
1156 | |||
1157 | set_wfp_delta_f1(); // 0x28 |
|
1157 | set_wfp_delta_f1(); // 0x28 | |
1158 |
|
1158 | |||
1159 | set_wfp_delta_f2(); // 0x2c |
|
1159 | set_wfp_delta_f2(); // 0x2c | |
1160 |
|
1160 | |||
1161 | DEBUG_PRINTF1("delta_snapshot %x\n", waveform_picker_regs->delta_snapshot) |
|
1161 | DEBUG_PRINTF1("delta_snapshot %x\n", waveform_picker_regs->delta_snapshot) | |
1162 | DEBUG_PRINTF1("delta_f0 %x\n", waveform_picker_regs->delta_f0) |
|
1162 | DEBUG_PRINTF1("delta_f0 %x\n", waveform_picker_regs->delta_f0) | |
1163 | DEBUG_PRINTF1("delta_f0_2 %x\n", waveform_picker_regs->delta_f0_2) |
|
1163 | DEBUG_PRINTF1("delta_f0_2 %x\n", waveform_picker_regs->delta_f0_2) | |
1164 | DEBUG_PRINTF1("delta_f1 %x\n", waveform_picker_regs->delta_f1) |
|
1164 | DEBUG_PRINTF1("delta_f1 %x\n", waveform_picker_regs->delta_f1) | |
1165 | DEBUG_PRINTF1("delta_f2 %x\n", waveform_picker_regs->delta_f2) |
|
1165 | DEBUG_PRINTF1("delta_f2 %x\n", waveform_picker_regs->delta_f2) | |
1166 | // 2688 = 8 * 336 |
|
1166 | // 2688 = 8 * 336 | |
1167 | waveform_picker_regs->nb_data_by_buffer = 0xa7f; // 0x30 *** 2688 - 1 => nb samples -1 |
|
1167 | waveform_picker_regs->nb_data_by_buffer = 0xa7f; // 0x30 *** 2688 - 1 => nb samples -1 | |
1168 | waveform_picker_regs->snapshot_param = 0xa80; // 0x34 *** 2688 => nb samples |
|
1168 | waveform_picker_regs->snapshot_param = 0xa80; // 0x34 *** 2688 => nb samples | |
1169 | waveform_picker_regs->start_date = 0x7fffffff; // 0x38 |
|
1169 | waveform_picker_regs->start_date = 0x7fffffff; // 0x38 | |
1170 | // |
|
1170 | // | |
1171 | // coarse time and fine time registers are not initialized, they are volatile |
|
1171 | // coarse time and fine time registers are not initialized, they are volatile | |
1172 | // |
|
1172 | // | |
1173 | waveform_picker_regs->buffer_length = 0x1f8;// buffer length in burst = 3 * 2688 / 16 = 504 = 0x1f8 |
|
1173 | waveform_picker_regs->buffer_length = 0x1f8;// buffer length in burst = 3 * 2688 / 16 = 504 = 0x1f8 | |
1174 | } |
|
1174 | } | |
1175 |
|
1175 | |||
1176 | void set_wfp_data_shaping( void ) |
|
1176 | void set_wfp_data_shaping( void ) | |
1177 | { |
|
1177 | { | |
1178 | /** This function sets the data_shaping register of the waveform picker module. |
|
1178 | /** This function sets the data_shaping register of the waveform picker module. | |
1179 | * |
|
1179 | * | |
1180 | * The value is read from one field of the parameter_dump_packet structure:\n |
|
1180 | * The value is read from one field of the parameter_dump_packet structure:\n | |
1181 | * bw_sp0_sp1_r0_r1 |
|
1181 | * bw_sp0_sp1_r0_r1 | |
1182 | * |
|
1182 | * | |
1183 | */ |
|
1183 | */ | |
1184 |
|
1184 | |||
1185 | unsigned char data_shaping; |
|
1185 | unsigned char data_shaping; | |
1186 |
|
1186 | |||
1187 | // get the parameters for the data shaping [BW SP0 SP1 R0 R1] in sy_lfr_common1 and configure the register |
|
1187 | // get the parameters for the data shaping [BW SP0 SP1 R0 R1] in sy_lfr_common1 and configure the register | |
1188 | // waveform picker : [R1 R0 SP1 SP0 BW] |
|
1188 | // waveform picker : [R1 R0 SP1 SP0 BW] | |
1189 |
|
1189 | |||
1190 | data_shaping = parameter_dump_packet.sy_lfr_common_parameters; |
|
1190 | data_shaping = parameter_dump_packet.sy_lfr_common_parameters; | |
1191 |
|
1191 | |||
1192 | waveform_picker_regs->data_shaping = |
|
1192 | waveform_picker_regs->data_shaping = | |
1193 | ( (data_shaping & 0x20) >> 5 ) // BW |
|
1193 | ( (data_shaping & 0x20) >> 5 ) // BW | |
1194 | + ( (data_shaping & 0x10) >> 3 ) // SP0 |
|
1194 | + ( (data_shaping & 0x10) >> 3 ) // SP0 | |
1195 | + ( (data_shaping & 0x08) >> 1 ) // SP1 |
|
1195 | + ( (data_shaping & 0x08) >> 1 ) // SP1 | |
1196 | + ( (data_shaping & 0x04) << 1 ) // R0 |
|
1196 | + ( (data_shaping & 0x04) << 1 ) // R0 | |
1197 | + ( (data_shaping & 0x02) << 3 ) // R1 |
|
1197 | + ( (data_shaping & 0x02) << 3 ) // R1 | |
1198 | + ( (data_shaping & 0x01) << 5 ); // R2 |
|
1198 | + ( (data_shaping & 0x01) << 5 ); // R2 | |
1199 | } |
|
1199 | } | |
1200 |
|
1200 | |||
1201 | void set_wfp_burst_enable_register( unsigned char mode ) |
|
1201 | void set_wfp_burst_enable_register( unsigned char mode ) | |
1202 | { |
|
1202 | { | |
1203 | /** This function sets the waveform picker burst_enable register depending on the mode. |
|
1203 | /** This function sets the waveform picker burst_enable register depending on the mode. | |
1204 | * |
|
1204 | * | |
1205 | * @param mode is the LFR mode to launch. |
|
1205 | * @param mode is the LFR mode to launch. | |
1206 | * |
|
1206 | * | |
1207 | * The burst bits shall be before the enable bits. |
|
1207 | * The burst bits shall be before the enable bits. | |
1208 | * |
|
1208 | * | |
1209 | */ |
|
1209 | */ | |
1210 |
|
1210 | |||
1211 | // [0000 0000] burst f2, f1, f0 enable f3 f2 f1 f0 |
|
1211 | // [0000 0000] burst f2, f1, f0 enable f3 f2 f1 f0 | |
1212 | // the burst bits shall be set first, before the enable bits |
|
1212 | // the burst bits shall be set first, before the enable bits | |
1213 | switch(mode) { |
|
1213 | switch(mode) { | |
1214 | case(LFR_MODE_NORMAL): |
|
1214 | case(LFR_MODE_NORMAL): | |
1215 | waveform_picker_regs->run_burst_enable = 0x00; // [0000 0000] no burst enable |
|
1215 | waveform_picker_regs->run_burst_enable = 0x00; // [0000 0000] no burst enable | |
1216 | waveform_picker_regs->run_burst_enable = 0x0f; // [0000 1111] enable f3 f2 f1 f0 |
|
1216 | waveform_picker_regs->run_burst_enable = 0x0f; // [0000 1111] enable f3 f2 f1 f0 | |
1217 | break; |
|
1217 | break; | |
1218 | case(LFR_MODE_BURST): |
|
1218 | case(LFR_MODE_BURST): | |
1219 | waveform_picker_regs->run_burst_enable = 0x40; // [0100 0000] f2 burst enabled |
|
1219 | waveform_picker_regs->run_burst_enable = 0x40; // [0100 0000] f2 burst enabled | |
1220 | // waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | 0x04; // [0100] enable f2 |
|
1220 | // waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | 0x04; // [0100] enable f2 | |
1221 | waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | 0x0c; // [1100] enable f3 AND f2 |
|
1221 | waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | 0x0c; // [1100] enable f3 AND f2 | |
1222 | break; |
|
1222 | break; | |
1223 | case(LFR_MODE_SBM1): |
|
1223 | case(LFR_MODE_SBM1): | |
1224 | waveform_picker_regs->run_burst_enable = 0x20; // [0010 0000] f1 burst enabled |
|
1224 | waveform_picker_regs->run_burst_enable = 0x20; // [0010 0000] f1 burst enabled | |
1225 | waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | 0x0f; // [1111] enable f3 f2 f1 f0 |
|
1225 | waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | 0x0f; // [1111] enable f3 f2 f1 f0 | |
1226 | break; |
|
1226 | break; | |
1227 | case(LFR_MODE_SBM2): |
|
1227 | case(LFR_MODE_SBM2): | |
1228 | waveform_picker_regs->run_burst_enable = 0x40; // [0100 0000] f2 burst enabled |
|
1228 | waveform_picker_regs->run_burst_enable = 0x40; // [0100 0000] f2 burst enabled | |
1229 | waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | 0x0f; // [1111] enable f3 f2 f1 f0 |
|
1229 | waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | 0x0f; // [1111] enable f3 f2 f1 f0 | |
1230 | break; |
|
1230 | break; | |
1231 | default: |
|
1231 | default: | |
1232 | waveform_picker_regs->run_burst_enable = 0x00; // [0000 0000] no burst enabled, no waveform enabled |
|
1232 | waveform_picker_regs->run_burst_enable = 0x00; // [0000 0000] no burst enabled, no waveform enabled | |
1233 | break; |
|
1233 | break; | |
1234 | } |
|
1234 | } | |
1235 | } |
|
1235 | } | |
1236 |
|
1236 | |||
1237 | void set_wfp_delta_snapshot( void ) |
|
1237 | void set_wfp_delta_snapshot( void ) | |
1238 | { |
|
1238 | { | |
1239 | /** This function sets the delta_snapshot register of the waveform picker module. |
|
1239 | /** This function sets the delta_snapshot register of the waveform picker module. | |
1240 | * |
|
1240 | * | |
1241 | * The value is read from two (unsigned char) of the parameter_dump_packet structure: |
|
1241 | * The value is read from two (unsigned char) of the parameter_dump_packet structure: | |
1242 | * - sy_lfr_n_swf_p[0] |
|
1242 | * - sy_lfr_n_swf_p[0] | |
1243 | * - sy_lfr_n_swf_p[1] |
|
1243 | * - sy_lfr_n_swf_p[1] | |
1244 | * |
|
1244 | * | |
1245 | */ |
|
1245 | */ | |
1246 |
|
1246 | |||
1247 | unsigned int delta_snapshot; |
|
1247 | unsigned int delta_snapshot; | |
1248 | unsigned int delta_snapshot_in_T2; |
|
1248 | unsigned int delta_snapshot_in_T2; | |
1249 |
|
1249 | |||
1250 | delta_snapshot = parameter_dump_packet.sy_lfr_n_swf_p[0]*256 |
|
1250 | delta_snapshot = parameter_dump_packet.sy_lfr_n_swf_p[0]*256 | |
1251 | + parameter_dump_packet.sy_lfr_n_swf_p[1]; |
|
1251 | + parameter_dump_packet.sy_lfr_n_swf_p[1]; | |
1252 |
|
1252 | |||
1253 | delta_snapshot_in_T2 = delta_snapshot * 256; |
|
1253 | delta_snapshot_in_T2 = delta_snapshot * 256; | |
1254 | waveform_picker_regs->delta_snapshot = delta_snapshot_in_T2 - 1; // max 4 bytes |
|
1254 | waveform_picker_regs->delta_snapshot = delta_snapshot_in_T2 - 1; // max 4 bytes | |
1255 | } |
|
1255 | } | |
1256 |
|
1256 | |||
1257 | void set_wfp_delta_f0_f0_2( void ) |
|
1257 | void set_wfp_delta_f0_f0_2( void ) | |
1258 | { |
|
1258 | { | |
1259 | unsigned int delta_snapshot; |
|
1259 | unsigned int delta_snapshot; | |
1260 | unsigned int nb_samples_per_snapshot; |
|
1260 | unsigned int nb_samples_per_snapshot; | |
1261 | float delta_f0_in_float; |
|
1261 | float delta_f0_in_float; | |
1262 |
|
1262 | |||
1263 | delta_snapshot = waveform_picker_regs->delta_snapshot; |
|
1263 | delta_snapshot = waveform_picker_regs->delta_snapshot; | |
1264 | nb_samples_per_snapshot = parameter_dump_packet.sy_lfr_n_swf_l[0] * 256 + parameter_dump_packet.sy_lfr_n_swf_l[1]; |
|
1264 | nb_samples_per_snapshot = parameter_dump_packet.sy_lfr_n_swf_l[0] * 256 + parameter_dump_packet.sy_lfr_n_swf_l[1]; | |
1265 | delta_f0_in_float =nb_samples_per_snapshot / 2. * ( 1. / 256. - 1. / 24576.) * 256.; |
|
1265 | delta_f0_in_float =nb_samples_per_snapshot / 2. * ( 1. / 256. - 1. / 24576.) * 256.; | |
1266 |
|
1266 | |||
1267 | waveform_picker_regs->delta_f0 = delta_snapshot - floor( delta_f0_in_float ); |
|
1267 | waveform_picker_regs->delta_f0 = delta_snapshot - floor( delta_f0_in_float ); | |
1268 | waveform_picker_regs->delta_f0_2 = 0x30; // 48 = 11 0000, max 7 bits |
|
1268 | waveform_picker_regs->delta_f0_2 = 0x30; // 48 = 11 0000, max 7 bits | |
1269 | } |
|
1269 | } | |
1270 |
|
1270 | |||
1271 | void set_wfp_delta_f1( void ) |
|
1271 | void set_wfp_delta_f1( void ) | |
1272 | { |
|
1272 | { | |
1273 | unsigned int delta_snapshot; |
|
1273 | unsigned int delta_snapshot; | |
1274 | unsigned int nb_samples_per_snapshot; |
|
1274 | unsigned int nb_samples_per_snapshot; | |
1275 | float delta_f1_in_float; |
|
1275 | float delta_f1_in_float; | |
1276 |
|
1276 | |||
1277 | delta_snapshot = waveform_picker_regs->delta_snapshot; |
|
1277 | delta_snapshot = waveform_picker_regs->delta_snapshot; | |
1278 | nb_samples_per_snapshot = parameter_dump_packet.sy_lfr_n_swf_l[0] * 256 + parameter_dump_packet.sy_lfr_n_swf_l[1]; |
|
1278 | nb_samples_per_snapshot = parameter_dump_packet.sy_lfr_n_swf_l[0] * 256 + parameter_dump_packet.sy_lfr_n_swf_l[1]; | |
1279 | delta_f1_in_float = nb_samples_per_snapshot / 2. * ( 1. / 256. - 1. / 4096.) * 256.; |
|
1279 | delta_f1_in_float = nb_samples_per_snapshot / 2. * ( 1. / 256. - 1. / 4096.) * 256.; | |
1280 |
|
1280 | |||
1281 | waveform_picker_regs->delta_f1 = delta_snapshot - floor( delta_f1_in_float ); |
|
1281 | waveform_picker_regs->delta_f1 = delta_snapshot - floor( delta_f1_in_float ); | |
1282 | } |
|
1282 | } | |
1283 |
|
1283 | |||
1284 | void set_wfp_delta_f2() |
|
1284 | void set_wfp_delta_f2() | |
1285 | { |
|
1285 | { | |
1286 | unsigned int delta_snapshot; |
|
1286 | unsigned int delta_snapshot; | |
1287 | unsigned int nb_samples_per_snapshot; |
|
1287 | unsigned int nb_samples_per_snapshot; | |
1288 |
|
1288 | |||
1289 | delta_snapshot = waveform_picker_regs->delta_snapshot; |
|
1289 | delta_snapshot = waveform_picker_regs->delta_snapshot; | |
1290 | nb_samples_per_snapshot = parameter_dump_packet.sy_lfr_n_swf_l[0] * 256 + parameter_dump_packet.sy_lfr_n_swf_l[1]; |
|
1290 | nb_samples_per_snapshot = parameter_dump_packet.sy_lfr_n_swf_l[0] * 256 + parameter_dump_packet.sy_lfr_n_swf_l[1]; | |
1291 |
|
1291 | |||
1292 | waveform_picker_regs->delta_f2 = delta_snapshot - nb_samples_per_snapshot / 2; |
|
1292 | waveform_picker_regs->delta_f2 = delta_snapshot - nb_samples_per_snapshot / 2; | |
1293 | } |
|
1293 | } | |
1294 |
|
1294 | |||
1295 | //***************** |
|
1295 | //***************** | |
1296 | // local parameters |
|
1296 | // local parameters | |
1297 |
|
1297 | |||
1298 | void increment_seq_counter_source_id( unsigned char *packet_sequence_control, unsigned int sid ) |
|
1298 | void increment_seq_counter_source_id( unsigned char *packet_sequence_control, unsigned int sid ) | |
1299 | { |
|
1299 | { | |
1300 | /** This function increments the parameter "sequence_cnt" depending on the sid passed in argument. |
|
1300 | /** This function increments the parameter "sequence_cnt" depending on the sid passed in argument. | |
1301 | * |
|
1301 | * | |
1302 | * @param packet_sequence_control is a pointer toward the parameter sequence_cnt to update. |
|
1302 | * @param packet_sequence_control is a pointer toward the parameter sequence_cnt to update. | |
1303 | * @param sid is the source identifier of the packet being updated. |
|
1303 | * @param sid is the source identifier of the packet being updated. | |
1304 | * |
|
1304 | * | |
1305 | * REQ-LFR-SRS-5240 / SSS-CP-FS-590 |
|
1305 | * REQ-LFR-SRS-5240 / SSS-CP-FS-590 | |
1306 | * The sequence counters shall wrap around from 2^14 to zero. |
|
1306 | * The sequence counters shall wrap around from 2^14 to zero. | |
1307 | * The sequence counter shall start at zero at startup. |
|
1307 | * The sequence counter shall start at zero at startup. | |
1308 | * |
|
1308 | * | |
1309 | * REQ-LFR-SRS-5239 / SSS-CP-FS-580 |
|
1309 | * REQ-LFR-SRS-5239 / SSS-CP-FS-580 | |
1310 | * All TM_LFR_SCIENCE_ packets are sent to ground, i.e. destination id = 0 |
|
1310 | * All TM_LFR_SCIENCE_ packets are sent to ground, i.e. destination id = 0 | |
1311 | * |
|
1311 | * | |
1312 | */ |
|
1312 | */ | |
1313 |
|
1313 | |||
1314 | unsigned short *sequence_cnt; |
|
1314 | unsigned short *sequence_cnt; | |
1315 | unsigned short segmentation_grouping_flag; |
|
1315 | unsigned short segmentation_grouping_flag; | |
1316 | unsigned short new_packet_sequence_control; |
|
1316 | unsigned short new_packet_sequence_control; | |
1317 | rtems_mode initial_mode_set; |
|
1317 | rtems_mode initial_mode_set; | |
1318 | rtems_mode current_mode_set; |
|
1318 | rtems_mode current_mode_set; | |
1319 | rtems_status_code status; |
|
1319 | rtems_status_code status; | |
1320 |
|
1320 | |||
1321 | //****************************************** |
|
1321 | //****************************************** | |
1322 | // CHANGE THE MODE OF THE CALLING RTEMS TASK |
|
1322 | // CHANGE THE MODE OF THE CALLING RTEMS TASK | |
1323 | status = rtems_task_mode( RTEMS_NO_PREEMPT, RTEMS_PREEMPT_MASK, &initial_mode_set ); |
|
1323 | status = rtems_task_mode( RTEMS_NO_PREEMPT, RTEMS_PREEMPT_MASK, &initial_mode_set ); | |
1324 |
|
1324 | |||
1325 | if ( (sid == SID_NORM_SWF_F0) || (sid == SID_NORM_SWF_F1) || (sid == SID_NORM_SWF_F2) |
|
1325 | if ( (sid == SID_NORM_SWF_F0) || (sid == SID_NORM_SWF_F1) || (sid == SID_NORM_SWF_F2) | |
1326 | || (sid == SID_NORM_CWF_F3) || (sid == SID_NORM_CWF_LONG_F3) |
|
1326 | || (sid == SID_NORM_CWF_F3) || (sid == SID_NORM_CWF_LONG_F3) | |
1327 | || (sid == SID_BURST_CWF_F2) |
|
1327 | || (sid == SID_BURST_CWF_F2) | |
1328 | || (sid == SID_NORM_ASM_F0) || (sid == SID_NORM_ASM_F1) || (sid == SID_NORM_ASM_F2) |
|
1328 | || (sid == SID_NORM_ASM_F0) || (sid == SID_NORM_ASM_F1) || (sid == SID_NORM_ASM_F2) | |
1329 | || (sid == SID_NORM_BP1_F0) || (sid == SID_NORM_BP1_F1) || (sid == SID_NORM_BP1_F2) |
|
1329 | || (sid == SID_NORM_BP1_F0) || (sid == SID_NORM_BP1_F1) || (sid == SID_NORM_BP1_F2) | |
1330 | || (sid == SID_NORM_BP2_F0) || (sid == SID_NORM_BP2_F1) || (sid == SID_NORM_BP2_F2) |
|
1330 | || (sid == SID_NORM_BP2_F0) || (sid == SID_NORM_BP2_F1) || (sid == SID_NORM_BP2_F2) | |
1331 | || (sid == SID_BURST_BP1_F0) || (sid == SID_BURST_BP2_F0) |
|
1331 | || (sid == SID_BURST_BP1_F0) || (sid == SID_BURST_BP2_F0) | |
1332 | || (sid == SID_BURST_BP1_F1) || (sid == SID_BURST_BP2_F1) ) |
|
1332 | || (sid == SID_BURST_BP1_F1) || (sid == SID_BURST_BP2_F1) ) | |
1333 | { |
|
1333 | { | |
1334 | sequence_cnt = (unsigned short *) &sequenceCounters_SCIENCE_NORMAL_BURST; |
|
1334 | sequence_cnt = (unsigned short *) &sequenceCounters_SCIENCE_NORMAL_BURST; | |
1335 | } |
|
1335 | } | |
1336 | else if ( (sid ==SID_SBM1_CWF_F1) || (sid ==SID_SBM2_CWF_F2) |
|
1336 | else if ( (sid ==SID_SBM1_CWF_F1) || (sid ==SID_SBM2_CWF_F2) | |
1337 | || (sid == SID_SBM1_BP1_F0) || (sid == SID_SBM1_BP2_F0) |
|
1337 | || (sid == SID_SBM1_BP1_F0) || (sid == SID_SBM1_BP2_F0) | |
1338 | || (sid == SID_SBM2_BP1_F0) || (sid == SID_SBM2_BP2_F0) |
|
1338 | || (sid == SID_SBM2_BP1_F0) || (sid == SID_SBM2_BP2_F0) | |
1339 | || (sid == SID_SBM2_BP1_F1) || (sid == SID_SBM2_BP2_F1) ) |
|
1339 | || (sid == SID_SBM2_BP1_F1) || (sid == SID_SBM2_BP2_F1) ) | |
1340 | { |
|
1340 | { | |
1341 | sequence_cnt = (unsigned short *) &sequenceCounters_SCIENCE_SBM1_SBM2; |
|
1341 | sequence_cnt = (unsigned short *) &sequenceCounters_SCIENCE_SBM1_SBM2; | |
1342 | } |
|
1342 | } | |
1343 | else |
|
1343 | else | |
1344 | { |
|
1344 | { | |
1345 | sequence_cnt = (unsigned short *) NULL; |
|
1345 | sequence_cnt = (unsigned short *) NULL; | |
1346 | PRINTF1("in increment_seq_counter_source_id *** ERR apid_destid %d not known\n", sid) |
|
1346 | PRINTF1("in increment_seq_counter_source_id *** ERR apid_destid %d not known\n", sid) | |
1347 | } |
|
1347 | } | |
1348 |
|
1348 | |||
1349 | if (sequence_cnt != NULL) |
|
1349 | if (sequence_cnt != NULL) | |
1350 | { |
|
1350 | { | |
1351 | segmentation_grouping_flag = TM_PACKET_SEQ_CTRL_STANDALONE << 8; |
|
1351 | segmentation_grouping_flag = TM_PACKET_SEQ_CTRL_STANDALONE << 8; | |
1352 | *sequence_cnt = (*sequence_cnt) & 0x3fff; |
|
1352 | *sequence_cnt = (*sequence_cnt) & 0x3fff; | |
1353 |
|
1353 | |||
1354 | new_packet_sequence_control = segmentation_grouping_flag | (*sequence_cnt) ; |
|
1354 | new_packet_sequence_control = segmentation_grouping_flag | (*sequence_cnt) ; | |
1355 |
|
1355 | |||
1356 | packet_sequence_control[0] = (unsigned char) (new_packet_sequence_control >> 8); |
|
1356 | packet_sequence_control[0] = (unsigned char) (new_packet_sequence_control >> 8); | |
1357 | packet_sequence_control[1] = (unsigned char) (new_packet_sequence_control ); |
|
1357 | packet_sequence_control[1] = (unsigned char) (new_packet_sequence_control ); | |
1358 |
|
1358 | |||
1359 | // increment the sequence counter |
|
1359 | // increment the sequence counter | |
1360 | if ( *sequence_cnt < SEQ_CNT_MAX) |
|
1360 | if ( *sequence_cnt < SEQ_CNT_MAX) | |
1361 | { |
|
1361 | { | |
1362 | *sequence_cnt = *sequence_cnt + 1; |
|
1362 | *sequence_cnt = *sequence_cnt + 1; | |
1363 | } |
|
1363 | } | |
1364 | else |
|
1364 | else | |
1365 | { |
|
1365 | { | |
1366 | *sequence_cnt = 0; |
|
1366 | *sequence_cnt = 0; | |
1367 | } |
|
1367 | } | |
1368 | } |
|
1368 | } | |
1369 |
|
1369 | |||
1370 | //*********************************** |
|
1370 | //************************************* | |
1371 |
// RES |
|
1371 | // RESTORE THE MODE OF THE CALLING TASK | |
1372 | status = rtems_task_mode( initial_mode_set, RTEMS_PREEMPT_MASK, ¤t_mode_set ); |
|
1372 | status = rtems_task_mode( initial_mode_set, RTEMS_PREEMPT_MASK, ¤t_mode_set ); | |
1373 | } |
|
1373 | } |
General Comments 0
You need to be logged in to leave comments.
Login now