Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
RIOT
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
cm-projects
RIOT
Commits
0ddd6ec1
Commit
0ddd6ec1
authored
9 years ago
by
Oleg Hahm
Browse files
Options
Downloads
Patches
Plain Diff
xtimer: implement xtimer_msg_receive_timeout
parent
567d0efe
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
sys/xtimer/xtimer.c
+31
-9
31 additions, 9 deletions
sys/xtimer/xtimer.c
with
31 additions
and
9 deletions
sys/xtimer/xtimer.c
+
31
−
9
View file @
0ddd6ec1
...
@@ -159,22 +159,44 @@ void xtimer_now_timex(timex_t *out)
...
@@ -159,22 +159,44 @@ void xtimer_now_timex(timex_t *out)
out
->
microseconds
=
now
-
(
out
->
seconds
*
SEC_IN_USEC
);
out
->
microseconds
=
now
-
(
out
->
seconds
*
SEC_IN_USEC
);
}
}
int
xtimer_msg_receive_timeout64
(
msg_t
*
m
,
uint64_t
timeout
)
{
/* Prepares the message to trigger the timeout.
msg_t
tmsg
;
* Additionally, the xtimer_t struct gets initialized.
tmsg
.
type
=
MSG_XTIMER
;
*/
tmsg
.
content
.
ptr
=
(
char
*
)
&
tmsg
;
static
void
_setup_timer_msg
(
msg_t
*
m
,
xtimer_t
*
t
)
{
m
->
type
=
MSG_XTIMER
;
m
->
content
.
ptr
=
(
char
*
)
m
;
xtimer_t
t
;
t
->
target
=
t
->
long_target
=
0
;
t
.
target
=
t
.
long_target
=
0
;
}
xtimer_set_msg64
(
&
t
,
timeout
,
&
tmsg
,
sched_active_pid
);
/* Waits for incoming message or timeout. */
static
int
_msg_wait
(
msg_t
*
m
,
msg_t
*
tmsg
,
xtimer_t
*
t
)
{
msg_receive
(
m
);
msg_receive
(
m
);
if
(
m
->
type
==
MSG_XTIMER
&&
m
->
content
.
ptr
==
(
char
*
)
&
tmsg
)
{
if
(
m
->
type
==
MSG_XTIMER
&&
m
->
content
.
ptr
==
(
char
*
)
tmsg
)
{
/* we hit the timeout */
/* we hit the timeout */
return
-
1
;
return
-
1
;
}
}
else
{
else
{
xtimer_remove
(
&
t
);
xtimer_remove
(
t
);
return
1
;
return
1
;
}
}
}
}
int
xtimer_msg_receive_timeout64
(
msg_t
*
m
,
uint64_t
timeout
)
{
msg_t
tmsg
;
xtimer_t
t
;
_setup_timer_msg
(
&
tmsg
,
&
t
);
xtimer_set_msg64
(
&
t
,
timeout
,
&
tmsg
,
sched_active_pid
);
return
_msg_wait
(
m
,
&
tmsg
,
&
t
);
}
int
xtimer_msg_receive_timeout
(
msg_t
*
msg
,
uint32_t
us
)
{
msg_t
tmsg
;
xtimer_t
t
;
_setup_timer_msg
(
&
tmsg
,
&
t
);
xtimer_set_msg
(
&
t
,
us
,
&
tmsg
,
sched_active_pid
);
return
_msg_wait
(
msg
,
&
tmsg
,
&
t
);
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment