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
ec441e9a
Commit
ec441e9a
authored
9 years ago
by
Kaspar Schleiser
Browse files
Options
Downloads
Patches
Plain Diff
native: periph/timer: prevent underflow in timer_set_absolute
parent
3f73e87f
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
cpu/native/periph/timer.c
+8
-1
8 additions, 1 deletion
cpu/native/periph/timer.c
with
8 additions
and
1 deletion
cpu/native/periph/timer.c
+
8
−
1
View file @
ec441e9a
...
...
@@ -122,8 +122,15 @@ int timer_set(tim_t dev, int channel, unsigned int offset)
int
timer_set_absolute
(
tim_t
dev
,
int
channel
,
unsigned
int
value
)
{
uint32_t
now
=
timer_read
(
dev
);
int64_t
target
=
(
int32_t
)(
value
-
now
);
timer_set
(
dev
,
channel
,
value
-
now
);
DEBUG
(
"timer_set_absolute(): delta=%lli
\n
"
,
target
);
if
(
target
<
0
&&
target
>
-
NATIVE_TIMER_MIN_RES
)
{
DEBUG
(
"timer_set_absolute(): preventing underflow.
\n
"
);
target
=
NATIVE_TIMER_MIN_RES
;
}
timer_set
(
dev
,
channel
,
target
);
return
1
;
}
...
...
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