VersBinarii / bme280-rs

A platform agnostic Rust driver for the Bosch BM[PE]-280
Other
59 stars 73 forks source link

RTIC example? #11

Closed arrowcircle closed 2 years ago

arrowcircle commented 3 years ago

Hi! I am struggling to use this driver with RTIC because of delay provider. What is the best way to use this library with RTIC?

nebelgrau77 commented 3 years ago

@arrowcircle You can get the delay in RTIC from core:

 #[init]
    fn init(cx: init::Context) -> init::LateResources {
        let dp = cx.device;
        let core = cx.core;

        //clocks and other peripherals defined here

        let mut delay = Delay::new(core.SYST, clocks);

Here's an example with a different I2C device:

https://github.com/jamwaffles/ssd1306/blob/master/examples/rtic_dvd.rs

arrowcircle commented 3 years ago

@nebelgrau77 I already tried this thing, but it does not work.

no field `SYST` on type `rtic::Peripherals`
nebelgrau77 commented 3 years ago

OK, here's my repo that works:

https://github.com/nebelgrau77/sensor_data_forwarder_Rust

You need to get SYST from cx.core, not cx.device.

arrowcircle commented 3 years ago

@nebelgrau77 I use bluepill and it looks like there are no SYST in cx.core of F1.

nebelgrau77 commented 3 years ago

I see... hmmm, try asking in RTIC channel here: https://app.element.io/#/room/#rtic:matrix.org - I didn't realize it might be a board/MCU specific issue.

...it's strange, though: that first example I indicated, the SSD1306, is for the F1xx. Weird...