Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
Firmware
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
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Alberto Ruiz Garcia
Firmware
Commits
e0a9024b
Commit
e0a9024b
authored
12 years ago
by
px4dev
Browse files
Options
Downloads
Patches
Plain Diff
Add some simple interrupt latency tracking.
parent
88f0080a
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
nuttx/configs/px4fmu/src/up_hrt.c
+39
-2
39 additions, 2 deletions
nuttx/configs/px4fmu/src/up_hrt.c
with
39 additions
and
2 deletions
nuttx/configs/px4fmu/src/up_hrt.c
+
39
−
2
View file @
e0a9024b
...
...
@@ -244,9 +244,21 @@
*/
static
struct
sq_queue_s
callout_queue
;
/* latency baseline (last compare value applied) */
static
uint16_t
latency_baseline
;
/* timer count at interrupt (for latency purposes) */
static
uint16_t
latency_actual
;
/* latency histogram */
#define LATENCY_BUCKET_COUNT 8
static
const
uint16_t
latency_buckets
[
LATENCY_BUCKET_COUNT
]
=
{
1
,
2
,
5
,
10
,
20
,
50
,
100
,
1000
};
static
uint32_t
latency_counters
[
LATENCY_BUCKET_COUNT
+
1
];
/* timer-specific functions */
static
void
hrt_tim_init
(
void
);
static
int
hrt_tim_isr
(
int
irq
,
void
*
context
);
static
void
hrt_latency_update
(
void
);
/* callout list manipulation */
static
void
hrt_call_internal
(
struct
hrt_call
*
entry
,
...
...
@@ -502,6 +514,9 @@ hrt_tim_isr(int irq, void *context)
{
uint32_t
status
;
/* grab the timer for latency tracking purposes */
latency_actual
=
rCNT
;
/* copy interrupt status */
status
=
rSR
;
...
...
@@ -516,6 +531,10 @@ hrt_tim_isr(int irq, void *context)
/* was this a timer tick? */
if
(
status
&
SR_INT_HRT
)
{
/* do latency calculations */
hrt_latency_update
();
/* run any callouts that have met their deadline */
hrt_call_invoke
();
...
...
@@ -799,8 +818,26 @@ hrt_call_reschedule()
}
//lldbg("schedule for %u at %u\n", (unsigned)(deadline & 0xffffffff), (unsigned)(now & 0xffffffff));
/* set the new compare value */
rCCR_HRT
=
deadline
&
0xffff
;
/* set the new compare value
and remember it for latency tracking
*/
rCCR_HRT
=
latency_baseline
=
deadline
&
0xffff
;
}
static
void
hrt_latency_update
(
void
)
{
uint16_t
latency
=
latency_actual
-
latency_baseline
;
unsigned
index
;
/* bounded buckets */
for
(
index
=
0
;
index
<
LATENCY_BUCKET_COUNT
;
index
++
)
{
if
(
latency
<=
latency_buckets
[
index
])
{
latency_counters
[
index
]
++
;
return
;
}
}
/* catch-all at the end */
latency_counters
[
index
]
++
;
}
#endif
/* CONFIG_HRT_TIMER */
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