stm32-rs / stm32l0xx-hal

A hardware abstraction layer (HAL) for the STM32L0 series microcontrollers written in Rust
BSD Zero Clause License
96 stars 60 forks source link

ADC code relies on deprecated feature macros #229

Open bcattle opened 1 year ago

bcattle commented 1 year ago

Hello everyone!

In src/adc.rs analog input pins are enabled based on feature macros like the following:

#[cfg(all(
    feature = "stm32l072",
    any(
        feature = "lqfp64",
        feature = "lqfp100",
        feature = "tfbga64",
        feature = "ufbga64",
        feature = "ufbga100",
        feature = "wlcsp49",
    ),
))]
adc_pins! {
    Channel10: (gpioc::PC0<Analog>, 10u8),
    Channel11: (gpioc::PC1<Analog>, 11u8),
    Channel12: (gpioc::PC2<Analog>, 12u8),
}

However the "stm32l072" feature is not defined in Cargo.tomland appears to have been replaced:

# Legacy features (don't use those anymore)
# ...
stm32l072 = ["stm32l0x2"]
#...

# Later for example ... 
mcu-STM32L072V8Tx = ["stm32l0x2", "lqfp100", "io-STM32L071", "eeprom-3072", "flash-64", "ram-20"]
m
# ...

Should I update adc.rs to use the new macros? Thanks.

jamwaffles commented 1 year ago

Hey, good catch! Yes if you don't mind updating them I'd happily accept a PR. I haven't touched this crate in a while so maybe this isn't the best way, but you could use something like this instead:

#[cfg(any(
    feature = "io-STM32L051",
    feature = "io-STM32L071",
    feature = "stm32l0x2",
    feature = "stm32l0x3"
))]

(based on this code) - ymmv!