diff --git a/FSW-qt/Makefile b/FSW-qt/Makefile --- a/FSW-qt/Makefile +++ b/FSW-qt/Makefile @@ -1,6 +1,6 @@ ############################################################################# # Makefile for building: bin/fsw-vhdl-dev -# Generated by qmake (2.01a) (Qt 4.8.5) on: Mon Jan 27 07:11:41 2014 +# Generated by qmake (2.01a) (Qt 4.8.5) on: Thu Feb 6 09:29:25 2014 # Project: fsw-qt.pro # Template: app # Command: /usr/bin/qmake-qt4 -spec /usr/lib64/qt4/mkspecs/linux-g++ -o Makefile fsw-qt.pro diff --git a/FSW-qt/fsw-qt.pro.user b/FSW-qt/fsw-qt.pro.user --- a/FSW-qt/fsw-qt.pro.user +++ b/FSW-qt/fsw-qt.pro.user @@ -1,10 +1,10 @@ - + ProjectExplorer.Project.ActiveTarget - 0 + 1 ProjectExplorer.Project.EditorSettings @@ -25,7 +25,7 @@ 2 - System + UTF-8 false 4 false @@ -51,14 +51,14 @@ ProjectExplorer.Project.Target.0 - Desktop-Qt 4.8.2 in PATH (System) - Desktop-Qt 4.8.2 in PATH (System) - {5289e843-9ef2-45ce-88c6-ad27d8e08def} + Desktop + Desktop + {e04e3924-0bd8-4708-be18-f1474e45608e} 0 0 - 1 + 0 - /opt/DEV_PLE/FSW-qt + true @@ -66,7 +66,7 @@ QtProjectManager.QMakeBuildStep false - true + false false @@ -80,7 +80,7 @@ -r false - -r -w -j 4 + 2 @@ -99,7 +99,7 @@ -r true - -r -w clean + clean 1 @@ -110,14 +110,93 @@ 2 false - Qt 4.8.2 in PATH (System) Release + Release Qt4ProjectManager.Qt4BuildConfiguration 0 - false + true + + 1 + + + 0 + Deploy + + ProjectExplorer.BuildSteps.Deploy + + 1 + Deploy locally + + ProjectExplorer.DefaultDeployConfiguration - - /opt/DEV_PLE/FSW-qt + 1 + + + + false + false + false + false + true + 0.01 + 10 + true + 1 + 25 + + 1 + true + false + true + valgrind + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + + 2 + + fsw-qt + + Qt4ProjectManager.Qt4RunConfiguration:/opt/DEV_PLE/FSW-qt/fsw-qt.pro + + fsw-qt.pro + false + true + + 3768 + false + true + false + false + true + + 1 + + + + ProjectExplorer.Project.Target.1 + + Desktop-Qt 4.8.2 in PATH (System) + Desktop-Qt 4.8.2 in PATH (System) + {5289e843-9ef2-45ce-88c6-ad27d8e08def} + 0 + 0 + 0 + + true @@ -125,7 +204,7 @@ QtProjectManager.QMakeBuildStep false - true + false false @@ -139,7 +218,7 @@ -r false - -r -w + 2 @@ -158,7 +237,7 @@ -r true - -r -w clean + clean 1 @@ -169,13 +248,13 @@ 2 false - Qt 4.8.2 in PATH (System) Debug + Release Qt4ProjectManager.Qt4BuildConfiguration - 2 - false + 0 + true - 2 + 1 0 @@ -184,7 +263,7 @@ ProjectExplorer.BuildSteps.Deploy 1 - No deployment + Deploy locally ProjectExplorer.DefaultDeployConfiguration @@ -240,65 +319,14 @@ false false false - false - - - - false - false - false - false - true - 0.01 - 10 - true - 1 - 25 - - 1 - true - false - true - valgrind - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - - 2 - - - doxygen - true - /opt/DEV_PLE/doc - Run doxygen - - ProjectExplorer.CustomExecutableRunConfiguration - 3768 - true - false - false - false true - 2 + 1 ProjectExplorer.Project.TargetCount - 1 + 2 ProjectExplorer.Project.Updater.EnvironmentId diff --git a/header/ccsds_types.h b/header/ccsds_types.h --- a/header/ccsds_types.h +++ b/header/ccsds_types.h @@ -210,19 +210,21 @@ enum apid_destid{ // R1 #define TM_LEN_SCI_SWF_340 4101 // 340 * 12 + 10 + 12 - 1 #define TM_LEN_SCI_SWF_8 117 // 8 * 12 + 10 + 12 - 1 -// R2 -#define TM_LEN_SCI_SWF_304 3669 // 304 * 12 + 10 + 12 - 1 -#define TM_LEN_SCI_SWF_224 2709 // 224 * 12 + 10 + 12 - 1 -// #define TM_LEN_SCI_CWF_340 4099 // 340 * 12 + 10 + 10 - 1 #define TM_LEN_SCI_CWF_8 115 // 8 * 12 + 10 + 10 - 1 #define TM_LEN_SCI_CWF3_LIGHT_340 2059 // 340 * 6 + 10 + 10 - 1 #define TM_LEN_SCI_CWF3_LIGHT_8 67 // 8 * 6 + 10 + 10 - 1 -#define DEFAULT_PKTCNT 0x07 -#define BLK_NR_340 0x0154 -#define BLK_NR_8 0x0008 -#define BLK_NR_304 0x0130 -#define BLK_NR_224 0x00e0 +// R2 +#define TM_LEN_SCI_SWF_304 3669 // 304 * 12 + 10 + 12 - 1 +#define TM_LEN_SCI_SWF_224 2709 // 224 * 12 + 10 + 12 - 1 +#define TM_LEN_SCI_CWF_336 4051 // 336 * 12 + 10 + 10 - 1 +#define TM_LEN_SCI_CWF_672 4051 // 672 * 6 + 10 + 10 - 1 +// +#define DEFAULT_PKTCNT 0x07 +#define BLK_NR_304 0x0130 +#define BLK_NR_224 0x00e0 +#define BLK_NR_CWF 0x0150 // 336 +#define BLK_NR_CWF_SHORT_F3 0x02a0 // 672 enum TM_TYPE{ TM_LFR_TC_EXE_OK, diff --git a/header/fsw_params.h b/header/fsw_params.h --- a/header/fsw_params.h +++ b/header/fsw_params.h @@ -9,6 +9,14 @@ #define GRSPW_DEVICE_NAME "/dev/grspw0" #define UART_DEVICE_NAME "/dev/console" +typedef struct ring_node +{ + struct ring_node *previous; + int buffer_address; + struct ring_node *next; + unsigned int status; +} ring_node; + //************************ // flight software version // this parameters is handled by the Qt project options @@ -16,14 +24,18 @@ //#define NB_SAMPLES_PER_SNAPSHOT 2048 #define NB_SAMPLES_PER_SNAPSHOT 2352 // 336 * 7 = 2352 #define TIME_OFFSET 2 +#define TIME_OFFSET_IN_BYTES 8 #define WAVEFORM_EXTENDED_HEADER_OFFSET 22 #define NB_BYTES_SWF_BLK (2 * 6) #define NB_WORDS_SWF_BLK 3 #define NB_BYTES_CWF3_LIGHT_BLK 6 #define WFRM_INDEX_OF_LAST_PACKET 6 // waveforms are transmitted in groups of 2048 blocks, 6 packets of 340 and 1 of 8 -#define NB_RING_NODES_F0 3 // AT LEAST 3 -#define NB_RING_NODES_F1 5 // AT LEAST 3 -#define NB_RING_NODES_F2 5 // AT LEAST 3 +#define NB_RING_NODES_F0 3 // AT LEAST 3 +#define NB_RING_NODES_F1 5 // AT LEAST 3 +#define NB_RING_NODES_F2 5 // AT LEAST 3 +#define NB_RING_NODES_ASM_F0 8 // AT LEAST 3 +#define NB_RING_NODES_ASM_F1 2 // AT LEAST 3 +#define NB_RING_NODES_ASM_F2 2 // AT LEAST 3 //********** // LFR MODES diff --git a/header/fsw_params_processing.h b/header/fsw_params_processing.h --- a/header/fsw_params_processing.h +++ b/header/fsw_params_processing.h @@ -1,10 +1,10 @@ #ifndef FSW_PARAMS_PROCESSING_H #define FSW_PARAMS_PROCESSING_H -#define NB_BINS_PER_SM 128 -#define NB_VALUES_PER_SM 25 -#define TOTAL_SIZE_SM 0 -#define SM_HEADER 0 +#define NB_BINS_PER_SM 128 // +#define NB_VALUES_PER_SM 25 // +#define TOTAL_SIZE_SM 3200 // 25 * 128 +#define SM_HEADER 0 // #define NB_BINS_COMPRESSED_SM_F0 11 #define NB_BINS_COMPRESSED_SM_F1 13 diff --git a/header/fsw_processing.h b/header/fsw_processing.h --- a/header/fsw_processing.h +++ b/header/fsw_processing.h @@ -11,24 +11,9 @@ #include "fsw_params.h" #include "fsw_spacewire.h" -extern volatile int spec_mat_f0_0[ ]; -extern volatile int spec_mat_f0_1[ ]; -extern volatile int spec_mat_f0_a[ ]; -extern volatile int spec_mat_f0_b[ ]; -extern volatile int spec_mat_f0_c[ ]; -extern volatile int spec_mat_f0_d[ ]; -extern volatile int spec_mat_f0_e[ ]; -extern volatile int spec_mat_f0_f[ ]; -extern volatile int spec_mat_f0_g[ ]; -extern volatile int spec_mat_f0_h[ ]; - -extern volatile int spec_mat_f1[ ]; -extern volatile int spec_mat_f2[ ]; - -extern volatile int spec_mat_f1_bis[ ]; -extern volatile int spec_mat_f2_bis[ ]; -extern volatile int spec_mat_f0_0_bis[ ]; -extern volatile int spec_mat_f0_1_bis[ ]; +extern volatile int sm_f0[ ][ SM_HEADER + TOTAL_SIZE_SM ]; +extern volatile int sm_f1[ ][ SM_HEADER + TOTAL_SIZE_SM ]; +extern volatile int sm_f2[ ][ SM_HEADER + TOTAL_SIZE_SM ]; // parameters extern struct param_local_str param_local; @@ -40,6 +25,9 @@ extern spectral_matrix_regs_t *spectral_ extern rtems_name misc_name[5]; extern rtems_id Task_id[20]; /* array of task ids */ +// +void init_asm_rings( void ); + // ISR rtems_isr spectral_matrices_isr( rtems_vector_number vector ); rtems_isr spectral_matrices_isr_simu( rtems_vector_number vector ); diff --git a/header/wf_handler.h b/header/wf_handler.h --- a/header/wf_handler.h +++ b/header/wf_handler.h @@ -12,14 +12,6 @@ #define pi 3.1415 -typedef struct ring_node -{ - struct ring_node *previous; - int buffer_address; - struct ring_node *next; - unsigned int status; -} ring_node; - extern int fdSPW; //***************** @@ -73,6 +65,8 @@ int send_waveform_CWF( volatile int *wa int send_waveform_CWF3( volatile int *waveform, unsigned int sid, Header_TM_LFR_SCIENCE_CWF_t *headerCWF, rtems_id queue_id ); int send_waveform_CWF3_light( volatile int *waveform, Header_TM_LFR_SCIENCE_CWF_t *headerCWF, rtems_id queue_id ); // +void compute_acquisition_time(unsigned int *coarseTime, unsigned int *fineTime, unsigned int sid, unsigned char pa_lfr_pkt_nr ); +// rtems_id get_pkts_queue_id( void ); //************** diff --git a/src/fsw_globals.c b/src/fsw_globals.c --- a/src/fsw_globals.c +++ b/src/fsw_globals.c @@ -39,29 +39,14 @@ volatile int wf_snap_f0[ NB_RING_NODES_F volatile int wf_snap_f1[ NB_RING_NODES_F1 ][ (NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK) + TIME_OFFSET + 46 ] __attribute__((aligned(0x100))); volatile int wf_snap_f2[ NB_RING_NODES_F2 ][ (NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK) + TIME_OFFSET + 46 ] __attribute__((aligned(0x100))); // F3 -volatile int wf_cont_f3_a[ NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK + TIME_OFFSET ] __attribute__((aligned(0x100))); -volatile int wf_cont_f3_b[ NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK + TIME_OFFSET ] __attribute__((aligned(0x100))); -char wf_cont_f3_light[ NB_SAMPLES_PER_SNAPSHOT * NB_BYTES_CWF3_LIGHT_BLK ] __attribute__((aligned(0x100))); +volatile int wf_cont_f3_a [ (NB_SAMPLES_PER_SNAPSHOT) * NB_WORDS_SWF_BLK + TIME_OFFSET ] __attribute__((aligned(0x100))); +volatile int wf_cont_f3_b [ (NB_SAMPLES_PER_SNAPSHOT) * NB_WORDS_SWF_BLK + TIME_OFFSET ] __attribute__((aligned(0x100))); +char wf_cont_f3_light[ (NB_SAMPLES_PER_SNAPSHOT) * NB_BYTES_CWF3_LIGHT_BLK + TIME_OFFSET_IN_BYTES ] __attribute__((aligned(0x100))); // SPECTRAL MATRICES GLOBAL VARIABLES -volatile int spec_mat_f0_0[ SM_HEADER + TOTAL_SIZE_SM ]; -volatile int spec_mat_f0_1[ SM_HEADER + TOTAL_SIZE_SM ]; -volatile int spec_mat_f0_a[ SM_HEADER + TOTAL_SIZE_SM ]; -volatile int spec_mat_f0_b[ SM_HEADER + TOTAL_SIZE_SM ]; -volatile int spec_mat_f0_c[ SM_HEADER + TOTAL_SIZE_SM ]; -volatile int spec_mat_f0_d[ SM_HEADER + TOTAL_SIZE_SM ]; -volatile int spec_mat_f0_e[ SM_HEADER + TOTAL_SIZE_SM ]; -volatile int spec_mat_f0_f[ SM_HEADER + TOTAL_SIZE_SM ]; -volatile int spec_mat_f0_g[ SM_HEADER + TOTAL_SIZE_SM ]; -volatile int spec_mat_f0_h[ SM_HEADER + TOTAL_SIZE_SM ]; -volatile int spec_mat_f0_0_bis[ SM_HEADER + TOTAL_SIZE_SM ]; -volatile int spec_mat_f0_1_bis[ SM_HEADER + TOTAL_SIZE_SM ]; -// -volatile int spec_mat_f1[ SM_HEADER + TOTAL_SIZE_SM ]; -volatile int spec_mat_f1_bis[ SM_HEADER + TOTAL_SIZE_SM ]; -// -volatile int spec_mat_f2[ SM_HEADER + TOTAL_SIZE_SM ]; -volatile int spec_mat_f2_bis[ SM_HEADER + TOTAL_SIZE_SM ]; +volatile int sm_f0[ NB_RING_NODES_ASM_F0 ][ SM_HEADER + TOTAL_SIZE_SM ]; +volatile int sm_f1[ NB_RING_NODES_ASM_F1 ][ SM_HEADER + TOTAL_SIZE_SM ]; +volatile int sm_f2[ NB_RING_NODES_ASM_F2 ][ SM_HEADER + TOTAL_SIZE_SM ]; // APB CONFIGURATION REGISTERS time_management_regs_t *time_management_regs = (time_management_regs_t*) REGS_ADDR_TIME_MANAGEMENT; diff --git a/src/fsw_processing.c b/src/fsw_processing.c --- a/src/fsw_processing.c +++ b/src/fsw_processing.c @@ -11,10 +11,48 @@ #include "fsw_processing_globals.c" +//************************ +// spectral matrices rings +ring_node sm_ring_f0[NB_RING_NODES_ASM_F0]; +ring_node sm_ring_f1[NB_RING_NODES_ASM_F1]; +ring_node sm_ring_f2[NB_RING_NODES_ASM_F2]; +ring_node *current_ring_node_sm_f0; +ring_node *current_ring_node_sm_f1; +ring_node *current_ring_node_sm_f2; + BP1_t data_BP1[ NB_BINS_COMPRESSED_SM_F0 ]; -float averaged_spec_mat_f0[ TOTAL_SIZE_SM ]; -char averaged_spec_mat_f0_char[ TOTAL_SIZE_SM * 2 ]; -float compressed_spec_mat_f0[ TOTAL_SIZE_COMPRESSED_MATRIX_f0 ]; +float averaged_sm_f0[ TOTAL_SIZE_SM ]; +char averaged_sm_f0_char[ TOTAL_SIZE_SM * 2 ]; +float compressed_sm_f0[ TOTAL_SIZE_COMPRESSED_MATRIX_f0 ]; + +void init_asm_rings( void ) +{ + unsigned char i; + + // F0 RING + sm_ring_f0[0].next = (ring_node*) &sm_ring_f0[1]; + sm_ring_f0[0].previous = (ring_node*) &sm_ring_f0[NB_RING_NODES_ASM_F0-1]; + sm_ring_f0[0].buffer_address = (int) &sm_f0[0][0]; + + sm_ring_f0[NB_RING_NODES_ASM_F0-1].next = (ring_node*) &sm_ring_f0[0]; + sm_ring_f0[NB_RING_NODES_ASM_F0-1].previous = (ring_node*) &sm_ring_f0[NB_RING_NODES_ASM_F0-2]; + sm_ring_f0[NB_RING_NODES_ASM_F0-1].buffer_address = (int) &sm_f0[NB_RING_NODES_ASM_F0-1][0]; + + for(i=1; imatrixF0_Address0 == (int) spec_mat_f0_0) - { - spectral_matrix_regs->matrixF0_Address0 = (int) spec_mat_f0_0_bis; - } - else - { - spectral_matrix_regs->matrixF0_Address0 = (int) spec_mat_f0_0; - } + current_ring_node_sm_f0 = current_ring_node_sm_f0->next; + spectral_matrix_regs->matrixF0_Address0 = current_ring_node_sm_f0->buffer_address; spectral_matrix_regs->status = spectral_matrix_regs->status & 0xfffffffe; break; case 1: - if (spectral_matrix_regs->matrixFO_Address1 == (int) spec_mat_f0_1) - { - spectral_matrix_regs->matrixFO_Address1 = (int) spec_mat_f0_1_bis; - } - else - { - spectral_matrix_regs->matrixFO_Address1 = (int) spec_mat_f0_1; - } - spectral_matrix_regs->status = spectral_matrix_regs->status & 0xfffffffd; break; case 2: - if (spectral_matrix_regs->matrixF1_Address == (int) spec_mat_f1) - { - spectral_matrix_regs->matrixF1_Address = (int) spec_mat_f1_bis; - } - else - { - spectral_matrix_regs->matrixF1_Address = (int) spec_mat_f1; - } - spectral_matrix_regs->status = spectral_matrix_regs->status & 0xfffffffb; - break; - case 3: - if (spectral_matrix_regs->matrixF2_Address == (int) spec_mat_f2) - { - spectral_matrix_regs->matrixF2_Address = (int) spec_mat_f2_bis; - } - else - { - spectral_matrix_regs->matrixF2_Address = (int) spec_mat_f2; - } - spectral_matrix_regs->status = spectral_matrix_regs->status & 0xfffffff7; break; default: break; @@ -144,14 +147,14 @@ rtems_task avf0_task(rtems_task_argument while(1){ rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0 for(i=0; imatrixF0_Address0 = (int) spec_mat_f0_0; - spectral_matrix_regs->matrixFO_Address1 = (int) spec_mat_f0_1; - spectral_matrix_regs->matrixF1_Address = (int) spec_mat_f1; - spectral_matrix_regs->matrixF2_Address = (int) spec_mat_f2; + spectral_matrix_regs->matrixF0_Address0 = current_ring_node_sm_f0->buffer_address; + spectral_matrix_regs->matrixFO_Address1 = current_ring_node_sm_f0->buffer_address; + spectral_matrix_regs->matrixF1_Address = current_ring_node_sm_f1->buffer_address; + spectral_matrix_regs->matrixF2_Address = current_ring_node_sm_f2->buffer_address; #endif } diff --git a/src/wf_handler.c b/src/wf_handler.c --- a/src/wf_handler.c +++ b/src/wf_handler.c @@ -36,8 +36,6 @@ ring_node *current_ring_node_f2; ring_node *ring_node_to_send_swf_f2; ring_node *ring_node_to_send_cwf_f2; -unsigned char doubleSendCWF2 = 0; - rtems_isr waveforms_isr( rtems_vector_number vector ) { /** This is the interrupt sub routine called by the waveform picker core. @@ -48,6 +46,8 @@ rtems_isr waveforms_isr( rtems_vector_nu * */ + static unsigned char nb_swf = 0; + if ( (lfrCurrentMode == LFR_MODE_NORMAL) || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) ) { // in modes other than STANDBY and BURST, send the CWF_F3 data @@ -94,9 +94,15 @@ rtems_isr waveforms_isr( rtems_vector_nu if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_NORMAL ) != RTEMS_SUCCESSFUL) { rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 ); } - waveform_picker_regs->status = waveform_picker_regs->status & 0xfffff888; // [1000 1000 1000] -// rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_7 ); -// reset_wfp_burst_enable(); +// nb_swf = nb_swf + 1; +// if (nb_swf == 2) +// { +// reset_wfp_burst_enable(); +// } +// else +// { + waveform_picker_regs->status = waveform_picker_regs->status & 0xfffff888; // [1000 1000 1000] +// } } break; @@ -211,9 +217,11 @@ rtems_task wfrm_task(rtems_task_argument RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); if (event_out == RTEMS_EVENT_MODE_NORMAL) { + PRINTF1("status %x\n", waveform_picker_regs->status ) send_waveform_SWF((volatile int*) ring_node_to_send_swf_f0->buffer_address, SID_NORM_SWF_F0, headerSWF_F0, queue_id); send_waveform_SWF((volatile int*) ring_node_to_send_swf_f1->buffer_address, SID_NORM_SWF_F1, headerSWF_F1, queue_id); send_waveform_SWF((volatile int*) ring_node_to_send_swf_f2->buffer_address, SID_NORM_SWF_F2, headerSWF_F2, queue_id); + waveform_picker_regs->status = waveform_picker_regs->status & 0xfffff888; // [1000 1000 1000] } else { @@ -527,33 +535,12 @@ int init_header_continuous_wf_table( uns headerCWF[ i ].packetID[0] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST >> 8); headerCWF[ i ].packetID[1] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST); } - if (i == 0) - { - headerCWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_FIRST; - headerCWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF_340 >> 8); - headerCWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF_340 ); - headerCWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_340 >> 8); - headerCWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_340 ); - } - else if (i == 6) - { - headerCWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_LAST; - headerCWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF_8 >> 8); - headerCWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF_8 ); - headerCWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_8 >> 8); - headerCWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_8 ); - } - else - { - headerCWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_CONTINUATION; - headerCWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF_340 >> 8); - headerCWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF_340 ); - headerCWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_340 >> 8); - headerCWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_340 ); - } + headerCWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; + headerCWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF_336 >> 8); + headerCWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF_336 ); + headerCWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_CWF >> 8); + headerCWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_CWF ); headerCWF[ i ].packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT; - // PKT_CNT - // PKT_NR // DATA FIELD HEADER headerCWF[ i ].spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2; headerCWF[ i ].serviceType = TM_TYPE_LFR_SCIENCE; // service type @@ -585,30 +572,13 @@ int init_header_continuous_cwf3_light_ta headerCWF[ i ].packetID[0] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST >> 8); headerCWF[ i ].packetID[1] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST); - if (i == 0) - { - headerCWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_FIRST; - headerCWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF3_LIGHT_340 >> 8); - headerCWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF3_LIGHT_340 ); - headerCWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_340 >> 8); - headerCWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_340 ); - } - else if (i == 6) - { - headerCWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_LAST; - headerCWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF3_LIGHT_8 >> 8); - headerCWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF3_LIGHT_8 ); - headerCWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_8 >> 8); - headerCWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_8 ); - } - else - { - headerCWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_CONTINUATION; - headerCWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF3_LIGHT_340 >> 8); - headerCWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF3_LIGHT_340 ); - headerCWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_340 >> 8); - headerCWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_340 ); - } + + headerCWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; + headerCWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF_672 >> 8); + headerCWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF_672 ); + headerCWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_CWF_SHORT_F3 >> 8); + headerCWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_CWF_SHORT_F3 ); + headerCWF[ i ].packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT; // DATA FIELD HEADER headerCWF[ i ].spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2; @@ -645,6 +615,8 @@ int send_waveform_SWF( volatile int *wav unsigned int i; int ret; + unsigned int coarseTime; + unsigned int fineTime; rtems_status_code status; spw_ioctl_pkt_send spw_ioctl_send_SWF; @@ -653,30 +625,46 @@ int send_waveform_SWF( volatile int *wav ret = LFR_DEFAULT; + PRINTF1("sid = %d, ", sid) + PRINTF2("coarse = %x, fine = %x\n", waveform[0], waveform[1]) + for (i=0; i<7; i++) // send waveform { #ifdef VHDL_DEV - spw_ioctl_send_SWF.data = (char*) &waveform[ (i * 304 * NB_WORDS_SWF_BLK) + TIME_OFFSET]; + spw_ioctl_send_SWF.data = (char*) &waveform[ (i * BLK_NR_304 * NB_WORDS_SWF_BLK) + TIME_OFFSET]; #else - spw_ioctl_send_SWF.data = (char*) &waveform[ (i * 304 * NB_WORDS_SWF_BLK) ]; + spw_ioctl_send_SWF.data = (char*) &waveform[ (i * BLK_NR_304 * NB_WORDS_SWF_BLK) ]; #endif spw_ioctl_send_SWF.hdr = (char*) &headerSWF[ i ]; // BUILD THE DATA if (i==6) { - spw_ioctl_send_SWF.dlen = 224 * NB_BYTES_SWF_BLK; + spw_ioctl_send_SWF.dlen = BLK_NR_224 * NB_BYTES_SWF_BLK; } else { - spw_ioctl_send_SWF.dlen = 304 * NB_BYTES_SWF_BLK; + spw_ioctl_send_SWF.dlen = BLK_NR_304 * NB_BYTES_SWF_BLK; } // SET PACKET SEQUENCE COUNTER increment_seq_counter_source_id( headerSWF[ i ].packetSequenceControl, sid ); // SET PACKET TIME +#ifdef VHDL_DEV + coarseTime = waveform[0]; + fineTime = waveform[1]; + compute_acquisition_time( &coarseTime, &fineTime, sid, i); + + headerSWF[ i ].acquisitionTime[0] = (unsigned char) (coarseTime >> 24 ); + headerSWF[ i ].acquisitionTime[1] = (unsigned char) (coarseTime >> 16 ); + headerSWF[ i ].acquisitionTime[2] = (unsigned char) (coarseTime >> 8 ); + headerSWF[ i ].acquisitionTime[3] = (unsigned char) (coarseTime ); + headerSWF[ i ].acquisitionTime[4] = (unsigned char) (fineTime >> 8 ); + headerSWF[ i ].acquisitionTime[5] = (unsigned char) (fineTime ); +#else headerSWF[ i ].acquisitionTime[0] = (unsigned char) (time_management_regs->coarse_time>>24); headerSWF[ i ].acquisitionTime[1] = (unsigned char) (time_management_regs->coarse_time>>16); headerSWF[ i ].acquisitionTime[2] = (unsigned char) (time_management_regs->coarse_time>>8); headerSWF[ i ].acquisitionTime[3] = (unsigned char) (time_management_regs->coarse_time); headerSWF[ i ].acquisitionTime[4] = (unsigned char) (time_management_regs->fine_time>>8); headerSWF[ i ].acquisitionTime[5] = (unsigned char) (time_management_regs->fine_time); +#endif headerSWF[ i ].time[0] = (unsigned char) (time_management_regs->coarse_time>>24); headerSWF[ i ].time[1] = (unsigned char) (time_management_regs->coarse_time>>16); headerSWF[ i ].time[2] = (unsigned char) (time_management_regs->coarse_time>>8); @@ -712,6 +700,8 @@ int send_waveform_CWF(volatile int *wave unsigned int i; int ret; + unsigned char *coarseTimePtr; + unsigned char *fineTimePtr; rtems_status_code status; spw_ioctl_pkt_send spw_ioctl_send_CWF; @@ -725,21 +715,26 @@ int send_waveform_CWF(volatile int *wave int coarseTime = 0x00; int fineTime = 0x00; #ifdef VHDL_DEV - spw_ioctl_send_CWF.data = (char*) &waveform[ (i * 340 * NB_WORDS_SWF_BLK) + TIME_OFFSET]; + spw_ioctl_send_CWF.data = (char*) &waveform[ (i * BLK_NR_CWF * NB_WORDS_SWF_BLK) + TIME_OFFSET]; #else - spw_ioctl_send_CWF.data = (char*) &waveform[ (i * 340 * NB_WORDS_SWF_BLK) ]; + spw_ioctl_send_CWF.data = (char*) &waveform[ (i * BLK_NR_CWF * NB_WORDS_SWF_BLK) ]; #endif spw_ioctl_send_CWF.hdr = (char*) &headerCWF[ i ]; // BUILD THE DATA - if (i==6) { - spw_ioctl_send_CWF.dlen = 8 * NB_BYTES_SWF_BLK; - } - else { - spw_ioctl_send_CWF.dlen = 340 * NB_BYTES_SWF_BLK; - } + spw_ioctl_send_CWF.dlen = BLK_NR_CWF * NB_BYTES_SWF_BLK; // SET PACKET SEQUENCE COUNTER increment_seq_counter_source_id( headerCWF[ i ].packetSequenceControl, sid ); // SET PACKET TIME +#ifdef VHDL_DEV + coarseTimePtr = (unsigned char *) &waveform; + fineTimePtr = (unsigned char *) &waveform[1]; + headerCWF[ i ].acquisitionTime[0] = coarseTimePtr[2]; + headerCWF[ i ].acquisitionTime[1] = coarseTimePtr[3]; + headerCWF[ i ].acquisitionTime[2] = coarseTimePtr[0]; + headerCWF[ i ].acquisitionTime[3] = coarseTimePtr[1]; + headerCWF[ i ].acquisitionTime[4] = fineTimePtr[0]; + headerCWF[ i ].acquisitionTime[5] = fineTimePtr[1]; +#else coarseTime = time_management_regs->coarse_time; fineTime = time_management_regs->fine_time; headerCWF[ i ].acquisitionTime[0] = (unsigned char) (coarseTime>>24); @@ -748,6 +743,8 @@ int send_waveform_CWF(volatile int *wave headerCWF[ i ].acquisitionTime[3] = (unsigned char) (coarseTime); headerCWF[ i ].acquisitionTime[4] = (unsigned char) (fineTime>>8); headerCWF[ i ].acquisitionTime[5] = (unsigned char) (fineTime); +#endif + headerCWF[ i ].time[0] = (unsigned char) (coarseTime>>24); headerCWF[ i ].time[1] = (unsigned char) (coarseTime>>16); headerCWF[ i ].time[2] = (unsigned char) (coarseTime>>8); @@ -793,6 +790,8 @@ int send_waveform_CWF3_light(volatile in unsigned int i; int ret; + unsigned char *coarseTimePtr; + unsigned char *fineTimePtr; rtems_status_code status; spw_ioctl_pkt_send spw_ioctl_send_CWF; char *sample; @@ -804,19 +803,25 @@ int send_waveform_CWF3_light(volatile in //********************** // BUILD CWF3_light DATA - for ( i=0; i< 2048; i++) + for ( i=0; i< NB_SAMPLES_PER_SNAPSHOT; i++) { #ifdef VHDL_DEV sample = (char*) &waveform[ (i * NB_WORDS_SWF_BLK) + TIME_OFFSET ]; + wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + TIME_OFFSET_IN_BYTES ] = sample[ 0 ]; + wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 1 + TIME_OFFSET_IN_BYTES ] = sample[ 1 ]; + wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 2 + TIME_OFFSET_IN_BYTES ] = sample[ 2 ]; + wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 3 + TIME_OFFSET_IN_BYTES ] = sample[ 3 ]; + wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 4 + TIME_OFFSET_IN_BYTES ] = sample[ 4 ]; + wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 5 + TIME_OFFSET_IN_BYTES ] = sample[ 5 ]; #else sample = (char*) &waveform[ i * NB_WORDS_SWF_BLK ]; -#endif wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) ] = sample[ 0 ]; wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 1 ] = sample[ 1 ]; wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 2 ] = sample[ 2 ]; wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 3 ] = sample[ 3 ]; wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 4 ] = sample[ 4 ]; wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 5 ] = sample[ 5 ]; +#endif } //********************* @@ -827,18 +832,27 @@ int send_waveform_CWF3_light(volatile in int coarseTime = 0x00; int fineTime = 0x00; - spw_ioctl_send_CWF.data = (char*) &wf_cont_f3_light[ (i * 340 * NB_BYTES_CWF3_LIGHT_BLK) ]; +#ifdef VHDL_DEV + spw_ioctl_send_CWF.data = (char*) &wf_cont_f3_light[ (i * BLK_NR_CWF_SHORT_F3 * NB_BYTES_CWF3_LIGHT_BLK) + TIME_OFFSET_IN_BYTES]; +#else + spw_ioctl_send_CWF.data = (char*) &wf_cont_f3_light[ (i * BLK_NR_CWF_SHORT_F3 * NB_BYTES_CWF3_LIGHT_BLK) ]; +#endif spw_ioctl_send_CWF.hdr = (char*) &headerCWF[ i ]; // BUILD THE DATA - if ( i == WFRM_INDEX_OF_LAST_PACKET ) { - spw_ioctl_send_CWF.dlen = 8 * NB_BYTES_CWF3_LIGHT_BLK; - } - else { - spw_ioctl_send_CWF.dlen = 340 * NB_BYTES_CWF3_LIGHT_BLK; - } + spw_ioctl_send_CWF.dlen = BLK_NR_CWF_SHORT_F3 * NB_BYTES_CWF3_LIGHT_BLK; // SET PACKET SEQUENCE COUNTER increment_seq_counter_source_id( headerCWF[ i ].packetSequenceControl, SID_NORM_CWF_F3 ); // SET PACKET TIME +#ifdef VHDL_DEV + coarseTimePtr = (unsigned char *) &waveform; + fineTimePtr = (unsigned char *) &waveform[1]; + headerCWF[ i ].acquisitionTime[0] = coarseTimePtr[2]; + headerCWF[ i ].acquisitionTime[1] = coarseTimePtr[3]; + headerCWF[ i ].acquisitionTime[2] = coarseTimePtr[0]; + headerCWF[ i ].acquisitionTime[3] = coarseTimePtr[1]; + headerCWF[ i ].acquisitionTime[4] = fineTimePtr[0]; + headerCWF[ i ].acquisitionTime[5] = fineTimePtr[1]; +#else coarseTime = time_management_regs->coarse_time; fineTime = time_management_regs->fine_time; headerCWF[ i ].acquisitionTime[0] = (unsigned char) (coarseTime>>24); @@ -847,6 +861,7 @@ int send_waveform_CWF3_light(volatile in headerCWF[ i ].acquisitionTime[3] = (unsigned char) (coarseTime); headerCWF[ i ].acquisitionTime[4] = (unsigned char) (fineTime>>8); headerCWF[ i ].acquisitionTime[5] = (unsigned char) (fineTime); +#endif headerCWF[ i ].time[0] = (unsigned char) (coarseTime>>24); headerCWF[ i ].time[1] = (unsigned char) (coarseTime>>16); headerCWF[ i ].time[2] = (unsigned char) (coarseTime>>8); @@ -865,6 +880,50 @@ int send_waveform_CWF3_light(volatile in return ret; } +void compute_acquisition_time( unsigned int *coarseTime, unsigned int *fineTime, unsigned int sid, unsigned char pa_lfr_pkt_nr ) +{ + unsigned long long int acquisitionTimeAsLong; + unsigned char acquisitionTime[6]; + float deltaT = 0.; + + acquisitionTime[0] = (unsigned char) ( *coarseTime >> 8 ); + acquisitionTime[1] = (unsigned char) ( *coarseTime ); + acquisitionTime[2] = (unsigned char) ( *coarseTime >> 24 ); + acquisitionTime[3] = (unsigned char) ( *coarseTime >> 16 ); + acquisitionTime[4] = (unsigned char) ( *fineTime >> 24 ); + acquisitionTime[5] = (unsigned char) ( *fineTime >> 16 ); + + acquisitionTimeAsLong = ( (unsigned long long int) acquisitionTime[0] << 40 ) + + ( (unsigned long long int) acquisitionTime[1] << 32 ) + + ( acquisitionTime[2] << 24 ) + + ( acquisitionTime[3] << 16 ) + + ( acquisitionTime[4] << 8 ) + + ( acquisitionTime[5] ); + + switch( sid ) + { + case SID_NORM_SWF_F0: + deltaT = ( (float ) (pa_lfr_pkt_nr) ) * BLK_NR_304 * 65536. / 24576. ; + break; + + case SID_NORM_SWF_F1: + deltaT = ( (float ) (pa_lfr_pkt_nr) ) * BLK_NR_304 * 65536. / 4096. ; + break; + + case SID_NORM_SWF_F2: + deltaT = ( (float ) (pa_lfr_pkt_nr) ) * BLK_NR_304 * 65536. / 256. ; + break; + + default: + deltaT = 0.; + break; + } + + acquisitionTimeAsLong = acquisitionTimeAsLong + (unsigned long long int) deltaT; + + *coarseTime = (unsigned int) (acquisitionTimeAsLong >> 16); + *fineTime = (unsigned int) (acquisitionTimeAsLong & 0xffff); +} //************** // wfp registers @@ -1066,18 +1125,28 @@ void reset_waveform_picker_regs() waveform_picker_regs->addr_data_f2 = current_ring_node_f2->buffer_address; // 0x10 waveform_picker_regs->addr_data_f3 = (int) (wf_cont_f3_a); // 0x14 waveform_picker_regs->status = 0x00; // 0x18 - // waveform_picker_regs->delta_snapshot = 0x12800; // 0x1c 296 * 256 = 75776 - waveform_picker_regs->delta_snapshot = 0x1000; // 0x1c 16 * 256 = 4096 - //waveform_picker_regs->delta_snapshot = 0x2000; // 0x1c 32 * 256 = 8192 - waveform_picker_regs->delta_f0 = 0xbf5; // 0x20 *** 1013 - waveform_picker_regs->delta_f0_2 = 0x7; // 0x24 *** 7 [7 bits] - waveform_picker_regs->delta_f1 = 0xbc0; // 0x28 *** 960 - // waveform_picker_regs->delta_f2 = 0x12200; // 0x2c *** 290 * 256 = 74240 - waveform_picker_regs->delta_f2 = 0xc00; // 0x2c *** 12 * 256 = 3072 - waveform_picker_regs->nb_data_by_buffer = 0x7ff; // 0x30 *** 2048 -1 => nb samples -1 - waveform_picker_regs->snapshot_param = 0x800; // 0x34 *** 2048 => nb samples - waveform_picker_regs->start_date = 0x00; // 0x38 - waveform_picker_regs->nb_word_in_buffer = 0x1802; // 0x3c *** 2048 * 3 + 2 = 6146 + // +// waveform_picker_regs->delta_snapshot = 0x1000; // 0x1c *** 4096 = 16 * 256 +// waveform_picker_regs->delta_f0 = 0xc0b; // 0x20 *** 3083 = 4096 - 1013 +// waveform_picker_regs->delta_f0_2 = 0x7; // 0x24 *** 7 [7 bits] +// waveform_picker_regs->delta_f1 = 0xc40; // 0x28 *** 3136 = 4096 - 960 +// waveform_picker_regs->delta_f2 = 0xc00; // 0x2c *** 3072 = 12 * 256 + // + waveform_picker_regs->delta_snapshot = 0x1000; // 0x1c *** 4096 = 16 * 256 + waveform_picker_regs->delta_f0 = 0x1; // 0x20 *** + waveform_picker_regs->delta_f0_2 = 0x7; // 0x24 *** 7 [7 bits] + waveform_picker_regs->delta_f1 = 0x1; // 0x28 *** + waveform_picker_regs->delta_f2 = 0x1; // 0x2c *** + // 2048 +// waveform_picker_regs->nb_data_by_buffer = 0x7ff; // 0x30 *** 2048 -1 => nb samples -1 +// waveform_picker_regs->snapshot_param = 0x800; // 0x34 *** 2048 => nb samples +// waveform_picker_regs->start_date = 0x00; // 0x38 +// waveform_picker_regs->nb_word_in_buffer = 0x1802; // 0x3c *** 2048 * 3 + 2 = 6146 + // 2352 = 7 * 336 + waveform_picker_regs->nb_data_by_buffer = 0x92f; // 0x30 *** 2352 - 1 => nb samples -1 + waveform_picker_regs->snapshot_param = 0x930; // 0x34 *** 2352 => nb samples + waveform_picker_regs->start_date = 0x00; // 0x38 + waveform_picker_regs->nb_word_in_buffer = 0x1b92; // 0x3c *** 2352 * 3 + 2 = 7058 } #else void reset_waveform_picker_regs()