Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
Baitboat
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
Baitboat
Commits
0c8cef57
Commit
0c8cef57
authored
12 years ago
by
Andrew Tridgell
Browse files
Options
Downloads
Patches
Plain Diff
ADC: switch to SREG = oldSREG pattern for interrupt mask/restore
parent
27e3f0c0
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_ADC/AP_ADC_ADS7844.cpp
+5
-2
5 additions, 2 deletions
libraries/AP_ADC/AP_ADC_ADS7844.cpp
with
5 additions
and
2 deletions
libraries/AP_ADC/AP_ADC_ADS7844.cpp
+
5
−
2
View file @
0c8cef57
...
...
@@ -179,12 +179,14 @@ float AP_ADC_ADS7844::Ch(uint8_t ch_num)
while
(
_count
[
ch_num
]
==
0
)
/* noop */
;
// grab the value with interrupts disabled, and clear the count
uint8_t
oldSREG
=
SREG
;
cli
();
count
=
_count
[
ch_num
];
sum
=
_sum
[
ch_num
];
_count
[
ch_num
]
=
0
;
_sum
[
ch_num
]
=
0
;
sei
();
SREG
=
oldSREG
;
return
((
float
)
sum
)
/
count
;
}
...
...
@@ -220,6 +222,7 @@ uint32_t AP_ADC_ADS7844::Ch6(const uint8_t *channel_numbers, float *result)
}
// grab the values with interrupts disabled, and clear the counts
uint8_t
oldSREG
=
SREG
;
cli
();
for
(
i
=
0
;
i
<
6
;
i
++
)
{
count
[
i
]
=
_count
[
channel_numbers
[
i
]];
...
...
@@ -233,7 +236,7 @@ uint32_t AP_ADC_ADS7844::Ch6(const uint8_t *channel_numbers, float *result)
uint32_t
ret
=
_ch6_last_sample_time_micros
-
_ch6_delta_time_start_micros
;
_ch6_delta_time_start_micros
=
_ch6_last_sample_time_micros
;
sei
()
;
SREG
=
oldSREG
;
// calculate averages. We keep this out of the cli region
// to prevent us stalling the ISR while doing the
...
...
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