-
Notifications
You must be signed in to change notification settings - Fork 248
Open
Description
Introduction
Some GPIO controllers have the ability to invert the logic level in HW. This is useful in cases where some generic code samples the state of a pin and take actions depending on the state. Rather than having the generic know about ActiveHigh vs ActiveLow, the HW invert the logic level and the generic code can rely solely on is_low()/is_high() as if the level was not inverted.
Proposal
There are two options here.
- Add a new
set_inverted(&mut self)API to the existingInputPinstruct - Add a new
InvertedInputPinwhich assumes GPIO is inverted.
Challenges
- It's unlikely that every GPIO controller is capable of inverting the logic level in HW. How can we guarantee that the HAL's SW implementation is sound?
- Adding a single new function to
InputPinwould allow for drivers to implement that API and maintain all their types. Existing code usingInputPinwould continue to work, but it would be a breaking change if the new method is required. - Adding a new
InvertedInputPinwould avoid a breaking change, but any piece of code polymorphic overInputPinwould have to be modified in order to useInvertedInputPin.
kurtjd and ilovefurnaces
Metadata
Metadata
Assignees
Labels
No labels