@@ -1,112 +1,112 | |||||
1 | cmake_minimum_required (VERSION 2.6) |
|
1 | cmake_minimum_required (VERSION 2.6) | |
2 | project (fsw) |
|
2 | project (fsw) | |
3 |
|
3 | |||
4 | include(sparc-rtems) |
|
4 | include(sparc-rtems) | |
5 | include(cppcheck) |
|
5 | include(cppcheck) | |
6 |
|
6 | |||
7 | include_directories("../header" |
|
7 | include_directories("../header" | |
8 | "../header/lfr_common_headers" |
|
8 | "../header/lfr_common_headers" | |
9 | "../header/processing" |
|
9 | "../header/processing" | |
10 | "../LFR_basic-parameters" |
|
10 | "../LFR_basic-parameters" | |
11 | "../src") |
|
11 | "../src") | |
12 |
|
12 | |||
13 | set(SOURCES wf_handler.c |
|
13 | set(SOURCES wf_handler.c | |
14 | tc_handler.c |
|
14 | tc_handler.c | |
15 | fsw_misc.c |
|
15 | fsw_misc.c | |
16 | fsw_init.c |
|
16 | fsw_init.c | |
17 | fsw_globals.c |
|
17 | fsw_globals.c | |
18 | fsw_spacewire.c |
|
18 | fsw_spacewire.c | |
19 | tc_load_dump_parameters.c |
|
19 | tc_load_dump_parameters.c | |
20 | tm_lfr_tc_exe.c |
|
20 | tm_lfr_tc_exe.c | |
21 | tc_acceptance.c |
|
21 | tc_acceptance.c | |
22 | processing/fsw_processing.c |
|
22 | processing/fsw_processing.c | |
23 | processing/avf0_prc0.c |
|
23 | processing/avf0_prc0.c | |
24 | processing/avf1_prc1.c |
|
24 | processing/avf1_prc1.c | |
25 | processing/avf2_prc2.c |
|
25 | processing/avf2_prc2.c | |
26 | lfr_cpu_usage_report.c |
|
26 | lfr_cpu_usage_report.c | |
27 | ${LFR_BP_SRC} |
|
27 | ${LFR_BP_SRC} | |
28 | ../header/wf_handler.h |
|
28 | ../header/wf_handler.h | |
29 | ../header/tc_handler.h |
|
29 | ../header/tc_handler.h | |
30 | ../header/grlib_regs.h |
|
30 | ../header/grlib_regs.h | |
31 | ../header/fsw_misc.h |
|
31 | ../header/fsw_misc.h | |
32 | ../header/fsw_init.h |
|
32 | ../header/fsw_init.h | |
33 | ../header/fsw_spacewire.h |
|
33 | ../header/fsw_spacewire.h | |
34 | ../header/tc_load_dump_parameters.h |
|
34 | ../header/tc_load_dump_parameters.h | |
35 | ../header/tm_lfr_tc_exe.h |
|
35 | ../header/tm_lfr_tc_exe.h | |
36 | ../header/tc_acceptance.h |
|
36 | ../header/tc_acceptance.h | |
37 | ../header/processing/fsw_processing.h |
|
37 | ../header/processing/fsw_processing.h | |
38 | ../header/processing/avf0_prc0.h |
|
38 | ../header/processing/avf0_prc0.h | |
39 | ../header/processing/avf1_prc1.h |
|
39 | ../header/processing/avf1_prc1.h | |
40 | ../header/processing/avf2_prc2.h |
|
40 | ../header/processing/avf2_prc2.h | |
41 | ../header/fsw_params_wf_handler.h |
|
41 | ../header/fsw_params_wf_handler.h | |
42 | ../header/lfr_cpu_usage_report.h |
|
42 | ../header/lfr_cpu_usage_report.h | |
43 | ../header/lfr_common_headers/ccsds_types.h |
|
43 | ../header/lfr_common_headers/ccsds_types.h | |
44 | ../header/lfr_common_headers/fsw_params.h |
|
44 | ../header/lfr_common_headers/fsw_params.h | |
45 | ../header/lfr_common_headers/fsw_params_nb_bytes.h |
|
45 | ../header/lfr_common_headers/fsw_params_nb_bytes.h | |
46 | ../header/lfr_common_headers/fsw_params_processing.h |
|
46 | ../header/lfr_common_headers/fsw_params_processing.h | |
47 | ../header/lfr_common_headers/tm_byte_positions.h |
|
47 | ../header/lfr_common_headers/tm_byte_positions.h | |
48 | ../LFR_basic-parameters/basic_parameters.h |
|
48 | ../LFR_basic-parameters/basic_parameters.h | |
49 | ../LFR_basic-parameters/basic_parameters_params.h |
|
49 | ../LFR_basic-parameters/basic_parameters_params.h | |
50 | ../header/GscMemoryLPP.hpp |
|
50 | ../header/GscMemoryLPP.hpp | |
51 | ) |
|
51 | ) | |
52 |
|
52 | |||
53 |
|
53 | |||
54 | option(FSW_verbose "Enable verbose LFR" OFF) |
|
54 | option(FSW_verbose "Enable verbose LFR" OFF) | |
55 | option(FSW_boot_messages "Enable LFR boot messages" OFF) |
|
55 | option(FSW_boot_messages "Enable LFR boot messages" OFF) | |
56 | option(FSW_debug_messages "Enable LFR debug messages" OFF) |
|
56 | option(FSW_debug_messages "Enable LFR debug messages" OFF) | |
57 | option(FSW_cpu_usage_report "Enable LFR cpu usage report" OFF) |
|
57 | option(FSW_cpu_usage_report "Enable LFR cpu usage report" OFF) | |
58 | option(FSW_stack_report "Enable LFR stack report" OFF) |
|
58 | option(FSW_stack_report "Enable LFR stack report" OFF) | |
59 | option(FSW_vhdl_dev "?" OFF) |
|
59 | option(FSW_vhdl_dev "?" OFF) | |
60 | option(FSW_lpp_dpu_destid "Set to debug at LPP" OFF) |
|
60 | option(FSW_lpp_dpu_destid "Set to debug at LPP" OFF) | |
61 | option(FSW_debug_watchdog "Enable debug watchdog" OFF) |
|
61 | option(FSW_debug_watchdog "Enable debug watchdog" OFF) | |
62 | option(FSW_debug_tch "?" OFF) |
|
62 | option(FSW_debug_tch "?" OFF) | |
63 |
|
63 | |||
64 | set(SW_VERSION_N1 "3" CACHE STRING "Choose N1 FSW Version." FORCE) |
|
64 | set(SW_VERSION_N1 "3" CACHE STRING "Choose N1 FSW Version." FORCE) | |
65 | set(SW_VERSION_N2 "2" CACHE STRING "Choose N2 FSW Version." FORCE) |
|
65 | set(SW_VERSION_N2 "2" CACHE STRING "Choose N2 FSW Version." FORCE) | |
66 | set(SW_VERSION_N3 "0" CACHE STRING "Choose N3 FSW Version." FORCE) |
|
66 | set(SW_VERSION_N3 "0" CACHE STRING "Choose N3 FSW Version." FORCE) | |
67 |
set(SW_VERSION_N4 "1 |
|
67 | set(SW_VERSION_N4 "16" CACHE STRING "Choose N4 FSW Version." FORCE) | |
68 |
|
68 | |||
69 | if(FSW_verbose) |
|
69 | if(FSW_verbose) | |
70 | add_definitions(-DPRINT_MESSAGES_ON_CONSOLE) |
|
70 | add_definitions(-DPRINT_MESSAGES_ON_CONSOLE) | |
71 | endif() |
|
71 | endif() | |
72 | if(FSW_boot_messages) |
|
72 | if(FSW_boot_messages) | |
73 | add_definitions(-DBOOT_MESSAGES) |
|
73 | add_definitions(-DBOOT_MESSAGES) | |
74 | endif() |
|
74 | endif() | |
75 | if(FSW_debug_messages) |
|
75 | if(FSW_debug_messages) | |
76 | add_definitions(-DDEBUG_MESSAGES) |
|
76 | add_definitions(-DDEBUG_MESSAGES) | |
77 | endif() |
|
77 | endif() | |
78 | if(FSW_cpu_usage_report) |
|
78 | if(FSW_cpu_usage_report) | |
79 | add_definitions(-DPRINT_TASK_STATISTICS) |
|
79 | add_definitions(-DPRINT_TASK_STATISTICS) | |
80 | endif() |
|
80 | endif() | |
81 | if(FSW_stack_report) |
|
81 | if(FSW_stack_report) | |
82 | add_definitions(-DPRINT_STACK_REPORT) |
|
82 | add_definitions(-DPRINT_STACK_REPORT) | |
83 | endif() |
|
83 | endif() | |
84 | if(FSW_vhdl_dev) |
|
84 | if(FSW_vhdl_dev) | |
85 | add_definitions(-DVHDL_DEV) |
|
85 | add_definitions(-DVHDL_DEV) | |
86 | endif() |
|
86 | endif() | |
87 | if(FSW_lpp_dpu_destid) |
|
87 | if(FSW_lpp_dpu_destid) | |
88 | add_definitions(-DLPP_DPU_DESTID) |
|
88 | add_definitions(-DLPP_DPU_DESTID) | |
89 | endif() |
|
89 | endif() | |
90 | if(FSW_debug_watchdog) |
|
90 | if(FSW_debug_watchdog) | |
91 | add_definitions(-DDEBUG_WATCHDOG) |
|
91 | add_definitions(-DDEBUG_WATCHDOG) | |
92 | endif() |
|
92 | endif() | |
93 | if(FSW_debug_tch) |
|
93 | if(FSW_debug_tch) | |
94 | add_definitions(-DDEBUG_TCH) |
|
94 | add_definitions(-DDEBUG_TCH) | |
95 | endif() |
|
95 | endif() | |
96 |
|
96 | |||
97 | add_definitions(-DMSB_FIRST_TCH) |
|
97 | add_definitions(-DMSB_FIRST_TCH) | |
98 |
|
98 | |||
99 | add_definitions(-DSWVERSION=-1-0) |
|
99 | add_definitions(-DSWVERSION=-1-0) | |
100 | add_definitions(-DSW_VERSION_N1=${SW_VERSION_N1}) |
|
100 | add_definitions(-DSW_VERSION_N1=${SW_VERSION_N1}) | |
101 | add_definitions(-DSW_VERSION_N2=${SW_VERSION_N2}) |
|
101 | add_definitions(-DSW_VERSION_N2=${SW_VERSION_N2}) | |
102 | add_definitions(-DSW_VERSION_N3=${SW_VERSION_N3}) |
|
102 | add_definitions(-DSW_VERSION_N3=${SW_VERSION_N3}) | |
103 | add_definitions(-DSW_VERSION_N4=${SW_VERSION_N4}) |
|
103 | add_definitions(-DSW_VERSION_N4=${SW_VERSION_N4}) | |
104 |
|
104 | |||
105 | add_executable(fsw ${SOURCES}) |
|
105 | add_executable(fsw ${SOURCES}) | |
106 |
|
106 | |||
107 | if(fix-b2bst) |
|
107 | if(fix-b2bst) | |
108 | check_b2bst(fsw ${CMAKE_CURRENT_BINARY_DIR}) |
|
108 | check_b2bst(fsw ${CMAKE_CURRENT_BINARY_DIR}) | |
109 | endif() |
|
109 | endif() | |
110 |
|
110 | |||
111 | add_test_cppcheck(fsw STYLE UNUSED_FUNCTIONS POSSIBLE_ERROR MISSING_INCLUDE) |
|
111 | add_test_cppcheck(fsw STYLE UNUSED_FUNCTIONS POSSIBLE_ERROR MISSING_INCLUDE) | |
112 |
|
112 |
@@ -1,514 +1,512 | |||||
1 | /** Functions to send TM packets related to TC parsing and execution. |
|
1 | /** Functions to send TM packets related to TC parsing and execution. | |
2 | * |
|
2 | * | |
3 | * @file |
|
3 | * @file | |
4 | * @author P. LEROY |
|
4 | * @author P. LEROY | |
5 | * |
|
5 | * | |
6 | * A group of functions to send appropriate TM packets after parsing and execution: |
|
6 | * A group of functions to send appropriate TM packets after parsing and execution: | |
7 | * - TM_LFR_TC_EXE_SUCCESS |
|
7 | * - TM_LFR_TC_EXE_SUCCESS | |
8 | * - TM_LFR_TC_EXE_INCONSISTENT |
|
8 | * - TM_LFR_TC_EXE_INCONSISTENT | |
9 | * - TM_LFR_TC_EXE_NOT_EXECUTABLE |
|
9 | * - TM_LFR_TC_EXE_NOT_EXECUTABLE | |
10 | * - TM_LFR_TC_EXE_NOT_IMPLEMENTED |
|
10 | * - TM_LFR_TC_EXE_NOT_IMPLEMENTED | |
11 | * - TM_LFR_TC_EXE_ERROR |
|
11 | * - TM_LFR_TC_EXE_ERROR | |
12 | * - TM_LFR_TC_EXE_CORRUPTED |
|
12 | * - TM_LFR_TC_EXE_CORRUPTED | |
13 | * |
|
13 | * | |
14 | */ |
|
14 | */ | |
15 |
|
15 | |||
16 | #include "tm_lfr_tc_exe.h" |
|
16 | #include "tm_lfr_tc_exe.h" | |
17 |
|
17 | |||
18 | int send_tm_lfr_tc_exe_success( ccsdsTelecommandPacket_t *TC, rtems_id queue_id ) |
|
18 | int send_tm_lfr_tc_exe_success( ccsdsTelecommandPacket_t *TC, rtems_id queue_id ) | |
19 | { |
|
19 | { | |
20 | /** This function sends a TM_LFR_TC_EXE_SUCCESS packet in the dedicated RTEMS message queue. |
|
20 | /** This function sends a TM_LFR_TC_EXE_SUCCESS packet in the dedicated RTEMS message queue. | |
21 | * |
|
21 | * | |
22 | * @param TC points to the TeleCommand packet that is being processed |
|
22 | * @param TC points to the TeleCommand packet that is being processed | |
23 | * @param queue_id is the id of the queue which handles TM |
|
23 | * @param queue_id is the id of the queue which handles TM | |
24 | * |
|
24 | * | |
25 | * @return RTEMS directive status code: |
|
25 | * @return RTEMS directive status code: | |
26 | * - RTEMS_SUCCESSFUL - message sent successfully |
|
26 | * - RTEMS_SUCCESSFUL - message sent successfully | |
27 | * - RTEMS_INVALID_ID - invalid queue id |
|
27 | * - RTEMS_INVALID_ID - invalid queue id | |
28 | * - RTEMS_INVALID_SIZE - invalid message size |
|
28 | * - RTEMS_INVALID_SIZE - invalid message size | |
29 | * - RTEMS_INVALID_ADDRESS - buffer is NULL |
|
29 | * - RTEMS_INVALID_ADDRESS - buffer is NULL | |
30 | * - RTEMS_UNSATISFIED - out of message buffers |
|
30 | * - RTEMS_UNSATISFIED - out of message buffers | |
31 | * - RTEMS_TOO_MANY - queue s limit has been reached |
|
31 | * - RTEMS_TOO_MANY - queue s limit has been reached | |
32 | * |
|
32 | * | |
33 | */ |
|
33 | */ | |
34 |
|
34 | |||
35 | rtems_status_code status; |
|
35 | rtems_status_code status; | |
36 | Packet_TM_LFR_TC_EXE_SUCCESS_t TM; |
|
36 | Packet_TM_LFR_TC_EXE_SUCCESS_t TM; | |
37 | unsigned char messageSize; |
|
37 | unsigned char messageSize; | |
38 |
|
38 | |||
39 | TM.targetLogicalAddress = CCSDS_DESTINATION_ID; |
|
39 | TM.targetLogicalAddress = CCSDS_DESTINATION_ID; | |
40 | TM.protocolIdentifier = CCSDS_PROTOCOLE_ID; |
|
40 | TM.protocolIdentifier = CCSDS_PROTOCOLE_ID; | |
41 | TM.reserved = DEFAULT_RESERVED; |
|
41 | TM.reserved = DEFAULT_RESERVED; | |
42 | TM.userApplication = CCSDS_USER_APP; |
|
42 | TM.userApplication = CCSDS_USER_APP; | |
43 | // PACKET HEADER |
|
43 | // PACKET HEADER | |
44 | TM.packetID[0] = (unsigned char) (APID_TM_TC_EXE >> SHIFT_1_BYTE); |
|
44 | TM.packetID[0] = (unsigned char) (APID_TM_TC_EXE >> SHIFT_1_BYTE); | |
45 | TM.packetID[1] = (unsigned char) (APID_TM_TC_EXE ); |
|
45 | TM.packetID[1] = (unsigned char) (APID_TM_TC_EXE ); | |
46 | increment_seq_counter_destination_id( TM.packetSequenceControl, TC->sourceID ); |
|
46 | increment_seq_counter_destination_id( TM.packetSequenceControl, TC->sourceID ); | |
47 | TM.packetLength[0] = (unsigned char) (PACKET_LENGTH_TC_EXE_SUCCESS >> SHIFT_1_BYTE); |
|
47 | TM.packetLength[0] = (unsigned char) (PACKET_LENGTH_TC_EXE_SUCCESS >> SHIFT_1_BYTE); | |
48 | TM.packetLength[1] = (unsigned char) (PACKET_LENGTH_TC_EXE_SUCCESS ); |
|
48 | TM.packetLength[1] = (unsigned char) (PACKET_LENGTH_TC_EXE_SUCCESS ); | |
49 | // DATA FIELD HEADER |
|
49 | // DATA FIELD HEADER | |
50 | TM.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2; |
|
50 | TM.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2; | |
51 | TM.serviceType = TM_TYPE_TC_EXE; |
|
51 | TM.serviceType = TM_TYPE_TC_EXE; | |
52 | TM.serviceSubType = TM_SUBTYPE_EXE_OK; |
|
52 | TM.serviceSubType = TM_SUBTYPE_EXE_OK; | |
53 | TM.destinationID = TC->sourceID; |
|
53 | TM.destinationID = TC->sourceID; | |
54 | TM.time[BYTE_0] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_3_BYTES); |
|
54 | TM.time[BYTE_0] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_3_BYTES); | |
55 | TM.time[BYTE_1] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_2_BYTES); |
|
55 | TM.time[BYTE_1] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_2_BYTES); | |
56 | TM.time[BYTE_2] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_1_BYTE); |
|
56 | TM.time[BYTE_2] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_1_BYTE); | |
57 | TM.time[BYTE_3] = (unsigned char) (time_management_regs->coarse_time); |
|
57 | TM.time[BYTE_3] = (unsigned char) (time_management_regs->coarse_time); | |
58 | TM.time[BYTE_4] = (unsigned char) (time_management_regs->fine_time >> SHIFT_1_BYTE); |
|
58 | TM.time[BYTE_4] = (unsigned char) (time_management_regs->fine_time >> SHIFT_1_BYTE); | |
59 | TM.time[BYTE_5] = (unsigned char) (time_management_regs->fine_time); |
|
59 | TM.time[BYTE_5] = (unsigned char) (time_management_regs->fine_time); | |
60 | // |
|
60 | // | |
61 | TM.telecommand_pkt_id[0] = TC->packetID[0]; |
|
61 | TM.telecommand_pkt_id[0] = TC->packetID[0]; | |
62 | TM.telecommand_pkt_id[1] = TC->packetID[1]; |
|
62 | TM.telecommand_pkt_id[1] = TC->packetID[1]; | |
63 | TM.pkt_seq_control[0] = TC->packetSequenceControl[0]; |
|
63 | TM.pkt_seq_control[0] = TC->packetSequenceControl[0]; | |
64 | TM.pkt_seq_control[1] = TC->packetSequenceControl[1]; |
|
64 | TM.pkt_seq_control[1] = TC->packetSequenceControl[1]; | |
65 |
|
65 | |||
66 | messageSize = PACKET_LENGTH_TC_EXE_SUCCESS + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES; |
|
66 | messageSize = PACKET_LENGTH_TC_EXE_SUCCESS + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES; | |
67 |
|
67 | |||
68 | // SEND DATA |
|
68 | // SEND DATA | |
69 | status = rtems_message_queue_send( queue_id, &TM, messageSize); |
|
69 | status = rtems_message_queue_send( queue_id, &TM, messageSize); | |
70 | if (status != RTEMS_SUCCESSFUL) { |
|
70 | if (status != RTEMS_SUCCESSFUL) { | |
71 | PRINTF("in send_tm_lfr_tc_exe_success *** ERR\n") |
|
71 | PRINTF("in send_tm_lfr_tc_exe_success *** ERR\n") | |
72 | } |
|
72 | } | |
73 |
|
73 | |||
74 | // UPDATE HK FIELDS |
|
74 | // UPDATE HK FIELDS | |
75 | update_last_TC_exe( TC, TM.time ); |
|
75 | update_last_TC_exe( TC, TM.time ); | |
76 |
|
76 | |||
77 | return status; |
|
77 | return status; | |
78 | } |
|
78 | } | |
79 |
|
79 | |||
80 | int send_tm_lfr_tc_exe_inconsistent( ccsdsTelecommandPacket_t *TC, rtems_id queue_id, |
|
80 | int send_tm_lfr_tc_exe_inconsistent( ccsdsTelecommandPacket_t *TC, rtems_id queue_id, | |
81 | unsigned char byte_position, unsigned char rcv_value ) |
|
81 | unsigned char byte_position, unsigned char rcv_value ) | |
82 | { |
|
82 | { | |
83 | /** This function sends a TM_LFR_TC_EXE_INCONSISTENT packet in the dedicated RTEMS message queue. |
|
83 | /** This function sends a TM_LFR_TC_EXE_INCONSISTENT packet in the dedicated RTEMS message queue. | |
84 | * |
|
84 | * | |
85 | * @param TC points to the TeleCommand packet that is being processed |
|
85 | * @param TC points to the TeleCommand packet that is being processed | |
86 | * @param queue_id is the id of the queue which handles TM |
|
86 | * @param queue_id is the id of the queue which handles TM | |
87 | * @param byte_position is the byte position of the MSB of the parameter that has been seen as inconsistent |
|
87 | * @param byte_position is the byte position of the MSB of the parameter that has been seen as inconsistent | |
88 | * @param rcv_value is the value of the LSB of the parameter that has been detected as inconsistent |
|
88 | * @param rcv_value is the value of the LSB of the parameter that has been detected as inconsistent | |
89 | * |
|
89 | * | |
90 | * @return RTEMS directive status code: |
|
90 | * @return RTEMS directive status code: | |
91 | * - RTEMS_SUCCESSFUL - message sent successfully |
|
91 | * - RTEMS_SUCCESSFUL - message sent successfully | |
92 | * - RTEMS_INVALID_ID - invalid queue id |
|
92 | * - RTEMS_INVALID_ID - invalid queue id | |
93 | * - RTEMS_INVALID_SIZE - invalid message size |
|
93 | * - RTEMS_INVALID_SIZE - invalid message size | |
94 | * - RTEMS_INVALID_ADDRESS - buffer is NULL |
|
94 | * - RTEMS_INVALID_ADDRESS - buffer is NULL | |
95 | * - RTEMS_UNSATISFIED - out of message buffers |
|
95 | * - RTEMS_UNSATISFIED - out of message buffers | |
96 | * - RTEMS_TOO_MANY - queue s limit has been reached |
|
96 | * - RTEMS_TOO_MANY - queue s limit has been reached | |
97 | * |
|
97 | * | |
98 | */ |
|
98 | */ | |
99 |
|
99 | |||
100 | rtems_status_code status; |
|
100 | rtems_status_code status; | |
101 | Packet_TM_LFR_TC_EXE_INCONSISTENT_t TM; |
|
101 | Packet_TM_LFR_TC_EXE_INCONSISTENT_t TM; | |
102 | unsigned char messageSize; |
|
102 | unsigned char messageSize; | |
103 |
|
103 | |||
104 | TM.targetLogicalAddress = CCSDS_DESTINATION_ID; |
|
104 | TM.targetLogicalAddress = CCSDS_DESTINATION_ID; | |
105 | TM.protocolIdentifier = CCSDS_PROTOCOLE_ID; |
|
105 | TM.protocolIdentifier = CCSDS_PROTOCOLE_ID; | |
106 | TM.reserved = DEFAULT_RESERVED; |
|
106 | TM.reserved = DEFAULT_RESERVED; | |
107 | TM.userApplication = CCSDS_USER_APP; |
|
107 | TM.userApplication = CCSDS_USER_APP; | |
108 | // PACKET HEADER |
|
108 | // PACKET HEADER | |
109 | TM.packetID[0] = (unsigned char) (APID_TM_TC_EXE >> SHIFT_1_BYTE); |
|
109 | TM.packetID[0] = (unsigned char) (APID_TM_TC_EXE >> SHIFT_1_BYTE); | |
110 | TM.packetID[1] = (unsigned char) (APID_TM_TC_EXE ); |
|
110 | TM.packetID[1] = (unsigned char) (APID_TM_TC_EXE ); | |
111 | increment_seq_counter_destination_id( TM.packetSequenceControl, TC->sourceID ); |
|
111 | increment_seq_counter_destination_id( TM.packetSequenceControl, TC->sourceID ); | |
112 | TM.packetLength[0] = (unsigned char) (PACKET_LENGTH_TC_EXE_INCONSISTENT >> SHIFT_1_BYTE); |
|
112 | TM.packetLength[0] = (unsigned char) (PACKET_LENGTH_TC_EXE_INCONSISTENT >> SHIFT_1_BYTE); | |
113 | TM.packetLength[1] = (unsigned char) (PACKET_LENGTH_TC_EXE_INCONSISTENT ); |
|
113 | TM.packetLength[1] = (unsigned char) (PACKET_LENGTH_TC_EXE_INCONSISTENT ); | |
114 | // DATA FIELD HEADER |
|
114 | // DATA FIELD HEADER | |
115 | TM.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2; |
|
115 | TM.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2; | |
116 | TM.serviceType = TM_TYPE_TC_EXE; |
|
116 | TM.serviceType = TM_TYPE_TC_EXE; | |
117 | TM.serviceSubType = TM_SUBTYPE_EXE_NOK; |
|
117 | TM.serviceSubType = TM_SUBTYPE_EXE_NOK; | |
118 | TM.destinationID = TC->sourceID; |
|
118 | TM.destinationID = TC->sourceID; | |
119 | TM.time[BYTE_0] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_3_BYTES); |
|
119 | TM.time[BYTE_0] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_3_BYTES); | |
120 | TM.time[BYTE_1] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_2_BYTES); |
|
120 | TM.time[BYTE_1] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_2_BYTES); | |
121 | TM.time[BYTE_2] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_1_BYTE); |
|
121 | TM.time[BYTE_2] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_1_BYTE); | |
122 | TM.time[BYTE_3] = (unsigned char) (time_management_regs->coarse_time); |
|
122 | TM.time[BYTE_3] = (unsigned char) (time_management_regs->coarse_time); | |
123 | TM.time[BYTE_4] = (unsigned char) (time_management_regs->fine_time >> SHIFT_1_BYTE); |
|
123 | TM.time[BYTE_4] = (unsigned char) (time_management_regs->fine_time >> SHIFT_1_BYTE); | |
124 | TM.time[BYTE_5] = (unsigned char) (time_management_regs->fine_time); |
|
124 | TM.time[BYTE_5] = (unsigned char) (time_management_regs->fine_time); | |
125 | // |
|
125 | // | |
126 | TM.tc_failure_code[0] = (char) (WRONG_APP_DATA >> SHIFT_1_BYTE); |
|
126 | TM.tc_failure_code[0] = (char) (WRONG_APP_DATA >> SHIFT_1_BYTE); | |
127 | TM.tc_failure_code[1] = (char) (WRONG_APP_DATA ); |
|
127 | TM.tc_failure_code[1] = (char) (WRONG_APP_DATA ); | |
128 | TM.telecommand_pkt_id[0] = TC->packetID[0]; |
|
128 | TM.telecommand_pkt_id[0] = TC->packetID[0]; | |
129 | TM.telecommand_pkt_id[1] = TC->packetID[1]; |
|
129 | TM.telecommand_pkt_id[1] = TC->packetID[1]; | |
130 | TM.pkt_seq_control[0] = TC->packetSequenceControl[0]; |
|
130 | TM.pkt_seq_control[0] = TC->packetSequenceControl[0]; | |
131 | TM.pkt_seq_control[1] = TC->packetSequenceControl[1]; |
|
131 | TM.pkt_seq_control[1] = TC->packetSequenceControl[1]; | |
132 | TM.tc_service = TC->serviceType; // type of the rejected TC |
|
132 | TM.tc_service = TC->serviceType; // type of the rejected TC | |
133 | TM.tc_subtype = TC->serviceSubType; // subtype of the rejected TC |
|
133 | TM.tc_subtype = TC->serviceSubType; // subtype of the rejected TC | |
134 | TM.byte_position = byte_position; |
|
134 | TM.byte_position = byte_position; | |
135 | TM.rcv_value = (unsigned char) rcv_value; |
|
135 | TM.rcv_value = (unsigned char) rcv_value; | |
136 |
|
136 | |||
137 | messageSize = PACKET_LENGTH_TC_EXE_INCONSISTENT + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES; |
|
137 | messageSize = PACKET_LENGTH_TC_EXE_INCONSISTENT + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES; | |
138 |
|
138 | |||
139 | // SEND DATA |
|
139 | // SEND DATA | |
140 | status = rtems_message_queue_send( queue_id, &TM, messageSize); |
|
140 | status = rtems_message_queue_send( queue_id, &TM, messageSize); | |
141 | if (status != RTEMS_SUCCESSFUL) { |
|
141 | if (status != RTEMS_SUCCESSFUL) { | |
142 | PRINTF("in send_tm_lfr_tc_exe_inconsistent *** ERR\n") |
|
142 | PRINTF("in send_tm_lfr_tc_exe_inconsistent *** ERR\n") | |
143 | } |
|
143 | } | |
144 |
|
144 | |||
145 | // UPDATE HK FIELDS |
|
145 | // UPDATE HK FIELDS | |
146 | update_last_TC_rej( TC, TM.time ); |
|
146 | update_last_TC_rej( TC, TM.time ); | |
147 |
|
147 | |||
148 | return status; |
|
148 | return status; | |
149 | } |
|
149 | } | |
150 |
|
150 | |||
151 | int send_tm_lfr_tc_exe_not_executable( ccsdsTelecommandPacket_t *TC, rtems_id queue_id ) |
|
151 | int send_tm_lfr_tc_exe_not_executable( ccsdsTelecommandPacket_t *TC, rtems_id queue_id ) | |
152 | { |
|
152 | { | |
153 | /** This function sends a TM_LFR_TC_EXE_NOT_EXECUTABLE packet in the dedicated RTEMS message queue. |
|
153 | /** This function sends a TM_LFR_TC_EXE_NOT_EXECUTABLE packet in the dedicated RTEMS message queue. | |
154 | * |
|
154 | * | |
155 | * @param TC points to the TeleCommand packet that is being processed |
|
155 | * @param TC points to the TeleCommand packet that is being processed | |
156 | * @param queue_id is the id of the queue which handles TM |
|
156 | * @param queue_id is the id of the queue which handles TM | |
157 | * |
|
157 | * | |
158 | * @return RTEMS directive status code: |
|
158 | * @return RTEMS directive status code: | |
159 | * - RTEMS_SUCCESSFUL - message sent successfully |
|
159 | * - RTEMS_SUCCESSFUL - message sent successfully | |
160 | * - RTEMS_INVALID_ID - invalid queue id |
|
160 | * - RTEMS_INVALID_ID - invalid queue id | |
161 | * - RTEMS_INVALID_SIZE - invalid message size |
|
161 | * - RTEMS_INVALID_SIZE - invalid message size | |
162 | * - RTEMS_INVALID_ADDRESS - buffer is NULL |
|
162 | * - RTEMS_INVALID_ADDRESS - buffer is NULL | |
163 | * - RTEMS_UNSATISFIED - out of message buffers |
|
163 | * - RTEMS_UNSATISFIED - out of message buffers | |
164 | * - RTEMS_TOO_MANY - queue s limit has been reached |
|
164 | * - RTEMS_TOO_MANY - queue s limit has been reached | |
165 | * |
|
165 | * | |
166 | */ |
|
166 | */ | |
167 |
|
167 | |||
168 | rtems_status_code status; |
|
168 | rtems_status_code status; | |
169 | Packet_TM_LFR_TC_EXE_NOT_EXECUTABLE_t TM; |
|
169 | Packet_TM_LFR_TC_EXE_NOT_EXECUTABLE_t TM; | |
170 | unsigned char messageSize; |
|
170 | unsigned char messageSize; | |
171 |
|
171 | |||
172 | TM.targetLogicalAddress = CCSDS_DESTINATION_ID; |
|
172 | TM.targetLogicalAddress = CCSDS_DESTINATION_ID; | |
173 | TM.protocolIdentifier = CCSDS_PROTOCOLE_ID; |
|
173 | TM.protocolIdentifier = CCSDS_PROTOCOLE_ID; | |
174 | TM.reserved = DEFAULT_RESERVED; |
|
174 | TM.reserved = DEFAULT_RESERVED; | |
175 | TM.userApplication = CCSDS_USER_APP; |
|
175 | TM.userApplication = CCSDS_USER_APP; | |
176 | // PACKET HEADER |
|
176 | // PACKET HEADER | |
177 | TM.packetID[0] = (unsigned char) (APID_TM_TC_EXE >> SHIFT_1_BYTE); |
|
177 | TM.packetID[0] = (unsigned char) (APID_TM_TC_EXE >> SHIFT_1_BYTE); | |
178 | TM.packetID[1] = (unsigned char) (APID_TM_TC_EXE ); |
|
178 | TM.packetID[1] = (unsigned char) (APID_TM_TC_EXE ); | |
179 | increment_seq_counter_destination_id( TM.packetSequenceControl, TC->sourceID ); |
|
179 | increment_seq_counter_destination_id( TM.packetSequenceControl, TC->sourceID ); | |
180 | TM.packetLength[0] = (unsigned char) (PACKET_LENGTH_TC_EXE_NOT_EXECUTABLE >> SHIFT_1_BYTE); |
|
180 | TM.packetLength[0] = (unsigned char) (PACKET_LENGTH_TC_EXE_NOT_EXECUTABLE >> SHIFT_1_BYTE); | |
181 | TM.packetLength[1] = (unsigned char) (PACKET_LENGTH_TC_EXE_NOT_EXECUTABLE ); |
|
181 | TM.packetLength[1] = (unsigned char) (PACKET_LENGTH_TC_EXE_NOT_EXECUTABLE ); | |
182 | // DATA FIELD HEADER |
|
182 | // DATA FIELD HEADER | |
183 | TM.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2; |
|
183 | TM.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2; | |
184 | TM.serviceType = TM_TYPE_TC_EXE; |
|
184 | TM.serviceType = TM_TYPE_TC_EXE; | |
185 | TM.serviceSubType = TM_SUBTYPE_EXE_NOK; |
|
185 | TM.serviceSubType = TM_SUBTYPE_EXE_NOK; | |
186 | TM.destinationID = TC->sourceID; // default destination id |
|
186 | TM.destinationID = TC->sourceID; // default destination id | |
187 | TM.time[BYTE_0] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_3_BYTES); |
|
187 | TM.time[BYTE_0] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_3_BYTES); | |
188 | TM.time[BYTE_1] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_2_BYTES); |
|
188 | TM.time[BYTE_1] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_2_BYTES); | |
189 | TM.time[BYTE_2] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_1_BYTE); |
|
189 | TM.time[BYTE_2] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_1_BYTE); | |
190 | TM.time[BYTE_3] = (unsigned char) (time_management_regs->coarse_time); |
|
190 | TM.time[BYTE_3] = (unsigned char) (time_management_regs->coarse_time); | |
191 | TM.time[BYTE_4] = (unsigned char) (time_management_regs->fine_time >> SHIFT_1_BYTE); |
|
191 | TM.time[BYTE_4] = (unsigned char) (time_management_regs->fine_time >> SHIFT_1_BYTE); | |
192 | TM.time[BYTE_5] = (unsigned char) (time_management_regs->fine_time); |
|
192 | TM.time[BYTE_5] = (unsigned char) (time_management_regs->fine_time); | |
193 | // |
|
193 | // | |
194 | TM.tc_failure_code[0] = (char) (TC_NOT_EXE >> SHIFT_1_BYTE); |
|
194 | TM.tc_failure_code[0] = (char) (TC_NOT_EXE >> SHIFT_1_BYTE); | |
195 | TM.tc_failure_code[1] = (char) (TC_NOT_EXE ); |
|
195 | TM.tc_failure_code[1] = (char) (TC_NOT_EXE ); | |
196 | TM.telecommand_pkt_id[0] = TC->packetID[0]; |
|
196 | TM.telecommand_pkt_id[0] = TC->packetID[0]; | |
197 | TM.telecommand_pkt_id[1] = TC->packetID[1]; |
|
197 | TM.telecommand_pkt_id[1] = TC->packetID[1]; | |
198 | TM.pkt_seq_control[0] = TC->packetSequenceControl[0]; |
|
198 | TM.pkt_seq_control[0] = TC->packetSequenceControl[0]; | |
199 | TM.pkt_seq_control[1] = TC->packetSequenceControl[1]; |
|
199 | TM.pkt_seq_control[1] = TC->packetSequenceControl[1]; | |
200 | TM.tc_service = TC->serviceType; // type of the rejected TC |
|
200 | TM.tc_service = TC->serviceType; // type of the rejected TC | |
201 | TM.tc_subtype = TC->serviceSubType; // subtype of the rejected TC |
|
201 | TM.tc_subtype = TC->serviceSubType; // subtype of the rejected TC | |
202 | TM.lfr_status_word[0] = housekeeping_packet.lfr_status_word[0]; |
|
202 | TM.lfr_status_word[0] = housekeeping_packet.lfr_status_word[0]; | |
203 | TM.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1]; |
|
203 | TM.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1]; | |
204 |
|
204 | |||
205 | messageSize = PACKET_LENGTH_TC_EXE_NOT_EXECUTABLE + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES; |
|
205 | messageSize = PACKET_LENGTH_TC_EXE_NOT_EXECUTABLE + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES; | |
206 |
|
206 | |||
207 | // SEND DATA |
|
207 | // SEND DATA | |
208 | status = rtems_message_queue_send( queue_id, &TM, messageSize); |
|
208 | status = rtems_message_queue_send( queue_id, &TM, messageSize); | |
209 | if (status != RTEMS_SUCCESSFUL) { |
|
209 | if (status != RTEMS_SUCCESSFUL) { | |
210 | PRINTF("in send_tm_lfr_tc_exe_not_executable *** ERR\n") |
|
210 | PRINTF("in send_tm_lfr_tc_exe_not_executable *** ERR\n") | |
211 | } |
|
211 | } | |
212 |
|
212 | |||
213 | // UPDATE HK FIELDS |
|
213 | // UPDATE HK FIELDS | |
214 | update_last_TC_rej( TC, TM.time ); |
|
214 | update_last_TC_rej( TC, TM.time ); | |
215 |
|
215 | |||
216 | return status; |
|
216 | return status; | |
217 | } |
|
217 | } | |
218 |
|
218 | |||
219 | int send_tm_lfr_tc_exe_not_implemented( ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time ) |
|
219 | int send_tm_lfr_tc_exe_not_implemented( ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time ) | |
220 | { |
|
220 | { | |
221 | /** This function sends a TM_LFR_TC_EXE_NOT_IMPLEMENTED packet in the dedicated RTEMS message queue. |
|
221 | /** This function sends a TM_LFR_TC_EXE_NOT_IMPLEMENTED packet in the dedicated RTEMS message queue. | |
222 | * |
|
222 | * | |
223 | * @param TC points to the TeleCommand packet that is being processed |
|
223 | * @param TC points to the TeleCommand packet that is being processed | |
224 | * @param queue_id is the id of the queue which handles TM |
|
224 | * @param queue_id is the id of the queue which handles TM | |
225 | * |
|
225 | * | |
226 | * @return RTEMS directive status code: |
|
226 | * @return RTEMS directive status code: | |
227 | * - RTEMS_SUCCESSFUL - message sent successfully |
|
227 | * - RTEMS_SUCCESSFUL - message sent successfully | |
228 | * - RTEMS_INVALID_ID - invalid queue id |
|
228 | * - RTEMS_INVALID_ID - invalid queue id | |
229 | * - RTEMS_INVALID_SIZE - invalid message size |
|
229 | * - RTEMS_INVALID_SIZE - invalid message size | |
230 | * - RTEMS_INVALID_ADDRESS - buffer is NULL |
|
230 | * - RTEMS_INVALID_ADDRESS - buffer is NULL | |
231 | * - RTEMS_UNSATISFIED - out of message buffers |
|
231 | * - RTEMS_UNSATISFIED - out of message buffers | |
232 | * - RTEMS_TOO_MANY - queue s limit has been reached |
|
232 | * - RTEMS_TOO_MANY - queue s limit has been reached | |
233 | * |
|
233 | * | |
234 | */ |
|
234 | */ | |
235 |
|
235 | |||
236 | rtems_status_code status; |
|
236 | rtems_status_code status; | |
237 | Packet_TM_LFR_TC_EXE_NOT_IMPLEMENTED_t TM; |
|
237 | Packet_TM_LFR_TC_EXE_NOT_IMPLEMENTED_t TM; | |
238 | unsigned char messageSize; |
|
238 | unsigned char messageSize; | |
239 |
|
239 | |||
240 | TM.targetLogicalAddress = CCSDS_DESTINATION_ID; |
|
240 | TM.targetLogicalAddress = CCSDS_DESTINATION_ID; | |
241 | TM.protocolIdentifier = CCSDS_PROTOCOLE_ID; |
|
241 | TM.protocolIdentifier = CCSDS_PROTOCOLE_ID; | |
242 | TM.reserved = DEFAULT_RESERVED; |
|
242 | TM.reserved = DEFAULT_RESERVED; | |
243 | TM.userApplication = CCSDS_USER_APP; |
|
243 | TM.userApplication = CCSDS_USER_APP; | |
244 | // PACKET HEADER |
|
244 | // PACKET HEADER | |
245 | TM.packetID[0] = (unsigned char) (APID_TM_TC_EXE >> SHIFT_1_BYTE); |
|
245 | TM.packetID[0] = (unsigned char) (APID_TM_TC_EXE >> SHIFT_1_BYTE); | |
246 | TM.packetID[1] = (unsigned char) (APID_TM_TC_EXE ); |
|
246 | TM.packetID[1] = (unsigned char) (APID_TM_TC_EXE ); | |
247 | increment_seq_counter_destination_id( TM.packetSequenceControl, TC->sourceID ); |
|
247 | increment_seq_counter_destination_id( TM.packetSequenceControl, TC->sourceID ); | |
248 | TM.packetLength[0] = (unsigned char) (PACKET_LENGTH_TC_EXE_NOT_IMPLEMENTED >> SHIFT_1_BYTE); |
|
248 | TM.packetLength[0] = (unsigned char) (PACKET_LENGTH_TC_EXE_NOT_IMPLEMENTED >> SHIFT_1_BYTE); | |
249 | TM.packetLength[1] = (unsigned char) (PACKET_LENGTH_TC_EXE_NOT_IMPLEMENTED ); |
|
249 | TM.packetLength[1] = (unsigned char) (PACKET_LENGTH_TC_EXE_NOT_IMPLEMENTED ); | |
250 | // DATA FIELD HEADER |
|
250 | // DATA FIELD HEADER | |
251 | TM.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2; |
|
251 | TM.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2; | |
252 | TM.serviceType = TM_TYPE_TC_EXE; |
|
252 | TM.serviceType = TM_TYPE_TC_EXE; | |
253 | TM.serviceSubType = TM_SUBTYPE_EXE_NOK; |
|
253 | TM.serviceSubType = TM_SUBTYPE_EXE_NOK; | |
254 | TM.destinationID = TC->sourceID; // default destination id |
|
254 | TM.destinationID = TC->sourceID; // default destination id | |
255 | TM.time[BYTE_0] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_3_BYTES); |
|
255 | TM.time[BYTE_0] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_3_BYTES); | |
256 | TM.time[BYTE_1] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_2_BYTES); |
|
256 | TM.time[BYTE_1] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_2_BYTES); | |
257 | TM.time[BYTE_2] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_1_BYTE); |
|
257 | TM.time[BYTE_2] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_1_BYTE); | |
258 | TM.time[BYTE_3] = (unsigned char) (time_management_regs->coarse_time); |
|
258 | TM.time[BYTE_3] = (unsigned char) (time_management_regs->coarse_time); | |
259 | TM.time[BYTE_4] = (unsigned char) (time_management_regs->fine_time >> SHIFT_1_BYTE); |
|
259 | TM.time[BYTE_4] = (unsigned char) (time_management_regs->fine_time >> SHIFT_1_BYTE); | |
260 | TM.time[BYTE_5] = (unsigned char) (time_management_regs->fine_time); |
|
260 | TM.time[BYTE_5] = (unsigned char) (time_management_regs->fine_time); | |
261 | // |
|
261 | // | |
262 | TM.tc_failure_code[0] = (char) (FUNCT_NOT_IMPL >> SHIFT_1_BYTE); |
|
262 | TM.tc_failure_code[0] = (char) (FUNCT_NOT_IMPL >> SHIFT_1_BYTE); | |
263 | TM.tc_failure_code[1] = (char) (FUNCT_NOT_IMPL ); |
|
263 | TM.tc_failure_code[1] = (char) (FUNCT_NOT_IMPL ); | |
264 | TM.telecommand_pkt_id[0] = TC->packetID[0]; |
|
264 | TM.telecommand_pkt_id[0] = TC->packetID[0]; | |
265 | TM.telecommand_pkt_id[1] = TC->packetID[1]; |
|
265 | TM.telecommand_pkt_id[1] = TC->packetID[1]; | |
266 | TM.pkt_seq_control[0] = TC->packetSequenceControl[0]; |
|
266 | TM.pkt_seq_control[0] = TC->packetSequenceControl[0]; | |
267 | TM.pkt_seq_control[1] = TC->packetSequenceControl[1]; |
|
267 | TM.pkt_seq_control[1] = TC->packetSequenceControl[1]; | |
268 | TM.tc_service = TC->serviceType; // type of the rejected TC |
|
268 | TM.tc_service = TC->serviceType; // type of the rejected TC | |
269 | TM.tc_subtype = TC->serviceSubType; // subtype of the rejected TC |
|
269 | TM.tc_subtype = TC->serviceSubType; // subtype of the rejected TC | |
270 |
|
270 | |||
271 | messageSize = PACKET_LENGTH_TC_EXE_NOT_IMPLEMENTED + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES; |
|
271 | messageSize = PACKET_LENGTH_TC_EXE_NOT_IMPLEMENTED + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES; | |
272 |
|
272 | |||
273 | // SEND DATA |
|
273 | // SEND DATA | |
274 | status = rtems_message_queue_send( queue_id, &TM, messageSize); |
|
274 | status = rtems_message_queue_send( queue_id, &TM, messageSize); | |
275 | if (status != RTEMS_SUCCESSFUL) { |
|
275 | if (status != RTEMS_SUCCESSFUL) { | |
276 | PRINTF("in send_tm_lfr_tc_exe_not_implemented *** ERR\n") |
|
276 | PRINTF("in send_tm_lfr_tc_exe_not_implemented *** ERR\n") | |
277 | } |
|
277 | } | |
278 |
|
278 | |||
279 | // UPDATE HK FIELDS |
|
279 | // UPDATE HK FIELDS | |
280 | update_last_TC_rej( TC, TM.time ); |
|
280 | update_last_TC_rej( TC, TM.time ); | |
281 |
|
281 | |||
282 | return status; |
|
282 | return status; | |
283 | } |
|
283 | } | |
284 |
|
284 | |||
285 | int send_tm_lfr_tc_exe_error( ccsdsTelecommandPacket_t *TC, rtems_id queue_id ) |
|
285 | int send_tm_lfr_tc_exe_error( ccsdsTelecommandPacket_t *TC, rtems_id queue_id ) | |
286 | { |
|
286 | { | |
287 | /** This function sends a TM_LFR_TC_EXE_ERROR packet in the dedicated RTEMS message queue. |
|
287 | /** This function sends a TM_LFR_TC_EXE_ERROR packet in the dedicated RTEMS message queue. | |
288 | * |
|
288 | * | |
289 | * @param TC points to the TeleCommand packet that is being processed |
|
289 | * @param TC points to the TeleCommand packet that is being processed | |
290 | * @param queue_id is the id of the queue which handles TM |
|
290 | * @param queue_id is the id of the queue which handles TM | |
291 | * |
|
291 | * | |
292 | * @return RTEMS directive status code: |
|
292 | * @return RTEMS directive status code: | |
293 | * - RTEMS_SUCCESSFUL - message sent successfully |
|
293 | * - RTEMS_SUCCESSFUL - message sent successfully | |
294 | * - RTEMS_INVALID_ID - invalid queue id |
|
294 | * - RTEMS_INVALID_ID - invalid queue id | |
295 | * - RTEMS_INVALID_SIZE - invalid message size |
|
295 | * - RTEMS_INVALID_SIZE - invalid message size | |
296 | * - RTEMS_INVALID_ADDRESS - buffer is NULL |
|
296 | * - RTEMS_INVALID_ADDRESS - buffer is NULL | |
297 | * - RTEMS_UNSATISFIED - out of message buffers |
|
297 | * - RTEMS_UNSATISFIED - out of message buffers | |
298 | * - RTEMS_TOO_MANY - queue s limit has been reached |
|
298 | * - RTEMS_TOO_MANY - queue s limit has been reached | |
299 | * |
|
299 | * | |
300 | */ |
|
300 | */ | |
301 |
|
301 | |||
302 | rtems_status_code status; |
|
302 | rtems_status_code status; | |
303 | Packet_TM_LFR_TC_EXE_ERROR_t TM; |
|
303 | Packet_TM_LFR_TC_EXE_ERROR_t TM; | |
304 | unsigned char messageSize; |
|
304 | unsigned char messageSize; | |
305 |
|
305 | |||
306 | TM.targetLogicalAddress = CCSDS_DESTINATION_ID; |
|
306 | TM.targetLogicalAddress = CCSDS_DESTINATION_ID; | |
307 | TM.protocolIdentifier = CCSDS_PROTOCOLE_ID; |
|
307 | TM.protocolIdentifier = CCSDS_PROTOCOLE_ID; | |
308 | TM.reserved = DEFAULT_RESERVED; |
|
308 | TM.reserved = DEFAULT_RESERVED; | |
309 | TM.userApplication = CCSDS_USER_APP; |
|
309 | TM.userApplication = CCSDS_USER_APP; | |
310 | // PACKET HEADER |
|
310 | // PACKET HEADER | |
311 | TM.packetID[0] = (unsigned char) (APID_TM_TC_EXE >> SHIFT_1_BYTE); |
|
311 | TM.packetID[0] = (unsigned char) (APID_TM_TC_EXE >> SHIFT_1_BYTE); | |
312 | TM.packetID[1] = (unsigned char) (APID_TM_TC_EXE ); |
|
312 | TM.packetID[1] = (unsigned char) (APID_TM_TC_EXE ); | |
313 | increment_seq_counter_destination_id( TM.packetSequenceControl, TC->sourceID ); |
|
313 | increment_seq_counter_destination_id( TM.packetSequenceControl, TC->sourceID ); | |
314 | TM.packetLength[0] = (unsigned char) (PACKET_LENGTH_TC_EXE_ERROR >> SHIFT_1_BYTE); |
|
314 | TM.packetLength[0] = (unsigned char) (PACKET_LENGTH_TC_EXE_ERROR >> SHIFT_1_BYTE); | |
315 | TM.packetLength[1] = (unsigned char) (PACKET_LENGTH_TC_EXE_ERROR ); |
|
315 | TM.packetLength[1] = (unsigned char) (PACKET_LENGTH_TC_EXE_ERROR ); | |
316 | // DATA FIELD HEADER |
|
316 | // DATA FIELD HEADER | |
317 | TM.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2; |
|
317 | TM.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2; | |
318 | TM.serviceType = TM_TYPE_TC_EXE; |
|
318 | TM.serviceType = TM_TYPE_TC_EXE; | |
319 | TM.serviceSubType = TM_SUBTYPE_EXE_NOK; |
|
319 | TM.serviceSubType = TM_SUBTYPE_EXE_NOK; | |
320 | TM.destinationID = TC->sourceID; // default destination id |
|
320 | TM.destinationID = TC->sourceID; // default destination id | |
321 | TM.time[BYTE_0] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_3_BYTES); |
|
321 | TM.time[BYTE_0] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_3_BYTES); | |
322 | TM.time[BYTE_1] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_2_BYTES); |
|
322 | TM.time[BYTE_1] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_2_BYTES); | |
323 | TM.time[BYTE_2] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_1_BYTE); |
|
323 | TM.time[BYTE_2] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_1_BYTE); | |
324 | TM.time[BYTE_3] = (unsigned char) (time_management_regs->coarse_time); |
|
324 | TM.time[BYTE_3] = (unsigned char) (time_management_regs->coarse_time); | |
325 | TM.time[BYTE_4] = (unsigned char) (time_management_regs->fine_time >> SHIFT_1_BYTE); |
|
325 | TM.time[BYTE_4] = (unsigned char) (time_management_regs->fine_time >> SHIFT_1_BYTE); | |
326 | TM.time[BYTE_5] = (unsigned char) (time_management_regs->fine_time); |
|
326 | TM.time[BYTE_5] = (unsigned char) (time_management_regs->fine_time); | |
327 | // |
|
327 | // | |
328 | TM.tc_failure_code[0] = (char) (FAIL_DETECTED >> SHIFT_1_BYTE); |
|
328 | TM.tc_failure_code[0] = (char) (FAIL_DETECTED >> SHIFT_1_BYTE); | |
329 | TM.tc_failure_code[1] = (char) (FAIL_DETECTED ); |
|
329 | TM.tc_failure_code[1] = (char) (FAIL_DETECTED ); | |
330 | TM.telecommand_pkt_id[0] = TC->packetID[0]; |
|
330 | TM.telecommand_pkt_id[0] = TC->packetID[0]; | |
331 | TM.telecommand_pkt_id[1] = TC->packetID[1]; |
|
331 | TM.telecommand_pkt_id[1] = TC->packetID[1]; | |
332 | TM.pkt_seq_control[0] = TC->packetSequenceControl[0]; |
|
332 | TM.pkt_seq_control[0] = TC->packetSequenceControl[0]; | |
333 | TM.pkt_seq_control[1] = TC->packetSequenceControl[1]; |
|
333 | TM.pkt_seq_control[1] = TC->packetSequenceControl[1]; | |
334 | TM.tc_service = TC->serviceType; // type of the rejected TC |
|
334 | TM.tc_service = TC->serviceType; // type of the rejected TC | |
335 | TM.tc_subtype = TC->serviceSubType; // subtype of the rejected TC |
|
335 | TM.tc_subtype = TC->serviceSubType; // subtype of the rejected TC | |
336 |
|
336 | |||
337 | messageSize = PACKET_LENGTH_TC_EXE_ERROR + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES; |
|
337 | messageSize = PACKET_LENGTH_TC_EXE_ERROR + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES; | |
338 |
|
338 | |||
339 | // SEND DATA |
|
339 | // SEND DATA | |
340 | status = rtems_message_queue_send( queue_id, &TM, messageSize); |
|
340 | status = rtems_message_queue_send( queue_id, &TM, messageSize); | |
341 | if (status != RTEMS_SUCCESSFUL) { |
|
341 | if (status != RTEMS_SUCCESSFUL) { | |
342 | PRINTF("in send_tm_lfr_tc_exe_error *** ERR\n") |
|
342 | PRINTF("in send_tm_lfr_tc_exe_error *** ERR\n") | |
343 | } |
|
343 | } | |
344 |
|
344 | |||
345 | // UPDATE HK FIELDS |
|
345 | // UPDATE HK FIELDS | |
346 | update_last_TC_rej( TC, TM.time ); |
|
346 | update_last_TC_rej( TC, TM.time ); | |
347 |
|
347 | |||
348 | return status; |
|
348 | return status; | |
349 | } |
|
349 | } | |
350 |
|
350 | |||
351 | int send_tm_lfr_tc_exe_corrupted(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, |
|
351 | int send_tm_lfr_tc_exe_corrupted(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, | |
352 | unsigned char *computed_CRC, unsigned char *currentTC_LEN_RCV, |
|
352 | unsigned char *computed_CRC, unsigned char *currentTC_LEN_RCV, | |
353 | unsigned char destinationID ) |
|
353 | unsigned char destinationID ) | |
354 | { |
|
354 | { | |
355 | /** This function sends a TM_LFR_TC_EXE_CORRUPTED packet in the dedicated RTEMS message queue. |
|
355 | /** This function sends a TM_LFR_TC_EXE_CORRUPTED packet in the dedicated RTEMS message queue. | |
356 | * |
|
356 | * | |
357 | * @param TC points to the TeleCommand packet that is being processed |
|
357 | * @param TC points to the TeleCommand packet that is being processed | |
358 | * @param queue_id is the id of the queue which handles TM |
|
358 | * @param queue_id is the id of the queue which handles TM | |
359 | * @param computed_CRC points to a buffer of two bytes containing the CRC computed during the parsing of the TeleCommand |
|
359 | * @param computed_CRC points to a buffer of two bytes containing the CRC computed during the parsing of the TeleCommand | |
360 | * @param currentTC_LEN_RCV points to a buffer of two bytes containing a packet size field computed on the received data |
|
360 | * @param currentTC_LEN_RCV points to a buffer of two bytes containing a packet size field computed on the received data | |
361 | * |
|
361 | * | |
362 | * @return RTEMS directive status code: |
|
362 | * @return RTEMS directive status code: | |
363 | * - RTEMS_SUCCESSFUL - message sent successfully |
|
363 | * - RTEMS_SUCCESSFUL - message sent successfully | |
364 | * - RTEMS_INVALID_ID - invalid queue id |
|
364 | * - RTEMS_INVALID_ID - invalid queue id | |
365 | * - RTEMS_INVALID_SIZE - invalid message size |
|
365 | * - RTEMS_INVALID_SIZE - invalid message size | |
366 | * - RTEMS_INVALID_ADDRESS - buffer is NULL |
|
366 | * - RTEMS_INVALID_ADDRESS - buffer is NULL | |
367 | * - RTEMS_UNSATISFIED - out of message buffers |
|
367 | * - RTEMS_UNSATISFIED - out of message buffers | |
368 | * - RTEMS_TOO_MANY - queue s limit has been reached |
|
368 | * - RTEMS_TOO_MANY - queue s limit has been reached | |
369 | * |
|
369 | * | |
370 | */ |
|
370 | */ | |
371 |
|
371 | |||
372 | rtems_status_code status; |
|
372 | rtems_status_code status; | |
373 | Packet_TM_LFR_TC_EXE_CORRUPTED_t TM; |
|
373 | Packet_TM_LFR_TC_EXE_CORRUPTED_t TM; | |
374 | unsigned char messageSize; |
|
374 | unsigned char messageSize; | |
375 | unsigned int packetLength; |
|
375 | unsigned int packetLength; | |
376 | unsigned int estimatedPacketLength; |
|
376 | unsigned int estimatedPacketLength; | |
377 | unsigned char *packetDataField; |
|
377 | unsigned char *packetDataField; | |
378 |
|
378 | |||
379 | packetLength = (TC->packetLength[0] * CONST_256) + TC->packetLength[1]; // compute the packet length parameter written in the TC |
|
379 | packetLength = (TC->packetLength[0] * CONST_256) + TC->packetLength[1]; // compute the packet length parameter written in the TC | |
380 | estimatedPacketLength = (unsigned int) ((currentTC_LEN_RCV[0] * CONST_256) + currentTC_LEN_RCV[1]); |
|
380 | estimatedPacketLength = (unsigned int) ((currentTC_LEN_RCV[0] * CONST_256) + currentTC_LEN_RCV[1]); | |
381 | packetDataField = (unsigned char *) &TC->headerFlag_pusVersion_Ack; // get the beginning of the data field |
|
381 | packetDataField = (unsigned char *) &TC->headerFlag_pusVersion_Ack; // get the beginning of the data field | |
382 |
|
382 | |||
383 | TM.targetLogicalAddress = CCSDS_DESTINATION_ID; |
|
383 | TM.targetLogicalAddress = CCSDS_DESTINATION_ID; | |
384 | TM.protocolIdentifier = CCSDS_PROTOCOLE_ID; |
|
384 | TM.protocolIdentifier = CCSDS_PROTOCOLE_ID; | |
385 | TM.reserved = DEFAULT_RESERVED; |
|
385 | TM.reserved = DEFAULT_RESERVED; | |
386 | TM.userApplication = CCSDS_USER_APP; |
|
386 | TM.userApplication = CCSDS_USER_APP; | |
387 | // PACKET HEADER |
|
387 | // PACKET HEADER | |
388 | TM.packetID[0] = (unsigned char) (APID_TM_TC_EXE >> SHIFT_1_BYTE); |
|
388 | TM.packetID[0] = (unsigned char) (APID_TM_TC_EXE >> SHIFT_1_BYTE); | |
389 | TM.packetID[1] = (unsigned char) (APID_TM_TC_EXE ); |
|
389 | TM.packetID[1] = (unsigned char) (APID_TM_TC_EXE ); | |
390 | increment_seq_counter_destination_id( TM.packetSequenceControl, TC->sourceID ); |
|
390 | increment_seq_counter_destination_id( TM.packetSequenceControl, TC->sourceID ); | |
391 | TM.packetLength[0] = (unsigned char) (PACKET_LENGTH_TC_EXE_CORRUPTED >> SHIFT_1_BYTE); |
|
391 | TM.packetLength[0] = (unsigned char) (PACKET_LENGTH_TC_EXE_CORRUPTED >> SHIFT_1_BYTE); | |
392 | TM.packetLength[1] = (unsigned char) (PACKET_LENGTH_TC_EXE_CORRUPTED ); |
|
392 | TM.packetLength[1] = (unsigned char) (PACKET_LENGTH_TC_EXE_CORRUPTED ); | |
393 | // DATA FIELD HEADER |
|
393 | // DATA FIELD HEADER | |
394 | TM.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2; |
|
394 | TM.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2; | |
395 | TM.serviceType = TM_TYPE_TC_EXE; |
|
395 | TM.serviceType = TM_TYPE_TC_EXE; | |
396 | TM.serviceSubType = TM_SUBTYPE_EXE_NOK; |
|
396 | TM.serviceSubType = TM_SUBTYPE_EXE_NOK; | |
397 | TM.destinationID = destinationID; |
|
397 | TM.destinationID = destinationID; | |
398 | TM.time[BYTE_0] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_3_BYTES); |
|
398 | TM.time[BYTE_0] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_3_BYTES); | |
399 | TM.time[BYTE_1] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_2_BYTES); |
|
399 | TM.time[BYTE_1] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_2_BYTES); | |
400 | TM.time[BYTE_2] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_1_BYTE); |
|
400 | TM.time[BYTE_2] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_1_BYTE); | |
401 | TM.time[BYTE_3] = (unsigned char) (time_management_regs->coarse_time); |
|
401 | TM.time[BYTE_3] = (unsigned char) (time_management_regs->coarse_time); | |
402 | TM.time[BYTE_4] = (unsigned char) (time_management_regs->fine_time >> SHIFT_1_BYTE); |
|
402 | TM.time[BYTE_4] = (unsigned char) (time_management_regs->fine_time >> SHIFT_1_BYTE); | |
403 | TM.time[BYTE_5] = (unsigned char) (time_management_regs->fine_time); |
|
403 | TM.time[BYTE_5] = (unsigned char) (time_management_regs->fine_time); | |
404 | // |
|
404 | // | |
405 | TM.tc_failure_code[0] = (unsigned char) (CORRUPTED >> SHIFT_1_BYTE); |
|
405 | TM.tc_failure_code[0] = (unsigned char) (CORRUPTED >> SHIFT_1_BYTE); | |
406 | TM.tc_failure_code[1] = (unsigned char) (CORRUPTED ); |
|
406 | TM.tc_failure_code[1] = (unsigned char) (CORRUPTED ); | |
407 | TM.telecommand_pkt_id[0] = TC->packetID[0]; |
|
407 | TM.telecommand_pkt_id[0] = TC->packetID[0]; | |
408 | TM.telecommand_pkt_id[1] = TC->packetID[1]; |
|
408 | TM.telecommand_pkt_id[1] = TC->packetID[1]; | |
409 | TM.pkt_seq_control[0] = TC->packetSequenceControl[0]; |
|
409 | TM.pkt_seq_control[0] = TC->packetSequenceControl[0]; | |
410 | TM.pkt_seq_control[1] = TC->packetSequenceControl[1]; |
|
410 | TM.pkt_seq_control[1] = TC->packetSequenceControl[1]; | |
411 | TM.tc_service = TC->serviceType; // type of the rejected TC |
|
411 | TM.tc_service = TC->serviceType; // type of the rejected TC | |
412 | TM.tc_subtype = TC->serviceSubType; // subtype of the rejected TC |
|
412 | TM.tc_subtype = TC->serviceSubType; // subtype of the rejected TC | |
413 | TM.pkt_len_rcv_value[0] = TC->packetLength[0]; |
|
413 | TM.pkt_len_rcv_value[0] = TC->packetLength[0]; | |
414 | TM.pkt_len_rcv_value[1] = TC->packetLength[1]; |
|
414 | TM.pkt_len_rcv_value[1] = TC->packetLength[1]; | |
415 | TM.pkt_datafieldsize_cnt[0] = currentTC_LEN_RCV[0]; |
|
415 | TM.pkt_datafieldsize_cnt[0] = currentTC_LEN_RCV[0]; | |
416 | TM.pkt_datafieldsize_cnt[1] = currentTC_LEN_RCV[1]; |
|
416 | TM.pkt_datafieldsize_cnt[1] = currentTC_LEN_RCV[1]; | |
417 | // TM.rcv_crc[0] = packetDataField[ packetLength - 1 ]; |
|
|||
418 | // TM.rcv_crc[1] = packetDataField[ packetLength ]; |
|
|||
419 | TM.rcv_crc[0] = packetDataField[ estimatedPacketLength - 1 ]; |
|
417 | TM.rcv_crc[0] = packetDataField[ estimatedPacketLength - 1 ]; | |
420 | TM.rcv_crc[1] = packetDataField[ estimatedPacketLength ]; |
|
418 | TM.rcv_crc[1] = packetDataField[ estimatedPacketLength ]; | |
421 | TM.computed_crc[0] = computed_CRC[0]; |
|
419 | TM.computed_crc[0] = computed_CRC[0]; | |
422 | TM.computed_crc[1] = computed_CRC[1]; |
|
420 | TM.computed_crc[1] = computed_CRC[1]; | |
423 |
|
421 | |||
424 | messageSize = PACKET_LENGTH_TC_EXE_CORRUPTED + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES; |
|
422 | messageSize = PACKET_LENGTH_TC_EXE_CORRUPTED + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES; | |
425 |
|
423 | |||
426 | // SEND DATA |
|
424 | // SEND DATA | |
427 | status = rtems_message_queue_send( queue_id, &TM, messageSize); |
|
425 | status = rtems_message_queue_send( queue_id, &TM, messageSize); | |
428 | if (status != RTEMS_SUCCESSFUL) { |
|
426 | if (status != RTEMS_SUCCESSFUL) { | |
429 | PRINTF("in send_tm_lfr_tc_exe_error *** ERR\n") |
|
427 | PRINTF("in send_tm_lfr_tc_exe_error *** ERR\n") | |
430 | } |
|
428 | } | |
431 |
|
429 | |||
432 | // UPDATE HK FIELDS |
|
430 | // UPDATE HK FIELDS | |
433 | update_last_TC_rej( TC, TM.time ); |
|
431 | update_last_TC_rej( TC, TM.time ); | |
434 |
|
432 | |||
435 | return status; |
|
433 | return status; | |
436 | } |
|
434 | } | |
437 |
|
435 | |||
438 | void increment_seq_counter_destination_id( unsigned char *packet_sequence_control, unsigned char destination_id ) |
|
436 | void increment_seq_counter_destination_id( unsigned char *packet_sequence_control, unsigned char destination_id ) | |
439 | { |
|
437 | { | |
440 | /** This function increment the packet sequence control parameter of a TC, depending on its destination ID. |
|
438 | /** This function increment the packet sequence control parameter of a TC, depending on its destination ID. | |
441 | * |
|
439 | * | |
442 | * @param packet_sequence_control points to the packet sequence control which will be incremented |
|
440 | * @param packet_sequence_control points to the packet sequence control which will be incremented | |
443 | * @param destination_id is the destination ID of the TM, there is one counter by destination ID |
|
441 | * @param destination_id is the destination ID of the TM, there is one counter by destination ID | |
444 | * |
|
442 | * | |
445 | * If the destination ID is not known, a dedicated counter is incremented. |
|
443 | * If the destination ID is not known, a dedicated counter is incremented. | |
446 | * |
|
444 | * | |
447 | */ |
|
445 | */ | |
448 |
|
446 | |||
449 | unsigned short sequence_cnt; |
|
447 | unsigned short sequence_cnt; | |
450 | unsigned short segmentation_grouping_flag; |
|
448 | unsigned short segmentation_grouping_flag; | |
451 | unsigned short new_packet_sequence_control; |
|
449 | unsigned short new_packet_sequence_control; | |
452 | unsigned char i; |
|
450 | unsigned char i; | |
453 |
|
451 | |||
454 | switch (destination_id) |
|
452 | switch (destination_id) | |
455 | { |
|
453 | { | |
456 | case SID_TC_GROUND: |
|
454 | case SID_TC_GROUND: | |
457 | i = GROUND; |
|
455 | i = GROUND; | |
458 | break; |
|
456 | break; | |
459 | case SID_TC_MISSION_TIMELINE: |
|
457 | case SID_TC_MISSION_TIMELINE: | |
460 | i = MISSION_TIMELINE; |
|
458 | i = MISSION_TIMELINE; | |
461 | break; |
|
459 | break; | |
462 | case SID_TC_TC_SEQUENCES: |
|
460 | case SID_TC_TC_SEQUENCES: | |
463 | i = TC_SEQUENCES; |
|
461 | i = TC_SEQUENCES; | |
464 | break; |
|
462 | break; | |
465 | case SID_TC_RECOVERY_ACTION_CMD: |
|
463 | case SID_TC_RECOVERY_ACTION_CMD: | |
466 | i = RECOVERY_ACTION_CMD; |
|
464 | i = RECOVERY_ACTION_CMD; | |
467 | break; |
|
465 | break; | |
468 | case SID_TC_BACKUP_MISSION_TIMELINE: |
|
466 | case SID_TC_BACKUP_MISSION_TIMELINE: | |
469 | i = BACKUP_MISSION_TIMELINE; |
|
467 | i = BACKUP_MISSION_TIMELINE; | |
470 | break; |
|
468 | break; | |
471 | case SID_TC_DIRECT_CMD: |
|
469 | case SID_TC_DIRECT_CMD: | |
472 | i = DIRECT_CMD; |
|
470 | i = DIRECT_CMD; | |
473 | break; |
|
471 | break; | |
474 | case SID_TC_SPARE_GRD_SRC1: |
|
472 | case SID_TC_SPARE_GRD_SRC1: | |
475 | i = SPARE_GRD_SRC1; |
|
473 | i = SPARE_GRD_SRC1; | |
476 | break; |
|
474 | break; | |
477 | case SID_TC_SPARE_GRD_SRC2: |
|
475 | case SID_TC_SPARE_GRD_SRC2: | |
478 | i = SPARE_GRD_SRC2; |
|
476 | i = SPARE_GRD_SRC2; | |
479 | break; |
|
477 | break; | |
480 | case SID_TC_OBCP: |
|
478 | case SID_TC_OBCP: | |
481 | i = OBCP; |
|
479 | i = OBCP; | |
482 | break; |
|
480 | break; | |
483 | case SID_TC_SYSTEM_CONTROL: |
|
481 | case SID_TC_SYSTEM_CONTROL: | |
484 | i = SYSTEM_CONTROL; |
|
482 | i = SYSTEM_CONTROL; | |
485 | break; |
|
483 | break; | |
486 | case SID_TC_AOCS: |
|
484 | case SID_TC_AOCS: | |
487 | i = AOCS; |
|
485 | i = AOCS; | |
488 | break; |
|
486 | break; | |
489 | case SID_TC_RPW_INTERNAL: |
|
487 | case SID_TC_RPW_INTERNAL: | |
490 | i = RPW_INTERNAL; |
|
488 | i = RPW_INTERNAL; | |
491 | break; |
|
489 | break; | |
492 | default: |
|
490 | default: | |
493 | i = GROUND; |
|
491 | i = GROUND; | |
494 | break; |
|
492 | break; | |
495 | } |
|
493 | } | |
496 |
|
494 | |||
497 | segmentation_grouping_flag = TM_PACKET_SEQ_CTRL_STANDALONE << SHIFT_1_BYTE; |
|
495 | segmentation_grouping_flag = TM_PACKET_SEQ_CTRL_STANDALONE << SHIFT_1_BYTE; | |
498 | sequence_cnt = sequenceCounters_TC_EXE[ i ] & SEQ_CNT_MASK; |
|
496 | sequence_cnt = sequenceCounters_TC_EXE[ i ] & SEQ_CNT_MASK; | |
499 |
|
497 | |||
500 | new_packet_sequence_control = segmentation_grouping_flag | sequence_cnt ; |
|
498 | new_packet_sequence_control = segmentation_grouping_flag | sequence_cnt ; | |
501 |
|
499 | |||
502 | packet_sequence_control[0] = (unsigned char) (new_packet_sequence_control >> SHIFT_1_BYTE); |
|
500 | packet_sequence_control[0] = (unsigned char) (new_packet_sequence_control >> SHIFT_1_BYTE); | |
503 | packet_sequence_control[1] = (unsigned char) (new_packet_sequence_control ); |
|
501 | packet_sequence_control[1] = (unsigned char) (new_packet_sequence_control ); | |
504 |
|
502 | |||
505 | // increment the sequence counter |
|
503 | // increment the sequence counter | |
506 | if ( sequenceCounters_TC_EXE[ i ] < SEQ_CNT_MAX ) |
|
504 | if ( sequenceCounters_TC_EXE[ i ] < SEQ_CNT_MAX ) | |
507 | { |
|
505 | { | |
508 | sequenceCounters_TC_EXE[ i ] = sequenceCounters_TC_EXE[ i ] + 1; |
|
506 | sequenceCounters_TC_EXE[ i ] = sequenceCounters_TC_EXE[ i ] + 1; | |
509 | } |
|
507 | } | |
510 | else |
|
508 | else | |
511 | { |
|
509 | { | |
512 | sequenceCounters_TC_EXE[ i ] = 0; |
|
510 | sequenceCounters_TC_EXE[ i ] = 0; | |
513 | } |
|
511 | } | |
514 | } |
|
512 | } |
@@ -1,1344 +1,1342 | |||||
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]= {0}; |
|
15 | ring_node waveform_ring_f0[NB_RING_NODES_F0]= {0}; | |
16 | ring_node *current_ring_node_f0 = NULL; |
|
16 | ring_node *current_ring_node_f0 = NULL; | |
17 | ring_node *ring_node_to_send_swf_f0 = NULL; |
|
17 | ring_node *ring_node_to_send_swf_f0 = NULL; | |
18 | // F1 |
|
18 | // F1 | |
19 | ring_node waveform_ring_f1[NB_RING_NODES_F1] = {0}; |
|
19 | ring_node waveform_ring_f1[NB_RING_NODES_F1] = {0}; | |
20 | ring_node *current_ring_node_f1 = NULL; |
|
20 | ring_node *current_ring_node_f1 = NULL; | |
21 | ring_node *ring_node_to_send_swf_f1 = NULL; |
|
21 | ring_node *ring_node_to_send_swf_f1 = NULL; | |
22 | ring_node *ring_node_to_send_cwf_f1 = NULL; |
|
22 | ring_node *ring_node_to_send_cwf_f1 = NULL; | |
23 | // F2 |
|
23 | // F2 | |
24 | ring_node waveform_ring_f2[NB_RING_NODES_F2] = {0}; |
|
24 | ring_node waveform_ring_f2[NB_RING_NODES_F2] = {0}; | |
25 | ring_node *current_ring_node_f2 = NULL; |
|
25 | ring_node *current_ring_node_f2 = NULL; | |
26 | ring_node *ring_node_to_send_swf_f2 = NULL; |
|
26 | ring_node *ring_node_to_send_swf_f2 = NULL; | |
27 | ring_node *ring_node_to_send_cwf_f2 = NULL; |
|
27 | ring_node *ring_node_to_send_cwf_f2 = NULL; | |
28 | // F3 |
|
28 | // F3 | |
29 | ring_node waveform_ring_f3[NB_RING_NODES_F3] = {0}; |
|
29 | ring_node waveform_ring_f3[NB_RING_NODES_F3] = {0}; | |
30 | ring_node *current_ring_node_f3 = NULL; |
|
30 | ring_node *current_ring_node_f3 = NULL; | |
31 | ring_node *ring_node_to_send_cwf_f3 = NULL; |
|
31 | ring_node *ring_node_to_send_cwf_f3 = NULL; | |
32 | char wf_cont_f3_light[ (NB_SAMPLES_PER_SNAPSHOT) * NB_BYTES_CWF3_LIGHT_BLK ] = {0}; |
|
32 | char wf_cont_f3_light[ (NB_SAMPLES_PER_SNAPSHOT) * NB_BYTES_CWF3_LIGHT_BLK ] = {0}; | |
33 |
|
33 | |||
34 | bool extractSWF1 = false; |
|
34 | bool extractSWF1 = false; | |
35 | bool extractSWF2 = false; |
|
35 | bool extractSWF2 = false; | |
36 | bool swf0_ready_flag_f1 = false; |
|
36 | bool swf0_ready_flag_f1 = false; | |
37 | bool swf0_ready_flag_f2 = false; |
|
37 | bool swf0_ready_flag_f2 = false; | |
38 | bool swf1_ready = false; |
|
38 | bool swf1_ready = false; | |
39 | bool swf2_ready = false; |
|
39 | bool swf2_ready = false; | |
40 |
|
40 | |||
41 | int swf1_extracted[ (NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK) ] = {0}; |
|
41 | int swf1_extracted[ (NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK) ] = {0}; | |
42 | int swf2_extracted[ (NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK) ] = {0}; |
|
42 | int swf2_extracted[ (NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK) ] = {0}; | |
43 | ring_node ring_node_swf1_extracted = {0}; |
|
43 | ring_node ring_node_swf1_extracted = {0}; | |
44 | ring_node ring_node_swf2_extracted = {0}; |
|
44 | ring_node ring_node_swf2_extracted = {0}; | |
45 |
|
45 | |||
46 | typedef enum resynchro_state_t |
|
46 | typedef enum resynchro_state_t | |
47 | { |
|
47 | { | |
48 | MEASURE, |
|
48 | MEASURE, | |
49 | CORRECTION |
|
49 | CORRECTION | |
50 | } resynchro_state; |
|
50 | } resynchro_state; | |
51 |
|
51 | |||
52 | //********************* |
|
52 | //********************* | |
53 | // Interrupt SubRoutine |
|
53 | // Interrupt SubRoutine | |
54 |
|
54 | |||
55 | ring_node * getRingNodeToSendCWF( unsigned char frequencyChannel) |
|
55 | ring_node * getRingNodeToSendCWF( unsigned char frequencyChannel) | |
56 | { |
|
56 | { | |
57 | ring_node *node; |
|
57 | ring_node *node; | |
58 |
|
58 | |||
59 | node = NULL; |
|
59 | node = NULL; | |
60 | switch ( frequencyChannel ) { |
|
60 | switch ( frequencyChannel ) { | |
61 | case CHANNELF1: |
|
61 | case CHANNELF1: | |
62 | node = ring_node_to_send_cwf_f1; |
|
62 | node = ring_node_to_send_cwf_f1; | |
63 | break; |
|
63 | break; | |
64 | case CHANNELF2: |
|
64 | case CHANNELF2: | |
65 | node = ring_node_to_send_cwf_f2; |
|
65 | node = ring_node_to_send_cwf_f2; | |
66 | break; |
|
66 | break; | |
67 | case CHANNELF3: |
|
67 | case CHANNELF3: | |
68 | node = ring_node_to_send_cwf_f3; |
|
68 | node = ring_node_to_send_cwf_f3; | |
69 | break; |
|
69 | break; | |
70 | default: |
|
70 | default: | |
71 | break; |
|
71 | break; | |
72 | } |
|
72 | } | |
73 |
|
73 | |||
74 | return node; |
|
74 | return node; | |
75 | } |
|
75 | } | |
76 |
|
76 | |||
77 | ring_node * getRingNodeToSendSWF( unsigned char frequencyChannel) |
|
77 | ring_node * getRingNodeToSendSWF( unsigned char frequencyChannel) | |
78 | { |
|
78 | { | |
79 | ring_node *node; |
|
79 | ring_node *node; | |
80 |
|
80 | |||
81 | node = NULL; |
|
81 | node = NULL; | |
82 | switch ( frequencyChannel ) { |
|
82 | switch ( frequencyChannel ) { | |
83 | case CHANNELF0: |
|
83 | case CHANNELF0: | |
84 | node = ring_node_to_send_swf_f0; |
|
84 | node = ring_node_to_send_swf_f0; | |
85 | break; |
|
85 | break; | |
86 | case CHANNELF1: |
|
86 | case CHANNELF1: | |
87 | node = ring_node_to_send_swf_f1; |
|
87 | node = ring_node_to_send_swf_f1; | |
88 | break; |
|
88 | break; | |
89 | case CHANNELF2: |
|
89 | case CHANNELF2: | |
90 | node = ring_node_to_send_swf_f2; |
|
90 | node = ring_node_to_send_swf_f2; | |
91 | break; |
|
91 | break; | |
92 | default: |
|
92 | default: | |
93 | break; |
|
93 | break; | |
94 | } |
|
94 | } | |
95 |
|
95 | |||
96 | return node; |
|
96 | return node; | |
97 | } |
|
97 | } | |
98 |
|
98 | |||
99 | void reset_extractSWF( void ) |
|
99 | void reset_extractSWF( void ) | |
100 | { |
|
100 | { | |
101 | extractSWF1 = false; |
|
101 | extractSWF1 = false; | |
102 | extractSWF2 = false; |
|
102 | extractSWF2 = false; | |
103 | swf0_ready_flag_f1 = false; |
|
103 | swf0_ready_flag_f1 = false; | |
104 | swf0_ready_flag_f2 = false; |
|
104 | swf0_ready_flag_f2 = false; | |
105 | swf1_ready = false; |
|
105 | swf1_ready = false; | |
106 | swf2_ready = false; |
|
106 | swf2_ready = false; | |
107 | } |
|
107 | } | |
108 |
|
108 | |||
109 | inline void waveforms_isr_f3( void ) |
|
109 | inline void waveforms_isr_f3( void ) | |
110 | { |
|
110 | { | |
111 | rtems_status_code spare_status; |
|
111 | rtems_status_code spare_status; | |
112 |
|
112 | |||
113 | 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 |
|
113 | 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 | |
114 | || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) ) |
|
114 | || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) ) | |
115 | { // in modes other than STANDBY and BURST, send the CWF_F3 data |
|
115 | { // in modes other than STANDBY and BURST, send the CWF_F3 data | |
116 | //*** |
|
116 | //*** | |
117 | // F3 |
|
117 | // F3 | |
118 | if ( (waveform_picker_regs->status & BITS_WFP_STATUS_F3) != INIT_CHAR ) { // [1100 0000] check the f3 full bits |
|
118 | if ( (waveform_picker_regs->status & BITS_WFP_STATUS_F3) != INIT_CHAR ) { // [1100 0000] check the f3 full bits | |
119 | ring_node_to_send_cwf_f3 = current_ring_node_f3->previous; |
|
119 | ring_node_to_send_cwf_f3 = current_ring_node_f3->previous; | |
120 | current_ring_node_f3 = current_ring_node_f3->next; |
|
120 | current_ring_node_f3 = current_ring_node_f3->next; | |
121 | if ((waveform_picker_regs->status & BIT_WFP_BUF_F3_0) == BIT_WFP_BUF_F3_0){ // [0100 0000] f3 buffer 0 is full |
|
121 | if ((waveform_picker_regs->status & BIT_WFP_BUF_F3_0) == BIT_WFP_BUF_F3_0){ // [0100 0000] f3 buffer 0 is full | |
122 | ring_node_to_send_cwf_f3->coarseTime = waveform_picker_regs->f3_0_coarse_time; |
|
122 | ring_node_to_send_cwf_f3->coarseTime = waveform_picker_regs->f3_0_coarse_time; | |
123 | ring_node_to_send_cwf_f3->fineTime = waveform_picker_regs->f3_0_fine_time; |
|
123 | ring_node_to_send_cwf_f3->fineTime = waveform_picker_regs->f3_0_fine_time; | |
124 | waveform_picker_regs->addr_data_f3_0 = current_ring_node_f3->buffer_address; |
|
124 | waveform_picker_regs->addr_data_f3_0 = current_ring_node_f3->buffer_address; | |
125 | waveform_picker_regs->status = waveform_picker_regs->status & RST_WFP_F3_0; // [1000 1000 0100 0000] |
|
125 | waveform_picker_regs->status = waveform_picker_regs->status & RST_WFP_F3_0; // [1000 1000 0100 0000] | |
126 | } |
|
126 | } | |
127 | else if ((waveform_picker_regs->status & BIT_WFP_BUF_F3_1) == BIT_WFP_BUF_F3_1){ // [1000 0000] f3 buffer 1 is full |
|
127 | else if ((waveform_picker_regs->status & BIT_WFP_BUF_F3_1) == BIT_WFP_BUF_F3_1){ // [1000 0000] f3 buffer 1 is full | |
128 | ring_node_to_send_cwf_f3->coarseTime = waveform_picker_regs->f3_1_coarse_time; |
|
128 | ring_node_to_send_cwf_f3->coarseTime = waveform_picker_regs->f3_1_coarse_time; | |
129 | ring_node_to_send_cwf_f3->fineTime = waveform_picker_regs->f3_1_fine_time; |
|
129 | ring_node_to_send_cwf_f3->fineTime = waveform_picker_regs->f3_1_fine_time; | |
130 | waveform_picker_regs->addr_data_f3_1 = current_ring_node_f3->buffer_address; |
|
130 | waveform_picker_regs->addr_data_f3_1 = current_ring_node_f3->buffer_address; | |
131 | waveform_picker_regs->status = waveform_picker_regs->status & RST_WFP_F3_1; // [1000 1000 1000 0000] |
|
131 | waveform_picker_regs->status = waveform_picker_regs->status & RST_WFP_F3_1; // [1000 1000 1000 0000] | |
132 | } |
|
132 | } | |
133 | if (rtems_event_send( Task_id[TASKID_CWF3], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) { |
|
133 | if (rtems_event_send( Task_id[TASKID_CWF3], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) { | |
134 | spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ); |
|
134 | spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ); | |
135 | } |
|
135 | } | |
136 | } |
|
136 | } | |
137 | } |
|
137 | } | |
138 | } |
|
138 | } | |
139 |
|
139 | |||
140 | inline void waveforms_isr_burst( void ) |
|
140 | inline void waveforms_isr_burst( void ) | |
141 | { |
|
141 | { | |
142 | unsigned char status; |
|
142 | unsigned char status; | |
143 | rtems_status_code spare_status; |
|
143 | rtems_status_code spare_status; | |
144 |
|
144 | |||
145 | status = (waveform_picker_regs->status & BITS_WFP_STATUS_F2) >> SHIFT_WFP_STATUS_F2; // [0011 0000] get the status bits for f2 |
|
145 | status = (waveform_picker_regs->status & BITS_WFP_STATUS_F2) >> SHIFT_WFP_STATUS_F2; // [0011 0000] get the status bits for f2 | |
146 |
|
146 | |||
147 | switch(status) |
|
147 | switch(status) | |
148 | { |
|
148 | { | |
149 | case BIT_WFP_BUFFER_0: |
|
149 | case BIT_WFP_BUFFER_0: | |
150 | ring_node_to_send_cwf_f2 = current_ring_node_f2->previous; |
|
150 | ring_node_to_send_cwf_f2 = current_ring_node_f2->previous; | |
151 | ring_node_to_send_cwf_f2->sid = SID_BURST_CWF_F2; |
|
151 | ring_node_to_send_cwf_f2->sid = SID_BURST_CWF_F2; | |
152 | ring_node_to_send_cwf_f2->coarseTime = waveform_picker_regs->f2_0_coarse_time; |
|
152 | ring_node_to_send_cwf_f2->coarseTime = waveform_picker_regs->f2_0_coarse_time; | |
153 | ring_node_to_send_cwf_f2->fineTime = waveform_picker_regs->f2_0_fine_time; |
|
153 | ring_node_to_send_cwf_f2->fineTime = waveform_picker_regs->f2_0_fine_time; | |
154 | current_ring_node_f2 = current_ring_node_f2->next; |
|
154 | current_ring_node_f2 = current_ring_node_f2->next; | |
155 | waveform_picker_regs->addr_data_f2_0 = current_ring_node_f2->buffer_address; |
|
155 | waveform_picker_regs->addr_data_f2_0 = current_ring_node_f2->buffer_address; | |
156 | if (rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_BURST ) != RTEMS_SUCCESSFUL) { |
|
156 | if (rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_BURST ) != RTEMS_SUCCESSFUL) { | |
157 | spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ); |
|
157 | spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ); | |
158 | } |
|
158 | } | |
159 | waveform_picker_regs->status = waveform_picker_regs->status & RST_WFP_F2_0; // [0100 0100 0001 0000] |
|
159 | waveform_picker_regs->status = waveform_picker_regs->status & RST_WFP_F2_0; // [0100 0100 0001 0000] | |
160 | break; |
|
160 | break; | |
161 | case BIT_WFP_BUFFER_1: |
|
161 | case BIT_WFP_BUFFER_1: | |
162 | ring_node_to_send_cwf_f2 = current_ring_node_f2->previous; |
|
162 | ring_node_to_send_cwf_f2 = current_ring_node_f2->previous; | |
163 | ring_node_to_send_cwf_f2->sid = SID_BURST_CWF_F2; |
|
163 | ring_node_to_send_cwf_f2->sid = SID_BURST_CWF_F2; | |
164 | ring_node_to_send_cwf_f2->coarseTime = waveform_picker_regs->f2_1_coarse_time; |
|
164 | ring_node_to_send_cwf_f2->coarseTime = waveform_picker_regs->f2_1_coarse_time; | |
165 | ring_node_to_send_cwf_f2->fineTime = waveform_picker_regs->f2_1_fine_time; |
|
165 | ring_node_to_send_cwf_f2->fineTime = waveform_picker_regs->f2_1_fine_time; | |
166 | current_ring_node_f2 = current_ring_node_f2->next; |
|
166 | current_ring_node_f2 = current_ring_node_f2->next; | |
167 | waveform_picker_regs->addr_data_f2_1 = current_ring_node_f2->buffer_address; |
|
167 | waveform_picker_regs->addr_data_f2_1 = current_ring_node_f2->buffer_address; | |
168 | if (rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_BURST ) != RTEMS_SUCCESSFUL) { |
|
168 | if (rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_BURST ) != RTEMS_SUCCESSFUL) { | |
169 | spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ); |
|
169 | spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ); | |
170 | } |
|
170 | } | |
171 | waveform_picker_regs->status = waveform_picker_regs->status & RST_WFP_F2_1; // [0100 0100 0010 0000] |
|
171 | waveform_picker_regs->status = waveform_picker_regs->status & RST_WFP_F2_1; // [0100 0100 0010 0000] | |
172 | break; |
|
172 | break; | |
173 | default: |
|
173 | default: | |
174 | break; |
|
174 | break; | |
175 | } |
|
175 | } | |
176 | } |
|
176 | } | |
177 |
|
177 | |||
178 | inline void waveform_isr_normal_sbm1_sbm2( void ) |
|
178 | inline void waveform_isr_normal_sbm1_sbm2( void ) | |
179 | { |
|
179 | { | |
180 | rtems_status_code status; |
|
180 | rtems_status_code status; | |
181 |
|
181 | |||
182 | //*** |
|
182 | //*** | |
183 | // F0 |
|
183 | // F0 | |
184 | if ( (waveform_picker_regs->status & BITS_WFP_STATUS_F0) != INIT_CHAR ) // [0000 0011] check the f0 full bits |
|
184 | if ( (waveform_picker_regs->status & BITS_WFP_STATUS_F0) != INIT_CHAR ) // [0000 0011] check the f0 full bits | |
185 | { |
|
185 | { | |
186 | swf0_ready_flag_f1 = true; |
|
186 | swf0_ready_flag_f1 = true; | |
187 | swf0_ready_flag_f2 = true; |
|
187 | swf0_ready_flag_f2 = true; | |
188 | ring_node_to_send_swf_f0 = current_ring_node_f0->previous; |
|
188 | ring_node_to_send_swf_f0 = current_ring_node_f0->previous; | |
189 | current_ring_node_f0 = current_ring_node_f0->next; |
|
189 | current_ring_node_f0 = current_ring_node_f0->next; | |
190 | if ( (waveform_picker_regs->status & BIT_WFP_BUFFER_0) == BIT_WFP_BUFFER_0) |
|
190 | if ( (waveform_picker_regs->status & BIT_WFP_BUFFER_0) == BIT_WFP_BUFFER_0) | |
191 | { |
|
191 | { | |
192 |
|
192 | |||
193 | ring_node_to_send_swf_f0->coarseTime = waveform_picker_regs->f0_0_coarse_time; |
|
193 | ring_node_to_send_swf_f0->coarseTime = waveform_picker_regs->f0_0_coarse_time; | |
194 | ring_node_to_send_swf_f0->fineTime = waveform_picker_regs->f0_0_fine_time; |
|
194 | ring_node_to_send_swf_f0->fineTime = waveform_picker_regs->f0_0_fine_time; | |
195 | waveform_picker_regs->addr_data_f0_0 = current_ring_node_f0->buffer_address; |
|
195 | waveform_picker_regs->addr_data_f0_0 = current_ring_node_f0->buffer_address; | |
196 | waveform_picker_regs->status = waveform_picker_regs->status & RST_WFP_F0_0; // [0001 0001 0000 0001] |
|
196 | waveform_picker_regs->status = waveform_picker_regs->status & RST_WFP_F0_0; // [0001 0001 0000 0001] | |
197 | } |
|
197 | } | |
198 | else if ( (waveform_picker_regs->status & BIT_WFP_BUFFER_1) == BIT_WFP_BUFFER_1) |
|
198 | else if ( (waveform_picker_regs->status & BIT_WFP_BUFFER_1) == BIT_WFP_BUFFER_1) | |
199 | { |
|
199 | { | |
200 | ring_node_to_send_swf_f0->coarseTime = waveform_picker_regs->f0_1_coarse_time; |
|
200 | ring_node_to_send_swf_f0->coarseTime = waveform_picker_regs->f0_1_coarse_time; | |
201 | ring_node_to_send_swf_f0->fineTime = waveform_picker_regs->f0_1_fine_time; |
|
201 | ring_node_to_send_swf_f0->fineTime = waveform_picker_regs->f0_1_fine_time; | |
202 | waveform_picker_regs->addr_data_f0_1 = current_ring_node_f0->buffer_address; |
|
202 | waveform_picker_regs->addr_data_f0_1 = current_ring_node_f0->buffer_address; | |
203 | waveform_picker_regs->status = waveform_picker_regs->status & RST_WFP_F0_1; // [0001 0001 0000 0010] |
|
203 | waveform_picker_regs->status = waveform_picker_regs->status & RST_WFP_F0_1; // [0001 0001 0000 0010] | |
204 | } |
|
204 | } | |
205 | // send an event to the WFRM task for resynchro activities |
|
205 | // send an event to the WFRM task for resynchro activities | |
206 | status = rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_SWF_RESYNCH ); |
|
206 | status = rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_SWF_RESYNCH ); | |
207 | status = rtems_event_send( Task_id[TASKID_CALI], RTEMS_EVENT_CAL_SWEEP_WAKE ); |
|
207 | status = rtems_event_send( Task_id[TASKID_CALI], RTEMS_EVENT_CAL_SWEEP_WAKE ); | |
208 | } |
|
208 | } | |
209 |
|
209 | |||
210 | //*** |
|
210 | //*** | |
211 | // F1 |
|
211 | // F1 | |
212 | if ( (waveform_picker_regs->status & BITS_WFP_STATUS_F1) != INIT_CHAR ) { // [0000 1100] check the f1 full bits |
|
212 | if ( (waveform_picker_regs->status & BITS_WFP_STATUS_F1) != INIT_CHAR ) { // [0000 1100] check the f1 full bits | |
213 | // (1) change the receiving buffer for the waveform picker |
|
213 | // (1) change the receiving buffer for the waveform picker | |
214 | ring_node_to_send_cwf_f1 = current_ring_node_f1->previous; |
|
214 | ring_node_to_send_cwf_f1 = current_ring_node_f1->previous; | |
215 | current_ring_node_f1 = current_ring_node_f1->next; |
|
215 | current_ring_node_f1 = current_ring_node_f1->next; | |
216 | if ( (waveform_picker_regs->status & BIT_WFP_BUF_F1_0) == BIT_WFP_BUF_F1_0) |
|
216 | if ( (waveform_picker_regs->status & BIT_WFP_BUF_F1_0) == BIT_WFP_BUF_F1_0) | |
217 | { |
|
217 | { | |
218 | ring_node_to_send_cwf_f1->coarseTime = waveform_picker_regs->f1_0_coarse_time; |
|
218 | ring_node_to_send_cwf_f1->coarseTime = waveform_picker_regs->f1_0_coarse_time; | |
219 | ring_node_to_send_cwf_f1->fineTime = waveform_picker_regs->f1_0_fine_time; |
|
219 | ring_node_to_send_cwf_f1->fineTime = waveform_picker_regs->f1_0_fine_time; | |
220 | waveform_picker_regs->addr_data_f1_0 = current_ring_node_f1->buffer_address; |
|
220 | waveform_picker_regs->addr_data_f1_0 = current_ring_node_f1->buffer_address; | |
221 | waveform_picker_regs->status = waveform_picker_regs->status & RST_WFP_F1_0; // [0010 0010 0000 0100] f1 bits = 0 |
|
221 | waveform_picker_regs->status = waveform_picker_regs->status & RST_WFP_F1_0; // [0010 0010 0000 0100] f1 bits = 0 | |
222 | } |
|
222 | } | |
223 | else if ( (waveform_picker_regs->status & BIT_WFP_BUF_F1_1) == BIT_WFP_BUF_F1_1) |
|
223 | else if ( (waveform_picker_regs->status & BIT_WFP_BUF_F1_1) == BIT_WFP_BUF_F1_1) | |
224 | { |
|
224 | { | |
225 | ring_node_to_send_cwf_f1->coarseTime = waveform_picker_regs->f1_1_coarse_time; |
|
225 | ring_node_to_send_cwf_f1->coarseTime = waveform_picker_regs->f1_1_coarse_time; | |
226 | ring_node_to_send_cwf_f1->fineTime = waveform_picker_regs->f1_1_fine_time; |
|
226 | ring_node_to_send_cwf_f1->fineTime = waveform_picker_regs->f1_1_fine_time; | |
227 | waveform_picker_regs->addr_data_f1_1 = current_ring_node_f1->buffer_address; |
|
227 | waveform_picker_regs->addr_data_f1_1 = current_ring_node_f1->buffer_address; | |
228 | waveform_picker_regs->status = waveform_picker_regs->status & RST_WFP_F1_1; // [0010 0010 0000 1000] f1 bits = 0 |
|
228 | waveform_picker_regs->status = waveform_picker_regs->status & RST_WFP_F1_1; // [0010 0010 0000 1000] f1 bits = 0 | |
229 | } |
|
229 | } | |
230 | // (2) send an event for the the CWF1 task for transmission (and snapshot extraction if needed) |
|
230 | // (2) send an event for the the CWF1 task for transmission (and snapshot extraction if needed) | |
231 | status = rtems_event_send( Task_id[TASKID_CWF1], RTEMS_EVENT_MODE_NORM_S1_S2 ); |
|
231 | status = rtems_event_send( Task_id[TASKID_CWF1], RTEMS_EVENT_MODE_NORM_S1_S2 ); | |
232 | } |
|
232 | } | |
233 |
|
233 | |||
234 | //*** |
|
234 | //*** | |
235 | // F2 |
|
235 | // F2 | |
236 | if ( (waveform_picker_regs->status & BITS_WFP_STATUS_F2) != INIT_CHAR ) { // [0011 0000] check the f2 full bit |
|
236 | if ( (waveform_picker_regs->status & BITS_WFP_STATUS_F2) != INIT_CHAR ) { // [0011 0000] check the f2 full bit | |
237 | // (1) change the receiving buffer for the waveform picker |
|
237 | // (1) change the receiving buffer for the waveform picker | |
238 | ring_node_to_send_cwf_f2 = current_ring_node_f2->previous; |
|
238 | ring_node_to_send_cwf_f2 = current_ring_node_f2->previous; | |
239 | ring_node_to_send_cwf_f2->sid = SID_SBM2_CWF_F2; |
|
239 | ring_node_to_send_cwf_f2->sid = SID_SBM2_CWF_F2; | |
240 | current_ring_node_f2 = current_ring_node_f2->next; |
|
240 | current_ring_node_f2 = current_ring_node_f2->next; | |
241 | if ( (waveform_picker_regs->status & BIT_WFP_BUF_F2_0) == BIT_WFP_BUF_F2_0) |
|
241 | if ( (waveform_picker_regs->status & BIT_WFP_BUF_F2_0) == BIT_WFP_BUF_F2_0) | |
242 | { |
|
242 | { | |
243 | ring_node_to_send_cwf_f2->coarseTime = waveform_picker_regs->f2_0_coarse_time; |
|
243 | ring_node_to_send_cwf_f2->coarseTime = waveform_picker_regs->f2_0_coarse_time; | |
244 | ring_node_to_send_cwf_f2->fineTime = waveform_picker_regs->f2_0_fine_time; |
|
244 | ring_node_to_send_cwf_f2->fineTime = waveform_picker_regs->f2_0_fine_time; | |
245 | waveform_picker_regs->addr_data_f2_0 = current_ring_node_f2->buffer_address; |
|
245 | waveform_picker_regs->addr_data_f2_0 = current_ring_node_f2->buffer_address; | |
246 | waveform_picker_regs->status = waveform_picker_regs->status & RST_WFP_F2_0; // [0100 0100 0001 0000] |
|
246 | waveform_picker_regs->status = waveform_picker_regs->status & RST_WFP_F2_0; // [0100 0100 0001 0000] | |
247 | } |
|
247 | } | |
248 | else if ( (waveform_picker_regs->status & BIT_WFP_BUF_F2_1) == BIT_WFP_BUF_F2_1) |
|
248 | else if ( (waveform_picker_regs->status & BIT_WFP_BUF_F2_1) == BIT_WFP_BUF_F2_1) | |
249 | { |
|
249 | { | |
250 | ring_node_to_send_cwf_f2->coarseTime = waveform_picker_regs->f2_1_coarse_time; |
|
250 | ring_node_to_send_cwf_f2->coarseTime = waveform_picker_regs->f2_1_coarse_time; | |
251 | ring_node_to_send_cwf_f2->fineTime = waveform_picker_regs->f2_1_fine_time; |
|
251 | ring_node_to_send_cwf_f2->fineTime = waveform_picker_regs->f2_1_fine_time; | |
252 | waveform_picker_regs->addr_data_f2_1 = current_ring_node_f2->buffer_address; |
|
252 | waveform_picker_regs->addr_data_f2_1 = current_ring_node_f2->buffer_address; | |
253 | waveform_picker_regs->status = waveform_picker_regs->status & RST_WFP_F2_1; // [0100 0100 0010 0000] |
|
253 | waveform_picker_regs->status = waveform_picker_regs->status & RST_WFP_F2_1; // [0100 0100 0010 0000] | |
254 | } |
|
254 | } | |
255 | // (2) send an event for the waveforms transmission |
|
255 | // (2) send an event for the waveforms transmission | |
256 | status = rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_NORM_S1_S2 ); |
|
256 | status = rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_NORM_S1_S2 ); | |
257 | } |
|
257 | } | |
258 | } |
|
258 | } | |
259 |
|
259 | |||
260 | rtems_isr waveforms_isr( rtems_vector_number vector ) |
|
260 | rtems_isr waveforms_isr( rtems_vector_number vector ) | |
261 | { |
|
261 | { | |
262 | /** This is the interrupt sub routine called by the waveform picker core. |
|
262 | /** This is the interrupt sub routine called by the waveform picker core. | |
263 | * |
|
263 | * | |
264 | * This ISR launch different actions depending mainly on two pieces of information: |
|
264 | * This ISR launch different actions depending mainly on two pieces of information: | |
265 | * 1. the values read in the registers of the waveform picker. |
|
265 | * 1. the values read in the registers of the waveform picker. | |
266 | * 2. the current LFR mode. |
|
266 | * 2. the current LFR mode. | |
267 | * |
|
267 | * | |
268 | */ |
|
268 | */ | |
269 |
|
269 | |||
270 | // STATUS |
|
270 | // STATUS | |
271 | // new error error buffer full |
|
271 | // new error error buffer full | |
272 | // 15 14 13 12 11 10 9 8 |
|
272 | // 15 14 13 12 11 10 9 8 | |
273 | // f3 f2 f1 f0 f3 f2 f1 f0 |
|
273 | // f3 f2 f1 f0 f3 f2 f1 f0 | |
274 | // |
|
274 | // | |
275 | // ready buffer |
|
275 | // ready buffer | |
276 | // 7 6 5 4 3 2 1 0 |
|
276 | // 7 6 5 4 3 2 1 0 | |
277 | // f3_1 f3_0 f2_1 f2_0 f1_1 f1_0 f0_1 f0_0 |
|
277 | // f3_1 f3_0 f2_1 f2_0 f1_1 f1_0 f0_1 f0_0 | |
278 |
|
278 | |||
279 | rtems_status_code spare_status; |
|
279 | rtems_status_code spare_status; | |
280 |
|
280 | |||
281 | waveforms_isr_f3(); |
|
281 | waveforms_isr_f3(); | |
282 |
|
282 | |||
283 | //************************************************* |
|
283 | //************************************************* | |
284 | // copy the status bits in the housekeeping packets |
|
284 | // copy the status bits in the housekeeping packets | |
285 | housekeeping_packet.hk_lfr_vhdl_iir_cal = |
|
285 | housekeeping_packet.hk_lfr_vhdl_iir_cal = | |
286 | (unsigned char) ((waveform_picker_regs->status & BYTE0_MASK) >> SHIFT_1_BYTE); |
|
286 | (unsigned char) ((waveform_picker_regs->status & BYTE0_MASK) >> SHIFT_1_BYTE); | |
287 |
|
287 | |||
288 | if ( (waveform_picker_regs->status & BYTE0_MASK) != INIT_CHAR) // [1111 1111 0000 0000] check the error bits |
|
288 | if ( (waveform_picker_regs->status & BYTE0_MASK) != INIT_CHAR) // [1111 1111 0000 0000] check the error bits | |
289 | { |
|
289 | { | |
290 | spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_10 ); |
|
290 | spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_10 ); | |
291 | } |
|
291 | } | |
292 |
|
292 | |||
293 | switch(lfrCurrentMode) |
|
293 | switch(lfrCurrentMode) | |
294 | { |
|
294 | { | |
295 | //******** |
|
295 | //******** | |
296 | // STANDBY |
|
296 | // STANDBY | |
297 | case LFR_MODE_STANDBY: |
|
297 | case LFR_MODE_STANDBY: | |
298 | break; |
|
298 | break; | |
299 | //************************** |
|
299 | //************************** | |
300 | // LFR NORMAL, SBM1 and SBM2 |
|
300 | // LFR NORMAL, SBM1 and SBM2 | |
301 | case LFR_MODE_NORMAL: |
|
301 | case LFR_MODE_NORMAL: | |
302 | case LFR_MODE_SBM1: |
|
302 | case LFR_MODE_SBM1: | |
303 | case LFR_MODE_SBM2: |
|
303 | case LFR_MODE_SBM2: | |
304 | waveform_isr_normal_sbm1_sbm2(); |
|
304 | waveform_isr_normal_sbm1_sbm2(); | |
305 | break; |
|
305 | break; | |
306 | //****** |
|
306 | //****** | |
307 | // BURST |
|
307 | // BURST | |
308 | case LFR_MODE_BURST: |
|
308 | case LFR_MODE_BURST: | |
309 | waveforms_isr_burst(); |
|
309 | waveforms_isr_burst(); | |
310 | break; |
|
310 | break; | |
311 | //******** |
|
311 | //******** | |
312 | // DEFAULT |
|
312 | // DEFAULT | |
313 | default: |
|
313 | default: | |
314 | break; |
|
314 | break; | |
315 | } |
|
315 | } | |
316 | } |
|
316 | } | |
317 |
|
317 | |||
318 | //************ |
|
318 | //************ | |
319 | // RTEMS TASKS |
|
319 | // RTEMS TASKS | |
320 |
|
320 | |||
321 | rtems_task wfrm_task(rtems_task_argument argument) //used with the waveform picker VHDL IP |
|
321 | rtems_task wfrm_task(rtems_task_argument argument) //used with the waveform picker VHDL IP | |
322 | { |
|
322 | { | |
323 | /** This RTEMS task is dedicated to the transmission of snapshots of the NORMAL mode. |
|
323 | /** This RTEMS task is dedicated to the transmission of snapshots of the NORMAL mode. | |
324 | * |
|
324 | * | |
325 | * @param unused is the starting argument of the RTEMS task |
|
325 | * @param unused is the starting argument of the RTEMS task | |
326 | * |
|
326 | * | |
327 | * The following data packets are sent by this task: |
|
327 | * The following data packets are sent by this task: | |
328 | * - TM_LFR_SCIENCE_NORMAL_SWF_F0 |
|
328 | * - TM_LFR_SCIENCE_NORMAL_SWF_F0 | |
329 | * - TM_LFR_SCIENCE_NORMAL_SWF_F1 |
|
329 | * - TM_LFR_SCIENCE_NORMAL_SWF_F1 | |
330 | * - TM_LFR_SCIENCE_NORMAL_SWF_F2 |
|
330 | * - TM_LFR_SCIENCE_NORMAL_SWF_F2 | |
331 | * |
|
331 | * | |
332 | */ |
|
332 | */ | |
333 |
|
333 | |||
334 | rtems_event_set event_out; |
|
334 | rtems_event_set event_out; | |
335 | rtems_id queue_id; |
|
335 | rtems_id queue_id; | |
336 | rtems_status_code status; |
|
336 | rtems_status_code status; | |
337 | ring_node *ring_node_swf1_extracted_ptr; |
|
337 | ring_node *ring_node_swf1_extracted_ptr; | |
338 | ring_node *ring_node_swf2_extracted_ptr; |
|
338 | ring_node *ring_node_swf2_extracted_ptr; | |
339 |
|
339 | |||
340 | event_out = EVENT_SETS_NONE_PENDING; |
|
340 | event_out = EVENT_SETS_NONE_PENDING; | |
341 | queue_id = RTEMS_ID_NONE; |
|
341 | queue_id = RTEMS_ID_NONE; | |
342 |
|
342 | |||
343 | ring_node_swf1_extracted_ptr = (ring_node *) &ring_node_swf1_extracted; |
|
343 | ring_node_swf1_extracted_ptr = (ring_node *) &ring_node_swf1_extracted; | |
344 | ring_node_swf2_extracted_ptr = (ring_node *) &ring_node_swf2_extracted; |
|
344 | ring_node_swf2_extracted_ptr = (ring_node *) &ring_node_swf2_extracted; | |
345 |
|
345 | |||
346 | status = get_message_queue_id_send( &queue_id ); |
|
346 | status = get_message_queue_id_send( &queue_id ); | |
347 | if (status != RTEMS_SUCCESSFUL) |
|
347 | if (status != RTEMS_SUCCESSFUL) | |
348 | { |
|
348 | { | |
349 | PRINTF1("in WFRM *** ERR get_message_queue_id_send %d\n", status); |
|
349 | PRINTF1("in WFRM *** ERR get_message_queue_id_send %d\n", status); | |
350 | } |
|
350 | } | |
351 |
|
351 | |||
352 | BOOT_PRINTF("in WFRM ***\n"); |
|
352 | BOOT_PRINTF("in WFRM ***\n"); | |
353 |
|
353 | |||
354 | while(1){ |
|
354 | while(1){ | |
355 | // wait for an RTEMS_EVENT |
|
355 | // wait for an RTEMS_EVENT | |
356 | rtems_event_receive(RTEMS_EVENT_MODE_NORMAL | RTEMS_EVENT_SWF_RESYNCH, |
|
356 | rtems_event_receive(RTEMS_EVENT_MODE_NORMAL | RTEMS_EVENT_SWF_RESYNCH, | |
357 | RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); |
|
357 | RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); | |
358 |
|
358 | |||
359 | if (event_out == RTEMS_EVENT_MODE_NORMAL) |
|
359 | if (event_out == RTEMS_EVENT_MODE_NORMAL) | |
360 | { |
|
360 | { | |
361 | DEBUG_PRINTF("WFRM received RTEMS_EVENT_MODE_SBM2\n"); |
|
361 | DEBUG_PRINTF("WFRM received RTEMS_EVENT_MODE_SBM2\n"); | |
362 | ring_node_to_send_swf_f0->sid = SID_NORM_SWF_F0; |
|
362 | ring_node_to_send_swf_f0->sid = SID_NORM_SWF_F0; | |
363 | ring_node_swf1_extracted_ptr->sid = SID_NORM_SWF_F1; |
|
363 | ring_node_swf1_extracted_ptr->sid = SID_NORM_SWF_F1; | |
364 | ring_node_swf2_extracted_ptr->sid = SID_NORM_SWF_F2; |
|
364 | ring_node_swf2_extracted_ptr->sid = SID_NORM_SWF_F2; | |
365 | status = rtems_message_queue_send( queue_id, &ring_node_to_send_swf_f0, sizeof( ring_node* ) ); |
|
365 | status = rtems_message_queue_send( queue_id, &ring_node_to_send_swf_f0, sizeof( ring_node* ) ); | |
366 | status = rtems_message_queue_send( queue_id, &ring_node_swf1_extracted_ptr, sizeof( ring_node* ) ); |
|
366 | status = rtems_message_queue_send( queue_id, &ring_node_swf1_extracted_ptr, sizeof( ring_node* ) ); | |
367 | status = rtems_message_queue_send( queue_id, &ring_node_swf2_extracted_ptr, sizeof( ring_node* ) ); |
|
367 | status = rtems_message_queue_send( queue_id, &ring_node_swf2_extracted_ptr, sizeof( ring_node* ) ); | |
368 | } |
|
368 | } | |
369 | if (event_out == RTEMS_EVENT_SWF_RESYNCH) |
|
369 | if (event_out == RTEMS_EVENT_SWF_RESYNCH) | |
370 | { |
|
370 | { | |
371 | snapshot_resynchronization( (unsigned char *) &ring_node_to_send_swf_f0->coarseTime ); |
|
371 | snapshot_resynchronization( (unsigned char *) &ring_node_to_send_swf_f0->coarseTime ); | |
372 | } |
|
372 | } | |
373 | } |
|
373 | } | |
374 | } |
|
374 | } | |
375 |
|
375 | |||
376 | rtems_task cwf3_task(rtems_task_argument argument) //used with the waveform picker VHDL IP |
|
376 | rtems_task cwf3_task(rtems_task_argument argument) //used with the waveform picker VHDL IP | |
377 | { |
|
377 | { | |
378 | /** This RTEMS task is dedicated to the transmission of continuous waveforms at f3. |
|
378 | /** This RTEMS task is dedicated to the transmission of continuous waveforms at f3. | |
379 | * |
|
379 | * | |
380 | * @param unused is the starting argument of the RTEMS task |
|
380 | * @param unused is the starting argument of the RTEMS task | |
381 | * |
|
381 | * | |
382 | * The following data packet is sent by this task: |
|
382 | * The following data packet is sent by this task: | |
383 | * - TM_LFR_SCIENCE_NORMAL_CWF_F3 |
|
383 | * - TM_LFR_SCIENCE_NORMAL_CWF_F3 | |
384 | * |
|
384 | * | |
385 | */ |
|
385 | */ | |
386 |
|
386 | |||
387 | rtems_event_set event_out; |
|
387 | rtems_event_set event_out; | |
388 | rtems_id queue_id; |
|
388 | rtems_id queue_id; | |
389 | rtems_status_code status; |
|
389 | rtems_status_code status; | |
390 | ring_node ring_node_cwf3_light; |
|
390 | ring_node ring_node_cwf3_light; | |
391 | ring_node *ring_node_to_send_cwf; |
|
391 | ring_node *ring_node_to_send_cwf; | |
392 |
|
392 | |||
393 | event_out = EVENT_SETS_NONE_PENDING; |
|
393 | event_out = EVENT_SETS_NONE_PENDING; | |
394 | queue_id = RTEMS_ID_NONE; |
|
394 | queue_id = RTEMS_ID_NONE; | |
395 |
|
395 | |||
396 | status = get_message_queue_id_send( &queue_id ); |
|
396 | status = get_message_queue_id_send( &queue_id ); | |
397 | if (status != RTEMS_SUCCESSFUL) |
|
397 | if (status != RTEMS_SUCCESSFUL) | |
398 | { |
|
398 | { | |
399 | PRINTF1("in CWF3 *** ERR get_message_queue_id_send %d\n", status) |
|
399 | PRINTF1("in CWF3 *** ERR get_message_queue_id_send %d\n", status) | |
400 | } |
|
400 | } | |
401 |
|
401 | |||
402 | ring_node_to_send_cwf_f3->sid = SID_NORM_CWF_LONG_F3; |
|
402 | ring_node_to_send_cwf_f3->sid = SID_NORM_CWF_LONG_F3; | |
403 |
|
403 | |||
404 | // init the ring_node_cwf3_light structure |
|
404 | // init the ring_node_cwf3_light structure | |
405 | ring_node_cwf3_light.buffer_address = (int) wf_cont_f3_light; |
|
405 | ring_node_cwf3_light.buffer_address = (int) wf_cont_f3_light; | |
406 | ring_node_cwf3_light.coarseTime = INIT_CHAR; |
|
406 | ring_node_cwf3_light.coarseTime = INIT_CHAR; | |
407 | ring_node_cwf3_light.fineTime = INIT_CHAR; |
|
407 | ring_node_cwf3_light.fineTime = INIT_CHAR; | |
408 | ring_node_cwf3_light.next = NULL; |
|
408 | ring_node_cwf3_light.next = NULL; | |
409 | ring_node_cwf3_light.previous = NULL; |
|
409 | ring_node_cwf3_light.previous = NULL; | |
410 | ring_node_cwf3_light.sid = SID_NORM_CWF_F3; |
|
410 | ring_node_cwf3_light.sid = SID_NORM_CWF_F3; | |
411 | ring_node_cwf3_light.status = INIT_CHAR; |
|
411 | ring_node_cwf3_light.status = INIT_CHAR; | |
412 |
|
412 | |||
413 | BOOT_PRINTF("in CWF3 ***\n"); |
|
413 | BOOT_PRINTF("in CWF3 ***\n"); | |
414 |
|
414 | |||
415 | while(1){ |
|
415 | while(1){ | |
416 | // wait for an RTEMS_EVENT |
|
416 | // wait for an RTEMS_EVENT | |
417 | rtems_event_receive( RTEMS_EVENT_0, |
|
417 | rtems_event_receive( RTEMS_EVENT_0, | |
418 | RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); |
|
418 | RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); | |
419 | if ( (lfrCurrentMode == LFR_MODE_NORMAL) |
|
419 | if ( (lfrCurrentMode == LFR_MODE_NORMAL) | |
420 | || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode==LFR_MODE_SBM2) ) |
|
420 | || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode==LFR_MODE_SBM2) ) | |
421 | { |
|
421 | { | |
422 | ring_node_to_send_cwf = getRingNodeToSendCWF( CHANNELF3 ); |
|
422 | ring_node_to_send_cwf = getRingNodeToSendCWF( CHANNELF3 ); | |
423 | if ( (parameter_dump_packet.sy_lfr_n_cwf_long_f3 & BIT_CWF_LONG_F3) == BIT_CWF_LONG_F3) |
|
423 | if ( (parameter_dump_packet.sy_lfr_n_cwf_long_f3 & BIT_CWF_LONG_F3) == BIT_CWF_LONG_F3) | |
424 | { |
|
424 | { | |
425 | PRINTF("send CWF_LONG_F3\n"); |
|
425 | PRINTF("send CWF_LONG_F3\n"); | |
426 | ring_node_to_send_cwf_f3->sid = SID_NORM_CWF_LONG_F3; |
|
426 | ring_node_to_send_cwf_f3->sid = SID_NORM_CWF_LONG_F3; | |
427 | status = rtems_message_queue_send( queue_id, &ring_node_to_send_cwf, sizeof( ring_node* ) ); |
|
427 | status = rtems_message_queue_send( queue_id, &ring_node_to_send_cwf, sizeof( ring_node* ) ); | |
428 | } |
|
428 | } | |
429 | else |
|
429 | else | |
430 | { |
|
430 | { | |
431 | PRINTF("send CWF_F3 (light)\n"); |
|
431 | PRINTF("send CWF_F3 (light)\n"); | |
432 | send_waveform_CWF3_light( ring_node_to_send_cwf, &ring_node_cwf3_light, queue_id ); |
|
432 | send_waveform_CWF3_light( ring_node_to_send_cwf, &ring_node_cwf3_light, queue_id ); | |
433 | } |
|
433 | } | |
434 |
|
434 | |||
435 | } |
|
435 | } | |
436 | else |
|
436 | else | |
437 | { |
|
437 | { | |
438 | PRINTF1("in CWF3 *** lfrCurrentMode is %d, no data will be sent\n", lfrCurrentMode) |
|
438 | PRINTF1("in CWF3 *** lfrCurrentMode is %d, no data will be sent\n", lfrCurrentMode) | |
439 | } |
|
439 | } | |
440 | } |
|
440 | } | |
441 | } |
|
441 | } | |
442 |
|
442 | |||
443 | rtems_task cwf2_task(rtems_task_argument argument) // ONLY USED IN BURST AND SBM2 |
|
443 | rtems_task cwf2_task(rtems_task_argument argument) // ONLY USED IN BURST AND SBM2 | |
444 | { |
|
444 | { | |
445 | /** This RTEMS task is dedicated to the transmission of continuous waveforms at f2. |
|
445 | /** This RTEMS task is dedicated to the transmission of continuous waveforms at f2. | |
446 | * |
|
446 | * | |
447 | * @param unused is the starting argument of the RTEMS task |
|
447 | * @param unused is the starting argument of the RTEMS task | |
448 | * |
|
448 | * | |
449 | * The following data packet is sent by this function: |
|
449 | * The following data packet is sent by this function: | |
450 | * - TM_LFR_SCIENCE_BURST_CWF_F2 |
|
450 | * - TM_LFR_SCIENCE_BURST_CWF_F2 | |
451 | * - TM_LFR_SCIENCE_SBM2_CWF_F2 |
|
451 | * - TM_LFR_SCIENCE_SBM2_CWF_F2 | |
452 | * |
|
452 | * | |
453 | */ |
|
453 | */ | |
454 |
|
454 | |||
455 | rtems_event_set event_out; |
|
455 | rtems_event_set event_out; | |
456 | rtems_id queue_id; |
|
456 | rtems_id queue_id; | |
457 | rtems_status_code status; |
|
457 | rtems_status_code status; | |
458 | ring_node *ring_node_to_send; |
|
458 | ring_node *ring_node_to_send; | |
459 | unsigned long long int acquisitionTimeF0_asLong; |
|
459 | unsigned long long int acquisitionTimeF0_asLong; | |
460 |
|
460 | |||
461 | event_out = EVENT_SETS_NONE_PENDING; |
|
461 | event_out = EVENT_SETS_NONE_PENDING; | |
462 | queue_id = RTEMS_ID_NONE; |
|
462 | queue_id = RTEMS_ID_NONE; | |
463 |
|
463 | |||
464 | acquisitionTimeF0_asLong = INIT_CHAR; |
|
464 | acquisitionTimeF0_asLong = INIT_CHAR; | |
465 |
|
465 | |||
466 | status = get_message_queue_id_send( &queue_id ); |
|
466 | status = get_message_queue_id_send( &queue_id ); | |
467 | if (status != RTEMS_SUCCESSFUL) |
|
467 | if (status != RTEMS_SUCCESSFUL) | |
468 | { |
|
468 | { | |
469 | PRINTF1("in CWF2 *** ERR get_message_queue_id_send %d\n", status) |
|
469 | PRINTF1("in CWF2 *** ERR get_message_queue_id_send %d\n", status) | |
470 | } |
|
470 | } | |
471 |
|
471 | |||
472 | BOOT_PRINTF("in CWF2 ***\n"); |
|
472 | BOOT_PRINTF("in CWF2 ***\n"); | |
473 |
|
473 | |||
474 | while(1){ |
|
474 | while(1){ | |
475 | // wait for an RTEMS_EVENT// send the snapshot when built |
|
475 | // wait for an RTEMS_EVENT// send the snapshot when built | |
476 | status = rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_SBM2 ); |
|
476 | status = rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_SBM2 ); | |
477 | rtems_event_receive( RTEMS_EVENT_MODE_NORM_S1_S2 | RTEMS_EVENT_MODE_BURST, |
|
477 | rtems_event_receive( RTEMS_EVENT_MODE_NORM_S1_S2 | RTEMS_EVENT_MODE_BURST, | |
478 | RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); |
|
478 | RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); | |
479 | ring_node_to_send = getRingNodeToSendCWF( CHANNELF2 ); |
|
479 | ring_node_to_send = getRingNodeToSendCWF( CHANNELF2 ); | |
480 | if (event_out == RTEMS_EVENT_MODE_BURST) |
|
480 | if (event_out == RTEMS_EVENT_MODE_BURST) | |
481 | { // data are sent whatever the transition time |
|
481 | { // data are sent whatever the transition time | |
482 | status = rtems_message_queue_send( queue_id, &ring_node_to_send, sizeof( ring_node* ) ); |
|
482 | status = rtems_message_queue_send( queue_id, &ring_node_to_send, sizeof( ring_node* ) ); | |
483 | } |
|
483 | } | |
484 | else if (event_out == RTEMS_EVENT_MODE_NORM_S1_S2) |
|
484 | else if (event_out == RTEMS_EVENT_MODE_NORM_S1_S2) | |
485 | { |
|
485 | { | |
486 | if ( lfrCurrentMode == LFR_MODE_SBM2 ) |
|
486 | if ( lfrCurrentMode == LFR_MODE_SBM2 ) | |
487 | { |
|
487 | { | |
488 | // data are sent depending on the transition time |
|
488 | // data are sent depending on the transition time | |
489 | if ( time_management_regs->coarse_time >= lastValidEnterModeTime) |
|
489 | if ( time_management_regs->coarse_time >= lastValidEnterModeTime) | |
490 | { |
|
490 | { | |
491 | status = rtems_message_queue_send( queue_id, &ring_node_to_send, sizeof( ring_node* ) ); |
|
491 | status = rtems_message_queue_send( queue_id, &ring_node_to_send, sizeof( ring_node* ) ); | |
492 | } |
|
492 | } | |
493 | } |
|
493 | } | |
494 | // launch snapshot extraction if needed |
|
494 | // launch snapshot extraction if needed | |
495 | if (extractSWF2 == true) |
|
495 | if (extractSWF2 == true) | |
496 | { |
|
496 | { | |
497 | ring_node_to_send_swf_f2 = ring_node_to_send_cwf_f2; |
|
497 | ring_node_to_send_swf_f2 = ring_node_to_send_cwf_f2; | |
498 | // extract the snapshot |
|
498 | // extract the snapshot | |
499 | build_snapshot_from_ring( ring_node_to_send_swf_f2, CHANNELF2, acquisitionTimeF0_asLong, |
|
499 | build_snapshot_from_ring( ring_node_to_send_swf_f2, CHANNELF2, acquisitionTimeF0_asLong, | |
500 | &ring_node_swf2_extracted, swf2_extracted ); |
|
500 | &ring_node_swf2_extracted, swf2_extracted ); | |
501 | extractSWF2 = false; |
|
501 | extractSWF2 = false; | |
502 | swf2_ready = true; // once the snapshot at f2 is ready the CWF1 task will send an event to WFRM |
|
502 | swf2_ready = true; // once the snapshot at f2 is ready the CWF1 task will send an event to WFRM | |
503 | } |
|
503 | } | |
504 | if (swf0_ready_flag_f2 == true) |
|
504 | if (swf0_ready_flag_f2 == true) | |
505 | { |
|
505 | { | |
506 | extractSWF2 = true; |
|
506 | extractSWF2 = true; | |
507 | // record the acquition time of the f0 snapshot to use to build the snapshot at f2 |
|
507 | // record the acquition time of the f0 snapshot to use to build the snapshot at f2 | |
508 | acquisitionTimeF0_asLong = get_acquisition_time( (unsigned char *) &ring_node_to_send_swf_f0->coarseTime ); |
|
508 | acquisitionTimeF0_asLong = get_acquisition_time( (unsigned char *) &ring_node_to_send_swf_f0->coarseTime ); | |
509 | swf0_ready_flag_f2 = false; |
|
509 | swf0_ready_flag_f2 = false; | |
510 | } |
|
510 | } | |
511 | } |
|
511 | } | |
512 | } |
|
512 | } | |
513 | } |
|
513 | } | |
514 |
|
514 | |||
515 | rtems_task cwf1_task(rtems_task_argument argument) // ONLY USED IN SBM1 |
|
515 | rtems_task cwf1_task(rtems_task_argument argument) // ONLY USED IN SBM1 | |
516 | { |
|
516 | { | |
517 | /** This RTEMS task is dedicated to the transmission of continuous waveforms at f1. |
|
517 | /** This RTEMS task is dedicated to the transmission of continuous waveforms at f1. | |
518 | * |
|
518 | * | |
519 | * @param unused is the starting argument of the RTEMS task |
|
519 | * @param unused is the starting argument of the RTEMS task | |
520 | * |
|
520 | * | |
521 | * The following data packet is sent by this function: |
|
521 | * The following data packet is sent by this function: | |
522 | * - TM_LFR_SCIENCE_SBM1_CWF_F1 |
|
522 | * - TM_LFR_SCIENCE_SBM1_CWF_F1 | |
523 | * |
|
523 | * | |
524 | */ |
|
524 | */ | |
525 |
|
525 | |||
526 | rtems_event_set event_out; |
|
526 | rtems_event_set event_out; | |
527 | rtems_id queue_id; |
|
527 | rtems_id queue_id; | |
528 | rtems_status_code status; |
|
528 | rtems_status_code status; | |
529 |
|
529 | |||
530 | ring_node *ring_node_to_send_cwf; |
|
530 | ring_node *ring_node_to_send_cwf; | |
531 |
|
531 | |||
532 | event_out = EVENT_SETS_NONE_PENDING; |
|
532 | event_out = EVENT_SETS_NONE_PENDING; | |
533 | queue_id = RTEMS_ID_NONE; |
|
533 | queue_id = RTEMS_ID_NONE; | |
534 |
|
534 | |||
535 | status = get_message_queue_id_send( &queue_id ); |
|
535 | status = get_message_queue_id_send( &queue_id ); | |
536 | if (status != RTEMS_SUCCESSFUL) |
|
536 | if (status != RTEMS_SUCCESSFUL) | |
537 | { |
|
537 | { | |
538 | PRINTF1("in CWF1 *** ERR get_message_queue_id_send %d\n", status) |
|
538 | PRINTF1("in CWF1 *** ERR get_message_queue_id_send %d\n", status) | |
539 | } |
|
539 | } | |
540 |
|
540 | |||
541 | BOOT_PRINTF("in CWF1 ***\n"); |
|
541 | BOOT_PRINTF("in CWF1 ***\n"); | |
542 |
|
542 | |||
543 | while(1){ |
|
543 | while(1){ | |
544 | // wait for an RTEMS_EVENT |
|
544 | // wait for an RTEMS_EVENT | |
545 | rtems_event_receive( RTEMS_EVENT_MODE_NORM_S1_S2, |
|
545 | rtems_event_receive( RTEMS_EVENT_MODE_NORM_S1_S2, | |
546 | RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); |
|
546 | RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); | |
547 | ring_node_to_send_cwf = getRingNodeToSendCWF( 1 ); |
|
547 | ring_node_to_send_cwf = getRingNodeToSendCWF( 1 ); | |
548 | ring_node_to_send_cwf_f1->sid = SID_SBM1_CWF_F1; |
|
548 | ring_node_to_send_cwf_f1->sid = SID_SBM1_CWF_F1; | |
549 | if (lfrCurrentMode == LFR_MODE_SBM1) |
|
549 | if (lfrCurrentMode == LFR_MODE_SBM1) | |
550 | { |
|
550 | { | |
551 | // data are sent depending on the transition time |
|
551 | // data are sent depending on the transition time | |
552 | if ( time_management_regs->coarse_time >= lastValidEnterModeTime ) |
|
552 | if ( time_management_regs->coarse_time >= lastValidEnterModeTime ) | |
553 | { |
|
553 | { | |
554 | status = rtems_message_queue_send( queue_id, &ring_node_to_send_cwf, sizeof( ring_node* ) ); |
|
554 | status = rtems_message_queue_send( queue_id, &ring_node_to_send_cwf, sizeof( ring_node* ) ); | |
555 | } |
|
555 | } | |
556 | } |
|
556 | } | |
557 | // launch snapshot extraction if needed |
|
557 | // launch snapshot extraction if needed | |
558 | if (extractSWF1 == true) |
|
558 | if (extractSWF1 == true) | |
559 | { |
|
559 | { | |
560 | ring_node_to_send_swf_f1 = ring_node_to_send_cwf; |
|
560 | ring_node_to_send_swf_f1 = ring_node_to_send_cwf; | |
561 | // launch the snapshot extraction |
|
561 | // launch the snapshot extraction | |
562 | status = rtems_event_send( Task_id[TASKID_SWBD], RTEMS_EVENT_MODE_NORM_S1_S2 ); |
|
562 | status = rtems_event_send( Task_id[TASKID_SWBD], RTEMS_EVENT_MODE_NORM_S1_S2 ); | |
563 | extractSWF1 = false; |
|
563 | extractSWF1 = false; | |
564 | } |
|
564 | } | |
565 | if (swf0_ready_flag_f1 == true) |
|
565 | if (swf0_ready_flag_f1 == true) | |
566 | { |
|
566 | { | |
567 | extractSWF1 = true; |
|
567 | extractSWF1 = true; | |
568 | swf0_ready_flag_f1 = false; // this step shall be executed only one time |
|
568 | swf0_ready_flag_f1 = false; // this step shall be executed only one time | |
569 | } |
|
569 | } | |
570 | if ((swf1_ready == true) && (swf2_ready == true)) // swf_f1 is ready after the extraction |
|
570 | if ((swf1_ready == true) && (swf2_ready == true)) // swf_f1 is ready after the extraction | |
571 | { |
|
571 | { | |
572 | status = rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_NORMAL ); |
|
572 | status = rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_NORMAL ); | |
573 | swf1_ready = false; |
|
573 | swf1_ready = false; | |
574 | swf2_ready = false; |
|
574 | swf2_ready = false; | |
575 | } |
|
575 | } | |
576 | } |
|
576 | } | |
577 | } |
|
577 | } | |
578 |
|
578 | |||
579 | rtems_task swbd_task(rtems_task_argument argument) |
|
579 | rtems_task swbd_task(rtems_task_argument argument) | |
580 | { |
|
580 | { | |
581 | /** This RTEMS task is dedicated to the building of snapshots from different continuous waveforms buffers. |
|
581 | /** This RTEMS task is dedicated to the building of snapshots from different continuous waveforms buffers. | |
582 | * |
|
582 | * | |
583 | * @param unused is the starting argument of the RTEMS task |
|
583 | * @param unused is the starting argument of the RTEMS task | |
584 | * |
|
584 | * | |
585 | */ |
|
585 | */ | |
586 |
|
586 | |||
587 | rtems_event_set event_out; |
|
587 | rtems_event_set event_out; | |
588 | unsigned long long int acquisitionTimeF0_asLong; |
|
588 | unsigned long long int acquisitionTimeF0_asLong; | |
589 |
|
589 | |||
590 | event_out = EVENT_SETS_NONE_PENDING; |
|
590 | event_out = EVENT_SETS_NONE_PENDING; | |
591 | acquisitionTimeF0_asLong = INIT_CHAR; |
|
591 | acquisitionTimeF0_asLong = INIT_CHAR; | |
592 |
|
592 | |||
593 | BOOT_PRINTF("in SWBD ***\n") |
|
593 | BOOT_PRINTF("in SWBD ***\n") | |
594 |
|
594 | |||
595 | while(1){ |
|
595 | while(1){ | |
596 | // wait for an RTEMS_EVENT |
|
596 | // wait for an RTEMS_EVENT | |
597 | rtems_event_receive( RTEMS_EVENT_MODE_NORM_S1_S2, |
|
597 | rtems_event_receive( RTEMS_EVENT_MODE_NORM_S1_S2, | |
598 | RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); |
|
598 | RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); | |
599 | if (event_out == RTEMS_EVENT_MODE_NORM_S1_S2) |
|
599 | if (event_out == RTEMS_EVENT_MODE_NORM_S1_S2) | |
600 | { |
|
600 | { | |
601 | acquisitionTimeF0_asLong = get_acquisition_time( (unsigned char *) &ring_node_to_send_swf_f0->coarseTime ); |
|
601 | acquisitionTimeF0_asLong = get_acquisition_time( (unsigned char *) &ring_node_to_send_swf_f0->coarseTime ); | |
602 | build_snapshot_from_ring( ring_node_to_send_swf_f1, CHANNELF1, acquisitionTimeF0_asLong, |
|
602 | build_snapshot_from_ring( ring_node_to_send_swf_f1, CHANNELF1, acquisitionTimeF0_asLong, | |
603 | &ring_node_swf1_extracted, swf1_extracted ); |
|
603 | &ring_node_swf1_extracted, swf1_extracted ); | |
604 | swf1_ready = true; // the snapshot has been extracted and is ready to be sent |
|
604 | swf1_ready = true; // the snapshot has been extracted and is ready to be sent | |
605 | } |
|
605 | } | |
606 | else |
|
606 | else | |
607 | { |
|
607 | { | |
608 | PRINTF1("in SWBD *** unexpected rtems event received %x\n", (int) event_out) |
|
608 | PRINTF1("in SWBD *** unexpected rtems event received %x\n", (int) event_out) | |
609 | } |
|
609 | } | |
610 | } |
|
610 | } | |
611 | } |
|
611 | } | |
612 |
|
612 | |||
613 | //****************** |
|
613 | //****************** | |
614 | // general functions |
|
614 | // general functions | |
615 |
|
615 | |||
616 | void WFP_init_rings( void ) |
|
616 | void WFP_init_rings( void ) | |
617 | { |
|
617 | { | |
618 | // F0 RING |
|
618 | // F0 RING | |
619 | init_ring( waveform_ring_f0, NB_RING_NODES_F0, wf_buffer_f0, WFRM_BUFFER ); |
|
619 | init_ring( waveform_ring_f0, NB_RING_NODES_F0, wf_buffer_f0, WFRM_BUFFER ); | |
620 | // F1 RING |
|
620 | // F1 RING | |
621 | init_ring( waveform_ring_f1, NB_RING_NODES_F1, wf_buffer_f1, WFRM_BUFFER ); |
|
621 | init_ring( waveform_ring_f1, NB_RING_NODES_F1, wf_buffer_f1, WFRM_BUFFER ); | |
622 | // F2 RING |
|
622 | // F2 RING | |
623 | init_ring( waveform_ring_f2, NB_RING_NODES_F2, wf_buffer_f2, WFRM_BUFFER ); |
|
623 | init_ring( waveform_ring_f2, NB_RING_NODES_F2, wf_buffer_f2, WFRM_BUFFER ); | |
624 | // F3 RING |
|
624 | // F3 RING | |
625 | init_ring( waveform_ring_f3, NB_RING_NODES_F3, wf_buffer_f3, WFRM_BUFFER ); |
|
625 | init_ring( waveform_ring_f3, NB_RING_NODES_F3, wf_buffer_f3, WFRM_BUFFER ); | |
626 |
|
626 | |||
627 | ring_node_swf1_extracted.buffer_address = (int) swf1_extracted; |
|
627 | ring_node_swf1_extracted.buffer_address = (int) swf1_extracted; | |
628 | ring_node_swf2_extracted.buffer_address = (int) swf2_extracted; |
|
628 | ring_node_swf2_extracted.buffer_address = (int) swf2_extracted; | |
629 |
|
629 | |||
630 | DEBUG_PRINTF1("waveform_ring_f0 @%x\n", (unsigned int) waveform_ring_f0) |
|
630 | DEBUG_PRINTF1("waveform_ring_f0 @%x\n", (unsigned int) waveform_ring_f0) | |
631 | DEBUG_PRINTF1("waveform_ring_f1 @%x\n", (unsigned int) waveform_ring_f1) |
|
631 | DEBUG_PRINTF1("waveform_ring_f1 @%x\n", (unsigned int) waveform_ring_f1) | |
632 | DEBUG_PRINTF1("waveform_ring_f2 @%x\n", (unsigned int) waveform_ring_f2) |
|
632 | DEBUG_PRINTF1("waveform_ring_f2 @%x\n", (unsigned int) waveform_ring_f2) | |
633 | DEBUG_PRINTF1("waveform_ring_f3 @%x\n", (unsigned int) waveform_ring_f3) |
|
633 | DEBUG_PRINTF1("waveform_ring_f3 @%x\n", (unsigned int) waveform_ring_f3) | |
634 | DEBUG_PRINTF1("wf_buffer_f0 @%x\n", (unsigned int) wf_buffer_f0) |
|
634 | DEBUG_PRINTF1("wf_buffer_f0 @%x\n", (unsigned int) wf_buffer_f0) | |
635 | DEBUG_PRINTF1("wf_buffer_f1 @%x\n", (unsigned int) wf_buffer_f1) |
|
635 | DEBUG_PRINTF1("wf_buffer_f1 @%x\n", (unsigned int) wf_buffer_f1) | |
636 | DEBUG_PRINTF1("wf_buffer_f2 @%x\n", (unsigned int) wf_buffer_f2) |
|
636 | DEBUG_PRINTF1("wf_buffer_f2 @%x\n", (unsigned int) wf_buffer_f2) | |
637 | DEBUG_PRINTF1("wf_buffer_f3 @%x\n", (unsigned int) wf_buffer_f3) |
|
637 | DEBUG_PRINTF1("wf_buffer_f3 @%x\n", (unsigned int) wf_buffer_f3) | |
638 |
|
638 | |||
639 | } |
|
639 | } | |
640 |
|
640 | |||
641 | void WFP_reset_current_ring_nodes( void ) |
|
641 | void WFP_reset_current_ring_nodes( void ) | |
642 | { |
|
642 | { | |
643 | current_ring_node_f0 = waveform_ring_f0[0].next; |
|
643 | current_ring_node_f0 = waveform_ring_f0[0].next; | |
644 | current_ring_node_f1 = waveform_ring_f1[0].next; |
|
644 | current_ring_node_f1 = waveform_ring_f1[0].next; | |
645 | current_ring_node_f2 = waveform_ring_f2[0].next; |
|
645 | current_ring_node_f2 = waveform_ring_f2[0].next; | |
646 | current_ring_node_f3 = waveform_ring_f3[0].next; |
|
646 | current_ring_node_f3 = waveform_ring_f3[0].next; | |
647 |
|
647 | |||
648 | ring_node_to_send_swf_f0 = waveform_ring_f0; |
|
648 | ring_node_to_send_swf_f0 = waveform_ring_f0; | |
649 | ring_node_to_send_swf_f1 = waveform_ring_f1; |
|
649 | ring_node_to_send_swf_f1 = waveform_ring_f1; | |
650 | ring_node_to_send_swf_f2 = waveform_ring_f2; |
|
650 | ring_node_to_send_swf_f2 = waveform_ring_f2; | |
651 |
|
651 | |||
652 | ring_node_to_send_cwf_f1 = waveform_ring_f1; |
|
652 | ring_node_to_send_cwf_f1 = waveform_ring_f1; | |
653 | ring_node_to_send_cwf_f2 = waveform_ring_f2; |
|
653 | ring_node_to_send_cwf_f2 = waveform_ring_f2; | |
654 | ring_node_to_send_cwf_f3 = waveform_ring_f3; |
|
654 | ring_node_to_send_cwf_f3 = waveform_ring_f3; | |
655 | } |
|
655 | } | |
656 |
|
656 | |||
657 | int send_waveform_CWF3_light( ring_node *ring_node_to_send, ring_node *ring_node_cwf3_light, rtems_id queue_id ) |
|
657 | int send_waveform_CWF3_light( ring_node *ring_node_to_send, ring_node *ring_node_cwf3_light, rtems_id queue_id ) | |
658 | { |
|
658 | { | |
659 | /** This function sends CWF_F3 CCSDS packets without the b1, b2 and b3 data. |
|
659 | /** This function sends CWF_F3 CCSDS packets without the b1, b2 and b3 data. | |
660 | * |
|
660 | * | |
661 | * @param waveform points to the buffer containing the data that will be send. |
|
661 | * @param waveform points to the buffer containing the data that will be send. | |
662 | * @param headerCWF points to a table of headers that have been prepared for the data transmission. |
|
662 | * @param headerCWF points to a table of headers that have been prepared for the data transmission. | |
663 | * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures |
|
663 | * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures | |
664 | * contain information to setup the transmission of the data packets. |
|
664 | * contain information to setup the transmission of the data packets. | |
665 | * |
|
665 | * | |
666 | * By default, CWF_F3 packet are send without the b1, b2 and b3 data. This function rebuilds a data buffer |
|
666 | * By default, CWF_F3 packet are send without the b1, b2 and b3 data. This function rebuilds a data buffer | |
667 | * from the incoming data and sends it in 7 packets, 6 containing 340 blocks and 1 one containing 8 blocks. |
|
667 | * from the incoming data and sends it in 7 packets, 6 containing 340 blocks and 1 one containing 8 blocks. | |
668 | * |
|
668 | * | |
669 | */ |
|
669 | */ | |
670 |
|
670 | |||
671 | unsigned int i; |
|
671 | unsigned int i; | |
672 | unsigned int j; |
|
672 | unsigned int j; | |
673 | int ret; |
|
673 | int ret; | |
674 | rtems_status_code status; |
|
674 | rtems_status_code status; | |
675 |
|
675 | |||
676 | char *sample; |
|
676 | char *sample; | |
677 | int *dataPtr; |
|
677 | int *dataPtr; | |
678 |
|
678 | |||
679 | ret = LFR_DEFAULT; |
|
679 | ret = LFR_DEFAULT; | |
680 |
|
680 | |||
681 | dataPtr = (int*) ring_node_to_send->buffer_address; |
|
681 | dataPtr = (int*) ring_node_to_send->buffer_address; | |
682 |
|
682 | |||
683 | ring_node_cwf3_light->coarseTime = ring_node_to_send->coarseTime; |
|
683 | ring_node_cwf3_light->coarseTime = ring_node_to_send->coarseTime; | |
684 | ring_node_cwf3_light->fineTime = ring_node_to_send->fineTime; |
|
684 | ring_node_cwf3_light->fineTime = ring_node_to_send->fineTime; | |
685 |
|
685 | |||
686 | //********************** |
|
686 | //********************** | |
687 | // BUILD CWF3_light DATA |
|
687 | // BUILD CWF3_light DATA | |
688 | for ( i=0; i< NB_SAMPLES_PER_SNAPSHOT; i++) |
|
688 | for ( i=0; i< NB_SAMPLES_PER_SNAPSHOT; i++) | |
689 | { |
|
689 | { | |
690 | sample = (char*) &dataPtr[ (i * NB_WORDS_SWF_BLK) ]; |
|
690 | sample = (char*) &dataPtr[ (i * NB_WORDS_SWF_BLK) ]; | |
691 | for (j=0; j < CWF_BLK_SIZE; j++) |
|
691 | for (j=0; j < CWF_BLK_SIZE; j++) | |
692 | { |
|
692 | { | |
693 | wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + j] = sample[ j ]; |
|
693 | wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + j] = sample[ j ]; | |
694 | } |
|
694 | } | |
695 | } |
|
695 | } | |
696 |
|
696 | |||
697 | // SEND PACKET |
|
697 | // SEND PACKET | |
698 | status = rtems_message_queue_send( queue_id, &ring_node_cwf3_light, sizeof( ring_node* ) ); |
|
698 | status = rtems_message_queue_send( queue_id, &ring_node_cwf3_light, sizeof( ring_node* ) ); | |
699 | if (status != RTEMS_SUCCESSFUL) { |
|
699 | if (status != RTEMS_SUCCESSFUL) { | |
700 | ret = LFR_DEFAULT; |
|
700 | ret = LFR_DEFAULT; | |
701 | } |
|
701 | } | |
702 |
|
702 | |||
703 | return ret; |
|
703 | return ret; | |
704 | } |
|
704 | } | |
705 |
|
705 | |||
706 | void compute_acquisition_time( unsigned int coarseTime, unsigned int fineTime, |
|
706 | void compute_acquisition_time( unsigned int coarseTime, unsigned int fineTime, | |
707 | unsigned int sid, unsigned char pa_lfr_pkt_nr, unsigned char * acquisitionTime ) |
|
707 | unsigned int sid, unsigned char pa_lfr_pkt_nr, unsigned char * acquisitionTime ) | |
708 | { |
|
708 | { | |
709 | unsigned long long int acquisitionTimeAsLong; |
|
709 | unsigned long long int acquisitionTimeAsLong; | |
710 | unsigned char localAcquisitionTime[BYTES_PER_TIME]; |
|
710 | unsigned char localAcquisitionTime[BYTES_PER_TIME]; | |
711 | double deltaT; |
|
711 | double deltaT; | |
712 |
|
712 | |||
713 | deltaT = INIT_FLOAT; |
|
713 | deltaT = INIT_FLOAT; | |
714 |
|
714 | |||
715 | localAcquisitionTime[BYTE_0] = (unsigned char) ( coarseTime >> SHIFT_3_BYTES ); |
|
715 | localAcquisitionTime[BYTE_0] = (unsigned char) ( coarseTime >> SHIFT_3_BYTES ); | |
716 | localAcquisitionTime[BYTE_1] = (unsigned char) ( coarseTime >> SHIFT_2_BYTES ); |
|
716 | localAcquisitionTime[BYTE_1] = (unsigned char) ( coarseTime >> SHIFT_2_BYTES ); | |
717 | localAcquisitionTime[BYTE_2] = (unsigned char) ( coarseTime >> SHIFT_1_BYTE ); |
|
717 | localAcquisitionTime[BYTE_2] = (unsigned char) ( coarseTime >> SHIFT_1_BYTE ); | |
718 | localAcquisitionTime[BYTE_3] = (unsigned char) ( coarseTime ); |
|
718 | localAcquisitionTime[BYTE_3] = (unsigned char) ( coarseTime ); | |
719 | localAcquisitionTime[BYTE_4] = (unsigned char) ( fineTime >> SHIFT_1_BYTE ); |
|
719 | localAcquisitionTime[BYTE_4] = (unsigned char) ( fineTime >> SHIFT_1_BYTE ); | |
720 | localAcquisitionTime[BYTE_5] = (unsigned char) ( fineTime ); |
|
720 | localAcquisitionTime[BYTE_5] = (unsigned char) ( fineTime ); | |
721 |
|
721 | |||
722 | acquisitionTimeAsLong = ( (unsigned long long int) localAcquisitionTime[BYTE_0] << SHIFT_5_BYTES ) |
|
722 | acquisitionTimeAsLong = ( (unsigned long long int) localAcquisitionTime[BYTE_0] << SHIFT_5_BYTES ) | |
723 | + ( (unsigned long long int) localAcquisitionTime[BYTE_1] << SHIFT_4_BYTES ) |
|
723 | + ( (unsigned long long int) localAcquisitionTime[BYTE_1] << SHIFT_4_BYTES ) | |
724 | + ( (unsigned long long int) localAcquisitionTime[BYTE_2] << SHIFT_3_BYTES ) |
|
724 | + ( (unsigned long long int) localAcquisitionTime[BYTE_2] << SHIFT_3_BYTES ) | |
725 | + ( (unsigned long long int) localAcquisitionTime[BYTE_3] << SHIFT_2_BYTES ) |
|
725 | + ( (unsigned long long int) localAcquisitionTime[BYTE_3] << SHIFT_2_BYTES ) | |
726 | + ( (unsigned long long int) localAcquisitionTime[BYTE_4] << SHIFT_1_BYTE ) |
|
726 | + ( (unsigned long long int) localAcquisitionTime[BYTE_4] << SHIFT_1_BYTE ) | |
727 | + ( (unsigned long long int) localAcquisitionTime[BYTE_5] ); |
|
727 | + ( (unsigned long long int) localAcquisitionTime[BYTE_5] ); | |
728 |
|
728 | |||
729 | switch( sid ) |
|
729 | switch( sid ) | |
730 | { |
|
730 | { | |
731 | case SID_NORM_SWF_F0: |
|
731 | case SID_NORM_SWF_F0: | |
732 | deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_304 * T0_IN_FINETIME ; |
|
732 | deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_304 * T0_IN_FINETIME ; | |
733 | break; |
|
733 | break; | |
734 |
|
734 | |||
735 | case SID_NORM_SWF_F1: |
|
735 | case SID_NORM_SWF_F1: | |
736 | deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_304 * T1_IN_FINETIME ; |
|
736 | deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_304 * T1_IN_FINETIME ; | |
737 | break; |
|
737 | break; | |
738 |
|
738 | |||
739 | case SID_NORM_SWF_F2: |
|
739 | case SID_NORM_SWF_F2: | |
740 | deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_304 * T2_IN_FINETIME ; |
|
740 | deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_304 * T2_IN_FINETIME ; | |
741 | break; |
|
741 | break; | |
742 |
|
742 | |||
743 | case SID_SBM1_CWF_F1: |
|
743 | case SID_SBM1_CWF_F1: | |
744 | deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * T1_IN_FINETIME ; |
|
744 | deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * T1_IN_FINETIME ; | |
745 | break; |
|
745 | break; | |
746 |
|
746 | |||
747 | case SID_SBM2_CWF_F2: |
|
747 | case SID_SBM2_CWF_F2: | |
748 | deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * T2_IN_FINETIME ; |
|
748 | deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * T2_IN_FINETIME ; | |
749 | break; |
|
749 | break; | |
750 |
|
750 | |||
751 | case SID_BURST_CWF_F2: |
|
751 | case SID_BURST_CWF_F2: | |
752 | deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * T2_IN_FINETIME ; |
|
752 | deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * T2_IN_FINETIME ; | |
753 | break; |
|
753 | break; | |
754 |
|
754 | |||
755 | case SID_NORM_CWF_F3: |
|
755 | case SID_NORM_CWF_F3: | |
756 | deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF_SHORT_F3 * T3_IN_FINETIME ; |
|
756 | deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF_SHORT_F3 * T3_IN_FINETIME ; | |
757 | break; |
|
757 | break; | |
758 |
|
758 | |||
759 | case SID_NORM_CWF_LONG_F3: |
|
759 | case SID_NORM_CWF_LONG_F3: | |
760 | deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * T3_IN_FINETIME ; |
|
760 | deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * T3_IN_FINETIME ; | |
761 | break; |
|
761 | break; | |
762 |
|
762 | |||
763 | default: |
|
763 | default: | |
764 | PRINTF1("in compute_acquisition_time *** ERR unexpected sid %d\n", sid) |
|
764 | PRINTF1("in compute_acquisition_time *** ERR unexpected sid %d\n", sid) | |
765 | deltaT = 0.; |
|
765 | deltaT = 0.; | |
766 | break; |
|
766 | break; | |
767 | } |
|
767 | } | |
768 |
|
768 | |||
769 | acquisitionTimeAsLong = acquisitionTimeAsLong + (unsigned long long int) deltaT; |
|
769 | acquisitionTimeAsLong = acquisitionTimeAsLong + (unsigned long long int) deltaT; | |
770 | // |
|
770 | // | |
771 | acquisitionTime[BYTE_0] = (unsigned char) (acquisitionTimeAsLong >> SHIFT_5_BYTES); |
|
771 | acquisitionTime[BYTE_0] = (unsigned char) (acquisitionTimeAsLong >> SHIFT_5_BYTES); | |
772 | acquisitionTime[BYTE_1] = (unsigned char) (acquisitionTimeAsLong >> SHIFT_4_BYTES); |
|
772 | acquisitionTime[BYTE_1] = (unsigned char) (acquisitionTimeAsLong >> SHIFT_4_BYTES); | |
773 | acquisitionTime[BYTE_2] = (unsigned char) (acquisitionTimeAsLong >> SHIFT_3_BYTES); |
|
773 | acquisitionTime[BYTE_2] = (unsigned char) (acquisitionTimeAsLong >> SHIFT_3_BYTES); | |
774 | acquisitionTime[BYTE_3] = (unsigned char) (acquisitionTimeAsLong >> SHIFT_2_BYTES); |
|
774 | acquisitionTime[BYTE_3] = (unsigned char) (acquisitionTimeAsLong >> SHIFT_2_BYTES); | |
775 | acquisitionTime[BYTE_4] = (unsigned char) (acquisitionTimeAsLong >> SHIFT_1_BYTE ); |
|
775 | acquisitionTime[BYTE_4] = (unsigned char) (acquisitionTimeAsLong >> SHIFT_1_BYTE ); | |
776 | acquisitionTime[BYTE_5] = (unsigned char) (acquisitionTimeAsLong ); |
|
776 | acquisitionTime[BYTE_5] = (unsigned char) (acquisitionTimeAsLong ); | |
777 |
|
777 | |||
778 | } |
|
778 | } | |
779 |
|
779 | |||
780 | void build_snapshot_from_ring( ring_node *ring_node_to_send, |
|
780 | void build_snapshot_from_ring( ring_node *ring_node_to_send, | |
781 | unsigned char frequencyChannel, |
|
781 | unsigned char frequencyChannel, | |
782 | unsigned long long int acquisitionTimeF0_asLong, |
|
782 | unsigned long long int acquisitionTimeF0_asLong, | |
783 | ring_node *ring_node_swf_extracted, |
|
783 | ring_node *ring_node_swf_extracted, | |
784 | int *swf_extracted) |
|
784 | int *swf_extracted) | |
785 | { |
|
785 | { | |
786 | unsigned int i; |
|
786 | unsigned int i; | |
787 | unsigned int node; |
|
787 | unsigned int node; | |
788 | unsigned long long int centerTime_asLong; |
|
788 | unsigned long long int centerTime_asLong; | |
789 | unsigned long long int acquisitionTime_asLong; |
|
789 | unsigned long long int acquisitionTime_asLong; | |
790 | unsigned long long int bufferAcquisitionTime_asLong; |
|
790 | unsigned long long int bufferAcquisitionTime_asLong; | |
791 | unsigned char *ptr1; |
|
791 | unsigned char *ptr1; | |
792 | unsigned char *ptr2; |
|
792 | unsigned char *ptr2; | |
793 | unsigned char *timeCharPtr; |
|
793 | unsigned char *timeCharPtr; | |
794 | unsigned char nb_ring_nodes; |
|
794 | unsigned char nb_ring_nodes; | |
795 | unsigned long long int frequency_asLong; |
|
795 | unsigned long long int frequency_asLong; | |
796 | unsigned long long int nbTicksPerSample_asLong; |
|
796 | unsigned long long int nbTicksPerSample_asLong; | |
797 | unsigned long long int nbSamplesPart1_asLong; |
|
797 | unsigned long long int nbSamplesPart1_asLong; | |
798 | unsigned long long int sampleOffset_asLong; |
|
798 | unsigned long long int sampleOffset_asLong; | |
799 |
|
799 | |||
800 | unsigned int deltaT_F0; |
|
800 | unsigned int deltaT_F0; | |
801 | unsigned int deltaT_F1; |
|
801 | unsigned int deltaT_F1; | |
802 | unsigned long long int deltaT_F2; |
|
802 | unsigned long long int deltaT_F2; | |
803 |
|
803 | |||
804 | deltaT_F0 = DELTAT_F0; |
|
804 | deltaT_F0 = DELTAT_F0; | |
805 | deltaT_F1 = DELTAT_F1; |
|
805 | deltaT_F1 = DELTAT_F1; | |
806 | deltaT_F2 = DELTAT_F2; |
|
806 | deltaT_F2 = DELTAT_F2; | |
807 | sampleOffset_asLong = INIT_CHAR; |
|
807 | sampleOffset_asLong = INIT_CHAR; | |
808 |
|
808 | |||
809 | // (1) get the f0 acquisition time => the value is passed in argument |
|
809 | // (1) get the f0 acquisition time => the value is passed in argument | |
810 |
|
810 | |||
811 | // (2) compute the central reference time |
|
811 | // (2) compute the central reference time | |
812 | centerTime_asLong = acquisitionTimeF0_asLong + deltaT_F0; |
|
812 | centerTime_asLong = acquisitionTimeF0_asLong + deltaT_F0; | |
813 | acquisitionTime_asLong = centerTime_asLong; //set to default value (Don_Initialisation_P2) |
|
813 | acquisitionTime_asLong = centerTime_asLong; //set to default value (Don_Initialisation_P2) | |
814 | bufferAcquisitionTime_asLong = centerTime_asLong; //set to default value (Don_Initialisation_P2) |
|
814 | bufferAcquisitionTime_asLong = centerTime_asLong; //set to default value (Don_Initialisation_P2) | |
815 | nbTicksPerSample_asLong = TICKS_PER_T2; //set to default value (Don_Initialisation_P2) |
|
815 | nbTicksPerSample_asLong = TICKS_PER_T2; //set to default value (Don_Initialisation_P2) | |
816 |
|
816 | |||
817 | // (3) compute the acquisition time of the current snapshot |
|
817 | // (3) compute the acquisition time of the current snapshot | |
818 | switch(frequencyChannel) |
|
818 | switch(frequencyChannel) | |
819 | { |
|
819 | { | |
820 | case CHANNELF1: // 1 is for F1 = 4096 Hz |
|
820 | case CHANNELF1: // 1 is for F1 = 4096 Hz | |
821 | acquisitionTime_asLong = centerTime_asLong - deltaT_F1; |
|
821 | acquisitionTime_asLong = centerTime_asLong - deltaT_F1; | |
822 | nb_ring_nodes = NB_RING_NODES_F1; |
|
822 | nb_ring_nodes = NB_RING_NODES_F1; | |
823 | frequency_asLong = FREQ_F1; |
|
823 | frequency_asLong = FREQ_F1; | |
824 | nbTicksPerSample_asLong = TICKS_PER_T1; // 65536 / 4096; |
|
824 | nbTicksPerSample_asLong = TICKS_PER_T1; // 65536 / 4096; | |
825 | break; |
|
825 | break; | |
826 | case CHANNELF2: // 2 is for F2 = 256 Hz |
|
826 | case CHANNELF2: // 2 is for F2 = 256 Hz | |
827 | acquisitionTime_asLong = centerTime_asLong - deltaT_F2; |
|
827 | acquisitionTime_asLong = centerTime_asLong - deltaT_F2; | |
828 | nb_ring_nodes = NB_RING_NODES_F2; |
|
828 | nb_ring_nodes = NB_RING_NODES_F2; | |
829 | frequency_asLong = FREQ_F2; |
|
829 | frequency_asLong = FREQ_F2; | |
830 | nbTicksPerSample_asLong = TICKS_PER_T2; // 65536 / 256; |
|
830 | nbTicksPerSample_asLong = TICKS_PER_T2; // 65536 / 256; | |
831 | break; |
|
831 | break; | |
832 | default: |
|
832 | default: | |
833 | acquisitionTime_asLong = centerTime_asLong; |
|
833 | acquisitionTime_asLong = centerTime_asLong; | |
834 | nb_ring_nodes = 0; |
|
834 | nb_ring_nodes = 0; | |
835 | frequency_asLong = FREQ_F2; |
|
835 | frequency_asLong = FREQ_F2; | |
836 | nbTicksPerSample_asLong = TICKS_PER_T2; |
|
836 | nbTicksPerSample_asLong = TICKS_PER_T2; | |
837 | break; |
|
837 | break; | |
838 | } |
|
838 | } | |
839 |
|
839 | |||
840 | //***************************************************************************** |
|
840 | //***************************************************************************** | |
841 | // (4) search the ring_node with the acquisition time <= acquisitionTime_asLong |
|
841 | // (4) search the ring_node with the acquisition time <= acquisitionTime_asLong | |
842 | node = 0; |
|
842 | node = 0; | |
843 | while ( node < nb_ring_nodes) |
|
843 | while ( node < nb_ring_nodes) | |
844 | { |
|
844 | { | |
845 | //PRINTF1("%d ... ", node); |
|
|||
846 | bufferAcquisitionTime_asLong = get_acquisition_time( (unsigned char *) &ring_node_to_send->coarseTime ); |
|
845 | bufferAcquisitionTime_asLong = get_acquisition_time( (unsigned char *) &ring_node_to_send->coarseTime ); | |
847 | if (bufferAcquisitionTime_asLong <= acquisitionTime_asLong) |
|
846 | if (bufferAcquisitionTime_asLong <= acquisitionTime_asLong) | |
848 | { |
|
847 | { | |
849 | //PRINTF1("buffer found with acquisition time = %llx\n", bufferAcquisitionTime_asLong); |
|
|||
850 | node = nb_ring_nodes; |
|
848 | node = nb_ring_nodes; | |
851 | } |
|
849 | } | |
852 | else |
|
850 | else | |
853 | { |
|
851 | { | |
854 | node = node + 1; |
|
852 | node = node + 1; | |
855 | ring_node_to_send = ring_node_to_send->previous; |
|
853 | ring_node_to_send = ring_node_to_send->previous; | |
856 | } |
|
854 | } | |
857 | } |
|
855 | } | |
858 |
|
856 | |||
859 | // (5) compute the number of samples to take in the current buffer |
|
857 | // (5) compute the number of samples to take in the current buffer | |
860 | sampleOffset_asLong = ((acquisitionTime_asLong - bufferAcquisitionTime_asLong) * frequency_asLong ) >> SHIFT_2_BYTES; |
|
858 | sampleOffset_asLong = ((acquisitionTime_asLong - bufferAcquisitionTime_asLong) * frequency_asLong ) >> SHIFT_2_BYTES; | |
861 | nbSamplesPart1_asLong = NB_SAMPLES_PER_SNAPSHOT - sampleOffset_asLong; |
|
859 | nbSamplesPart1_asLong = NB_SAMPLES_PER_SNAPSHOT - sampleOffset_asLong; | |
862 | //PRINTF2("sampleOffset_asLong = %lld, nbSamplesPart1_asLong = %lld\n", sampleOffset_asLong, nbSamplesPart1_asLong); |
|
|||
863 |
|
860 | |||
864 | // (6) compute the final acquisition time |
|
861 | // (6) compute the final acquisition time | |
865 | acquisitionTime_asLong = bufferAcquisitionTime_asLong + |
|
862 | acquisitionTime_asLong = bufferAcquisitionTime_asLong + | |
866 | (sampleOffset_asLong * nbTicksPerSample_asLong); |
|
863 | (sampleOffset_asLong * nbTicksPerSample_asLong); | |
867 |
|
864 | |||
868 | // (7) copy the acquisition time at the beginning of the extrated snapshot |
|
865 | // (7) copy the acquisition time at the beginning of the extrated snapshot | |
869 | ptr1 = (unsigned char*) &acquisitionTime_asLong; |
|
866 | ptr1 = (unsigned char*) &acquisitionTime_asLong; | |
870 | // fine time |
|
867 | // fine time | |
871 | ptr2 = (unsigned char*) &ring_node_swf_extracted->fineTime; |
|
868 | ptr2 = (unsigned char*) &ring_node_swf_extracted->fineTime; | |
872 | ptr2[BYTE_2] = ptr1[ BYTE_4 + OFFSET_2_BYTES ]; |
|
869 | ptr2[BYTE_2] = ptr1[ BYTE_4 + OFFSET_2_BYTES ]; | |
873 | ptr2[BYTE_3] = ptr1[ BYTE_5 + OFFSET_2_BYTES ]; |
|
870 | ptr2[BYTE_3] = ptr1[ BYTE_5 + OFFSET_2_BYTES ]; | |
874 | // coarse time |
|
871 | // coarse time | |
875 | ptr2 = (unsigned char*) &ring_node_swf_extracted->coarseTime; |
|
872 | ptr2 = (unsigned char*) &ring_node_swf_extracted->coarseTime; | |
876 | ptr2[BYTE_0] = ptr1[ BYTE_0 + OFFSET_2_BYTES ]; |
|
873 | ptr2[BYTE_0] = ptr1[ BYTE_0 + OFFSET_2_BYTES ]; | |
877 | ptr2[BYTE_1] = ptr1[ BYTE_1 + OFFSET_2_BYTES ]; |
|
874 | ptr2[BYTE_1] = ptr1[ BYTE_1 + OFFSET_2_BYTES ]; | |
878 | ptr2[BYTE_2] = ptr1[ BYTE_2 + OFFSET_2_BYTES ]; |
|
875 | ptr2[BYTE_2] = ptr1[ BYTE_2 + OFFSET_2_BYTES ]; | |
879 | ptr2[BYTE_3] = ptr1[ BYTE_3 + OFFSET_2_BYTES ]; |
|
876 | ptr2[BYTE_3] = ptr1[ BYTE_3 + OFFSET_2_BYTES ]; | |
880 |
|
877 | |||
881 | // re set the synchronization bit |
|
878 | // re set the synchronization bit | |
882 | timeCharPtr = (unsigned char*) &ring_node_to_send->coarseTime; |
|
879 | timeCharPtr = (unsigned char*) &ring_node_to_send->coarseTime; | |
883 | ptr2[0] = ptr2[0] | (timeCharPtr[0] & SYNC_BIT); // [1000 0000] |
|
880 | ptr2[0] = ptr2[0] | (timeCharPtr[0] & SYNC_BIT); // [1000 0000] | |
884 |
|
881 | |||
885 |
if ( (nbSamplesPart1_asLong > |
|
882 | if ( (nbSamplesPart1_asLong > NB_SAMPLES_PER_SNAPSHOT) | (nbSamplesPart1_asLong < 0) ) | |
886 | { |
|
883 | { | |
887 | nbSamplesPart1_asLong = 0; |
|
884 | nbSamplesPart1_asLong = 0; | |
888 | } |
|
885 | } | |
889 | // copy the part 1 of the snapshot in the extracted buffer |
|
886 | // copy the part 1 of the snapshot in the extracted buffer | |
890 | for ( i = 0; i < (nbSamplesPart1_asLong * NB_WORDS_SWF_BLK); i++ ) |
|
887 | for ( i = 0; i < (nbSamplesPart1_asLong * NB_WORDS_SWF_BLK); i++ ) | |
891 | { |
|
888 | { | |
892 | swf_extracted[i] = |
|
889 | swf_extracted[i] = | |
893 | ((int*) ring_node_to_send->buffer_address)[ i + (sampleOffset_asLong * NB_WORDS_SWF_BLK) ]; |
|
890 | ((int*) ring_node_to_send->buffer_address)[ i + (sampleOffset_asLong * NB_WORDS_SWF_BLK) ]; | |
894 | } |
|
891 | } | |
895 | // copy the part 2 of the snapshot in the extracted buffer |
|
892 | // copy the part 2 of the snapshot in the extracted buffer | |
896 | ring_node_to_send = ring_node_to_send->next; |
|
893 | ring_node_to_send = ring_node_to_send->next; | |
897 | for ( i = (nbSamplesPart1_asLong * NB_WORDS_SWF_BLK); i < (NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK); i++ ) |
|
894 | for ( i = (nbSamplesPart1_asLong * NB_WORDS_SWF_BLK); i < (NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK); i++ ) | |
898 | { |
|
895 | { | |
899 | swf_extracted[i] = |
|
896 | swf_extracted[i] = | |
900 | ((int*) ring_node_to_send->buffer_address)[ (i-(nbSamplesPart1_asLong * NB_WORDS_SWF_BLK)) ]; |
|
897 | ((int*) ring_node_to_send->buffer_address)[ (i-(nbSamplesPart1_asLong * NB_WORDS_SWF_BLK)) ]; | |
901 | } |
|
898 | } | |
902 | } |
|
899 | } | |
903 |
|
900 | |||
904 | double computeCorrection( unsigned char *timePtr ) |
|
901 | double computeCorrection( unsigned char *timePtr ) | |
905 | { |
|
902 | { | |
906 | unsigned long long int acquisitionTime; |
|
903 | unsigned long long int acquisitionTime; | |
907 | unsigned long long int centerTime; |
|
904 | unsigned long long int centerTime; | |
908 | unsigned long long int previousTick; |
|
905 | unsigned long long int previousTick; | |
909 | unsigned long long int nextTick; |
|
906 | unsigned long long int nextTick; | |
910 | unsigned long long int deltaPreviousTick; |
|
907 | unsigned long long int deltaPreviousTick; | |
911 | unsigned long long int deltaNextTick; |
|
908 | unsigned long long int deltaNextTick; | |
912 | double deltaPrevious_ms; |
|
909 | double deltaPrevious_ms; | |
913 | double deltaNext_ms; |
|
910 | double deltaNext_ms; | |
914 | double correctionInF2; |
|
911 | double correctionInF2; | |
915 |
|
912 | |||
916 | correctionInF2 = 0; //set to default value (Don_Initialisation_P2) |
|
913 | correctionInF2 = 0; //set to default value (Don_Initialisation_P2) | |
917 |
|
914 | |||
918 | // get acquisition time in fine time ticks |
|
915 | // get acquisition time in fine time ticks | |
919 | acquisitionTime = get_acquisition_time( timePtr ); |
|
916 | acquisitionTime = get_acquisition_time( timePtr ); | |
920 |
|
917 | |||
921 | // compute center time |
|
918 | // compute center time | |
922 | centerTime = acquisitionTime + DELTAT_F0; // (2048. / 24576. / 2.) * 65536. = 2730.667; |
|
919 | centerTime = acquisitionTime + DELTAT_F0; // (2048. / 24576. / 2.) * 65536. = 2730.667; | |
923 | previousTick = centerTime - (centerTime & INT16_ALL_F); |
|
920 | previousTick = centerTime - (centerTime & INT16_ALL_F); | |
924 | nextTick = previousTick + TICKS_PER_S; |
|
921 | nextTick = previousTick + TICKS_PER_S; | |
925 |
|
922 | |||
926 | deltaPreviousTick = centerTime - previousTick; |
|
923 | deltaPreviousTick = centerTime - previousTick; | |
927 | deltaNextTick = nextTick - centerTime; |
|
924 | deltaNextTick = nextTick - centerTime; | |
928 |
|
925 | |||
929 | deltaPrevious_ms = (((double) deltaPreviousTick) / TICKS_PER_S) * MS_PER_S; |
|
926 | deltaPrevious_ms = (((double) deltaPreviousTick) / TICKS_PER_S) * MS_PER_S; | |
930 | deltaNext_ms = (((double) deltaNextTick) / TICKS_PER_S) * MS_PER_S; |
|
927 | deltaNext_ms = (((double) deltaNextTick) / TICKS_PER_S) * MS_PER_S; | |
931 |
|
928 | |||
932 | PRINTF2(" delta previous = %.3f ms, delta next = %.2f ms\n", deltaPrevious_ms, deltaNext_ms); |
|
929 | PRINTF2(" delta previous = %.3f ms, delta next = %.2f ms\n", deltaPrevious_ms, deltaNext_ms); | |
933 |
|
930 | |||
934 | // which tick is the closest? |
|
931 | // which tick is the closest? | |
935 | if (deltaPreviousTick > deltaNextTick) |
|
932 | if (deltaPreviousTick > deltaNextTick) | |
936 | { |
|
933 | { | |
937 | // the snapshot center is just before the second => increase delta_snapshot |
|
934 | // the snapshot center is just before the second => increase delta_snapshot | |
938 | correctionInF2 = + (deltaNext_ms * FREQ_F2 / MS_PER_S ); |
|
935 | correctionInF2 = + (deltaNext_ms * FREQ_F2 / MS_PER_S ); | |
939 | } |
|
936 | } | |
940 | else |
|
937 | else | |
941 | { |
|
938 | { | |
942 | // the snapshot center is just after the second => decrease delta_snapshot |
|
939 | // the snapshot center is just after the second => decrease delta_snapshot | |
943 | correctionInF2 = - (deltaPrevious_ms * FREQ_F2 / MS_PER_S ); |
|
940 | correctionInF2 = - (deltaPrevious_ms * FREQ_F2 / MS_PER_S ); | |
944 | } |
|
941 | } | |
945 |
|
942 | |||
946 | PRINTF1(" correctionInF2 = %.2f\n", correctionInF2); |
|
943 | PRINTF1(" correctionInF2 = %.2f\n", correctionInF2); | |
947 |
|
944 | |||
948 | return correctionInF2; |
|
945 | return correctionInF2; | |
949 | } |
|
946 | } | |
950 |
|
947 | |||
951 | void applyCorrection( double correction ) |
|
948 | void applyCorrection( double correction ) | |
952 | { |
|
949 | { | |
953 | int correctionInt; |
|
950 | int correctionInt; | |
954 |
|
951 | |||
955 | correctionInt = 0; |
|
952 | correctionInt = 0; | |
956 |
|
953 | |||
957 | if (correction >= 0.) |
|
954 | if (correction >= 0.) | |
958 | { |
|
955 | { | |
959 | if ( (ONE_TICK_CORR_INTERVAL_0_MIN < correction) && (correction < ONE_TICK_CORR_INTERVAL_0_MAX) ) |
|
956 | if ( (ONE_TICK_CORR_INTERVAL_0_MIN < correction) && (correction < ONE_TICK_CORR_INTERVAL_0_MAX) ) | |
960 | { |
|
957 | { | |
961 | correctionInt = ONE_TICK_CORR; |
|
958 | correctionInt = ONE_TICK_CORR; | |
962 | } |
|
959 | } | |
963 | else |
|
960 | else | |
964 | { |
|
961 | { | |
965 | correctionInt = CORR_MULT * floor(correction); |
|
962 | correctionInt = CORR_MULT * floor(correction); | |
966 | } |
|
963 | } | |
967 | } |
|
964 | } | |
968 | else |
|
965 | else | |
969 | { |
|
966 | { | |
970 | if ( (ONE_TICK_CORR_INTERVAL_1_MIN < correction) && (correction < ONE_TICK_CORR_INTERVAL_1_MAX) ) |
|
967 | if ( (ONE_TICK_CORR_INTERVAL_1_MIN < correction) && (correction < ONE_TICK_CORR_INTERVAL_1_MAX) ) | |
971 | { |
|
968 | { | |
972 | correctionInt = -ONE_TICK_CORR; |
|
969 | correctionInt = -ONE_TICK_CORR; | |
973 | } |
|
970 | } | |
974 | else |
|
971 | else | |
975 | { |
|
972 | { | |
976 | correctionInt = CORR_MULT * ceil(correction); |
|
973 | correctionInt = CORR_MULT * ceil(correction); | |
977 | } |
|
974 | } | |
978 | } |
|
975 | } | |
979 | waveform_picker_regs->delta_snapshot = waveform_picker_regs->delta_snapshot + correctionInt; |
|
976 | waveform_picker_regs->delta_snapshot = waveform_picker_regs->delta_snapshot + correctionInt; | |
980 | } |
|
977 | } | |
981 |
|
978 | |||
982 | void snapshot_resynchronization( unsigned char *timePtr ) |
|
979 | void snapshot_resynchronization( unsigned char *timePtr ) | |
983 | { |
|
980 | { | |
984 | /** This function compute a correction to apply on delta_snapshot. |
|
981 | /** This function compute a correction to apply on delta_snapshot. | |
985 | * |
|
982 | * | |
986 | * |
|
983 | * | |
987 | * @param timePtr is a pointer to the acquisition time of the snapshot being considered. |
|
984 | * @param timePtr is a pointer to the acquisition time of the snapshot being considered. | |
988 | * |
|
985 | * | |
989 | * @return void |
|
986 | * @return void | |
990 | * |
|
987 | * | |
991 | */ |
|
988 | */ | |
992 |
|
989 | |||
993 | static double correction = INIT_FLOAT; |
|
990 | static double correction = INIT_FLOAT; | |
994 | static resynchro_state state = MEASURE; |
|
991 | static resynchro_state state = MEASURE; | |
995 | static unsigned int nbSnapshots = 0; |
|
992 | static unsigned int nbSnapshots = 0; | |
996 |
|
993 | |||
997 | int correctionInt; |
|
994 | int correctionInt; | |
998 |
|
995 | |||
999 | correctionInt = 0; |
|
996 | correctionInt = 0; | |
1000 |
|
997 | |||
1001 | switch (state) |
|
998 | switch (state) | |
1002 | { |
|
999 | { | |
1003 |
|
1000 | |||
1004 | case MEASURE: |
|
1001 | case MEASURE: | |
1005 | // ******** |
|
1002 | // ******** | |
1006 | PRINTF1("MEASURE === %d\n", nbSnapshots); |
|
1003 | PRINTF1("MEASURE === %d\n", nbSnapshots); | |
1007 | state = CORRECTION; |
|
1004 | state = CORRECTION; | |
1008 | correction = computeCorrection( timePtr ); |
|
1005 | correction = computeCorrection( timePtr ); | |
1009 | PRINTF1("MEASURE === correction = %.2f\n", correction ); |
|
1006 | PRINTF1("MEASURE === correction = %.2f\n", correction ); | |
1010 | applyCorrection( correction ); |
|
1007 | applyCorrection( correction ); | |
1011 | PRINTF1("MEASURE === delta_snapshot = %d\n", waveform_picker_regs->delta_snapshot); |
|
1008 | PRINTF1("MEASURE === delta_snapshot = %d\n", waveform_picker_regs->delta_snapshot); | |
1012 | //**** |
|
1009 | //**** | |
1013 | break; |
|
1010 | break; | |
1014 |
|
1011 | |||
1015 | case CORRECTION: |
|
1012 | case CORRECTION: | |
1016 | //************ |
|
1013 | //************ | |
1017 | PRINTF1("CORRECTION === %d\n", nbSnapshots); |
|
1014 | PRINTF1("CORRECTION === %d\n", nbSnapshots); | |
1018 | state = MEASURE; |
|
1015 | state = MEASURE; | |
1019 | computeCorrection( timePtr ); |
|
1016 | computeCorrection( timePtr ); | |
1020 | set_wfp_delta_snapshot(); |
|
1017 | set_wfp_delta_snapshot(); | |
1021 | PRINTF1("CORRECTION === delta_snapshot = %d\n", waveform_picker_regs->delta_snapshot); |
|
1018 | PRINTF1("CORRECTION === delta_snapshot = %d\n", waveform_picker_regs->delta_snapshot); | |
1022 | //**** |
|
1019 | //**** | |
1023 | break; |
|
1020 | break; | |
1024 |
|
1021 | |||
1025 | default: |
|
1022 | default: | |
1026 | break; |
|
1023 | break; | |
1027 |
|
1024 | |||
1028 | } |
|
1025 | } | |
1029 |
|
1026 | |||
1030 | nbSnapshots++; |
|
1027 | nbSnapshots++; | |
1031 | } |
|
1028 | } | |
1032 |
|
1029 | |||
1033 | //************** |
|
1030 | //************** | |
1034 | // wfp registers |
|
1031 | // wfp registers | |
1035 | void reset_wfp_burst_enable( void ) |
|
1032 | void reset_wfp_burst_enable( void ) | |
1036 | { |
|
1033 | { | |
1037 | /** This function resets the waveform picker burst_enable register. |
|
1034 | /** This function resets the waveform picker burst_enable register. | |
1038 | * |
|
1035 | * | |
1039 | * The burst bits [f2 f1 f0] and the enable bits [f3 f2 f1 f0] are set to 0. |
|
1036 | * The burst bits [f2 f1 f0] and the enable bits [f3 f2 f1 f0] are set to 0. | |
1040 | * |
|
1037 | * | |
1041 | */ |
|
1038 | */ | |
1042 |
|
1039 | |||
1043 | // [1000 000] burst f2, f1, f0 enable f3, f2, f1, f0 |
|
1040 | // [1000 000] burst f2, f1, f0 enable f3, f2, f1, f0 | |
1044 | waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable & RST_BITS_RUN_BURST_EN; |
|
1041 | waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable & RST_BITS_RUN_BURST_EN; | |
1045 | } |
|
1042 | } | |
1046 |
|
1043 | |||
1047 | void reset_wfp_status( void ) |
|
1044 | void reset_wfp_status( void ) | |
1048 | { |
|
1045 | { | |
1049 | /** This function resets the waveform picker status register. |
|
1046 | /** This function resets the waveform picker status register. | |
1050 | * |
|
1047 | * | |
1051 | * All status bits are set to 0 [new_err full_err full]. |
|
1048 | * All status bits are set to 0 [new_err full_err full]. | |
1052 | * |
|
1049 | * | |
1053 | */ |
|
1050 | */ | |
1054 |
|
1051 | |||
1055 | waveform_picker_regs->status = INT16_ALL_F; |
|
1052 | waveform_picker_regs->status = INT16_ALL_F; | |
1056 | } |
|
1053 | } | |
1057 |
|
1054 | |||
1058 | void reset_wfp_buffer_addresses( void ) |
|
1055 | void reset_wfp_buffer_addresses( void ) | |
1059 | { |
|
1056 | { | |
1060 | // F0 |
|
1057 | // F0 | |
1061 | waveform_picker_regs->addr_data_f0_0 = current_ring_node_f0->previous->buffer_address; // 0x08 |
|
1058 | waveform_picker_regs->addr_data_f0_0 = current_ring_node_f0->previous->buffer_address; // 0x08 | |
1062 | waveform_picker_regs->addr_data_f0_1 = current_ring_node_f0->buffer_address; // 0x0c |
|
1059 | waveform_picker_regs->addr_data_f0_1 = current_ring_node_f0->buffer_address; // 0x0c | |
1063 | // F1 |
|
1060 | // F1 | |
1064 | waveform_picker_regs->addr_data_f1_0 = current_ring_node_f1->previous->buffer_address; // 0x10 |
|
1061 | waveform_picker_regs->addr_data_f1_0 = current_ring_node_f1->previous->buffer_address; // 0x10 | |
1065 | waveform_picker_regs->addr_data_f1_1 = current_ring_node_f1->buffer_address; // 0x14 |
|
1062 | waveform_picker_regs->addr_data_f1_1 = current_ring_node_f1->buffer_address; // 0x14 | |
1066 | // F2 |
|
1063 | // F2 | |
1067 | waveform_picker_regs->addr_data_f2_0 = current_ring_node_f2->previous->buffer_address; // 0x18 |
|
1064 | waveform_picker_regs->addr_data_f2_0 = current_ring_node_f2->previous->buffer_address; // 0x18 | |
1068 | waveform_picker_regs->addr_data_f2_1 = current_ring_node_f2->buffer_address; // 0x1c |
|
1065 | waveform_picker_regs->addr_data_f2_1 = current_ring_node_f2->buffer_address; // 0x1c | |
1069 | // F3 |
|
1066 | // F3 | |
1070 | waveform_picker_regs->addr_data_f3_0 = current_ring_node_f3->previous->buffer_address; // 0x20 |
|
1067 | waveform_picker_regs->addr_data_f3_0 = current_ring_node_f3->previous->buffer_address; // 0x20 | |
1071 | waveform_picker_regs->addr_data_f3_1 = current_ring_node_f3->buffer_address; // 0x24 |
|
1068 | waveform_picker_regs->addr_data_f3_1 = current_ring_node_f3->buffer_address; // 0x24 | |
1072 | } |
|
1069 | } | |
1073 |
|
1070 | |||
1074 | void reset_waveform_picker_regs( void ) |
|
1071 | void reset_waveform_picker_regs( void ) | |
1075 | { |
|
1072 | { | |
1076 | /** This function resets the waveform picker module registers. |
|
1073 | /** This function resets the waveform picker module registers. | |
1077 | * |
|
1074 | * | |
1078 | * The registers affected by this function are located at the following offset addresses: |
|
1075 | * The registers affected by this function are located at the following offset addresses: | |
1079 | * - 0x00 data_shaping |
|
1076 | * - 0x00 data_shaping | |
1080 | * - 0x04 run_burst_enable |
|
1077 | * - 0x04 run_burst_enable | |
1081 | * - 0x08 addr_data_f0 |
|
1078 | * - 0x08 addr_data_f0 | |
1082 | * - 0x0C addr_data_f1 |
|
1079 | * - 0x0C addr_data_f1 | |
1083 | * - 0x10 addr_data_f2 |
|
1080 | * - 0x10 addr_data_f2 | |
1084 | * - 0x14 addr_data_f3 |
|
1081 | * - 0x14 addr_data_f3 | |
1085 | * - 0x18 status |
|
1082 | * - 0x18 status | |
1086 | * - 0x1C delta_snapshot |
|
1083 | * - 0x1C delta_snapshot | |
1087 | * - 0x20 delta_f0 |
|
1084 | * - 0x20 delta_f0 | |
1088 | * - 0x24 delta_f0_2 |
|
1085 | * - 0x24 delta_f0_2 | |
1089 | * - 0x28 delta_f1 (obsolet parameter) |
|
1086 | * - 0x28 delta_f1 (obsolet parameter) | |
1090 | * - 0x2c delta_f2 |
|
1087 | * - 0x2c delta_f2 | |
1091 | * - 0x30 nb_data_by_buffer |
|
1088 | * - 0x30 nb_data_by_buffer | |
1092 | * - 0x34 nb_snapshot_param |
|
1089 | * - 0x34 nb_snapshot_param | |
1093 | * - 0x38 start_date |
|
1090 | * - 0x38 start_date | |
1094 | * - 0x3c nb_word_in_buffer |
|
1091 | * - 0x3c nb_word_in_buffer | |
1095 | * |
|
1092 | * | |
1096 | */ |
|
1093 | */ | |
1097 |
|
1094 | |||
1098 | set_wfp_data_shaping(); // 0x00 *** R1 R0 SP1 SP0 BW |
|
1095 | set_wfp_data_shaping(); // 0x00 *** R1 R0 SP1 SP0 BW | |
1099 |
|
1096 | |||
1100 | reset_wfp_burst_enable(); // 0x04 *** [run *** burst f2, f1, f0 *** enable f3, f2, f1, f0 ] |
|
1097 | reset_wfp_burst_enable(); // 0x04 *** [run *** burst f2, f1, f0 *** enable f3, f2, f1, f0 ] | |
1101 |
|
1098 | |||
1102 | reset_wfp_buffer_addresses(); |
|
1099 | reset_wfp_buffer_addresses(); | |
1103 |
|
1100 | |||
1104 | reset_wfp_status(); // 0x18 |
|
1101 | reset_wfp_status(); // 0x18 | |
1105 |
|
1102 | |||
1106 | set_wfp_delta_snapshot(); // 0x1c *** 300 s => 0x12bff |
|
1103 | set_wfp_delta_snapshot(); // 0x1c *** 300 s => 0x12bff | |
1107 |
|
1104 | |||
1108 | set_wfp_delta_f0_f0_2(); // 0x20, 0x24 |
|
1105 | set_wfp_delta_f0_f0_2(); // 0x20, 0x24 | |
1109 |
|
1106 | |||
1110 | //the parameter delta_f1 [0x28] is not used anymore |
|
1107 | //the parameter delta_f1 [0x28] is not used anymore | |
1111 |
|
1108 | |||
1112 | set_wfp_delta_f2(); // 0x2c |
|
1109 | set_wfp_delta_f2(); // 0x2c | |
1113 |
|
1110 | |||
1114 | DEBUG_PRINTF1("delta_snapshot %x\n", waveform_picker_regs->delta_snapshot); |
|
1111 | DEBUG_PRINTF1("delta_snapshot %x\n", waveform_picker_regs->delta_snapshot); | |
1115 | DEBUG_PRINTF1("delta_f0 %x\n", waveform_picker_regs->delta_f0); |
|
1112 | DEBUG_PRINTF1("delta_f0 %x\n", waveform_picker_regs->delta_f0); | |
1116 | DEBUG_PRINTF1("delta_f0_2 %x\n", waveform_picker_regs->delta_f0_2); |
|
1113 | DEBUG_PRINTF1("delta_f0_2 %x\n", waveform_picker_regs->delta_f0_2); | |
1117 | DEBUG_PRINTF1("delta_f1 %x\n", waveform_picker_regs->delta_f1); |
|
1114 | DEBUG_PRINTF1("delta_f1 %x\n", waveform_picker_regs->delta_f1); | |
1118 | DEBUG_PRINTF1("delta_f2 %x\n", waveform_picker_regs->delta_f2); |
|
1115 | DEBUG_PRINTF1("delta_f2 %x\n", waveform_picker_regs->delta_f2); | |
1119 | // 2688 = 8 * 336 |
|
1116 | // 2688 = 8 * 336 | |
1120 | waveform_picker_regs->nb_data_by_buffer = DFLT_WFP_NB_DATA_BY_BUFFER; // 0x30 *** 2688 - 1 => nb samples -1 |
|
1117 | waveform_picker_regs->nb_data_by_buffer = DFLT_WFP_NB_DATA_BY_BUFFER; // 0x30 *** 2688 - 1 => nb samples -1 | |
1121 | waveform_picker_regs->snapshot_param = DFLT_WFP_SNAPSHOT_PARAM; // 0x34 *** 2688 => nb samples |
|
1118 | waveform_picker_regs->snapshot_param = DFLT_WFP_SNAPSHOT_PARAM; // 0x34 *** 2688 => nb samples | |
1122 | waveform_picker_regs->start_date = COARSE_TIME_MASK; |
|
1119 | waveform_picker_regs->start_date = COARSE_TIME_MASK; | |
1123 | // |
|
1120 | // | |
1124 | // coarse time and fine time registers are not initialized, they are volatile |
|
1121 | // coarse time and fine time registers are not initialized, they are volatile | |
1125 | // |
|
1122 | // | |
1126 | waveform_picker_regs->buffer_length = DFLT_WFP_BUFFER_LENGTH; // buffer length in burst = 3 * 2688 / 16 = 504 = 0x1f8 |
|
1123 | waveform_picker_regs->buffer_length = DFLT_WFP_BUFFER_LENGTH; // buffer length in burst = 3 * 2688 / 16 = 504 = 0x1f8 | |
1127 | } |
|
1124 | } | |
1128 |
|
1125 | |||
1129 | void set_wfp_data_shaping( void ) |
|
1126 | void set_wfp_data_shaping( void ) | |
1130 | { |
|
1127 | { | |
1131 | /** This function sets the data_shaping register of the waveform picker module. |
|
1128 | /** This function sets the data_shaping register of the waveform picker module. | |
1132 | * |
|
1129 | * | |
1133 | * The value is read from one field of the parameter_dump_packet structure:\n |
|
1130 | * The value is read from one field of the parameter_dump_packet structure:\n | |
1134 | * bw_sp0_sp1_r0_r1 |
|
1131 | * bw_sp0_sp1_r0_r1 | |
1135 | * |
|
1132 | * | |
1136 | */ |
|
1133 | */ | |
1137 |
|
1134 | |||
1138 | unsigned char data_shaping; |
|
1135 | unsigned char data_shaping; | |
1139 |
|
1136 | |||
1140 | // get the parameters for the data shaping [BW SP0 SP1 R0 R1] in sy_lfr_common1 and configure the register |
|
1137 | // get the parameters for the data shaping [BW SP0 SP1 R0 R1] in sy_lfr_common1 and configure the register | |
1141 | // waveform picker : [R1 R0 SP1 SP0 BW] |
|
1138 | // waveform picker : [R1 R0 SP1 SP0 BW] | |
1142 |
|
1139 | |||
1143 | data_shaping = parameter_dump_packet.sy_lfr_common_parameters; |
|
1140 | data_shaping = parameter_dump_packet.sy_lfr_common_parameters; | |
1144 |
|
1141 | |||
1145 | waveform_picker_regs->data_shaping = |
|
1142 | waveform_picker_regs->data_shaping = | |
1146 | ( (data_shaping & BIT_5) >> SHIFT_5_BITS ) // BW |
|
1143 | ( (data_shaping & BIT_5) >> SHIFT_5_BITS ) // BW | |
1147 | + ( (data_shaping & BIT_4) >> SHIFT_3_BITS ) // SP0 |
|
1144 | + ( (data_shaping & BIT_4) >> SHIFT_3_BITS ) // SP0 | |
1148 | + ( (data_shaping & BIT_3) >> 1 ) // SP1 |
|
1145 | + ( (data_shaping & BIT_3) >> 1 ) // SP1 | |
1149 | + ( (data_shaping & BIT_2) << 1 ) // R0 |
|
1146 | + ( (data_shaping & BIT_2) << 1 ) // R0 | |
1150 | + ( (data_shaping & BIT_1) << SHIFT_3_BITS ) // R1 |
|
1147 | + ( (data_shaping & BIT_1) << SHIFT_3_BITS ) // R1 | |
1151 | + ( (data_shaping & BIT_0) << SHIFT_5_BITS ); // R2 |
|
1148 | + ( (data_shaping & BIT_0) << SHIFT_5_BITS ); // R2 | |
1152 | } |
|
1149 | } | |
1153 |
|
1150 | |||
1154 | void set_wfp_burst_enable_register( unsigned char mode ) |
|
1151 | void set_wfp_burst_enable_register( unsigned char mode ) | |
1155 | { |
|
1152 | { | |
1156 | /** This function sets the waveform picker burst_enable register depending on the mode. |
|
1153 | /** This function sets the waveform picker burst_enable register depending on the mode. | |
1157 | * |
|
1154 | * | |
1158 | * @param mode is the LFR mode to launch. |
|
1155 | * @param mode is the LFR mode to launch. | |
1159 | * |
|
1156 | * | |
1160 | * The burst bits shall be before the enable bits. |
|
1157 | * The burst bits shall be before the enable bits. | |
1161 | * |
|
1158 | * | |
1162 | */ |
|
1159 | */ | |
1163 |
|
1160 | |||
1164 | // [0000 0000] burst f2, f1, f0 enable f3 f2 f1 f0 |
|
1161 | // [0000 0000] burst f2, f1, f0 enable f3 f2 f1 f0 | |
1165 | // the burst bits shall be set first, before the enable bits |
|
1162 | // the burst bits shall be set first, before the enable bits | |
1166 | switch(mode) { |
|
1163 | switch(mode) { | |
1167 | case LFR_MODE_NORMAL: |
|
1164 | case LFR_MODE_NORMAL: | |
1168 | case LFR_MODE_SBM1: |
|
1165 | case LFR_MODE_SBM1: | |
1169 | case LFR_MODE_SBM2: |
|
1166 | case LFR_MODE_SBM2: | |
1170 | waveform_picker_regs->run_burst_enable = RUN_BURST_ENABLE_SBM2; // [0110 0000] enable f2 and f1 burst |
|
1167 | waveform_picker_regs->run_burst_enable = RUN_BURST_ENABLE_SBM2; // [0110 0000] enable f2 and f1 burst | |
1171 | waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | BITS_WFP_ENABLE_ALL; // [1111] enable f3 f2 f1 f0 |
|
1168 | waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | BITS_WFP_ENABLE_ALL; // [1111] enable f3 f2 f1 f0 | |
1172 | break; |
|
1169 | break; | |
1173 | case LFR_MODE_BURST: |
|
1170 | case LFR_MODE_BURST: | |
1174 | waveform_picker_regs->run_burst_enable = RUN_BURST_ENABLE_BURST; // [0100 0000] f2 burst enabled |
|
1171 | waveform_picker_regs->run_burst_enable = RUN_BURST_ENABLE_BURST; // [0100 0000] f2 burst enabled | |
1175 | waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | BITS_WFP_ENABLE_BURST; // [1100] enable f3 and f2 |
|
1172 | waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | BITS_WFP_ENABLE_BURST; // [1100] enable f3 and f2 | |
1176 | break; |
|
1173 | break; | |
1177 | default: |
|
1174 | default: | |
1178 | waveform_picker_regs->run_burst_enable = INIT_CHAR; // [0000 0000] no burst enabled, no waveform enabled |
|
1175 | waveform_picker_regs->run_burst_enable = INIT_CHAR; // [0000 0000] no burst enabled, no waveform enabled | |
1179 | break; |
|
1176 | break; | |
1180 | } |
|
1177 | } | |
1181 | } |
|
1178 | } | |
1182 |
|
1179 | |||
1183 | void set_wfp_delta_snapshot( void ) |
|
1180 | void set_wfp_delta_snapshot( void ) | |
1184 | { |
|
1181 | { | |
1185 | /** This function sets the delta_snapshot register of the waveform picker module. |
|
1182 | /** This function sets the delta_snapshot register of the waveform picker module. | |
1186 | * |
|
1183 | * | |
1187 | * The value is read from two (unsigned char) of the parameter_dump_packet structure: |
|
1184 | * The value is read from two (unsigned char) of the parameter_dump_packet structure: | |
1188 | * - sy_lfr_n_swf_p[0] |
|
1185 | * - sy_lfr_n_swf_p[0] | |
1189 | * - sy_lfr_n_swf_p[1] |
|
1186 | * - sy_lfr_n_swf_p[1] | |
1190 | * |
|
1187 | * | |
1191 | */ |
|
1188 | */ | |
1192 |
|
1189 | |||
1193 | unsigned int delta_snapshot; |
|
1190 | unsigned int delta_snapshot; | |
1194 | unsigned int delta_snapshot_in_T2; |
|
1191 | unsigned int delta_snapshot_in_T2; | |
1195 |
|
1192 | |||
1196 | delta_snapshot = (parameter_dump_packet.sy_lfr_n_swf_p[0] * CONST_256) |
|
1193 | delta_snapshot = (parameter_dump_packet.sy_lfr_n_swf_p[0] * CONST_256) | |
1197 | + parameter_dump_packet.sy_lfr_n_swf_p[1]; |
|
1194 | + parameter_dump_packet.sy_lfr_n_swf_p[1]; | |
1198 |
|
1195 | |||
1199 | delta_snapshot_in_T2 = delta_snapshot * FREQ_F2; |
|
1196 | delta_snapshot_in_T2 = delta_snapshot * FREQ_F2; | |
1200 | waveform_picker_regs->delta_snapshot = delta_snapshot_in_T2 - 1; // max 4 bytes |
|
1197 | waveform_picker_regs->delta_snapshot = delta_snapshot_in_T2 - 1; // max 4 bytes | |
1201 | } |
|
1198 | } | |
1202 |
|
1199 | |||
1203 | void set_wfp_delta_f0_f0_2( void ) |
|
1200 | void set_wfp_delta_f0_f0_2( void ) | |
1204 | { |
|
1201 | { | |
1205 | unsigned int delta_snapshot; |
|
1202 | unsigned int delta_snapshot; | |
1206 | unsigned int nb_samples_per_snapshot; |
|
1203 | unsigned int nb_samples_per_snapshot; | |
1207 | float delta_f0_in_float; |
|
1204 | float delta_f0_in_float; | |
1208 |
|
1205 | |||
1209 | delta_snapshot = waveform_picker_regs->delta_snapshot; |
|
1206 | delta_snapshot = waveform_picker_regs->delta_snapshot; | |
1210 | nb_samples_per_snapshot = (parameter_dump_packet.sy_lfr_n_swf_l[0] * CONST_256) + parameter_dump_packet.sy_lfr_n_swf_l[1]; |
|
1207 | nb_samples_per_snapshot = (parameter_dump_packet.sy_lfr_n_swf_l[0] * CONST_256) + parameter_dump_packet.sy_lfr_n_swf_l[1]; | |
1211 | delta_f0_in_float = (nb_samples_per_snapshot / 2.) * ( (1. / FREQ_F2) - (1. / FREQ_F0) ) * FREQ_F2; |
|
1208 | delta_f0_in_float = (nb_samples_per_snapshot / 2.) * ( (1. / FREQ_F2) - (1. / FREQ_F0) ) * FREQ_F2; | |
1212 |
|
1209 | |||
1213 | waveform_picker_regs->delta_f0 = delta_snapshot - floor( delta_f0_in_float ); |
|
1210 | waveform_picker_regs->delta_f0 = delta_snapshot - floor( delta_f0_in_float ); | |
1214 | waveform_picker_regs->delta_f0_2 = DFLT_WFP_DELTA_F0_2; |
|
1211 | waveform_picker_regs->delta_f0_2 = DFLT_WFP_DELTA_F0_2; | |
1215 | } |
|
1212 | } | |
1216 |
|
1213 | |||
1217 | void set_wfp_delta_f1( void ) |
|
1214 | void set_wfp_delta_f1( void ) | |
1218 | { |
|
1215 | { | |
1219 | /** Sets the value of the delta_f1 parameter |
|
1216 | /** Sets the value of the delta_f1 parameter | |
1220 | * |
|
1217 | * | |
1221 | * @param void |
|
1218 | * @param void | |
1222 | * |
|
1219 | * | |
1223 | * @return void |
|
1220 | * @return void | |
1224 | * |
|
1221 | * | |
1225 | * delta_f1 is not used, the snapshots are extracted from CWF_F1 waveforms. |
|
1222 | * delta_f1 is not used, the snapshots are extracted from CWF_F1 waveforms. | |
1226 | * |
|
1223 | * | |
1227 | */ |
|
1224 | */ | |
1228 |
|
1225 | |||
1229 | unsigned int delta_snapshot; |
|
1226 | unsigned int delta_snapshot; | |
1230 | unsigned int nb_samples_per_snapshot; |
|
1227 | unsigned int nb_samples_per_snapshot; | |
1231 | float delta_f1_in_float; |
|
1228 | float delta_f1_in_float; | |
1232 |
|
1229 | |||
1233 | delta_snapshot = waveform_picker_regs->delta_snapshot; |
|
1230 | delta_snapshot = waveform_picker_regs->delta_snapshot; | |
1234 | nb_samples_per_snapshot = (parameter_dump_packet.sy_lfr_n_swf_l[0] * CONST_256) + parameter_dump_packet.sy_lfr_n_swf_l[1]; |
|
1231 | nb_samples_per_snapshot = (parameter_dump_packet.sy_lfr_n_swf_l[0] * CONST_256) + parameter_dump_packet.sy_lfr_n_swf_l[1]; | |
1235 | delta_f1_in_float = (nb_samples_per_snapshot / 2.) * ( (1. / FREQ_F2) - (1. / FREQ_F1) ) * FREQ_F2; |
|
1232 | delta_f1_in_float = (nb_samples_per_snapshot / 2.) * ( (1. / FREQ_F2) - (1. / FREQ_F1) ) * FREQ_F2; | |
1236 |
|
1233 | |||
1237 | waveform_picker_regs->delta_f1 = delta_snapshot - floor( delta_f1_in_float ); |
|
1234 | waveform_picker_regs->delta_f1 = delta_snapshot - floor( delta_f1_in_float ); | |
1238 | } |
|
1235 | } | |
1239 |
|
1236 | |||
1240 | void set_wfp_delta_f2( void ) // parameter not used, only delta_f0 and delta_f0_2 are used |
|
1237 | void set_wfp_delta_f2( void ) // parameter not used, only delta_f0 and delta_f0_2 are used | |
1241 | { |
|
1238 | { | |
1242 | /** Sets the value of the delta_f2 parameter |
|
1239 | /** Sets the value of the delta_f2 parameter | |
1243 | * |
|
1240 | * | |
1244 | * @param void |
|
1241 | * @param void | |
1245 | * |
|
1242 | * | |
1246 | * @return void |
|
1243 | * @return void | |
1247 | * |
|
1244 | * | |
1248 | * delta_f2 is used only for the first snapshot generation, even when the snapshots are extracted from CWF_F2 |
|
1245 | * delta_f2 is used only for the first snapshot generation, even when the snapshots are extracted from CWF_F2 | |
1249 | * waveforms (see lpp_waveform_snapshot_controler.vhd for details). |
|
1246 | * waveforms (see lpp_waveform_snapshot_controler.vhd for details). | |
1250 | * |
|
1247 | * | |
1251 | */ |
|
1248 | */ | |
1252 |
|
1249 | |||
1253 | unsigned int delta_snapshot; |
|
1250 | unsigned int delta_snapshot; | |
1254 | unsigned int nb_samples_per_snapshot; |
|
1251 | unsigned int nb_samples_per_snapshot; | |
1255 |
|
1252 | |||
1256 | delta_snapshot = waveform_picker_regs->delta_snapshot; |
|
1253 | delta_snapshot = waveform_picker_regs->delta_snapshot; | |
1257 | nb_samples_per_snapshot = (parameter_dump_packet.sy_lfr_n_swf_l[0] * CONST_256) + parameter_dump_packet.sy_lfr_n_swf_l[1]; |
|
1254 | nb_samples_per_snapshot = (parameter_dump_packet.sy_lfr_n_swf_l[0] * CONST_256) + parameter_dump_packet.sy_lfr_n_swf_l[1]; | |
1258 |
|
1255 | |||
1259 | waveform_picker_regs->delta_f2 = delta_snapshot - (nb_samples_per_snapshot / 2) - 1; |
|
1256 | waveform_picker_regs->delta_f2 = delta_snapshot - (nb_samples_per_snapshot / 2) - 1; | |
1260 | } |
|
1257 | } | |
1261 |
|
1258 | |||
1262 | //***************** |
|
1259 | //***************** | |
1263 | // local parameters |
|
1260 | // local parameters | |
1264 |
|
1261 | |||
1265 | void increment_seq_counter_source_id( unsigned char *packet_sequence_control, unsigned int sid ) |
|
1262 | void increment_seq_counter_source_id( unsigned char *packet_sequence_control, unsigned int sid ) | |
1266 | { |
|
1263 | { | |
1267 | /** This function increments the parameter "sequence_cnt" depending on the sid passed in argument. |
|
1264 | /** This function increments the parameter "sequence_cnt" depending on the sid passed in argument. | |
1268 | * |
|
1265 | * | |
1269 | * @param packet_sequence_control is a pointer toward the parameter sequence_cnt to update. |
|
1266 | * @param packet_sequence_control is a pointer toward the parameter sequence_cnt to update. | |
1270 | * @param sid is the source identifier of the packet being updated. |
|
1267 | * @param sid is the source identifier of the packet being updated. | |
1271 | * |
|
1268 | * | |
1272 | * REQ-LFR-SRS-5240 / SSS-CP-FS-590 |
|
1269 | * REQ-LFR-SRS-5240 / SSS-CP-FS-590 | |
1273 | * The sequence counters shall wrap around from 2^14 to zero. |
|
1270 | * The sequence counters shall wrap around from 2^14 to zero. | |
1274 | * The sequence counter shall start at zero at startup. |
|
1271 | * The sequence counter shall start at zero at startup. | |
1275 | * |
|
1272 | * | |
1276 | * REQ-LFR-SRS-5239 / SSS-CP-FS-580 |
|
1273 | * REQ-LFR-SRS-5239 / SSS-CP-FS-580 | |
1277 | * All TM_LFR_SCIENCE_ packets are sent to ground, i.e. destination id = 0 |
|
1274 | * All TM_LFR_SCIENCE_ packets are sent to ground, i.e. destination id = 0 | |
1278 | * |
|
1275 | * | |
1279 | */ |
|
1276 | */ | |
1280 |
|
1277 | |||
1281 | unsigned short *sequence_cnt; |
|
1278 | unsigned short *sequence_cnt; | |
1282 | unsigned short segmentation_grouping_flag; |
|
1279 | unsigned short segmentation_grouping_flag; | |
1283 | unsigned short new_packet_sequence_control; |
|
1280 | unsigned short new_packet_sequence_control; | |
1284 | rtems_mode initial_mode_set; |
|
1281 | rtems_mode initial_mode_set; | |
1285 | rtems_mode current_mode_set; |
|
1282 | rtems_mode current_mode_set; | |
1286 | rtems_status_code status; |
|
1283 | rtems_status_code status; | |
1287 |
|
1284 | |||
1288 | initial_mode_set = RTEMS_DEFAULT_MODES; |
|
1285 | initial_mode_set = RTEMS_DEFAULT_MODES; | |
1289 | current_mode_set = RTEMS_DEFAULT_MODES; |
|
1286 | current_mode_set = RTEMS_DEFAULT_MODES; | |
1290 | sequence_cnt = NULL; |
|
1287 | sequence_cnt = NULL; | |
1291 |
|
1288 | |||
1292 | //****************************************** |
|
1289 | //****************************************** | |
1293 | // CHANGE THE MODE OF THE CALLING RTEMS TASK |
|
1290 | // CHANGE THE MODE OF THE CALLING RTEMS TASK | |
1294 | status = rtems_task_mode( RTEMS_NO_PREEMPT, RTEMS_PREEMPT_MASK, &initial_mode_set ); |
|
1291 | status = rtems_task_mode( RTEMS_NO_PREEMPT, RTEMS_PREEMPT_MASK, &initial_mode_set ); | |
1295 |
|
1292 | |||
1296 | if ( (sid == SID_NORM_SWF_F0) || (sid == SID_NORM_SWF_F1) || (sid == SID_NORM_SWF_F2) |
|
1293 | if ( (sid == SID_NORM_SWF_F0) || (sid == SID_NORM_SWF_F1) || (sid == SID_NORM_SWF_F2) | |
1297 | || (sid == SID_NORM_CWF_F3) || (sid == SID_NORM_CWF_LONG_F3) |
|
1294 | || (sid == SID_NORM_CWF_F3) || (sid == SID_NORM_CWF_LONG_F3) | |
1298 | || (sid == SID_BURST_CWF_F2) |
|
1295 | || (sid == SID_BURST_CWF_F2) | |
1299 | || (sid == SID_NORM_ASM_F0) || (sid == SID_NORM_ASM_F1) || (sid == SID_NORM_ASM_F2) |
|
1296 | || (sid == SID_NORM_ASM_F0) || (sid == SID_NORM_ASM_F1) || (sid == SID_NORM_ASM_F2) | |
1300 | || (sid == SID_NORM_BP1_F0) || (sid == SID_NORM_BP1_F1) || (sid == SID_NORM_BP1_F2) |
|
1297 | || (sid == SID_NORM_BP1_F0) || (sid == SID_NORM_BP1_F1) || (sid == SID_NORM_BP1_F2) | |
1301 | || (sid == SID_NORM_BP2_F0) || (sid == SID_NORM_BP2_F1) || (sid == SID_NORM_BP2_F2) |
|
1298 | || (sid == SID_NORM_BP2_F0) || (sid == SID_NORM_BP2_F1) || (sid == SID_NORM_BP2_F2) | |
1302 | || (sid == SID_BURST_BP1_F0) || (sid == SID_BURST_BP2_F0) |
|
1299 | || (sid == SID_BURST_BP1_F0) || (sid == SID_BURST_BP2_F0) | |
1303 | || (sid == SID_BURST_BP1_F1) || (sid == SID_BURST_BP2_F1) ) |
|
1300 | || (sid == SID_BURST_BP1_F1) || (sid == SID_BURST_BP2_F1) ) | |
1304 | { |
|
1301 | { | |
1305 | sequence_cnt = (unsigned short *) &sequenceCounters_SCIENCE_NORMAL_BURST; |
|
1302 | sequence_cnt = (unsigned short *) &sequenceCounters_SCIENCE_NORMAL_BURST; | |
1306 | } |
|
1303 | } | |
1307 | else if ( (sid ==SID_SBM1_CWF_F1) || (sid ==SID_SBM2_CWF_F2) |
|
1304 | else if ( (sid ==SID_SBM1_CWF_F1) || (sid ==SID_SBM2_CWF_F2) | |
1308 | || (sid == SID_SBM1_BP1_F0) || (sid == SID_SBM1_BP2_F0) |
|
1305 | || (sid == SID_SBM1_BP1_F0) || (sid == SID_SBM1_BP2_F0) | |
1309 | || (sid == SID_SBM2_BP1_F0) || (sid == SID_SBM2_BP2_F0) |
|
1306 | || (sid == SID_SBM2_BP1_F0) || (sid == SID_SBM2_BP2_F0) | |
1310 | || (sid == SID_SBM2_BP1_F1) || (sid == SID_SBM2_BP2_F1) ) |
|
1307 | || (sid == SID_SBM2_BP1_F1) || (sid == SID_SBM2_BP2_F1) ) | |
1311 | { |
|
1308 | { | |
1312 | sequence_cnt = (unsigned short *) &sequenceCounters_SCIENCE_SBM1_SBM2; |
|
1309 | sequence_cnt = (unsigned short *) &sequenceCounters_SCIENCE_SBM1_SBM2; | |
1313 | } |
|
1310 | } | |
1314 | else |
|
1311 | else | |
1315 | { |
|
1312 | { | |
1316 | sequence_cnt = (unsigned short *) NULL; |
|
1313 | sequence_cnt = (unsigned short *) NULL; | |
1317 | PRINTF1("in increment_seq_counter_source_id *** ERR apid_destid %d not known\n", sid) |
|
1314 | PRINTF1("in increment_seq_counter_source_id *** ERR apid_destid %d not known\n", sid) | |
1318 | } |
|
1315 | } | |
1319 |
|
1316 | |||
1320 | if (sequence_cnt != NULL) |
|
1317 | if (sequence_cnt != NULL) | |
1321 | { |
|
1318 | { | |
1322 | segmentation_grouping_flag = TM_PACKET_SEQ_CTRL_STANDALONE << SHIFT_1_BYTE; |
|
1319 | segmentation_grouping_flag = TM_PACKET_SEQ_CTRL_STANDALONE << SHIFT_1_BYTE; | |
1323 | *sequence_cnt = (*sequence_cnt) & SEQ_CNT_MASK; |
|
1320 | *sequence_cnt = (*sequence_cnt) & SEQ_CNT_MASK; | |
1324 |
|
1321 | |||
1325 | new_packet_sequence_control = segmentation_grouping_flag | (*sequence_cnt) ; |
|
1322 | new_packet_sequence_control = segmentation_grouping_flag | (*sequence_cnt) ; | |
1326 |
|
1323 | |||
1327 | packet_sequence_control[0] = (unsigned char) (new_packet_sequence_control >> SHIFT_1_BYTE); |
|
1324 | packet_sequence_control[0] = (unsigned char) (new_packet_sequence_control >> SHIFT_1_BYTE); | |
1328 | packet_sequence_control[1] = (unsigned char) (new_packet_sequence_control ); |
|
1325 | packet_sequence_control[1] = (unsigned char) (new_packet_sequence_control ); | |
1329 |
|
1326 | |||
1330 | // increment the sequence counter |
|
1327 | // increment the sequence counter | |
1331 | if ( *sequence_cnt < SEQ_CNT_MAX) |
|
1328 | if ( *sequence_cnt < SEQ_CNT_MAX) | |
1332 | { |
|
1329 | { | |
1333 | *sequence_cnt = *sequence_cnt + 1; |
|
1330 | *sequence_cnt = *sequence_cnt + 1; | |
1334 | } |
|
1331 | } | |
1335 | else |
|
1332 | else | |
1336 | { |
|
1333 | { | |
1337 | *sequence_cnt = 0; |
|
1334 | *sequence_cnt = 0; | |
1338 | } |
|
1335 | } | |
1339 | } |
|
1336 | } | |
1340 |
|
1337 | |||
1341 | //************************************* |
|
1338 | //************************************* | |
1342 | // RESTORE THE MODE OF THE CALLING TASK |
|
1339 | // RESTORE THE MODE OF THE CALLING TASK | |
1343 | status = rtems_task_mode( initial_mode_set, RTEMS_PREEMPT_MASK, ¤t_mode_set ); |
|
1340 | status = rtems_task_mode( initial_mode_set, RTEMS_PREEMPT_MASK, ¤t_mode_set ); | |
1344 | } |
|
1341 | } | |
|
1342 |
General Comments 0
You need to be logged in to leave comments.
Login now