- Use separate jobs instead of `matrix`. The Github Actions matrix is very cursed, especially if you use `include`. We don't have that many combinations, IMO doing separate jobs is way more straightforward and only slightly more verbose.
- `embedded-hal` needs `rust-version = 1.60` because it uses `dep:`.
Fixes#538
`feature()` is only allowed on Nightly, it's completely disallowed on stable and beta
even for already-stabilized features. So, we autodetect whether the user is using nightly
and conditionally use `feature()`. This allows the crates to Just Work on current 1.75 beta
and will also Just Work when 1.75 stable is out.
Keeping `feature()` is desirable to keep support for:
- Espressif's xtensa rustc fork. (they build from the stable branch but enable use of `feature()`, so latest xtensa rustc still requires `feature()`)
- Users of older nightlies
Once xtensa rust 1.75 is out, we can remove this (upstream nightlies that require `feature()` will be quite old by then, so dropping support for them should be OK).
I decided to not use already-made crates like `rustversion` to do this because they're quite big and do way more than what we need, so I felt badd adding another dep. The code is inspired from `rustversion`'s build.rs.
Adds `#[allow(async_fn_in_trait)]` to disable the lint in `async` trait
functions recommending `Send` in the return type.
Adding the type annotation is currently unstable, has little-to-no
utility in current crates using `embedded-hal`, and will break those users.
See
<https://github.com/rust-embedded/embedded-hal/pull/515#issuecomment-1763525962>
for details and discussion.
440: I2c: simplify, expand docs, document shared bus usage. r=eldruin a=Dirbaio
~Depends on #441 -- check that one out first.~
This does some simplifications to the trait that I think we should do:
- Implement all methods in terms of `transaction`. This way HALs have to implement just that.
- Removed byte-wise-iteration methods: `write_iter` and `write_iter_read`. The reason is that they're quite inefficient, especially with DMA implementations. We've already removed these on other traits, so I think we should do as well here.
- Removed `transaction_iter`. I don't think it's much useful in practice, because the way iterators work all the yielded `Operation`s must have the same lifetime. This means that, even if the user can generate the `Operation`s on the fly, they can't allocate buffers for these on the fly, all buffers must be pre-allocated. So it's not useful for, say, streaming a large transfer by reusing some small buffer repeatedly. See #367
- Removed useless lifetimes
- Standardized buffer names on `read` and `write`, I think they're clearer.
It also specifies how i2c bus sharing is supposed to work. This is an alternative to #392 . After the discussions there, I don't think we should split I2C into Bus and Device anymore. For SPI it makes sense, because drivers want to enforce that there's a CS pin (`SpiDevice`) or not (`SpiBus`). This is not the case with I2C, the API is exactly the same in the shared and non-shared case. Drivers shouldn't care which case it is.
So all we have to do to "support" bus sharing is docs, This PR does:
- Document that it's allowed for implementations to be either shared or not.
- Document some guidelines for drivers and HALs on how to best use the traits, expand the examples.
Co-authored-by: Dario Nieuwenhuis <dirbaio@dirbaio.net>