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: Thu Feb 13 07:43:27 2014 +# Makefile for building: bin/fsw +# Generated by qmake (2.01a) (Qt 4.8.5) on: Mon Feb 17 07:55: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 @@ -10,7 +10,7 @@ CC = sparc-rtems-gcc CXX = sparc-rtems-g++ -DEFINES = -DSW_VERSION_N1=1 -DSW_VERSION_N2=0 -DSW_VERSION_N3=0 -DSW_VERSION_N4=1 -DPRINT_MESSAGES_ON_CONSOLE -DDEBUG_MESSAGES -DPRINT_TASK_STATISTICS -DVHDL_DEV +DEFINES = -DSW_VERSION_N1=1 -DSW_VERSION_N2=0 -DSW_VERSION_N3=0 -DSW_VERSION_N4=1 -DPRINT_MESSAGES_ON_CONSOLE CFLAGS = -pipe -O3 -Wall $(DEFINES) CXXFLAGS = -pipe -O3 -Wall $(DEFINES) INCPATH = -I/usr/lib64/qt4/mkspecs/linux-g++ -I. -I../src -I../header -I../../LFR_basic-parameters @@ -89,9 +89,9 @@ DIST = /usr/lib64/qt4/mkspecs/c /usr/lib64/qt4/mkspecs/features/lex.prf \ /usr/lib64/qt4/mkspecs/features/include_source_dir.prf \ fsw-qt.pro -QMAKE_TARGET = fsw-vhdl-dev +QMAKE_TARGET = fsw DESTDIR = bin/ -TARGET = bin/fsw-vhdl-dev +TARGET = bin/fsw first: all ####### Implicit rules @@ -172,8 +172,8 @@ qmake: FORCE @$(QMAKE) -spec /usr/lib64/qt4/mkspecs/linux-g++ -o Makefile fsw-qt.pro dist: - @$(CHK_DIR_EXISTS) obj/fsw-vhdl-dev1.0.0 || $(MKDIR) obj/fsw-vhdl-dev1.0.0 - $(COPY_FILE) --parents $(SOURCES) $(DIST) obj/fsw-vhdl-dev1.0.0/ && (cd `dirname obj/fsw-vhdl-dev1.0.0` && $(TAR) fsw-vhdl-dev1.0.0.tar fsw-vhdl-dev1.0.0 && $(COMPRESS) fsw-vhdl-dev1.0.0.tar) && $(MOVE) `dirname obj/fsw-vhdl-dev1.0.0`/fsw-vhdl-dev1.0.0.tar.gz . && $(DEL_FILE) -r obj/fsw-vhdl-dev1.0.0 + @$(CHK_DIR_EXISTS) obj/fsw1.0.0 || $(MKDIR) obj/fsw1.0.0 + $(COPY_FILE) --parents $(SOURCES) $(DIST) obj/fsw1.0.0/ && (cd `dirname obj/fsw1.0.0` && $(TAR) fsw1.0.0.tar fsw1.0.0 && $(COMPRESS) fsw1.0.0.tar) && $(MOVE) `dirname obj/fsw1.0.0`/fsw1.0.0.tar.gz . && $(DEL_FILE) -r obj/fsw1.0.0 clean:compiler_clean diff --git a/FSW-qt/bin/LEON3_LOAD_SPW.py b/FSW-qt/bin/LEON3_LOAD_SPW.py --- a/FSW-qt/bin/LEON3_LOAD_SPW.py +++ b/FSW-qt/bin/LEON3_LOAD_SPW.py @@ -7,7 +7,7 @@ proxy.loadSysDriverToParent("dsu3plugin" BUTTON_selectGRESB.click() BUTTON_rmapOpenCommunication.click() -dsu3plugin0.openFile("/opt/DEV_PLE/FSW-qt/bin/fsw-vhdl-dev") +dsu3plugin0.openFile("/opt/DEV_PLE/FSW-qt/bin/fsw") dsu3plugin0.loadFile() dsu3plugin0.run() diff --git a/FSW-qt/bin/LEON3_RELOAD_SPW.py b/FSW-qt/bin/LEON3_RELOAD_SPW.py --- a/FSW-qt/bin/LEON3_RELOAD_SPW.py +++ b/FSW-qt/bin/LEON3_RELOAD_SPW.py @@ -1,6 +1,6 @@ #!/usr/bin/lppmon -e -dsu3plugin0.openFile("/opt/DEV_PLE/FSW-qt/bin/fsw-vhdl-dev") +dsu3plugin0.openFile("/opt/DEV_PLE/FSW-qt/bin/fsw") dsu3plugin0.loadFile() dsu3plugin0.run() diff --git a/FSW-qt/fsw-qt.pro b/FSW-qt/fsw-qt.pro --- a/FSW-qt/fsw-qt.pro +++ b/FSW-qt/fsw-qt.pro @@ -1,7 +1,7 @@ TEMPLATE = app # CONFIG += console v8 sim -# CONFIG options = verbose *** boot_messages *** debug_messages *** cpu_usage_report *** stack_report *** gsa *** vhdl_dev -CONFIG += console verbose debug_messages vhdl_dev cpu_usage_report +# CONFIG options = verbose *** boot_messages *** debug_messages *** cpu_usage_report *** stack_report +CONFIG += console verbose CONFIG -= qt include(./sparc.pri) @@ -38,16 +38,6 @@ contains( CONFIG, boot_messages ) { #QMAKE_EXTRA_TARGETS += doxygen TARGET = fsw -contains( CONFIG, gsa ) { - DEFINES += GSA - TARGET = fsw-gsa -} - -TARGET = fsw -contains( CONFIG, vhdl_dev ) { - DEFINES += VHDL_DEV - TARGET = fsw-vhdl-dev -} INCLUDEPATH += \ ../src \ diff --git a/header/fsw_params.h b/header/fsw_params.h --- a/header/fsw_params.h +++ b/header/fsw_params.h @@ -29,8 +29,9 @@ typedef struct ring_node_sm // flight software version // this parameters is handled by the Qt project options -//#define NB_SAMPLES_PER_SNAPSHOT 2048 -#define NB_SAMPLES_PER_SNAPSHOT 2352 // 336 * 7 = 2352 +#define NB_PACKETS_PER_GROUP_OF_CWF 8 // 8 packets containing 336 blk +#define NB_PACKETS_PER_GROUP_OF_CWF_LIGHT 4 // 4 packets containing 672 blk +#define NB_SAMPLES_PER_SNAPSHOT 2688 // 336 * 8 = 672 * 4 = 2688 #define TIME_OFFSET 2 #define TIME_OFFSET_IN_BYTES 8 #define WAVEFORM_EXTENDED_HEADER_OFFSET 22 @@ -75,6 +76,7 @@ typedef struct ring_node_sm #define SY_LFR_N_ASM_P 3600 // sec #define SY_LFR_N_BP_P0 4 // sec #define SY_LFR_N_BP_P1 20 // sec +#define SY_LFR_N_CWF_LONG_F3 0 // 0 => production of light continuous waveforms at f3 #define MIN_DELTA_SNAPSHOT 16 // sec // BURST #define DEFAULT_SY_LFR_B_BP_P0 1 // sec @@ -98,19 +100,15 @@ typedef struct ring_node_sm //***************************** // APB REGISTERS BASE ADDRESSES -#define REGS_ADDR_APBUART 0x80000100 -#define REGS_ADDR_GPTIMER 0x80000300 -#define REGS_ADDR_GRSPW 0x80000500 -#define REGS_ADDR_TIME_MANAGEMENT 0x80000600 -#define REGS_ADDR_SPECTRAL_MATRIX 0x80000f00 +#define REGS_ADDR_APBUART 0x80000100 +#define REGS_ADDR_GPTIMER 0x80000300 +#define REGS_ADDR_GRSPW 0x80000500 +#define REGS_ADDR_TIME_MANAGEMENT 0x80000600 +#define REGS_ADDR_SPECTRAL_MATRIX 0x80000f00 +#define REGS_ADDR_WAVEFORM_PICKER 0x80000f20 -#ifdef GSA -#else - #define REGS_ADDR_WAVEFORM_PICKER 0x80000f20 -#endif - -#define APBUART_CTRL_REG_MASK_DB 0xfffff7ff -#define APBUART_CTRL_REG_MASK_TE 0x00000002 +#define APBUART_CTRL_REG_MASK_DB 0xfffff7ff +#define APBUART_CTRL_REG_MASK_TE 0x00000002 #define APBUART_SCALER_RELOAD_VALUE 0x00000050 // 25 MHz => about 38400 (0x50) //********** diff --git a/header/tc_handler.h b/header/tc_handler.h --- a/header/tc_handler.h +++ b/header/tc_handler.h @@ -33,13 +33,8 @@ int action_update_time(ccsdsTelecommandP // mode transition int transition_validation(unsigned char requestedMode); -int stop_current_mode(); +int stop_current_mode( void ); int enter_mode(unsigned char mode); -int enter_standby_mode(); -int enter_normal_mode(); -int enter_burst_mode(); -int enter_sbm1_mode(); -int enter_sbm2_mode(); int restart_science_tasks(); int suspend_science_tasks(); void launch_waveform_picker( unsigned char mode ); diff --git a/header/wf_handler.h b/header/wf_handler.h --- a/header/wf_handler.h +++ b/header/wf_handler.h @@ -27,11 +27,7 @@ extern volatile int wf_cont_f3_a[ ]; extern volatile int wf_cont_f3_b[ ]; extern char wf_cont_f3_light[ ]; -#ifdef VHDL_DEV extern waveform_picker_regs_new_t *waveform_picker_regs; -#else -extern waveform_picker_regs_t *waveform_picker_regs; -#endif extern time_management_regs_t *time_management_regs; extern Packet_TM_LFR_HK_t housekeeping_packet; extern Packet_TM_LFR_PARAMETER_DUMP_t parameter_dump_packet; @@ -66,7 +62,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 ); +void compute_acquisition_time(unsigned int coarseTime, unsigned int fineTime, + unsigned int sid, unsigned char pa_lfr_pkt_nr, unsigned char *acquisitionTime ); // 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 @@ -51,12 +51,7 @@ volatile int sm_f2[ NB_RING_NODES_ASM_F2 // APB CONFIGURATION REGISTERS time_management_regs_t *time_management_regs = (time_management_regs_t*) REGS_ADDR_TIME_MANAGEMENT; gptimer_regs_t *gptimer_regs = (gptimer_regs_t *) REGS_ADDR_GPTIMER; - -#ifdef VHDL_DEV waveform_picker_regs_new_t *waveform_picker_regs = (waveform_picker_regs_new_t*) REGS_ADDR_WAVEFORM_PICKER; -#else -waveform_picker_regs_t *waveform_picker_regs = (waveform_picker_regs_t*) REGS_ADDR_WAVEFORM_PICKER; -#endif spectral_matrix_regs_t *spectral_matrix_regs = (spectral_matrix_regs_t*) REGS_ADDR_SPECTRAL_MATRIX; // MODE PARAMETERS diff --git a/src/fsw_init.c b/src/fsw_init.c --- a/src/fsw_init.c +++ b/src/fsw_init.c @@ -79,16 +79,17 @@ rtems_task Init( rtems_task_argument ign send_console_outputs_on_apbuart_port(); set_apbuart_scaler_reload_register(REGS_ADDR_APBUART, APBUART_SCALER_RELOAD_VALUE); enable_apbuart_transmitter(); - PRINTF("\n\n\n\n\nIn INIT *** Now the console is on port COM1\n") + DEBUG_PRINTF("\n\n\n\n\nIn INIT *** Now the console is on port COM1\n") - BOOT_PRINTF("\n\n\n\n\n") - BOOT_PRINTF("***************************\n") - BOOT_PRINTF("** START Flight Software **\n") -#ifdef VHDL_DEV - PRINTF("/!\\ this is the VHDL_DEV flight software /!\\ \n") -#endif - BOOT_PRINTF("***************************\n") - BOOT_PRINTF("\n\n") + PRINTF("\n\n\n\n\n") + PRINTF("*************************\n") + PRINTF("** LFR Flight Software **\n") + PRINTF1("** %d.", SW_VERSION_N1) + PRINTF1("%d.", SW_VERSION_N2) + PRINTF1("%d.", SW_VERSION_N3) + PRINTF1("%d\n", SW_VERSION_N4) + PRINTF("*************************\n") + PRINTF("\n\n") reset_wfp_burst_enable(); // stop the waveform picker if it was running init_waveform_rings(); // initialize the waveform rings @@ -364,7 +365,7 @@ int create_all_tasks( void ) // create a status = rtems_task_create( Task_name[TASKID_CWF3], TASK_PRIORITY_CWF3, RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_MODES, - RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_CWF3] + RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_CWF3] ); } if (status == RTEMS_SUCCESSFUL) // CWF2 @@ -372,7 +373,7 @@ int create_all_tasks( void ) // create a status = rtems_task_create( Task_name[TASKID_CWF2], TASK_PRIORITY_CWF2, RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_MODES, - RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_CWF2] + RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_CWF2] ); } if (status == RTEMS_SUCCESSFUL) // CWF1 @@ -380,7 +381,7 @@ int create_all_tasks( void ) // create a status = rtems_task_create( Task_name[TASKID_CWF1], TASK_PRIORITY_CWF1, RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_MODES, - RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_CWF1] + RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_CWF1] ); } if (status == RTEMS_SUCCESSFUL) // SEND diff --git a/src/fsw_spacewire.c b/src/fsw_spacewire.c --- a/src/fsw_spacewire.c +++ b/src/fsw_spacewire.c @@ -87,7 +87,7 @@ rtems_task spiq_task(rtems_task_argument if ( status != RTEMS_SUCCESSFUL ) { PRINTF1("in SPIQ *** ERR stop_current_mode *** code %d\n", status) } - status = enter_standby_mode(); + status = enter_mode( LFR_MODE_STANDBY ); if ( status != RTEMS_SUCCESSFUL ) { PRINTF1("in SPIQ *** ERR enter_standby_mode *** code %d\n", status) } diff --git a/src/tc_handler.c b/src/tc_handler.c --- a/src/tc_handler.c +++ b/src/tc_handler.c @@ -379,7 +379,7 @@ int transition_validation(unsigned char return status; } -int stop_current_mode() +int stop_current_mode(void) { /** This function stops the current mode by masking interrupt lines and suspending science tasks. * @@ -438,132 +438,43 @@ int enter_mode(unsigned char mode ) housekeeping_packet.lfr_status_word[0] = (unsigned char) ((mode << 4) + 0x0d); updateLFRCurrentMode(); - switch(mode){ - case LFR_MODE_STANDBY: - status = enter_standby_mode( ); - break; - case LFR_MODE_NORMAL: - status = enter_normal_mode( ); - break; - case LFR_MODE_BURST: - status = enter_burst_mode( ); - break; - case LFR_MODE_SBM1: - status = enter_sbm1_mode( ); - break; - case LFR_MODE_SBM2: - status = enter_sbm2_mode( ); - break; - default: + if ( (mode == LFR_MODE_NORMAL) || (mode == LFR_MODE_BURST) + || (mode == LFR_MODE_SBM1) || (mode == LFR_MODE_SBM2) ) + { + status = restart_science_tasks(); + launch_waveform_picker( mode ); +// launch_spectral_matrix( mode ); + } + else if ( mode == LFR_MODE_STANDBY ) + { + status = stop_current_mode(); + } + else + { status = RTEMS_UNSATISFIED; } + if (mode == LFR_MODE_STANDBY) + { + PRINTF1("maxCount = %d\n", maxCount) +#ifdef PRINT_TASK_STATISTICS + rtems_cpu_usage_report(); +#endif + +#ifdef PRINT_STACK_REPORT + rtems_stack_checker_report_usage(); +#endif + } + if (status != RTEMS_SUCCESSFUL) { - PRINTF("in enter_mode *** ERR\n") + PRINTF1("in enter_mode *** ERR = %d\n", status) status = RTEMS_UNSATISFIED; } return status; } -int enter_standby_mode() -{ - /** This function is used to enter the STANDBY mode. - * - * @return RTEMS directive status codes: - * - RTEMS_SUCCESSFUL - the mode has been entered successfully - * - */ - - PRINTF1("maxCount = %d\n", maxCount) - -#ifdef PRINT_TASK_STATISTICS - rtems_cpu_usage_report(); -#endif - -#ifdef PRINT_STACK_REPORT - rtems_stack_checker_report_usage(); -#endif - - return LFR_SUCCESSFUL; -} - -int enter_normal_mode() -{ - rtems_status_code status; - - status = restart_science_tasks(); - - launch_waveform_picker( LFR_MODE_NORMAL ); -// launch_spectral_matrix( LFR_MODE_NORMAL ); - - return status; -} - -int enter_burst_mode() -{ - /** This function is used to enter the STANDBY mode. - * - * @return RTEMS directive status codes: - * - RTEMS_SUCCESSFUL - the mode has been entered successfully - * - RTEMS_INVALID_ID - task id invalid - * - RTEMS_INCORRECT_STATE - task never started - * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task - * - */ - - rtems_status_code status; - - status = restart_science_tasks(); - - launch_waveform_picker( LFR_MODE_BURST ); - - return status; -} - -int enter_sbm1_mode() -{ - /** This function is used to enter the SBM1 mode. - * - * @return RTEMS directive status codes: - * - RTEMS_SUCCESSFUL - the mode has been entered successfully - * - RTEMS_INVALID_ID - task id invalid - * - RTEMS_INCORRECT_STATE - task never started - * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task - * - */ - - rtems_status_code status; - - status = restart_science_tasks(); - - launch_waveform_picker( LFR_MODE_SBM1 ); - - return status; -} - -int enter_sbm2_mode() -{ - /** This function is used to enter the SBM2 mode. - * - * @return RTEMS directive status codes: - * - RTEMS_SUCCESSFUL - the mode has been entered successfully - * - RTEMS_INVALID_ID - task id invalid - * - RTEMS_INCORRECT_STATE - task never started - * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task - * - */ - - rtems_status_code status; - - status = restart_science_tasks(); - - launch_waveform_picker( LFR_MODE_SBM2 ); - - return status; -} - int restart_science_tasks() { /** This function is used to restart all science tasks. diff --git a/src/tc_load_dump_parameters.c b/src/tc_load_dump_parameters.c --- a/src/tc_load_dump_parameters.c +++ b/src/tc_load_dump_parameters.c @@ -73,7 +73,7 @@ int action_load_normal_par(ccsdsTelecomm } //*************** - // SY_LFR_N_ASM_P + // sy_lfr_n_asm_p if (flag == LFR_SUCCESSFUL) { result = set_sy_lfr_n_asm_p( TC, queue_id ); @@ -84,7 +84,7 @@ int action_load_normal_par(ccsdsTelecomm } //*************** - // SY_LFR_N_BP_P0 + // sy_lfr_n_bp_p0 if (flag == LFR_SUCCESSFUL) { result = set_sy_lfr_n_bp_p0( TC, queue_id ); @@ -457,6 +457,7 @@ void init_parameter_dump( void ) parameter_dump_packet.sy_lfr_n_asm_p[1] = (unsigned char) (SY_LFR_N_ASM_P ); parameter_dump_packet.sy_lfr_n_bp_p0 = (unsigned char) SY_LFR_N_BP_P0; parameter_dump_packet.sy_lfr_n_bp_p1 = (unsigned char) SY_LFR_N_BP_P1; + parameter_dump_packet.sy_lfr_n_cwf_long_f3 = (unsigned char) SY_LFR_N_CWF_LONG_F3; //***************** // BURST PARAMETERS diff --git a/src/wf_handler.c b/src/wf_handler.c --- a/src/wf_handler.c +++ b/src/wf_handler.c @@ -16,11 +16,11 @@ Header_TM_LFR_SCIENCE_SWF_t headerSWF_F0 Header_TM_LFR_SCIENCE_SWF_t headerSWF_F1[7]; Header_TM_LFR_SCIENCE_SWF_t headerSWF_F2[7]; // CWF -Header_TM_LFR_SCIENCE_CWF_t headerCWF_F1[7]; -Header_TM_LFR_SCIENCE_CWF_t headerCWF_F2_BURST[7]; -Header_TM_LFR_SCIENCE_CWF_t headerCWF_F2_SBM2[7]; -Header_TM_LFR_SCIENCE_CWF_t headerCWF_F3[7]; -Header_TM_LFR_SCIENCE_CWF_t headerCWF_F3_light[7]; +Header_TM_LFR_SCIENCE_CWF_t headerCWF_F1[ NB_PACKETS_PER_GROUP_OF_CWF ]; +Header_TM_LFR_SCIENCE_CWF_t headerCWF_F2_BURST[ NB_PACKETS_PER_GROUP_OF_CWF ]; +Header_TM_LFR_SCIENCE_CWF_t headerCWF_F2_SBM2[ NB_PACKETS_PER_GROUP_OF_CWF ]; +Header_TM_LFR_SCIENCE_CWF_t headerCWF_F3[ NB_PACKETS_PER_GROUP_OF_CWF ]; +Header_TM_LFR_SCIENCE_CWF_t headerCWF_F3_light[ NB_PACKETS_PER_GROUP_OF_CWF_LIGHT ]; //************** // waveform ring @@ -429,7 +429,14 @@ rtems_task cwf3_task(rtems_task_argument // wait for an RTEMS_EVENT rtems_event_receive( RTEMS_EVENT_0, RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); - PRINTF("send CWF F3 \n") + if ( (parameter_dump_packet.sy_lfr_n_cwf_long_f3 & 0x01) == 0x01) + { + PRINTF("send CWF_LONG_F3\n") + } + else + { + PRINTF("send CWF_F3 (light)\n") + } if (waveform_picker_regs->addr_data_f3 == (int) wf_cont_f3_a) { if ( (parameter_dump_packet.sy_lfr_n_cwf_long_f3 & 0x01) == 0x01) { @@ -442,7 +449,7 @@ rtems_task cwf3_task(rtems_task_argument } else { - if ( (parameter_dump_packet.sy_lfr_n_cwf_long_f3 & 0x01) == 0x00) + if ( (parameter_dump_packet.sy_lfr_n_cwf_long_f3 & 0x01) == 0x01) { send_waveform_CWF( wf_cont_f3_a, SID_NORM_CWF_LONG_F3, headerCWF_F3, queue_id ); } @@ -688,7 +695,7 @@ int init_header_continuous_wf_table( uns { unsigned int i; - for (i=0; i<7; i++) + for (i=0; i> 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 + compute_acquisition_time( coarseTime, fineTime, sid, i, headerSWF[ i ].acquisitionTime ); + // 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); @@ -846,7 +835,7 @@ int send_waveform_SWF( volatile int *wav printf("%d-%d, ERR %d\n", sid, i, (int) status); ret = LFR_DEFAULT; } -// rtems_task_wake_after(TIME_BETWEEN_TWO_SWF_PACKETS); // 300 ms between each packet => 7 * 3 = 21 packets => 6.3 seconds + rtems_task_wake_after(TIME_BETWEEN_TWO_SWF_PACKETS); // 300 ms between each packet => 7 * 3 = 21 packets => 6.3 seconds } return ret; @@ -869,8 +858,8 @@ int send_waveform_CWF(volatile int *wave unsigned int i; int ret; - unsigned char *coarseTimePtr; - unsigned char *fineTimePtr; + unsigned int coarseTime; + unsigned int fineTime; rtems_status_code status; spw_ioctl_pkt_send spw_ioctl_send_CWF; @@ -879,47 +868,26 @@ int send_waveform_CWF(volatile int *wave ret = LFR_DEFAULT; - for (i=0; i<7; i++) // send waveform + coarseTime = waveform[0]; + fineTime = waveform[1]; + + for (i=0; icoarse_time; - fineTime = time_management_regs->fine_time; - headerCWF[ i ].acquisitionTime[0] = (unsigned char) (coarseTime>>24); - headerCWF[ i ].acquisitionTime[1] = (unsigned char) (coarseTime>>16); - headerCWF[ i ].acquisitionTime[2] = (unsigned char) (coarseTime>>8); - 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); - headerCWF[ i ].time[3] = (unsigned char) (coarseTime); - headerCWF[ i ].time[4] = (unsigned char) (fineTime>>8); - headerCWF[ i ].time[5] = (unsigned char) (fineTime); + compute_acquisition_time( coarseTime, fineTime, sid, i, headerCWF[ i ].acquisitionTime); + // + headerCWF[ i ].time[0] = (unsigned char) (time_management_regs->coarse_time>>24); + headerCWF[ i ].time[1] = (unsigned char) (time_management_regs->coarse_time>>16); + headerCWF[ i ].time[2] = (unsigned char) (time_management_regs->coarse_time>>8); + headerCWF[ i ].time[3] = (unsigned char) (time_management_regs->coarse_time); + headerCWF[ i ].time[4] = (unsigned char) (time_management_regs->fine_time>>8); + headerCWF[ i ].time[5] = (unsigned char) (time_management_regs->fine_time); // SEND PACKET if (sid == SID_NORM_CWF_LONG_F3) { @@ -959,8 +927,8 @@ int send_waveform_CWF3_light(volatile in unsigned int i; int ret; - unsigned char *coarseTimePtr; - unsigned char *fineTimePtr; + unsigned int coarseTime; + unsigned int fineTime; rtems_status_code status; spw_ioctl_pkt_send spw_ioctl_send_CWF; char *sample; @@ -974,69 +942,37 @@ int send_waveform_CWF3_light(volatile in // BUILD CWF3_light DATA 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 ]; - 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 + wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 5 + TIME_OFFSET_IN_BYTES ] = sample[ 5 ]; } + coarseTime = waveform[0]; + fineTime = waveform[1]; + //********************* // SEND CWF3_light DATA - - for (i=0; i<7; i++) // send waveform + for (i=0; icoarse_time; - fineTime = time_management_regs->fine_time; - headerCWF[ i ].acquisitionTime[0] = (unsigned char) (coarseTime>>24); - headerCWF[ i ].acquisitionTime[1] = (unsigned char) (coarseTime>>16); - headerCWF[ i ].acquisitionTime[2] = (unsigned char) (coarseTime>>8); - 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); - headerCWF[ i ].time[3] = (unsigned char) (coarseTime); - headerCWF[ i ].time[4] = (unsigned char) (fineTime>>8); - headerCWF[ i ].time[5] = (unsigned char) (fineTime); + compute_acquisition_time( coarseTime, fineTime, SID_NORM_CWF_F3, i, headerCWF[ i ].acquisitionTime ); + // + headerCWF[ i ].time[0] = (unsigned char) (time_management_regs->coarse_time>>24); + headerCWF[ i ].time[1] = (unsigned char) (time_management_regs->coarse_time>>16); + headerCWF[ i ].time[2] = (unsigned char) (time_management_regs->coarse_time>>8); + headerCWF[ i ].time[3] = (unsigned char) (time_management_regs->coarse_time); + headerCWF[ i ].time[4] = (unsigned char) (time_management_regs->fine_time>>8); + headerCWF[ i ].time[5] = (unsigned char) (time_management_regs->fine_time); // SEND PACKET status = rtems_message_queue_send( queue_id, &spw_ioctl_send_CWF, sizeof(spw_ioctl_send_CWF)); if (status != RTEMS_SUCCESSFUL) { @@ -1049,39 +985,56 @@ 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 ) +void compute_acquisition_time( unsigned int coarseTime, unsigned int fineTime, + unsigned int sid, unsigned char pa_lfr_pkt_nr, unsigned char * acquisitionTime ) { unsigned long long int acquisitionTimeAsLong; - unsigned char acquisitionTime[6]; - float deltaT = 0.; + unsigned char localAcquisitionTime[6]; + double 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 ); + localAcquisitionTime[0] = (unsigned char) ( coarseTime >> 8 ); + localAcquisitionTime[1] = (unsigned char) ( coarseTime ); + localAcquisitionTime[2] = (unsigned char) ( coarseTime >> 24 ); + localAcquisitionTime[3] = (unsigned char) ( coarseTime >> 16 ); + localAcquisitionTime[4] = (unsigned char) ( fineTime >> 24 ); + localAcquisitionTime[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] ); + acquisitionTimeAsLong = ( (unsigned long long int) localAcquisitionTime[0] << 40 ) + + ( (unsigned long long int) localAcquisitionTime[1] << 32 ) + + ( localAcquisitionTime[2] << 24 ) + + ( localAcquisitionTime[3] << 16 ) + + ( localAcquisitionTime[4] << 8 ) + + ( localAcquisitionTime[5] ); switch( sid ) { case SID_NORM_SWF_F0: - deltaT = ( (float ) (pa_lfr_pkt_nr) ) * BLK_NR_304 * 65536. / 24576. ; - break; + deltaT = ( (double ) (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; + deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_304 * 65536. / 4096. ; + break; + + case SID_SBM1_CWF_F1: + deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * 65536. / 4096. ; + break; case SID_NORM_SWF_F2: - deltaT = ( (float ) (pa_lfr_pkt_nr) ) * BLK_NR_304 * 65536. / 256. ; - break; + deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_304 * 65536. / 256. ; + break; + + case SID_SBM2_CWF_F2: + deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * 65536. / 256. ; + break; + + case SID_NORM_CWF_F3: + deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF_SHORT_F3 * 65536. / 16. ; + break; + + case SID_NORM_CWF_LONG_F3: + deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * 65536. / 16. ; + break; default: deltaT = 0.; @@ -1089,9 +1042,13 @@ void compute_acquisition_time( unsigned } acquisitionTimeAsLong = acquisitionTimeAsLong + (unsigned long long int) deltaT; - - *coarseTime = (unsigned int) (acquisitionTimeAsLong >> 16); - *fineTime = (unsigned int) (acquisitionTimeAsLong & 0xffff); + // + acquisitionTime[0] = (unsigned char) (acquisitionTimeAsLong >> 40); + acquisitionTime[1] = (unsigned char) (acquisitionTimeAsLong >> 32); + acquisitionTime[2] = (unsigned char) (acquisitionTimeAsLong >> 24); + acquisitionTime[3] = (unsigned char) (acquisitionTimeAsLong >> 16); + acquisitionTime[4] = (unsigned char) (acquisitionTimeAsLong >> 8 ); + acquisitionTime[5] = (unsigned char) (acquisitionTimeAsLong ); } //************** @@ -1104,11 +1061,7 @@ void reset_wfp_burst_enable(void) * */ -#ifdef VHDL_DEV waveform_picker_regs->run_burst_enable = 0x00; // burst f2, f1, f0 enable f3, f2, f1, f0 -#else - waveform_picker_regs->burst_enable = 0x00; // burst f2, f1, f0 enable f3, f2, f1, f0 -#endif } void reset_wfp_status( void ) @@ -1119,10 +1072,7 @@ void reset_wfp_status( void ) * */ -#ifdef GSA -#else waveform_picker_regs->status = 0x00; // burst f2, f1, f0 enable f3, f2, f1, f0 -#endif } void reset_waveform_picker_regs(void) @@ -1166,11 +1116,11 @@ void reset_waveform_picker_regs(void) DEBUG_PRINTF1("delta_f0_2 %x\n", waveform_picker_regs->delta_f0_2) DEBUG_PRINTF1("delta_f1 %x\n", waveform_picker_regs->delta_f1) DEBUG_PRINTF1("delta_f2 %x\n", waveform_picker_regs->delta_f2) - // 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 + // 2688 = 8 * 336 + waveform_picker_regs->nb_data_by_buffer = 0xa7f; // 0x30 *** 2688 - 1 => nb samples -1 + waveform_picker_regs->snapshot_param = 0xa80; // 0x34 *** 2688 => nb samples waveform_picker_regs->start_date = 0x00; // 0x38 - waveform_picker_regs->nb_word_in_buffer = 0x1b92; // 0x3c *** 2352 * 3 + 2 = 7058 + waveform_picker_regs->nb_word_in_buffer = 0x1f82; // 0x3c *** 2688 * 3 + 2 = 8066 } void set_wfp_data_shaping( void )