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
fd396045
Commit
fd396045
authored
7 years ago
by
Bas Stottelaar
Browse files
Options
Downloads
Patches
Plain Diff
test: periph_timer: check if argument is passed.
parent
6eaffbb2
No related branches found
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
tests/periph_timer/main.c
+9
-2
9 additions, 2 deletions
tests/periph_timer/main.c
with
9 additions
and
2 deletions
tests/periph_timer/main.c
+
9
−
2
View file @
fd396045
...
@@ -34,15 +34,17 @@
...
@@ -34,15 +34,17 @@
#define MAX_CHANNELS (10U)
#define MAX_CHANNELS (10U)
#define TIM_SPEED (1000000ul)
/* try to run with 1MHz */
#define TIM_SPEED (1000000ul)
/* try to run with 1MHz */
#define CHAN_OFFSET (5000U)
/* fire every 5ms */
#define CHAN_OFFSET (5000U)
/* fire every 5ms */
#define COOKIE (100U)
/* for checking if arg is passed */
static
volatile
int
fired
;
static
volatile
int
fired
;
static
volatile
uint32_t
sw_count
;
static
volatile
uint32_t
sw_count
;
static
volatile
uint32_t
timeouts
[
MAX_CHANNELS
];
static
volatile
uint32_t
timeouts
[
MAX_CHANNELS
];
static
volatile
unsigned
args
[
MAX_CHANNELS
];
static
void
cb
(
void
*
arg
,
int
chan
)
static
void
cb
(
void
*
arg
,
int
chan
)
{
{
(
void
)
arg
;
timeouts
[
chan
]
=
sw_count
;
timeouts
[
chan
]
=
sw_count
;
args
[
chan
]
=
(
unsigned
)
arg
+
chan
;
fired
++
;
fired
++
;
}
}
...
@@ -55,10 +57,11 @@ static int test_timer(unsigned num)
...
@@ -55,10 +57,11 @@ static int test_timer(unsigned num)
fired
=
0
;
fired
=
0
;
for
(
unsigned
i
=
0
;
i
<
MAX_CHANNELS
;
i
++
)
{
for
(
unsigned
i
=
0
;
i
<
MAX_CHANNELS
;
i
++
)
{
timeouts
[
i
]
=
0
;
timeouts
[
i
]
=
0
;
args
[
i
]
=
UINT_MAX
;
}
}
/* initialize and halt timer */
/* initialize and halt timer */
if
(
timer_init
(
TIMER_DEV
(
num
),
TIM_SPEED
,
cb
,
NULL
)
<
0
)
{
if
(
timer_init
(
TIMER_DEV
(
num
),
TIM_SPEED
,
cb
,
(
void
*
)(
COOKIE
*
num
)
)
<
0
)
{
printf
(
"TIMER_%u: ERROR on initialization - skipping
\n\n
"
,
num
);
printf
(
"TIMER_%u: ERROR on initialization - skipping
\n\n
"
,
num
);
return
0
;
return
0
;
}
}
...
@@ -91,6 +94,10 @@ static int test_timer(unsigned num)
...
@@ -91,6 +94,10 @@ static int test_timer(unsigned num)
}
while
(
fired
!=
set
);
}
while
(
fired
!=
set
);
/* collect results */
/* collect results */
for
(
int
i
=
0
;
i
<
fired
;
i
++
)
{
for
(
int
i
=
0
;
i
<
fired
;
i
++
)
{
if
(
args
[
i
]
!=
((
COOKIE
*
num
)
+
i
))
{
printf
(
"TIMER_%u: ERROR callback argument mismatch
\n\n
"
,
num
);
return
0
;
}
printf
(
"TIMER_%u: channel %i fired at SW count %8u"
,
printf
(
"TIMER_%u: channel %i fired at SW count %8u"
,
num
,
i
,
(
unsigned
)
timeouts
[
i
]);
num
,
i
,
(
unsigned
)
timeouts
[
i
]);
if
(
i
==
0
)
{
if
(
i
==
0
)
{
...
...
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