diff --git a/core/common/include/hw/wb_fmc_adc_common_regs.h b/core/common/include/hw/wb_fmc_adc_common_regs.h index 22748bc3..500099c7 100644 --- a/core/common/include/hw/wb_fmc_adc_common_regs.h +++ b/core/common/include/hw/wb_fmc_adc_common_regs.h @@ -3,7 +3,7 @@ * File : wb_fmc_adc_common_regs.h * Author : auto-generated by wbgen2 from wb_fmc_adc_common_regs.wb - * Created : Mon Apr 18 09:02:33 2016 + * Created : Fri Jul 21 13:54:07 2017 * Standard : ANSI C THIS FILE WAS GENERATED BY wbgen2 FROM SOURCE FILE wb_fmc_adc_common_regs.wb @@ -79,11 +79,14 @@ /* definitions for field: Led 3 in reg: Monitor and FMC status control register */ #define WB_FMC_ADC_COMMON_CSR_MONITOR_LED3 WBGEN2_GEN_MASK(3, 1) +/* definitions for field: MMCM reset in reg: Monitor and FMC status control register */ +#define WB_FMC_ADC_COMMON_CSR_MONITOR_MMCM_RST WBGEN2_GEN_MASK(4, 1) + /* definitions for field: Reserved in reg: Monitor and FMC status control register */ -#define WB_FMC_ADC_COMMON_CSR_MONITOR_RESERVED_MASK WBGEN2_GEN_MASK(4, 28) -#define WB_FMC_ADC_COMMON_CSR_MONITOR_RESERVED_SHIFT 4 -#define WB_FMC_ADC_COMMON_CSR_MONITOR_RESERVED_W(value) WBGEN2_GEN_WRITE(value, 4, 28) -#define WB_FMC_ADC_COMMON_CSR_MONITOR_RESERVED_R(reg) WBGEN2_GEN_READ(reg, 4, 28) +#define WB_FMC_ADC_COMMON_CSR_MONITOR_RESERVED_MASK WBGEN2_GEN_MASK(5, 27) +#define WB_FMC_ADC_COMMON_CSR_MONITOR_RESERVED_SHIFT 5 +#define WB_FMC_ADC_COMMON_CSR_MONITOR_RESERVED_W(value) WBGEN2_GEN_WRITE(value, 5, 27) +#define WB_FMC_ADC_COMMON_CSR_MONITOR_RESERVED_R(reg) WBGEN2_GEN_READ(reg, 5, 27) /* [0x0]: REG Status register */ #define WB_FMC_ADC_COMMON_CSR_REG_FMC_STATUS 0x00000000 /* [0x4]: REG Trigger control */ diff --git a/core/common/include/hw/wb_pos_calc_regs.h b/core/common/include/hw/wb_pos_calc_regs.h index 98b1ea92..044e6b16 100644 --- a/core/common/include/hw/wb_pos_calc_regs.h +++ b/core/common/include/hw/wb_pos_calc_regs.h @@ -3,7 +3,7 @@ * File : pos_calc_regs.h * Author : auto-generated by wbgen2 from wb_pos_calc_regs.wb - * Created : Mon Jan 23 10:11:17 2017 + * Created : Fri Jul 14 16:40:58 2017 * Standard : ANSI C THIS FILE WAS GENERATED BY wbgen2 FROM SOURCE FILE wb_pos_calc_regs.wb @@ -11,6 +11,9 @@ */ +/* Modified to include 32-bit register modifier. This needed a 64-bit + * shitft macro to avoid "left shift count >= width of type" errors*/ + #ifndef __WBGEN2_REGDEFS_WB_POS_CALC_REGS_WB #define __WBGEN2_REGDEFS_WB_POS_CALC_REGS_WB @@ -22,321 +25,321 @@ #error "Unsupported compiler?" #endif -#ifndef __WBGEN2_MACROS_DEFINED__ -#define __WBGEN2_MACROS_DEFINED__ -#define WBGEN2_GEN_MASK(offset, size) (((1<<(size))-1) << (offset)) -#define WBGEN2_GEN_WRITE(value, offset, size) (((value) & ((1<<(size))-1)) << (offset)) -#define WBGEN2_GEN_READ(reg, offset, size) (((reg) >> (offset)) & ((1<<(size))-1)) -#define WBGEN2_SIGN_EXTEND(value, bits) (((value) & (1<> (offset)) & (((uint64_t)1<<(size))-1)) +#define WBGEN2_DSP_SIGN_EXTEND(value, bits) (((value) & ((uint64_t)1<new_amp_data = false; + data->new_pos_data = false; - rw_err |= GET_PARAM(self, dsp, 0x0, POS_CALC, - DSP_MONIT_AMP_CH0, /* field = NULL */, MULT_BIT_PARAM, + /* Check if FIFO is empty before reading from it */ + GET_PARAM(self, dsp, 0x0, POS_CALC, + AMPFIFO_CSR, EMPTY, SINGLE_BIT_PARAM, + ampfifo_empty, NO_FMT_FUNC); + GET_PARAM(self, dsp, 0x0, POS_CALC, + POSFIFO_CSR, EMPTY, SINGLE_BIT_PARAM, + posfifo_empty, NO_FMT_FUNC); + + DBE_DEBUG (DBG_SM_IO | DBG_LVL_TRACE, "[sm_io:dsp] " + "ampfifo empty: %u\n", ampfifo_empty); + DBE_DEBUG (DBG_SM_IO | DBG_LVL_TRACE, "[sm_io:dsp] " + "posfifo empty: %u\n", posfifo_empty); + + if (!ampfifo_empty) { + GET_PARAM(self, dsp, 0x0, POS_CALC, + AMPFIFO_R0, MONIT_AMP_CH0, MULT_BIT_PARAM, data->amp_ch0, NO_FMT_FUNC); - rw_err |= GET_PARAM(self, dsp, 0x0, POS_CALC, - DSP_MONIT_AMP_CH1, /* field = NULL */, MULT_BIT_PARAM, + GET_PARAM(self, dsp, 0x0, POS_CALC, + AMPFIFO_R1, MONIT_AMP_CH1, MULT_BIT_PARAM, data->amp_ch1, NO_FMT_FUNC); - rw_err |= GET_PARAM(self, dsp, 0x0, POS_CALC, - DSP_MONIT_AMP_CH2, /* field = NULL */, MULT_BIT_PARAM, + GET_PARAM(self, dsp, 0x0, POS_CALC, + AMPFIFO_R2, MONIT_AMP_CH2, MULT_BIT_PARAM, data->amp_ch2, NO_FMT_FUNC); - rw_err |= GET_PARAM(self, dsp, 0x0, POS_CALC, - DSP_MONIT_AMP_CH3, /* field = NULL */, MULT_BIT_PARAM, + GET_PARAM(self, dsp, 0x0, POS_CALC, + AMPFIFO_R3, MONIT_AMP_CH3, MULT_BIT_PARAM, data->amp_ch3, NO_FMT_FUNC); - ASSERT_TEST(rw_err == RW_OK, "Could not get MONIT. amp/pos parameters", - err_exit, -DSP_ERR); - - return sizeof (*data); + } + + if (!posfifo_empty) { + GET_PARAM(self, dsp, 0x0, POS_CALC, + POSFIFO_R0, MONIT_POS_X, MULT_BIT_PARAM, + data->pos_x, NO_FMT_FUNC); + GET_PARAM(self, dsp, 0x0, POS_CALC, + POSFIFO_R1, MONIT_POS_Y, MULT_BIT_PARAM, + data->pos_y, NO_FMT_FUNC); + GET_PARAM(self, dsp, 0x0, POS_CALC, + POSFIFO_R2, MONIT_POS_Q, MULT_BIT_PARAM, + data->pos_q, NO_FMT_FUNC); + GET_PARAM(self, dsp, 0x0, POS_CALC, + POSFIFO_R3, MONIT_POS_SUM, MULT_BIT_PARAM, + data->pos_sum, NO_FMT_FUNC); + } + + if (!ampfifo_empty) { + DBE_DEBUG (DBG_SM_IO | DBG_LVL_TRACE, "[sm_io:dsp_exp] Data AMP: %u %u %u %u\n", + data->amp_ch0, data->amp_ch1, data->amp_ch2, data->amp_ch3); + data->new_amp_data = true; + err = sizeof (*data); + } + + if (!posfifo_empty) { + DBE_DEBUG (DBG_SM_IO | DBG_LVL_TRACE, "[sm_io:dsp_exp] Data POS: %d %d %d %d\n", + data->pos_x, data->pos_y, data->pos_q, data->pos_sum); + data->new_pos_data = true; + err = sizeof (*data); + } + + /* return the whole dsp_data structure even if we don't have new data. + * This avoids specific treatment for client handling */ + err = sizeof (*data); err_get_dsp_handler: -err_exit: return err; } diff --git a/core/sm_io/src/sm_io/c/modules/fmc_adc_common/sm_io_fmc_adc_common_exp.c b/core/sm_io/src/sm_io/c/modules/fmc_adc_common/sm_io_fmc_adc_common_exp.c index 6363a5e0..b2a10799 100644 --- a/core/sm_io/src/sm_io/c/modules/fmc_adc_common/sm_io_fmc_adc_common_exp.c +++ b/core/sm_io/src/sm_io/c/modules/fmc_adc_common/sm_io_fmc_adc_common_exp.c @@ -54,6 +54,16 @@ RW_PARAM_FUNC(fmc_adc_common, leds) { NO_FMT_FUNC, SET_FIELD); } + +#define HALCS_FMC_ADC_COMMON_MMCM_RST_MIN 0 /* No effect */ +#define HALCS_FMC_ADC_COMMON_MMCM_RST_MAX 1 /* Reset MMCM. Must clear the bit after a while */ +RW_PARAM_FUNC(fmc_adc_common, mmcm_rst) { + SET_GET_PARAM(fmc_adc_common, 0x0, WB_FMC_ADC_COMMON_CSR, + MONITOR, MMCM_RST, SINGLE_BIT_PARAM, + HALCS_FMC_ADC_COMMON_MMCM_RST_MIN, HALCS_FMC_ADC_COMMON_MMCM_RST_MAX, + NO_CHK_FUNC, NO_FMT_FUNC, SET_FIELD); +} + /***************************** FPGA Control ***************************/ #define HALCS_FMC_ADC_COMMON_TEST_DATA_EN_MIN 0 /* TEST data enable off */ @@ -99,6 +109,7 @@ RW_PARAM_FUNC(fmc_adc_common, trig_val) { /* Exported function pointers */ const disp_table_func_fp fmc_adc_common_exp_fp [] = { RW_PARAM_FUNC_NAME(fmc_adc_common, leds), + RW_PARAM_FUNC_NAME(fmc_adc_common, mmcm_rst), RW_PARAM_FUNC_NAME(fmc_adc_common, test_data_en), RW_PARAM_FUNC_NAME(fmc_adc_common, trig_dir), RW_PARAM_FUNC_NAME(fmc_adc_common, trig_term), diff --git a/core/sm_io_table/include/sm_io_fmc_adc_common_exports.h b/core/sm_io_table/include/sm_io_fmc_adc_common_exports.h index 0b302f4f..3fc1c3f7 100644 --- a/core/sm_io_table/include/sm_io_fmc_adc_common_exports.h +++ b/core/sm_io_table/include/sm_io_fmc_adc_common_exports.h @@ -11,6 +11,7 @@ #include "disptable.h" extern disp_op_t fmc_adc_common_leds_exp; +extern disp_op_t fmc_adc_common_mmcm_rst_exp; extern disp_op_t fmc_adc_common_test_data_en_exp; extern disp_op_t fmc_adc_common_trig_dir_exp; extern disp_op_t fmc_adc_common_trig_term_exp; diff --git a/core/sm_io_table/src/sm_io_table/c/modules/fmc_adc_common/sm_io_fmc_adc_common_exports.c b/core/sm_io_table/src/sm_io_table/c/modules/fmc_adc_common/sm_io_fmc_adc_common_exports.c index 048a140c..d87cdc7e 100644 --- a/core/sm_io_table/src/sm_io_table/c/modules/fmc_adc_common/sm_io_fmc_adc_common_exports.c +++ b/core/sm_io_table/src/sm_io_table/c/modules/fmc_adc_common/sm_io_fmc_adc_common_exports.c @@ -22,6 +22,18 @@ disp_op_t fmc_adc_common_leds_exp = { } }; +disp_op_t fmc_adc_common_mmcm_rst_exp = { + .name = FMC_ADC_COMMON_NAME_MMCM_RST, + .opcode = FMC_ADC_COMMON_OPCODE_MMCM_RST, + .retval = DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + .retval_owner = DISP_OWNER_OTHER, + .args = { + DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), + DISP_ARG_END + } +}; + disp_op_t fmc_adc_common_test_data_en_exp = { .name = FMC_ADC_COMMON_NAME_TEST_DATA_EN, .opcode = FMC_ADC_COMMON_OPCODE_TEST_DATA_EN, @@ -73,6 +85,7 @@ disp_op_t fmc_adc_common_trig_val_exp = { /* Exported function description */ const disp_op_t *fmc_adc_common_exp_ops [] = { &fmc_adc_common_leds_exp, + &fmc_adc_common_mmcm_rst_exp, &fmc_adc_common_test_data_en_exp, &fmc_adc_common_trig_dir_exp, &fmc_adc_common_trig_term_exp, diff --git a/examples/src/acq/c/acq.c b/examples/src/acq/c/acq.c index 99a2e04c..68c9635e 100644 --- a/examples/src/acq/c/acq.c +++ b/examples/src/acq/c/acq.c @@ -25,6 +25,7 @@ #define MAX_NUM_CHANS (1 << 8) #define DFLT_FILE_FMT 0 +#define DFLT_NEWACQ_NUM 1 typedef enum { TEXT = 0, @@ -81,15 +82,16 @@ static struct option long_options[] = {"help", no_argument, NULL, 'h'}, {"brokerendp", required_argument, NULL, 'b'}, {"verbose", no_argument, NULL, 'v'}, - {"halcsnumber", required_argument, NULL, 's'}, + {"halcsnumber", required_argument, NULL, 's'}, {"boardslot", required_argument, NULL, 'o'}, {"channumber", required_argument, NULL, 'c'}, {"numsamples", required_argument, NULL, 'n'}, {"filefmt", required_argument, NULL, 'f'}, + {"newacq", required_argument, NULL, 'a'}, {NULL, 0, NULL, 0} }; -static const char* shortopt = "hb:vo:s:c:n:f:"; +static const char* shortopt = "hb:vo:s:c:n:f:a:"; void print_help (char *program_name) { @@ -111,7 +113,8 @@ void print_help (char *program_name) " 13 -> FOFB Pos; 14 -> Monit Amp; 15 -> Monit Pha; 16 -> Monit Pos]\n" " -n --numsamples Number of samples\n" " -f --filefmt \n" - " Output format\n", + " Output format\n" + " -a --newcq