Skip to content

Commit

Permalink
Merge branch 'devel'
Browse files Browse the repository at this point in the history
  • Loading branch information
lerwys committed Jul 24, 2017
2 parents f1e9a92 + 39102b1 commit 6499a6b
Show file tree
Hide file tree
Showing 15 changed files with 422 additions and 185 deletions.
13 changes: 8 additions & 5 deletions core/common/include/hw/wb_fmc_adc_common_regs.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 */
Expand Down
387 changes: 251 additions & 136 deletions core/common/include/hw/wb_pos_calc_regs.h

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions core/sm_io/include/sm_io_dsp_codes.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@ struct _smio_dsp_data_t {
uint32_t amp_ch1; /* Amplitude CH1 */
uint32_t amp_ch2; /* Amplitude CH2 */
uint32_t amp_ch3; /* Amplitude CH3 */
uint32_t new_amp_data; /* Do we have new AMP data? */
int32_t pos_x; /* Position X */
int32_t pos_y; /* Position Y */
int32_t pos_q; /* Position Q */
uint32_t pos_sum; /* Position Sum */
uint32_t new_pos_data; /* Do we have new POS data? */
};

/* Messaging OPCODES */
Expand Down
12 changes: 7 additions & 5 deletions core/sm_io/include/sm_io_fmc_adc_common_codes.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,17 @@

#define FMC_ADC_COMMON_OPCODE_LEDS 0
#define FMC_ADC_COMMON_NAME_LEDS "fmc_adc_common_leds"
#define FMC_ADC_COMMON_OPCODE_TEST_DATA_EN 1
#define FMC_ADC_COMMON_OPCODE_MMCM_RST 1
#define FMC_ADC_COMMON_NAME_MMCM_RST "fmc_adc_common_mmcm_rst"
#define FMC_ADC_COMMON_OPCODE_TEST_DATA_EN 2
#define FMC_ADC_COMMON_NAME_TEST_DATA_EN "fmc_adc_common_adc_test_data_en"
#define FMC_ADC_COMMON_OPCODE_TRIG_DIR 2
#define FMC_ADC_COMMON_OPCODE_TRIG_DIR 3
#define FMC_ADC_COMMON_NAME_TRIG_DIR "fmc_adc_common_trig_dir"
#define FMC_ADC_COMMON_OPCODE_TRIG_TERM 3
#define FMC_ADC_COMMON_OPCODE_TRIG_TERM 4
#define FMC_ADC_COMMON_NAME_TRIG_TERM "fmc_adc_common_trig_term"
#define FMC_ADC_COMMON_OPCODE_TRIG_VAL 4
#define FMC_ADC_COMMON_OPCODE_TRIG_VAL 5
#define FMC_ADC_COMMON_NAME_TRIG_VAL "fmc_adc_common_trig_val"
#define FMC_ADC_COMMON_OPCODE_END 5
#define FMC_ADC_COMMON_OPCODE_END 6

/* Messaging Reply OPCODES */
#define FMC_ADC_COMMON_REPLY_TYPE uint32_t
Expand Down
14 changes: 7 additions & 7 deletions core/sm_io/src/sm_io/c/chips/sm_ch_ad9510.c
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ smch_err_e smch_ad9510_cfg_defaults (smch_ad9510_t *self)
_smch_ad9510_write_8 (self, AD9510_REG_PLL_R_LSB_COUNTER, &data);

