Rahix / shared-bus

Crate for sharing buses between multiple devices
Apache License 2.0
129 stars 34 forks source link

Implement embedded_hal::i2c::I2c for I2C proxies #54

Closed avsaase closed 9 months ago

avsaase commented 9 months ago

Would it be possible to implement embedded_hal::i2c::I2c for the I2C proxy types? I'm using a driver crate for the bme280 sensor that depends on this this trait so it currently cannot be used together with shared-bus.

Rahix commented 9 months ago

You mean this one from e-h 1.0.0-rc1?

For e-h 1.0, the entire I2C and SPI bus traits have been reworked such that shared-bus isn't really needed anymore. Instead, you'll find simple "bus manager" implementations in embedded-hal-bus from now on. For example, RefCellDevice would be the replacement for BusManagerSimple.

avsaase commented 9 months ago

I wasn't aware of these changes in embedded-hal 1.0.0-rc1. I'll close this issue because the ecosystem seems to be moving to e-h 1.0.

hacknus commented 2 months ago

sorry to open this up again, but as I understand in embedd-hal-bus, sharing buses between tasks is only possible with critical sections, whereas with embedded-hal 0.2 and shared-bus, it was much easier to share the bus across different tasks. Will shared-bus be further updated to embedded-hal 1.0?

Rahix commented 1 month ago

@hacknus, shared-bus also just used critical sections for cross-task sharing. It just wasn't that visible.

hacknus commented 1 month ago

@Rahix yes I figured.. but with embedded-hal 1.0 i'd have to implement all the critical sections myself and it's not as elegant as with shared-bus, where I was able to share the i2c bus across different tasks in freeRTOS for example. every driver was able to accept the bus without any cs wrapped around it. or am I missing something and this is also possible in embedded hal 1.0?