Commit a0f3f992 authored by Lucas Russo's avatar Lucas Russo

sm_io/*/fmc130m_4ch/*: fix non protocol conformant functions

blink_leds and ad9510_cfg_defaults were not using
our simple messaging protocol, which causes some
confusion for the client programmer, as well as
for libbpmclient.
parent 127491c7
...@@ -67,7 +67,7 @@ smio_err_e fmc130m_4ch_config_defaults (char *broker_endp, char *service, ...@@ -67,7 +67,7 @@ smio_err_e fmc130m_4ch_config_defaults (char *broker_endp, char *service,
ASSERT_TEST(client_err == BPM_CLIENT_SUCCESS, "Could not set FMC TRIG DIR function", ASSERT_TEST(client_err == BPM_CLIENT_SUCCESS, "Could not set FMC TRIG DIR function",
err_param_set, SMIO_ERR_CONFIG_DFLT); err_param_set, SMIO_ERR_CONFIG_DFLT);
client_err = bpm_ad9510_cfg_defaults (config_client, service); client_err = bpm_ad9510_cfg_defaults (config_client, service, 0);
ASSERT_TEST(client_err == BPM_CLIENT_SUCCESS || ASSERT_TEST(client_err == BPM_CLIENT_SUCCESS ||
client_err == BPM_CLIENT_ERR_AGAIN, "Could not configure AD9510", client_err == BPM_CLIENT_ERR_AGAIN, "Could not configure AD9510",
err_param_set, SMIO_ERR_CONFIG_DFLT); err_param_set, SMIO_ERR_CONFIG_DFLT);
......
...@@ -53,25 +53,24 @@ ...@@ -53,25 +53,24 @@
} \ } \
}) })
static smch_err_e smch_ad9510_cfg_defaults_compat (smch_ad9510_t *self,
uint32_t *param);
/************************************************************/ /************************************************************/
/************ Specific FMC_130M_4CH Operations **************/ /************ Specific FMC_130M_4CH Operations **************/
/************************************************************/ /************************************************************/
static int _fmc130m_4ch_leds (void *owner, void *args, void *ret)
{
(void) ret;
assert (owner);
assert (args);
SMIO_OWNER_TYPE *self = SMIO_EXP_OWNER(owner); #define BPM_FMC130M_4CH_LEDS_MIN 0 /* LED 0 = 0, LED 1 = 0, LED 3 = 0*/
uint32_t leds = *(uint32_t *) EXP_MSG_ZMQ_FIRST_ARG(args); #define BPM_FMC130M_4CH_LEDS_MAX 7 /* LED 0 = 1, LED 1 = 1, LED 2 = 1*/
#define WB_FMC_130M_4CH_CSR_MONITOR_GLOBAL_MASK WBGEN2_GEN_MASK(1, 3)
#define WB_FMC_130M_4CH_CSR_MONITOR_GLOBAL_W(val) WBGEN2_GEN_WRITE(val, 1, 3)
#define WB_FMC_130M_4CH_CSR_MONITOR_GLOBAL_R(reg) WBGEN2_GEN_READ(reg, 1, 3)
DBE_DEBUG (DBG_SM_IO | DBG_LVL_TRACE, "[sm_io:fmc130m_4ch] Calling _fmc130m_4ch_leds\n"); RW_PARAM_FUNC(fmc130m_4ch, leds) {
smio_thsafe_client_write_32 (self, FMC_130M_CTRL_REGS_OFFS | SET_GET_PARAM(fmc130m_4ch, FMC_130M_CTRL_REGS_OFFS, WB_FMC_130M_4CH_CSR,
WB_FMC_130M_4CH_CSR_REG_MONITOR , &leds); MONITOR, GLOBAL, MULT_BIT_PARAM,
DBE_DEBUG (DBG_SM_IO | DBG_LVL_TRACE, "[sm_io:fmc130m_4ch] Led write: 0x%08x\n", BPM_FMC130M_4CH_LEDS_MIN, BPM_FMC130M_4CH_LEDS_MAX, NO_CHK_FUNC,
leds); NO_FMT_FUNC, SET_FIELD);
return -FMC130M_4CH_OK;
} }
#define BPM_FMC130M_4CH_SI571_OE_MIN 0 /* SI571 Output disable */ #define BPM_FMC130M_4CH_SI571_OE_MIN 0 /* SI571 Output disable */
...@@ -84,7 +83,6 @@ RW_PARAM_FUNC(fmc130m_4ch, si571_oe) { ...@@ -84,7 +83,6 @@ RW_PARAM_FUNC(fmc130m_4ch, si571_oe) {
NO_FMT_FUNC, SET_FIELD); NO_FMT_FUNC, SET_FIELD);
} }
#define BPM_FMC130M_4CH_PLL_FUNC_MIN 0 /* PLL FUNCTION pin 0 */ #define BPM_FMC130M_4CH_PLL_FUNC_MIN 0 /* PLL FUNCTION pin 0 */
#define BPM_FMC130M_4CH_PLL_FUNC_MAX 1 /* PLL FUNCTION pin 1 */ #define BPM_FMC130M_4CH_PLL_FUNC_MAX 1 /* PLL FUNCTION pin 1 */
...@@ -465,33 +463,6 @@ RW_PARAM_FUNC(fmc130m_4ch, trig_val) { ...@@ -465,33 +463,6 @@ RW_PARAM_FUNC(fmc130m_4ch, trig_val) {
/******************************** Chips Export functions *************************/ /******************************** Chips Export functions *************************/
static int _fmc130m_4ch_ad9510_cfg_defaults (void *owner, void *args, void *ret)
{
(void) ret;
assert (owner);
assert (args);
int err = -FMC130M_4CH_OK;
SMIO_OWNER_TYPE *self = SMIO_EXP_OWNER(owner);
smio_fmc130m_4ch_t *fmc130m = smio_get_handler (self);
ASSERT_TEST(fmc130m != NULL, "Could not get SMIO FMC130M handler",
err_get_fmc130m_handler, -FMC130M_4CH_ERR);
smch_ad9510_t *smch_ad9510 = SMIO_AD9510_HANDLER(fmc130m);
FMC130M_4CH_CHECK_ACTIVE(self);
DBE_DEBUG (DBG_SM_IO | DBG_LVL_TRACE, "[sm_io:fmc130m_4ch] Calling "
"_fmc130m_4ch_ad9510_cfg_defaults\n");
smch_err_e serr = smch_ad9510_cfg_defaults (smch_ad9510);
ASSERT_TEST(serr == SMCH_SUCCESS, "Could not config AD9510 defaults",
err_smpr_write, -FMC130M_4CH_ERR);
err_smpr_write:
err_get_fmc130m_handler:
return err;
}
/* Macros to avoid repetition of the function body AD9510 */ /* Macros to avoid repetition of the function body AD9510 */
typedef smch_err_e (*smch_ad9510_func_fp) (smch_ad9510_t *self, uint32_t *param); typedef smch_err_e (*smch_ad9510_func_fp) (smch_ad9510_t *self, uint32_t *param);
...@@ -504,7 +475,6 @@ typedef smch_err_e (*smch_ad9510_func_fp) (smch_ad9510_t *self, uint32_t *param) ...@@ -504,7 +475,6 @@ typedef smch_err_e (*smch_ad9510_func_fp) (smch_ad9510_t *self, uint32_t *param)
#define FMC130M_4CH_AD9510_FUNC_BODY(owner, args, ret, read_func, write_func, \ #define FMC130M_4CH_AD9510_FUNC_BODY(owner, args, ret, read_func, write_func, \
error_msg) \ error_msg) \
do { \ do { \
(void) ret; \
assert (owner); \ assert (owner); \
assert (args); \ assert (args); \
\ \
...@@ -523,9 +493,17 @@ typedef smch_err_e (*smch_ad9510_func_fp) (smch_ad9510_t *self, uint32_t *param) ...@@ -523,9 +493,17 @@ typedef smch_err_e (*smch_ad9510_func_fp) (smch_ad9510_t *self, uint32_t *param)
FMC130M_4CH_CHECK_ACTIVE(self); \ FMC130M_4CH_CHECK_ACTIVE(self); \
\ \
smch_err_e serr = SMCH_SUCCESS; \ smch_err_e serr = SMCH_SUCCESS; \
uint32_t value = 0; \
/* Call specific function */ \ /* Call specific function */ \
if (rw) { \ if (rw) { \
WHEN(ISEMPTY(read_func))( \
(void) ret; \
DBE_DEBUG (DBG_SM_IO | DBG_LVL_TRACE, "[sm_io:fmc130m_4ch_exp] " \
"AD9510 read function not implemented\n"); \
err = -FMC130M_4CH_UNINPL; \
return err; \
) \
WHENNOT(ISEMPTY(read_func))( \
uint32_t value = 0; \
serr = ((smch_ad9510_func_fp) read_func) (smch_ad9510, \ serr = ((smch_ad9510_func_fp) read_func) (smch_ad9510, \
&value); \ &value); \
if (serr != SMCH_SUCCESS) { \ if (serr != SMCH_SUCCESS) { \
...@@ -537,8 +515,16 @@ typedef smch_err_e (*smch_ad9510_func_fp) (smch_ad9510_t *self, uint32_t *param) ...@@ -537,8 +515,16 @@ typedef smch_err_e (*smch_ad9510_func_fp) (smch_ad9510_t *self, uint32_t *param)
DBE_DEBUG (DBG_SM_IO | DBG_LVL_TRACE, "[sm_io:fmc130m_4ch_exp] " \ DBE_DEBUG (DBG_SM_IO | DBG_LVL_TRACE, "[sm_io:fmc130m_4ch_exp] " \
"AD9510 function read value = 0x%08X\n", value); \ "AD9510 function read value = 0x%08X\n", value); \
} \ } \
) \
} \ } \
else { \ else { \
WHEN(ISEMPTY(write_func))( \
DBE_DEBUG (DBG_SM_IO | DBG_LVL_TRACE, "[sm_io:fmc130m_4ch_exp] " \
"AD9510 write function not implemented\n"); \
err = -FMC130M_4CH_UNINPL; \
return err; \
) \
WHENNOT(ISEMPTY(write_func))( \
serr = ((smch_ad9510_func_fp) write_func) (smch_ad9510, \ serr = ((smch_ad9510_func_fp) write_func) (smch_ad9510, \
&param); \ &param); \
if (serr != SMCH_SUCCESS) { \ if (serr != SMCH_SUCCESS) { \
...@@ -547,12 +533,25 @@ typedef smch_err_e (*smch_ad9510_func_fp) (smch_ad9510_t *self, uint32_t *param) ...@@ -547,12 +533,25 @@ typedef smch_err_e (*smch_ad9510_func_fp) (smch_ad9510_t *self, uint32_t *param)
else { \ else { \
err = -FMC130M_4CH_OK; \ err = -FMC130M_4CH_OK; \
} \ } \
) \
} \ } \
\ \
err_get_fmc130m_handler: \ err_get_fmc130m_handler: \
return err; \ return err; \
} while(0) } while(0)
static smch_err_e smch_ad9510_cfg_defaults_compat (smch_ad9510_t *self, uint32_t *param)
{
(void) param;
return smch_ad9510_cfg_defaults (self);
}
FMC130M_4CH_AD9510_FUNC_NAME_HEADER(cfg_defaults)
{
FMC130M_4CH_AD9510_FUNC_BODY(owner, args, ret, /* No read function */,
smch_ad9510_cfg_defaults_compat, "Could not set/get AD9510 defaults");
}
FMC130M_4CH_AD9510_FUNC_NAME_HEADER(pll_a_div) FMC130M_4CH_AD9510_FUNC_NAME_HEADER(pll_a_div)
{ {
FMC130M_4CH_AD9510_FUNC_BODY(owner, args, ret, smch_ad9510_get_pll_a_div, FMC130M_4CH_AD9510_FUNC_BODY(owner, args, ret, smch_ad9510_get_pll_a_div,
...@@ -660,7 +659,7 @@ FMC130M_4CH_SI571_FUNC_NAME_HEADER(get_defaults) ...@@ -660,7 +659,7 @@ FMC130M_4CH_SI571_FUNC_NAME_HEADER(get_defaults)
/* Exported function pointers */ /* Exported function pointers */
const disp_table_func_fp fmc130m_4ch_exp_fp [] = { const disp_table_func_fp fmc130m_4ch_exp_fp [] = {
_fmc130m_4ch_leds, RW_PARAM_FUNC_NAME(fmc130m_4ch, leds),
RW_PARAM_FUNC_NAME(fmc130m_4ch, si571_oe), RW_PARAM_FUNC_NAME(fmc130m_4ch, si571_oe),
RW_PARAM_FUNC_NAME(fmc130m_4ch, pll_func), RW_PARAM_FUNC_NAME(fmc130m_4ch, pll_func),
RW_PARAM_FUNC_NAME(fmc130m_4ch, pll_status), RW_PARAM_FUNC_NAME(fmc130m_4ch, pll_status),
...@@ -693,7 +692,7 @@ const disp_table_func_fp fmc130m_4ch_exp_fp [] = { ...@@ -693,7 +692,7 @@ const disp_table_func_fp fmc130m_4ch_exp_fp [] = {
RW_PARAM_FUNC_NAME(fmc130m_4ch, trig_dir), RW_PARAM_FUNC_NAME(fmc130m_4ch, trig_dir),
RW_PARAM_FUNC_NAME(fmc130m_4ch, trig_term), RW_PARAM_FUNC_NAME(fmc130m_4ch, trig_term),
RW_PARAM_FUNC_NAME(fmc130m_4ch, trig_val), RW_PARAM_FUNC_NAME(fmc130m_4ch, trig_val),
_fmc130m_4ch_ad9510_cfg_defaults, FMC130M_4CH_AD9510_FUNC_NAME(cfg_defaults),
FMC130M_4CH_AD9510_FUNC_NAME(pll_a_div), FMC130M_4CH_AD9510_FUNC_NAME(pll_a_div),
FMC130M_4CH_AD9510_FUNC_NAME(pll_b_div), FMC130M_4CH_AD9510_FUNC_NAME(pll_b_div),
FMC130M_4CH_AD9510_FUNC_NAME(pll_prescaler), FMC130M_4CH_AD9510_FUNC_NAME(pll_prescaler),
......
...@@ -13,9 +13,10 @@ ...@@ -13,9 +13,10 @@
disp_op_t fmc130m_4ch_leds_exp = { disp_op_t fmc130m_4ch_leds_exp = {
.name = FMC130M_4CH_NAME_LEDS, .name = FMC130M_4CH_NAME_LEDS,
.opcode = FMC130M_4CH_OPCODE_LEDS, .opcode = FMC130M_4CH_OPCODE_LEDS,
.retval = DISP_ARG_END, .retval = DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t),
.retval_owner = DISP_OWNER_OTHER, .retval_owner = DISP_OWNER_OTHER,
.args = { .args = {
DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t),
DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t), DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t),
DISP_ARG_END DISP_ARG_END
} }
...@@ -410,9 +411,11 @@ disp_op_t fmc130m_4ch_trig_val_exp = { ...@@ -410,9 +411,11 @@ disp_op_t fmc130m_4ch_trig_val_exp = {
disp_op_t fmc130m_4ch_ad9510_cfg_defaults_exp = { disp_op_t fmc130m_4ch_ad9510_cfg_defaults_exp = {
.name = FMC130M_4CH_NAME_AD9510_CFG_DEFAULTS, .name = FMC130M_4CH_NAME_AD9510_CFG_DEFAULTS,
.opcode = FMC130M_4CH_OPCODE_AD9510_CFG_DEFAULTS, .opcode = FMC130M_4CH_OPCODE_AD9510_CFG_DEFAULTS,
.retval = DISP_ARG_END, .retval = DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t),
.retval_owner = DISP_OWNER_OTHER, .retval_owner = DISP_OWNER_OTHER,
.args = { .args = {
DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t),
DISP_ARG_ENCODE(DISP_ATYPE_UINT32, uint32_t),
DISP_ARG_END DISP_ARG_END
} }
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment