Skip to content

Commit 1731687

Browse files
committed
Fix wait_advregen_startup
1 parent 58cda72 commit 1731687

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/adc.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ use cortex_m::asm;
1515
use embedded_hal::adc::{Channel, OneShot};
1616

1717
use crate::time::rate::{Generic, Hertz};
18+
use crate::time::duration::Microseconds;
19+
use crate::time::fixed_point::FixedPoint;
1820

1921
use crate::gpio::{self, Analog};
2022
use crate::pac::RCC;
@@ -34,7 +36,7 @@ use stm32f3::Variant;
3436
))]
3537
use crate::pac::{ADC1, ADC1_2, ADC2, ADC3, ADC3_4, ADC4};
3638

37-
const MAX_ADVREGEN_STARTUP_US: u32 = 10;
39+
const MAX_ADVREGEN_STARTUP: Microseconds = Microseconds(10);
3840

3941
/// Analog Digital Converter Peripheral
4042
// TODO: Remove `pub` from the register block once all functionalities are implemented.
@@ -432,7 +434,10 @@ where
432434
///
433435
/// This is based on the MAX_ADVREGEN_STARTUP_US of the device.
434436
fn wait_advregen_startup(&self, clocks: Clocks) {
435-
asm::delay((MAX_ADVREGEN_STARTUP_US * 1_000_000) / clocks.sysclk().0);
437+
let wait = MAX_ADVREGEN_STARTUP.integer()
438+
* clocks.sysclk().integer()
439+
* <Microseconds as FixedPoint>::SCALING_FACTOR;
440+
asm::delay(wait);
436441
}
437442

438443
/// busy ADC read

0 commit comments

Comments
 (0)