/* Power-up LVPECL outputs */
DBE_DEBUG (DBG_SM_CH | DBG_LVL_INFO,
DBE_DEBUG (DBG_SM_CH | DBG_LVL_TRACE,
"[sm_ch:ad9510] Powering up LVPECL outputs 0-3\n");
data = AD9510_LVPECL_OUT_LVL_W(0x02) /* 810 mV output */ |
AD9510_LVPECL_OUT_PDOWN_W(0x0) /* Do not power down */;
Expand All @@ -201,14 +201,14 @@ smch_err_e smch_ad9510_cfg_defaults (smch_ad9510_t *self)
_smch_ad9510_write_8 (self, AD9510_REG_LVPECL_OUT3, &data);

/* Power-up LVCMOS/LVDS output 4 (DEBUG) */
DBE_DEBUG (DBG_SM_CH | DBG_LVL_INFO,
DBE_DEBUG (DBG_SM_CH | DBG_LVL_TRACE,
"[sm_ch:ad9510] Powering up LVDS/CMOS output 4\n");
data = AD9510_LVDS_CMOS_CURR_W(0x1) /* 3.5 mA, 100 Ohm */ & (
~AD9510_LVDS_CMOS_PDOWN /* Do not power down */);
_smch_ad9510_write_8 (self, AD9510_REG_LVDS_CMOS_OUT4, &data);

/* Power-down LVCMOS/LVDS outputs 5-7*/
DBE_DEBUG (DBG_SM_CH | DBG_LVL_INFO,
DBE_DEBUG (DBG_SM_CH | DBG_LVL_TRACE,
"[sm_ch:ad9510] Powering down LVDS/CMOS outputs 5-7\n");
data = AD9510_LVDS_CMOS_CURR_W(0x1) /* 3.5 mA, 100 Ohm */ | (
AD9510_LVDS_CMOS_PDOWN /* Power down */);
Expand Down Expand Up @@ -601,14 +601,14 @@ smch_err_e smch_ad9510_set_outputs (smch_ad9510_t *self, uint32_t *out_en)

/* Output disabled */
if ((__out_en & AD9510_OUTPUT_EN_LSB_MASK) == 0) {
DBE_DEBUG (DBG_SM_CH | DBG_LVL_INFO,
DBE_DEBUG (DBG_SM_CH | DBG_LVL_TRACE,
"[sm_ch:ad9510] Output #%u is going to be disabled\n", i);
data = (data & ~AD9510_LVPECL_OUT_PDOWN_MASK) |
AD9510_LVPECL_OUT_PDOWN_W(0x02); /* Safe power down */
}
/* Output enabled */
else {
DBE_DEBUG (DBG_SM_CH | DBG_LVL_INFO,
DBE_DEBUG (DBG_SM_CH | DBG_LVL_TRACE,
"[sm_ch:ad9510] Output #%u is going to be enabled\n", i);
data = (data & ~AD9510_LVPECL_OUT_PDOWN_MASK) |
AD9510_LVPECL_OUT_PDOWN_W(0x00); /* Power up */
Expand All @@ -624,13 +624,13 @@ smch_err_e smch_ad9510_set_outputs (smch_ad9510_t *self, uint32_t *out_en)

/* Output disabled */
if ((__out_en & AD9510_OUTPUT_EN_LSB_MASK) == 0) {
DBE_DEBUG (DBG_SM_CH | DBG_LVL_INFO,
DBE_DEBUG (DBG_SM_CH | DBG_LVL_TRACE,
"[sm_ch:ad9510] Output #%u is going to be enabled\n", i);
data |= AD9510_LVDS_CMOS_PDOWN;
}
/* Output enabled */
else {
DBE_DEBUG (DBG_SM_CH | DBG_LVL_INFO,
DBE_DEBUG (DBG_SM_CH | DBG_LVL_TRACE,
"[sm_ch:ad9510] Output #%u is going to be enabled\n", i);
data &= ~AD9510_LVDS_CMOS_PDOWN;
}
Expand Down
4 changes: 2 additions & 2 deletions core/sm_io/src/sm_io/c/chips/sm_ch_si57x.c
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ static smch_err_e _smch_si57x_get_divs (smch_si57x_t *self, uint64_t *rfreq,
tmp = (tmp << 8) + SI57X_RFREQ4_RFREQ_7_0_R(divs[5]);
*rfreq = tmp;

DBE_DEBUG (DBG_SM_CH | DBG_LVL_INFO, "[sm_ch:si57x_get_divs]\n"
DBE_DEBUG (DBG_SM_CH | DBG_LVL_TRACE, "[sm_ch:si57x_get_divs]\n"
"\tRFREQ = %"PRIu64", HS_DIV = %u, N1 = %u\n", *rfreq, *hs_div, *n1);

err_exit:
Expand Down Expand Up @@ -416,7 +416,7 @@ static smch_err_e _smch_si57x_set_freq_raw (smch_si57x_t *self, uint8_t *data,
err = _smch_si57x_wait_new_freq (self);
ASSERT_TEST(err == SMCH_SUCCESS, "New frequency setting timeout", err_exit);

DBE_DEBUG (DBG_SM_CH | DBG_LVL_INFO, "[sm_ch:si57x_set_freq_raw] Setup new "
DBE_DEBUG (DBG_SM_CH | DBG_LVL_TRACE, "[sm_ch:si57x_set_freq_raw] Setup new "
"frequency completed\n");

err_exit:
Expand Down
75 changes: 61 additions & 14 deletions core/sm_io/src/sm_io/c/modules/dsp/sm_io_dsp_exp.c
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,8 @@ static int _dsp_monit_amp_pos (void *owner, void *args, void *ret)
assert (owner);
assert (args);
int err = -DSP_OK;
RW_REPLY_TYPE rw_err = RW_OK;
uint32_t ampfifo_empty;
uint32_t posfifo_empty;

DBE_DEBUG (DBG_SM_IO | DBG_LVL_TRACE, "[sm_io:dsp] "
"Calling _dsp_monit_amp_pos\n");
Expand All @@ -199,27 +200,73 @@ static int _dsp_monit_amp_pos (void *owner, void *args, void *ret)
* Message is:
* frame 0: operation code
*/

smio_dsp_data_t *data = (smio_dsp_data_t *) ret;
data->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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -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),
Expand Down
1 change: 1 addition & 0 deletions core/sm_io_table/include/sm_io_fmc_adc_common_exports.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
32 changes: 27 additions & 5 deletions examples/src/acq/c/acq.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#define MAX_NUM_CHANS (1 << 8)

#define DFLT_FILE_FMT 0
#define DFLT_NEWACQ_NUM 1

typedef enum {
TEXT = 0,
Expand Down Expand Up @@ -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)
{
Expand All @@ -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> Number of samples\n"
" -f --filefmt <Output format = [0 = text | 1=binary]>\n"
" Output format\n",
" Output format\n"
" -a --newcq <Trigger new acquisition = [0 = no | 1 = yes]\n",
program_name);
}

Expand All @@ -123,6 +126,7 @@ int main (int argc, char *argv [])
char *board_number_str = NULL;
char *halcs_number_str = NULL;
char *chan_str = NULL;
char *new_acq_str = NULL;
char *file_fmt_str = NULL;
int opt;

Expand Down Expand Up @@ -159,6 +163,10 @@ int main (int argc, char *argv [])
num_samples_str = strdup (optarg);
break;

case 'a':
new_acq_str = strdup (optarg);
break;

case 'f':
file_fmt_str = strdup (optarg);
break;
Expand Down Expand Up @@ -259,6 +267,20 @@ int main (int argc, char *argv [])
}
}

/* Set new_acq */
uint32_t new_acq;
if (new_acq_str == NULL) {
new_acq = DFLT_NEWACQ_NUM;
}
else {
new_acq = strtoul (new_acq_str, NULL, 10);

if (new_acq != 0 && new_acq != 1) {
fprintf (stderr, "[client:acq]: Newacq parameter is invalid\n");
exit (1);
}
}

char service[50];
snprintf (service, sizeof (service), "HALCS%u:DEVIO:ACQ%u", board_number, halcs_number);

Expand Down Expand Up @@ -295,7 +317,7 @@ int main (int argc, char *argv [])

uint32_t data_size = num_samples*req_ch_sample_size;
uint32_t *data = (uint32_t *) zmalloc (data_size*sizeof (uint8_t));
bool new_acq = true;
bool new_acq_arg = new_acq;
acq_trans_t acq_trans = {.req = {
.num_samples_pre = num_samples,
.num_samples_post = 0,
Expand All @@ -307,7 +329,7 @@ int main (int argc, char *argv [])
.data_size = data_size,
}
};
err = acq_full_compat (acq_client, service, &acq_trans, 50000, new_acq);
err = acq_full_compat (acq_client, service, &acq_trans, 50000, new_acq_arg);
if (err != HALCS_CLIENT_SUCCESS){
fprintf (stderr, "[client:acq]: acq_full_compat failed\n");
goto err_acq_full_compat;
Expand Down
Loading

0 comments on commit 6499a6b

Please sign in to comment.