Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong example, not working #15

Closed
paologaleotti opened this issue May 31, 2024 · 5 comments
Closed

Wrong example, not working #15

paologaleotti opened this issue May 31, 2024 · 5 comments

Comments

@paologaleotti
Copy link

So im writing a firmware for STM32 in rust using this sensor, there is something wrong in the lib. Following the example (disabled std feature of course), once created the object it does not have all the fields and methods that it should:

immagine

@teamplayer3
Copy link
Owner

I tested it again and for me the auto-completion worked. You can try reloading the workspace in the rust-analyser extension. How do you create the i2c variable?

@paologaleotti
Copy link
Author

It is possible that maybe my i2c is not compatible with the trait wanted by the library?

use stm32f1xx_hal::{
    i2c::{BlockingI2c, DutyCycle, Mode},
    prelude::*,
    stm32,
};

 let i2c = BlockingI2c::i2c1(
        dp.I2C1,
        (scl, sda),
        &mut afio.mapr,
        Mode::Fast {
            frequency: 400_000.Hz(),
            duty_cycle: DutyCycle::Ratio2to1,
        },
        clocks,
        1000,
        10,
        1000,
        1000,
    );

I'm just using the plain i2c from the stm32 HAL

@teamplayer3
Copy link
Owner

teamplayer3 commented Jun 5, 2024

The hal you are using is using the old embedded_hal (0.2.7) version. ens160 only supports > 1.0. If this PR gets merged it will work. Maybe you can ask for the state of it.

A workaround would be to write a wrapper around the i2c impl which impls the new embedded-hal traits in your project.

@paologaleotti
Copy link
Author

Oh ok so its actually the stm32 HAL that is using an old embedded_hal? i actually did not notice that.

@teamplayer3
Copy link
Owner

teamplayer3 commented Jun 5, 2024

Yes, that's correct. I hope the workaround will work, or the PR is merged soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants