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

Fixed SPI for sync implementation #28

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

wiktorwieclaw
Copy link

@wiktorwieclaw wiktorwieclaw commented Jan 23, 2023

This PR fixes SPI communication for sync implementation of the BME280 driver. I didn't fix async impl, because I couldn't get it to compile. I'd need to be investigate the problem first and I don't have much time right now. @VersBinarii try to run
cargo b --features=async and let me know what you get.

I also upgraded stm32f4xx_hal dev-dependency because I build anything due to conflicts

Related issues

Testing

Tested on stm32f446re and bmp280

let sck = gpiob.pb10.into_alternate();
let miso = gpioc.pc2.into_alternate();
let mosi = gpioc.pc1.into_alternate();
let cs = gpioc.pc3.into_push_pull_output();
let reset = gpioc.pc0.into_push_pull_output();

let spi = device
    .SPI2
    .spi((sck, miso, mosi), embedded_hal::spi::MODE_0, 8.MHz(), &clocks);
            
let device = embedded_hal::spi::blocking::ExclusiveDevice::new(spi, cs);
let mut bme = BME280::new(device).unwrap();
bme.init(&mut delay).unwrap();
let m = bme.measure(&mut delay).unwrap();
defmt::println!("{}", defmt::Debug2Format(&m));

Output:

Measurements { temperature: 26.200403, pressure: 100920.3, humidity: 0.0

Note: Humidity == 0.0 to be expected, bmp280 doesn't support it.

fredszaq added a commit to fredszaq/bme280-rs that referenced this pull request Nov 17, 2024
This fixes VersBinarii#25.

Any try to call the `init` function will fail with an `UnsupportedChip`
error without this (using the defautl `sync` feature).

Previous attempts were made to fix this (VersBinarii#28 and VersBinarii#38) but these where
made before `embedded-hal` `1.0.0` and currently have conflicts
preventing their merge (and can't directly be used in a project using
`embedded-hal` `1.0.0`

closes VersBinarii#28
@fredszaq fredszaq mentioned this pull request Nov 17, 2024
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

Successfully merging this pull request may close these issues.

1 participant