Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
B
Beam Positoning Monitor - Software
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
Beam Positoning Monitor - Software
Commits
0265c597
Commit
0265c597
authored
Dec 17, 2014
by
Lucas Russo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
hal/*/protocols/sm_pr*: add set/unset protocol ops
parent
df096ee8
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
40 additions
and
3 deletions
+40
-3
sm_pr.c
hal/sm_io/protocols/sm_pr.c
+31
-0
sm_pr.h
hal/sm_io/protocols/sm_pr.h
+4
-0
sm_pr_err.c
hal/sm_io/protocols/sm_pr_err.c
+2
-1
sm_pr_err.h
hal/sm_io/protocols/sm_pr_err.h
+3
-2
No files found.
hal/sm_io/protocols/sm_pr.c
View file @
0265c597
...
...
@@ -97,6 +97,37 @@ smpr_err_e smpr_destroy (smpr_t **self_p)
return
SMPR_SUCCESS
;
}
/* Register Specific Protocol operations to smpr instance */
smpr_err_e
smpr_set_handler
(
smpr_t
*
self
,
void
*
handler
)
{
assert
(
self
);
assert
(
handler
);
smpr_err_e
err
=
SMPR_SUCCESS
;
ASSERT_TEST
(
self
->
proto_handler
==
NULL
,
"Trying to set another handler to "
"SMPR instance"
,
err_dup_handler
,
SMPR_ERR_DUP_HANDLER
);
DBE_DEBUG
(
DBG_SM_PR
|
DBG_LVL_INFO
,
"[sm_pr] Setting protocol handler: %s
\n
"
,
self
->
name
);
self
->
proto_handler
=
handler
;
err_dup_handler:
return
err
;
}
/* Unregister Specific Protocol operations to smpr instance */
void
*
smpr_unset_handler
(
smpr_t
*
self
)
{
assert
(
self
);
void
*
proto_handler
=
self
->
proto_handler
;
DBE_DEBUG
(
DBG_SM_PR
|
DBG_LVL_INFO
,
"[sm_pr] Unsetting protocol handler: %s
\n
"
,
self
->
name
);
self
->
proto_handler
=
NULL
;
return
proto_handler
;
}
/**************** Helper Functions ***************/
/* Register Specific Protocol operations to smpr instance. Helper function */
...
...
hal/sm_io/protocols/sm_pr.h
View file @
0265c597
...
...
@@ -102,6 +102,10 @@ typedef enum _smpr_type_e smpr_type_e;
smpr_t
*
smpr_new
(
char
*
name
,
smio_t
*
parent
,
smpr_type_e
type
,
int
verbose
);
/* Destroy an instance of the Low-level I/O */
smpr_err_e
smpr_destroy
(
smpr_t
**
self_p
);
/* Register Specific Protocol operations to smpr instance */
smpr_err_e
smpr_set_handler
(
smpr_t
*
self
,
void
*
handler
);
/* Unregister Specific Protocol operations to smpr instance */
void
*
smpr_unset_handler
(
smpr_t
*
self
);
/************************************************************/
/***************** Thsafe generic methods API ***************/
...
...
hal/sm_io/protocols/sm_pr_err.c
View file @
0265c597
...
...
@@ -16,7 +16,8 @@ static const char *smpr_err [SMPR_ERR_END] =
[
SMPR_ERR_ALLOC
]
=
"Could not allocate memory"
,
[
SMPR_ERR_INV_FUNC_PARAM
]
=
"Invalid function parameter"
,
[
SMPR_ERR_RW_SMIO
]
=
"Could not Read/Write to/from SMIO"
,
[
SMPR_ERR_FUNC_NOT_IMPL
]
=
"Function not implemented"
[
SMPR_ERR_FUNC_NOT_IMPL
]
=
"Function not implemented"
,
[
SMPR_ERR_DUP_HANDLER
]
=
"Protocol handler already set"
};
/* Convert enumeration type to string */
...
...
hal/sm_io/protocols/sm_pr_err.h
View file @
0265c597
...
...
@@ -15,9 +15,10 @@ enum _smpr_err_e
{
SMPR_SUCCESS
=
0
,
/* No error */
SMPR_ERR_ALLOC
,
/* Could not allocate memory */
SMPR_ERR_INV_FUNC_PARAM
,
/* Invalid function paramter */
SMPR_ERR_FUNC_NOT_IMPL
,
/* Fu
cn
tions not implemented */
SMPR_ERR_INV_FUNC_PARAM
,
/* Invalid function param
e
ter */
SMPR_ERR_FUNC_NOT_IMPL
,
/* Fu
nc
tions not implemented */
SMPR_ERR_RW_SMIO
,
/* Invalid function parameter */
SMPR_ERR_DUP_HANDLER
,
/* Protocol handler already set */
SMPR_ERR_END
/* End of enum marker */
};
...
...
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