Prototype of an I2C constructor which doesn't own pins#499
Prototype of an I2C constructor which doesn't own pins#499jannic wants to merge 3 commits intorp-rs:mainfrom
Conversation
|
I have a proof-of-concept driver that's not client code that shows what I want to do. Is it possible you could create a branch with these changes on top of #482 so that I can push the repo with the proof-of-concept? |
Sure, just merged both branches together: |
|
I think the point of the peripheral taking ownership of the pins is to be able to guaranty that the pins will remain in a valid state for the peripheral to function as expected. This imply validating that the pair of dynpin is valid for the given peripheral and that their state (function) will remain the same until the peripheral gets released. |
I guess my follow-up question is "why doesn't the SPI peripheral do this"? |
|
SPI peripheral driver predates us switching to the atsamd pin traits. Really needs to be updated to match everything else, but there's always so many things to fix. |
|
First, a general question: Do we really need to guarantee that the pin mode is and stays correct? Rationale:
That said, if all reasonable use cases can be handled with a variant that owns the DynPins, and checks (or activates) the correct pin function, we should do that. In fact, the main reason I didn't do it for this proof of concept was that this would have been slightly more work. |
Just a simple PoC showing that the existing I2C struct is flexible enough to be extended with a variant that doesn't own SCL/SDA pins. That way, it would be easy to use I2C with DynPins.
For now I only tested that this still builds. And the function naming needs to be improved. (Also, lots of unnecessary code duplication in controller.rs)
@cr1901: Would that, in combination with #482, solve #481?