stm32-rs / stm32l4xx-hal

A Hardware abstraction layer for the stm32l432xx series chips written in rust.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ADC example doesn't work because of imports

stonefoxes opened this issue · comments

Hi, I'm trying to use ADC on STM32L451, according to examples: simple read and read with DMA. But I have the following error:

39 |     adc::{Adc, AdcCommon, DmaMode, SampleTime, Sequence},
   |           ^^^  ^^^^^^^^^ no `AdcCommon` in `adc`
   |           |
   |           no `Adc` in `adc`
   |           help: a similar name exists in the module: `ADC`

What am I doing wrong and how to make it work? Thank you in advance.

It seems like cargo has an old version in registry "26e0917e782402251e3eeaef53f1adb4fad22a42" according to .cargo_vsc_info.json file. If I use git version of HAL in my Cargo.toml imports are fine. Should we bump version and publish actual repo on cargo?

@stonefoxes I also struggled with the same issue, but I found a solution in the past records of the ADC example. The problem code works when changed as follows.
let mut adc = ADC::new(dp.ADC1, dp.ADC_COMMON, &mut rcc.ahb2, &mut rcc.ccipr, &mut delay);

Check the full example here:
https://github.com/stm32-rs/stm32l4xx-hal/blob/c2e63acc4035537b07ceae84c31f8057484a964f/examples/adc.rs