summaryrefslogtreecommitdiff
path: root/embassy-stm32
diff options
context:
space:
mode:
authorDario Nieuwenhuis <dirbaio@dirbaio.net>2021-07-05 03:09:42 +0200
committerDario Nieuwenhuis <dirbaio@dirbaio.net>2021-07-05 03:18:23 +0200
commitecc151d4e28394ed2dcec466e86ea1880095f9aa (patch)
tree76ec36764d49225112056f8e3ef38d40ad5f7cde /embassy-stm32
parent7ebd4e3aa946a4b5aeea086959a38c94487470a3 (diff)
downloadembassy-ecc151d4e28394ed2dcec466e86ea1880095f9aa.zip
stm32/adc: simplify delay handling
Diffstat (limited to 'embassy-stm32')
-rw-r--r--embassy-stm32/src/adc/v3.rs22
1 files changed, 9 insertions, 13 deletions
diff --git a/embassy-stm32/src/adc/v3.rs b/embassy-stm32/src/adc/v3.rs
index 36af6ec4..7480c4a3 100644
--- a/embassy-stm32/src/adc/v3.rs
+++ b/embassy-stm32/src/adc/v3.rs
@@ -1,6 +1,5 @@
use crate::adc::{AdcPin, Instance};
use core::marker::PhantomData;
-use cortex_m::delay::Delay;
use embassy::util::Unborrow;
use embassy_extras::unborrow;
use embedded_hal::blocking::delay::DelayUs;
@@ -123,7 +122,7 @@ pub struct Adc<'d, T: Instance> {
}
impl<'d, T: Instance> Adc<'d, T> {
- pub fn new(_peri: impl Unborrow<Target = T> + 'd, mut delay: Delay) -> (Self, Delay) {
+ pub fn new(_peri: impl Unborrow<Target = T> + 'd, delay: &mut impl DelayUs<u32>) -> Self {
unborrow!(_peri);
unsafe {
T::regs().cr().modify(|reg| {
@@ -142,18 +141,15 @@ impl<'d, T: Instance> Adc<'d, T> {
delay.delay_us(1);
- (
- Self {
- sample_time: Default::default(),
- resolution: Resolution::default(),
- calibrated_vdda: VDDA_CALIB_MV,
- phantom: PhantomData,
- },
- delay,
- )
+ Self {
+ sample_time: Default::default(),
+ resolution: Resolution::default(),
+ calibrated_vdda: VDDA_CALIB_MV,
+ phantom: PhantomData,
+ }
}
- pub fn enable_vref(&self, mut delay: Delay) -> (Vref, Delay) {
+ pub fn enable_vref(&self, delay: &mut impl DelayUs<u32>) -> Vref {
unsafe {
T::common_regs().ccr().modify(|reg| {
reg.set_vrefen(true);
@@ -166,7 +162,7 @@ impl<'d, T: Instance> Adc<'d, T> {
//cortex_m::asm::delay(20_000_000);
delay.delay_us(15);
- (Vref {}, delay)
+ Vref {}
}
pub fn enable_temperature(&self) -> Temperature {