Skip to content

Commit

Permalink
Fix errors for devices with no adc2
Browse files Browse the repository at this point in the history
  • Loading branch information
usbalbin committed Dec 15, 2024
1 parent 66f75f1 commit f80df21
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 15 deletions.
33 changes: 19 additions & 14 deletions src/adc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1472,7 +1472,12 @@ macro_rules! adc_common {
}

fn clock(&self, clocks: &Clocks) -> Option<Hertz> {
use crate::pac::rcc::cfgr2::ADC1PRES;
#[cfg(feature = "svd-f301")]
use crate::pac::rcc::cfgr2::ADC1PRES as PRES;

#[cfg(not(feature = "svd-f301"))]
use crate::pac::rcc::cfgr2::ADC12PRES as PRES;

use crate::pac::RCC;
// SAFETY: atomic read with no side effects
let adc_pres = unsafe { &(*RCC::ptr()).cfgr2().read().$adcXYpres() };
Expand All @@ -1485,19 +1490,19 @@ macro_rules! adc_common {
Some(pllclk) if !adc_pres.is_no_clock() => {
pllclk
/ match adc_pres.variant() {
Some(ADC1PRES::Div1) => 1,
Some(ADC1PRES::Div2) => 2,
Some(ADC1PRES::Div4) => 4,
Some(ADC1PRES::Div6) => 6,
Some(ADC1PRES::Div8) => 8,
Some(ADC1PRES::Div10) => 10,
Some(ADC1PRES::Div12) => 12,
Some(ADC1PRES::Div16) => 16,
Some(ADC1PRES::Div32) => 32,
Some(ADC1PRES::Div64) => 64,
Some(ADC1PRES::Div128) => 128,
Some(ADC1PRES::Div256) => 256,
Some(ADC1PRES::NoClock) | None => 1,
Some(PRES::Div1) => 1,
Some(PRES::Div2) => 2,
Some(PRES::Div4) => 4,
Some(PRES::Div6) => 6,
Some(PRES::Div8) => 8,
Some(PRES::Div10) => 10,
Some(PRES::Div12) => 12,
Some(PRES::Div16) => 16,
Some(PRES::Div32) => 32,
Some(PRES::Div64) => 64,
Some(PRES::Div128) => 128,
Some(PRES::Div256) => 256,
Some(PRES::NoClock) | None => 1,
}
}
_ => {
Expand Down
2 changes: 1 addition & 1 deletion src/gpio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,7 @@ where
#[cfg(feature = "svd-f373")]
macro_rules! reg_for_cpu {
($exti:expr, $xr:ident) => {
$exti.$xr
$exti.$xr()
};
}

Expand Down

0 comments on commit f80df21

Please sign in to comment.