3 ms·
Isn't there a bunch of embassy based async stuff in esp-rs?
by zwirbl 3y ago
Isn't there a bunch of embassy based async stuff in esp-rs?
- abound 3y agoGood question! As far as I can tell from the docs, it looks like I2C is still synchronous [1], but this will be my first async embedded Rust project, so I'm still unfamiliar with the general shape and functionality of things. For comparison, things like WiFi are definitely async [2] [1] https://docs.rs/esp32s2-hal/latest/esp32s2_hal/i2c/index.html https://docs.rs/esp32s2-hal/latest/esp32s2_hal/i2c/index.htm... [2] https://github.com/esp-rs/esp-wifi/blob/main/examples-esp32s2/examples/embassy_dhcp.rs https://github.com/esp-rs/esp-wifi/blob/main/examples-esp32s...
- coder543 3y agoIn esp-hal, they offer both sync and async I2C implementations, depending on what works best for an application. Since the async implementation is gated by a feature, it may not show up in the docs you linked. Async implementation: https://github.com/esp-rs/esp-hal/blob/main/esp-hal-common/src/i2c.rs#L317 https://github.com/esp-rs/esp-hal/blob/main/esp-hal-common/s... You can also see the async feature mentioned here: https://docs.rs/crate/esp32s2-hal/latest/features https://docs.rs/crate/esp32s2-hal/latest/features There is a very brief example of using async i2c here: https://github.com/esp-rs/esp-hal/blob/main/esp32s3-hal/examples/embassy_i2c.rs https://github.com/esp-rs/esp-hal/blob/main/esp32s3-hal/exam... (you can see that it is using `lis3dh_async`, which requires async i2c) Not specific to the ESP platforms, but Embassy offers a more useful example of async i2c here: https://github.com/embassy-rs/embassy/blob/main/examples/rp/src/bin/i2c_async.rs#L79 https://github.com/embassy-rs/embassy/blob/main/examples/rp/... (and it would work the same on ESP)
- junon 3y agoIf there's something missing in Embassy, hop onto the Matrix and chat about it. Dario and company are about as responsive and pleasant to speak to as one could find in the OSS world.