Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
A
Ardupilot
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
OpenSource
Ardupilot
Commits
7831113f
Commit
7831113f
authored
11 years ago
by
Andrew Tridgell
Browse files
Options
Downloads
Patches
Plain Diff
AP_InertialSensor: yield the CPU for the right time in wait_for_sample()
this improves timing performance
parent
d973730b
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
libraries/AP_InertialSensor/AP_InertialSensor_PX4.cpp
+7
-1
7 additions, 1 deletion
libraries/AP_InertialSensor/AP_InertialSensor_PX4.cpp
with
7 additions
and
1 deletion
libraries/AP_InertialSensor/AP_InertialSensor_PX4.cpp
+
7
−
1
View file @
7831113f
...
@@ -159,7 +159,13 @@ bool AP_InertialSensor_PX4::wait_for_sample(uint16_t timeout_ms)
...
@@ -159,7 +159,13 @@ bool AP_InertialSensor_PX4::wait_for_sample(uint16_t timeout_ms)
}
}
uint32_t
start
=
hal
.
scheduler
->
millis
();
uint32_t
start
=
hal
.
scheduler
->
millis
();
while
((
hal
.
scheduler
->
millis
()
-
start
)
<
timeout_ms
)
{
while
((
hal
.
scheduler
->
millis
()
-
start
)
<
timeout_ms
)
{
hal
.
scheduler
->
delay_microseconds
(
100
);
uint64_t
tnow
=
hrt_absolute_time
();
// we spin for the last timing_lag microseconds. Before that
// we yield the CPU to allow IO to happen
const
uint16_t
timing_lag
=
400
;
if
(
_last_sample_timestamp
+
_sample_time_usec
>
tnow
+
timing_lag
)
{
hal
.
scheduler
->
delay_microseconds
(
_last_sample_timestamp
+
_sample_time_usec
-
(
tnow
+
timing_lag
));
}
if
(
sample_available
())
{
if
(
sample_available
())
{
return
true
;
return
true
;
}
}
...
...
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