-
Notifications
You must be signed in to change notification settings - Fork 200
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
Unify embedded_hal::spi
traits?
#525
Comments
I just consolidated the Spi |
I don't think this is a good idea.
If they're in a shared For the HALs it doesn't save code either, they don't implement SpiBus and SpiDevice on the same type at the same time for the same reason: it's either managing a CS pin or it's not. |
It would be useful to have the ability to use a bus as device. If the device has a CS pin, but it's permanent active by direct connection to GND or VCC. That would mean the driver implements device but it doesn't have a usable CS pin so for the user it would be a Bus. So in the hal an explicit conversion from bus to device, that behaves like a device would be useful. However here it was already discussed and the decision was against it. The argument was, that drivers depend on the CS toggling and some chips need the CS to actually toggle for correct functionality. However if this kind of error should be cought by the person designing the PCB not be the software developer. |
You can still do it if you write a struct that wraps SpiBus and implements SpiDevice. Same as I don't think we should allow silently using a SpiBus as SpiDevice. It doesn't enable new use cases (you can already do it with the current traits as I explained above), it just creates a footgun. |
I'm unfamiliar with SPI, so maybe I'm completely off here, but it seems like the two main traits in
embedded_hal::spi
could be somewhat unified?As an example, consider the API below.
Again, unsure if this is actually beneficial to driver / HAL authors or not?
The text was updated successfully, but these errors were encountered: