Skip to content

Commit ff65124

Browse files
authored
Merge pull request #217 from Rahix/fix-adc-init
Fix long delay during ADC initialization
2 parents 231c959 + 1810b4b commit ff65124

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/adc.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -399,8 +399,15 @@ macro_rules! adc_hal {
399399
}
400400

401401
fn wait_adc_clk_cycles(&self, cycles: u32) {
402-
let adc_clk_cycle = self.clocks.hclk().0 / (self.ckmode as u32);
403-
asm::delay(adc_clk_cycle * cycles);
402+
// using a match statement here so compilation will fail once asynchronous clk
403+
// mode is implemented (CKMODE[1:0] = 00b). This will force whoever is working
404+
// on it to rethink what needs to be done here :)
405+
let adc_per_cpu_cycles = match self.ckmode {
406+
CkMode::SYNCDIV1 => 1,
407+
CkMode::SYNCDIV2 => 2,
408+
CkMode::SYNCDIV4 => 4,
409+
};
410+
asm::delay(adc_per_cpu_cycles * cycles);
404411
}
405412

406413
fn advregen_enable(&mut self){

0 commit comments

Comments
 (0)