Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
B
bpm-sw
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
bpm
bpm-sw
Commits
fc8839d4
Commit
fc8839d4
authored
Aug 12, 2014
by
Lucas Russo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
hal/sm_io/*/fmc130m_4ch/*: add first AD9510 interface (WIP)
parent
1d9f4cbf
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
143 additions
and
15 deletions
+143
-15
fmc130m_4ch.mk
hal/sm_io/modules/fmc130m_4ch/fmc130m_4ch.mk
+2
-1
sm_io_fmc130m_4ch_codes.h
hal/sm_io/modules/fmc130m_4ch/sm_io_fmc130m_4ch_codes.h
+9
-5
sm_io_fmc130m_4ch_core.c
hal/sm_io/modules/fmc130m_4ch/sm_io_fmc130m_4ch_core.c
+10
-2
sm_io_fmc130m_4ch_core.h
hal/sm_io/modules/fmc130m_4ch/sm_io_fmc130m_4ch_core.h
+5
-4
sm_io_fmc130m_4ch_defaults.c
hal/sm_io/modules/fmc130m_4ch/sm_io_fmc130m_4ch_defaults.c
+59
-0
sm_io_fmc130m_4ch_defaults.h
hal/sm_io/modules/fmc130m_4ch/sm_io_fmc130m_4ch_defaults.h
+19
-0
sm_io_fmc130m_4ch_exp.c
hal/sm_io/modules/fmc130m_4ch/sm_io_fmc130m_4ch_exp.c
+39
-3
No files found.
hal/sm_io/modules/fmc130m_4ch/fmc130m_4ch.mk
View file @
fc8839d4
sm_io_fmc130m_4ch_DIR = hal/sm_io/modules/fmc130m_4ch
sm_io_fmc130m_4ch_OBJS = $(sm_io_fmc130m_4ch_DIR)/sm_io_fmc130m_4ch_core.o \
$(sm_io_fmc130m_4ch_DIR)/sm_io_fmc130m_4ch_exp.o
$(sm_io_fmc130m_4ch_DIR)/sm_io_fmc130m_4ch_exp.o \
$(sm_io_fmc130m_4ch_DIR)/sm_io_fmc130m_4ch_defaults.o
sm_io_fmc130m_4ch_INCLUDE_DIRS = $(sm_io_fmc130m_4ch_DIR)
hal/sm_io/modules/fmc130m_4ch/sm_io_fmc130m_4ch_codes.h
View file @
fc8839d4
...
...
@@ -11,12 +11,16 @@
#include <inttypes.h>
/* Messaging OPCODES */
#define FMC130M_4CH_OPCODE_SIZE (sizeof(uint32_t))
#define FMC130M_4CH_OPCODE_TYPE uint32_t
#define FMC130M_4CH_OPCODE_SIZE
(sizeof(uint32_t))
#define FMC130M_4CH_OPCODE_TYPE
uint32_t
#define FMC130M_4CH_OPCODE_LEDS 0
#define FMC130M_4CH_NAME_LEDS "leds"
#define FMC130M_4CH_OPCODE_END 1
#define FMC130M_4CH_OPCODE_LEDS 0
#define FMC130M_4CH_NAME_LEDS "leds"
#define FMC130M_4CH_OPCODE_PLL_FUNCTION 1
#define FMC130M_4CH_NAME_PLL_FUNCTION "pll_function"
#define FMC130M_4CH_OPCODE_AD9510_CFG_TEST 2
#define FMC130M_4CH_NAME_AD9510_CFG_TEST "ad9510_cfg_test"
#define FMC130M_4CH_OPCODE_END 3
/* Messaging Reply OPCODES */
#define FMC130M_4CH_REPLY_SIZE (sizeof(uint32_t))
...
...
hal/sm_io/modules/fmc130m_4ch/sm_io_fmc130m_4ch_core.c
View file @
fc8839d4
...
...
@@ -12,6 +12,8 @@
#include "sm_io_fmc130m_4ch_core.h"
#include "sm_io_err.h"
#include "hal_assert.h"
#include "hal_stddef.h"
#include "board.h"
/* Undef ASSERT_ALLOC to avoid conflicting with other ASSERT_ALLOC */
#ifdef ASSERT_TEST
...
...
@@ -37,15 +39,20 @@
smio_err_str (err_type))
/* Creates a new instance of Device Information */
smio_fmc130m_4ch_t
*
smio_fmc130m_4ch_new
(
uint32_t
dummy
)
smio_fmc130m_4ch_t
*
smio_fmc130m_4ch_new
(
smio_t
*
parent
)
{
(
void
)
parent
;
smio_fmc130m_4ch_t
*
self
=
(
smio_fmc130m_4ch_t
*
)
zmalloc
(
sizeof
*
self
);
ASSERT_ALLOC
(
self
,
err_self_alloc
);
self
->
dummy
=
dummy
;
self
->
smch_ad9510
=
smch_ad9510_new
(
parent
,
FMC_130M_AD9510_SPI_OFFS
/* Offset
to the beggining of the SMIO base */
,
FMC130M_4CH_AD9510_ADDR
,
0
);
ASSERT_ALLOC
(
self
->
smch_ad9510
,
err_smch_ad9510_alloc
);
return
self
;
err_smch_ad9510_alloc:
free
(
self
);
err_self_alloc:
return
NULL
;
}
...
...
@@ -58,6 +65,7 @@ smio_err_e smio_fmc130m_4ch_destroy (smio_fmc130m_4ch_t **self_p)
if
(
*
self_p
)
{
smio_fmc130m_4ch_t
*
self
=
*
self_p
;
smch_ad9510_destroy
(
&
self
->
smch_ad9510
);
free
(
self
);
*
self_p
=
NULL
;
}
...
...
hal/sm_io/modules/fmc130m_4ch/sm_io_fmc130m_4ch_core.h
View file @
fc8839d4
...
...
@@ -10,9 +10,10 @@
#include <inttypes.h>
#include "sm_io_err.h"
#include "sm_ch_ad9510.h"
struct
_smio_fmc130m_4ch_t
{
uint32_t
dummy
;
/* Just a dummy value to illustrate the idea
*/
smch_ad9510_t
*
smch_ad9510
;
/* AD9510 chip handler
*/
};
/* Opaque class structure */
...
...
@@ -20,9 +21,9 @@ typedef struct _smio_fmc130m_4ch_t smio_fmc130m_4ch_t;
/***************** Our methods *****************/
/* Creates a new instance of the smio realization
n
*/
smio_fmc130m_4ch_t
*
smio_fmc130m_4ch_new
(
uint32_t
dummy
);
/* Destroys the smio realization
n
*/
/* Creates a new instance of the smio realization */
smio_fmc130m_4ch_t
*
smio_fmc130m_4ch_new
(
smio_t
*
parent
);
/* Destroys the smio realization */
smio_err_e
smio_fmc130m_4ch_destroy
(
smio_fmc130m_4ch_t
**
self_p
);
#endif
hal/sm_io/modules/fmc130m_4ch/sm_io_fmc130m_4ch_defaults.c
0 → 100644
View file @
fc8839d4
#include "hal_assert.h"
#include "sm_io_err.h"
#include "sm_io_fmc130m_4ch_defaults.h"
/* We actually use the libclient to do the "heavy" work for us */
#include "bpm_client.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:fmc130m_4ch_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:fmc130m_4ch_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:fmc130m_4ch_defaults]", \
smio_err_str (err_type))
#define SMIO_FMC130M_4CH_LIBCLIENT_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
fmc130m_4ch_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:fmc130m_4ch_defaults] Configuring SMIO "
"SWAP 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_FMC130M_4CH_LIBCLIENT_LOG_MODE
);
client_err
=
bpm_set_fmc_pll_function
(
config_client
,
service
,
FMC130M_4CH_DFLT_PLL_FUNC
);
ASSERT_TEST
(
client_err
==
BPM_CLIENT_SUCCESS
,
"Could not set FMC PLL function"
,
err_param_set
,
SMIO_ERR_CONFIG_DFLT
);
err_param_set:
bpm_client_destroy
(
&
config_client
);
return
err
;
}
hal/sm_io/modules/fmc130m_4ch/sm_io_fmc130m_4ch_defaults.h
0 → 100644
View file @
fc8839d4
/*
* Copyright (C) 2014 LNLS (www.lnls.br)
* Author: Lucas Russo <lucas.russo@lnls.br>
*
* Released according to the GNU LGPL, version 3 or any later version.
*/
#ifndef _FMC130M_4CH_DEFAULTS_H_
#define _FMC130M_4CH_DEFAULTS_H_
#include "sm_io_err.h"
#define FMC130M_4CH_DFLT_PLL_FUNC 0x1
smio_err_e
fmc130m_4ch_config_defaults
(
char
*
broker_endp
,
char
*
service
,
const
char
*
log_file_name
);
#endif
hal/sm_io/modules/fmc130m_4ch/sm_io_fmc130m_4ch_exp.c
View file @
fc8839d4
...
...
@@ -9,10 +9,12 @@
#include "sm_io_fmc130m_4ch_exp.h"
#include "sm_io_fmc130m_4ch_codes.h"
#include "sm_io_fmc130m_4ch_defaults.h"
#include "sm_io.h"
#include "dev_io.h"
#include "board.h"
#include "hal_assert.h"
#include "rw_param.h"
#include "wb_fmc130m_4ch_regs.h"
/* Undef ASSERT_ALLOC to avoid conflicting with other ASSERT_ALLOC */
...
...
@@ -38,6 +40,9 @@
CHECK_HAL_ERR(err, SM_IO, "[sm_io:fmc130m_4ch_exp]", \
smio_err_str (err_type))
#define SMIO_FMC130_HANDLER(self) ((smio_fmc130m_4ch_t *) self->smio_handler)
#define SMIO_AD9510_HANDLER(self) ((smch_ad9510_t *) SMIO_FMC130_HANDLER(self)->smch_ad9510)
/************************************************************/
/************ Specific FMC_130M_4CH Operations **************/
/************************************************************/
...
...
@@ -58,13 +63,43 @@ static void *_fmc130m_4ch_leds (void *owner, void *args)
DBE_DEBUG
(
DBG_SM_IO
|
DBG_LVL_TRACE
,
"[sm_io:fmc130m_4ch_exp] Led write: 0x%08x
\n
"
,
leds
);
/* Don't send any response, for now... */
zmsg_destroy
(
exp_msg
->
msg
);
return
NULL
;
}
#define BPM_FMC130M_4CH_PLL_FUNC_MIN 0
/* PLL FUNCTION pin 0 */
#define BPM_FMC130M_4CH_PLL_FUNC_MAX 1
/* PLL FUNCTION pin 1 */
RW_PARAM_FUNC
(
fmc130m_4ch
,
pll_func
)
{
SET_GET_PARAM
(
fmc130m_4ch
,
FMC_130M_CTRL_REGS_OFFS
,
WB_FMC_130M_4CH_CSR
,
CLK_DISTRIB
,
PLL_FUNCTION
,
SINGLE_BIT_PARAM
,
BPM_FMC130M_4CH_PLL_FUNC_MIN
,
BPM_FMC130M_4CH_PLL_FUNC_MAX
,
NO_CHK_FUNC
,
NO_FMT_FUNC
,
SET_FIELD
);
}
static
void
*
_fmc130m_4ch_ad9510_cfg_test
(
void
*
owner
,
void
*
args
)
{
assert
(
owner
);
assert
(
args
);
smio_t
*
self
=
(
smio_t
*
)
owner
;
smch_ad9510_t
*
smch_ad9510
=
SMIO_AD9510_HANDLER
(
self
);
exp_msg_zmq_t
*
exp_msg
=
(
exp_msg_zmq_t
*
)
args
;
assert
(
zmsg_size
(
*
exp_msg
->
msg
)
>
0
);
DBE_DEBUG
(
DBG_SM_IO
|
DBG_LVL_TRACE
,
"[sm_io:fmc130m_4ch_exp] Calling _fmc130m_4ch_ad9510_config_test
\n
"
);
smch_ad9510_config_test
(
smch_ad9510
);
zmsg_destroy
(
exp_msg
->
msg
);
return
NULL
;
}
const
smio_exp_ops_t
fmc130m_exp_ops
[]
=
{
{.
name
=
FMC130M_4CH_NAME_LEDS
,
.
opcode
=
FMC130M_4CH_OPCODE_LEDS
,
.
func_fp
=
_fmc130m_4ch_leds
},
{.
name
=
FMC130M_4CH_NAME_PLL_FUNCTION
,
.
opcode
=
FMC130M_4CH_OPCODE_PLL_FUNCTION
,
.
func_fp
=
RW_PARAM_FUNC_NAME
(
fmc130m_4ch
,
pll_func
)},
{.
name
=
FMC130M_4CH_NAME_AD9510_CFG_TEST
,
.
opcode
=
FMC130M_4CH_OPCODE_AD9510_CFG_TEST
,
.
func_fp
=
_fmc130m_4ch_ad9510_cfg_test
},
{.
name
=
NULL
,
.
opcode
=
0
,
.
func_fp
=
NULL
}
/* Must end with this NULL pattern */
};
...
...
@@ -148,7 +183,7 @@ smio_err_e fmc130m_4ch_init (smio_t * self)
self
->
exp_ops
=
fmc130m_exp_ops
;
/* Initialize specific structure */
self
->
smio_handler
=
smio_fmc130m_4ch_new
(
0
);
self
->
smio_handler
=
smio_fmc130m_4ch_new
(
self
);
ASSERT_ALLOC
(
self
->
smio_handler
,
err_smio_handler_alloc
,
SMIO_ERR_ALLOC
);
return
err
;
...
...
@@ -175,5 +210,6 @@ smio_err_e fmc130m_4ch_shutdown (smio_t *self)
const
smio_bootstrap_ops_t
fmc130m_4ch_bootstrap_ops
=
{
.
init
=
fmc130m_4ch_init
,
.
shutdown
=
fmc130m_4ch_shutdown
.
shutdown
=
fmc130m_4ch_shutdown
,
.
config_defaults
=
fmc130m_4ch_config_defaults
};
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment