Commit f212bfac authored by Lucas Russo's avatar Lucas Russo

sm_io/modules/*: add new fmc_adc_common module

parent 1e076822
sm_io_fmc_adc_common_DIR = $(SRC_DIR)/sm_io/modules/fmc_adc_common
sm_io_fmc_adc_common_OBJS = $(sm_io_fmc_adc_common_DIR)/sm_io_fmc_adc_common_core.o \
$(sm_io_fmc_adc_common_DIR)/sm_io_fmc_adc_common_exp.o \
$(sm_io_fmc_adc_common_DIR)/sm_io_fmc_adc_common_exports.o \
$(sm_io_fmc_adc_common_DIR)/sm_io_fmc_adc_common_defaults.o
/*
* Copyright (C) 2014 LNLS (www.lnls.br)
* Author: Lucas Russo <lucas.russo@lnls.br>
*
* Released according to the GNU GPL, version 3 or any later version.
*/
#ifndef _SM_IO_FMC_ADC_COMMON_CODES_H_
#define _SM_IO_FMC_ADC_COMMON_CODES_H_
/* Messaging OPCODES */
#define FMC_ADC_COMMON_OPCODE_TYPE uint32_t
#define FMC_ADC_COMMON_OPCODE_SIZE (sizeof (FMC_ADC_COMMON_OPCODE_TYPE))
#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_NAME_TEST_DATA_EN "fmc_adc_common_adc_test_data_en"
#define FMC_ADC_COMMON_OPCODE_TRIG_DIR 2
#define FMC_ADC_COMMON_NAME_TRIG_DIR "fmc_adc_common_trig_dir"
#define FMC_ADC_COMMON_OPCODE_TRIG_TERM 3
#define FMC_ADC_COMMON_NAME_TRIG_TERM "fmc_adc_common_trig_term"
#define FMC_ADC_COMMON_OPCODE_TRIG_VAL 4
#define FMC_ADC_COMMON_NAME_TRIG_VAL "fmc_adc_common_trig_val"
#define FMC_ADC_COMMON_OPCODE_END 5
/* Messaging Reply OPCODES */
#define FMC_ADC_COMMON_REPLY_TYPE uint32_t
#define FMC_ADC_COMMON_REPLY_SIZE (sizeof (FMC_ADC_COMMON_REPLY_TYPE))
#define FMC_ADC_COMMON_OK 0 /* Operation was successful */
#define FMC_ADC_COMMON_ERR 1 /* Could not set/get value */
#define FMC_ADC_COMMON_UNINPL 2 /* Unimplemented function or operation */
#define FMC_ADC_COMMON_REPLY_END 3 /* End marker */
#endif
/*
* Copyright (C) 2014 LNLS (www.lnls.br)
* Author: Lucas Russo <lucas.russo@lnls.br>
*
* Released according to the GNU GPL, version 3 or any later version.
*/
#include "bpm_server.h"
/* Private headers */
#include "sm_io_fmc_adc_common_defaults.h"
#include "sm_io_fmc_adc_common_core.h"
/* Undef ASSERT_ALLOC to avoid conflicting with other ASSERT_ALLOC */
#ifdef ASSERT_TEST
#undef ASSERT_TEST
#endif
#define ASSERT_TEST(test_boolean, err_str, err_goto_label, /* err_core */ ...) \
ASSERT_HAL_TEST(test_boolean, SM_IO, "[sm_io_fmc_adc_common_core]", \
err_str, err_goto_label, /* err_core */ __VA_ARGS__)
#ifdef ASSERT_ALLOC
#undef ASSERT_ALLOC
#endif
#define ASSERT_ALLOC(ptr, err_goto_label, /* err_core */ ...) \
ASSERT_HAL_ALLOC(ptr, SM_IO, "[sm_io_fmc_adc_common_core]", \
smio_err_str(SMIO_ERR_ALLOC), \
err_goto_label, /* err_core */ __VA_ARGS__)
#ifdef CHECK_ERR
#undef CHECK_ERR
#endif
#define CHECK_ERR(err, err_type) \
CHECK_HAL_ERR(err, SM_IO, "[sm_io_fmc_adc_common_core]", \
smio_err_str (err_type))
/* Creates a new instance of Device Information */
smio_fmc_adc_common_t * smio_fmc_adc_common_new (smio_t *parent)
{
(void) parent;
smio_fmc_adc_common_t *self = (smio_fmc_adc_common_t *) zmalloc (sizeof *self);
ASSERT_ALLOC(self, err_self_alloc);
return self;
err_self_alloc:
return NULL;
}
/* Destroy an instance of the Device Information */
smio_err_e smio_fmc_adc_common_destroy (smio_fmc_adc_common_t **self_p)
{
assert (self_p);
if (*self_p) {
smio_fmc_adc_common_t *self = *self_p;
free (self);
*self_p = NULL;
}
return SMIO_SUCCESS;
}
/*
* Copyright (C) 2014 LNLS (www.lnls.br)
* Author: Lucas Russo <lucas.russo@lnls.br>
*
* Released according to the GNU GPL, version 3 or any later version.
*/
#ifndef _SM_IO_FMC_ADC_COMMON_CORE_H_
#define _SM_IO_FMC_ADC_COMMON_CORE_H_
typedef struct {
const uint32_t example;
} smio_fmc_adc_common_t;
/***************** Our methods *****************/
/* Creates a new instance of the smio realization */
smio_fmc_adc_common_t * smio_fmc_adc_common_new (smio_t *parent);
/* Destroys the smio realization */
smio_err_e smio_fmc_adc_common_destroy (smio_fmc_adc_common_t **self_p);
#endif
/*
* Copyright (C) 2014 LNLS (www.lnls.br)
* Author: Lucas Russo <lucas.russo@lnls.br>
*
* Released according to the GNU GPL, version 3 or any later version.
*/
#include "bpm_server.h"
/* Private headers */
#include "sm_io_fmc_adc_common_defaults.h"
/* Undef ASSERT_ALLOC to avoid conflicting with other ASSERT_ALLOC */
#ifdef ASSERT_TEST
#undef ASSERT_TEST
#endif
#define ASSERT_TEST(test_boolean, err_str, err_goto_label, /* err_core */ ...) \
ASSERT_HAL_TEST(test_boolean, SM_IO, "[sm_io:fmc_adc_common_defaults]", \
err_str, err_goto_label, /* err_core */ __VA_ARGS__)
#ifdef ASSERT_ALLOC
#undef ASSERT_ALLOC
#endif
#define ASSERT_ALLOC(ptr, err_goto_label, /* err_core */ ...) \
ASSERT_HAL_ALLOC(ptr, SM_IO, "[sm_io:fmc_adc_common_defaults]", \
smio_err_str(SMIO_ERR_ALLOC), \
err_goto_label, /* err_core */ __VA_ARGS__)
#ifdef CHECK_ERR
#undef CHECK_ERR
#endif
#define CHECK_ERR(err, err_type) \
CHECK_HAL_ERR(err, SM_IO, "[sm_io:fmc_adc_common_defaults]", \
smio_err_str (err_type))
#define SMIO_FMC_ADC_COMMON_LIBBPMCLIENT_LOG_MODE "a"
/* We use the actual libclient to send and configure our default values,
* maintaining internal consistency. So, in fact, we are sending ourselves
* a message containing the default values. Because of this approach, we
* only get to default our values when the functions are already exported
* to the broker, which happens on a late stage. This could cause a fast
* client to get an inconsistent state from our server */
/* TODO: Avoid exporting the functions before we have initialized
* our server with the default values */
smio_err_e fmc_adc_common_config_defaults (char *broker_endp, char *service,
const char *log_file_name)
{
(void) log_file_name;
DBE_DEBUG (DBG_SM_IO | DBG_LVL_INFO, "[sm_io:fmc_adc_common_defaults] Configuring SMIO "
"FMC_ADC_COMMON with default values ...\n");
bpm_client_err_e client_err = BPM_CLIENT_SUCCESS;
smio_err_e err = SMIO_SUCCESS;
bpm_client_t *config_client = bpm_client_new_log_mode (broker_endp, 0,
log_file_name, SMIO_FMC_ADC_COMMON_LIBBPMCLIENT_LOG_MODE);
ASSERT_ALLOC(config_client, err_alloc_client);
client_err = bpm_set_trig_dir (config_client, service, FMC_ADC_COMMON_DFLT_TRIG_DIR);
ASSERT_TEST(client_err == BPM_CLIENT_SUCCESS, "Could not set FMC TRIG DIR function",
err_param_set, SMIO_ERR_CONFIG_DFLT);
err_param_set:
bpm_client_destroy (&config_client);
err_alloc_client:
DBE_DEBUG (DBG_SM_IO | DBG_LVL_INFO, "[sm_io:fmc_adc_common_defaults] Exiting Config thread %s\n",
service);
return err;
}
/*
* Copyright (C) 2014 LNLS (www.lnls.br)
* Author: Lucas Russo <lucas.russo@lnls.br>
*
* Released according to the GNU GPL, version 3 or any later version.
*/
#ifndef _FMC_ADC_COMMON_DEFAULTS_H_
#define _FMC_ADC_COMMON_DEFAULTS_H_
#include "sm_io_err.h"
#define FMC_ADC_COMMON_DFLT_TRIG_DIR 0x0 /* Output direction */
smio_err_e fmc_adc_common_config_defaults (char *broker_endp, char *service,
const char *log_file_name);
#endif
This diff is collapsed.
/*
* Copyright (C) 2014 LNLS (www.lnls.br)
* Author: Lucas Russo <lucas.russo@lnls.br>
*
* Released according to the GNU GPL, version 3 or any later version.
*/
#ifndef _FMC_ADC_COMMON_H_
#define _FMC_ADC_COMMON_H_
/* Known modules IDs (from SDB records defined in FPGA) */
#define FMC_ADC_COMMON_SDB_DEVID 0x2403f569
#define FMC_ADC_COMMON_SDB_NAME "FMC_ADC_COMMON"
extern const smio_bootstrap_ops_t fmc_adc_common_bootstrap_ops;
#endif
/*
* Copyright (C) 2014 LNLS (www.lnls.br)
* Author: Lucas Russo <lucas.russo@lnls.br>
*
* Released according to the GNU GPL, version 3 or any later version.
*/
#include "sm_io_exports_helper.h"
#include "sm_io_codes.h"
/* Description SMIO FMC_ADC_COMMON functions */
disp_op_t fmc_adc_common_leds_exp = {
.name = FMC_ADC_COMMON_NAME_LEDS,
.opcode = FMC_ADC_COMMON_OPCODE_LEDS,
.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,
.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_trig_dir_exp = {
.name = FMC_ADC_COMMON_NAME_TRIG_DIR,
.opcode = FMC_ADC_COMMON_OPCODE_TRIG_DIR,
.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_trig_term_exp = {
.name = FMC_ADC_COMMON_NAME_TRIG_TERM,
.opcode = FMC_ADC_COMMON_OPCODE_TRIG_TERM,
.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_trig_val_exp = {
.name = FMC_ADC_COMMON_NAME_TRIG_VAL,
.opcode = FMC_ADC_COMMON_OPCODE_TRIG_VAL,
.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
}
};
/* Exported function description */
const disp_op_t *fmc_adc_common_exp_ops [] = {
&fmc_adc_common_leds_exp,
&fmc_adc_common_test_data_en_exp,
&fmc_adc_common_trig_dir_exp,
&fmc_adc_common_trig_term_exp,
&fmc_adc_common_trig_val_exp,
NULL
};
/*
* Copyright (C) 2014 LNLS (www.lnls.br)
* Author: Lucas Russo <lucas.russo@lnls.br>
*
* Released according to the GNU GPL, version 3 or any later version.
*/
#ifndef _SM_IO_FMC_ADC_COMMON_EXPORTS_H_
#define _SM_IO_FMC_ADC_COMMON_EXPORTS_H_
#include "disptable.h"
extern disp_op_t fmc_adc_common_leds_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;
extern disp_op_t fmc_adc_common_trig_val_exp;
extern const disp_op_t *fmc_adc_common_exp_ops [];
#endif
include $(SRC_DIR)/sm_io/modules/fmc130m_4ch/fmc130m_4ch.mk \
$(SRC_DIR)/sm_io/modules/fmc250m_4ch/fmc250m_4ch.mk \
$(SRC_DIR)/sm_io/modules/fmc_adc_common/fmc_adc_common.mk \
$(SRC_DIR)/sm_io/modules/acq/acq.mk \
$(SRC_DIR)/sm_io/modules/dsp/dsp.mk \
$(SRC_DIR)/sm_io/modules/swap/swap.mk \
......@@ -11,6 +12,7 @@ sm_io_modules_DIR = $(SRC_DIR)/sm_io/modules
sm_io_modules_OBJS = $(sm_io_modules_DIR)/sm_io_codes.o \
$(sm_io_fmc130m_4ch_OBJS) \
$(sm_io_fmc250m_4ch_OBJS) \
$(sm_io_fmc_adc_common_OBJS) \
$(sm_io_acq_OBJS) \
$(sm_io_dsp_OBJS) \
$(sm_io_swap_OBJS) \
......
......@@ -12,6 +12,7 @@ const disp_op_t **smio_exp_ops [] = {
dsp_exp_ops,
fmc130m_4ch_exp_ops,
fmc250m_4ch_exp_ops,
fmc_adc_common_exp_ops,
swap_exp_ops,
rffe_exp_ops,
afc_diag_exp_ops,
......
......@@ -24,6 +24,7 @@ typedef struct _smio_rffe_version_t smio_rffe_version_t;
/* Include all module's codes */
#include "sm_io_fmc130m_4ch_codes.h"
#include "sm_io_fmc250m_4ch_codes.h"
#include "sm_io_fmc_adc_common_codes.h"
#include "sm_io_acq_codes.h"
#include "sm_io_dsp_codes.h"
#include "sm_io_swap_codes.h"
......@@ -33,6 +34,7 @@ typedef struct _smio_rffe_version_t smio_rffe_version_t;
/* Include all function descriptors */
#include "sm_io_fmc130m_4ch_exports.h"
#include "sm_io_fmc250m_4ch_exports.h"
#include "sm_io_fmc_adc_common_exports.h"
#include "sm_io_acq_exports.h"
#include "sm_io_dsp_exports.h"
#include "sm_io_swap_exports.h"
......
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