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
fdb2baa1
Commit
fdb2baa1
authored
6 years ago
by
Josarn
Committed by
josua
6 years ago
Browse files
Options
Downloads
Patches
Plain Diff
test/xtimer_drift: interval calculation
parent
e8dfabd4
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
tests/xtimer_drift/main.c
+8
-4
8 additions, 4 deletions
tests/xtimer_drift/main.c
with
8 additions
and
4 deletions
tests/xtimer_drift/main.c
+
8
−
4
View file @
fdb2baa1
...
@@ -91,6 +91,10 @@ void *worker_thread(void *arg)
...
@@ -91,6 +91,10 @@ void *worker_thread(void *arg)
{
{
(
void
)
arg
;
(
void
)
arg
;
/* Calculate interval based on possible precision when 'XTIMER_SHIFT > 0',
* to apply precision loss to expected interval length.
* test_interval != TEST_INTERVAL */
uint32_t
test_interval
=
xtimer_usec_from_ticks
(
xtimer_ticks_from_usec
(
TEST_INTERVAL
));
uint32_t
loop_counter
=
0
;
uint32_t
loop_counter
=
0
;
uint32_t
start
=
0
;
uint32_t
start
=
0
;
uint32_t
last
=
0
;
uint32_t
last
=
0
;
...
@@ -111,14 +115,14 @@ void *worker_thread(void *arg)
...
@@ -111,14 +115,14 @@ void *worker_thread(void *arg)
else
if
((
loop_counter
%
TEST_HZ
)
==
0
)
{
else
if
((
loop_counter
%
TEST_HZ
)
==
0
)
{
uint32_t
us
=
now
%
US_PER_SEC
;
uint32_t
us
=
now
%
US_PER_SEC
;
uint32_t
sec
=
now
/
US_PER_SEC
;
uint32_t
sec
=
now
/
US_PER_SEC
;
uint32_t
expected
=
start
+
loop_counter
*
TEST_INTERVAL
;
uint32_t
expected
=
start
+
loop_counter
*
test_interval
;
int32_t
drift
=
now
-
expected
;
int32_t
drift
=
now
-
expected
;
expected
=
last
+
TEST_HZ
*
TEST_INTERVAL
;
expected
=
last
+
TEST_HZ
*
test_interval
;
int32_t
jitter
=
now
-
expected
;
int32_t
jitter
=
now
-
expected
;
printf
(
"now=%"
PRIu32
".%06"
PRIu32
" (0x%08"
PRIx32
" ticks), "
,
printf
(
"now=%"
PRIu32
".%06"
PRIu32
" (0x%08"
PRIx32
" ticks), "
,
sec
,
us
,
ticks
.
ticks32
);
sec
,
us
,
ticks
.
ticks32
);
printf
(
"drift=%"
PRId32
" us, jitter=%"
PRId32
" us
\n
"
,
printf
(
"drift=%"
PRId32
" us, jitter=%"
PRId32
" us
\n
"
,
drift
,
jitter
);
drift
,
jitter
);
last
=
now
;
last
=
now
;
}
}
++
loop_counter
;
++
loop_counter
;
...
...
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