-
Notifications
You must be signed in to change notification settings - Fork 237
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 existingInputPin
struct - Add a new
InvertedInputPin
which 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
InputPin
would allow for drivers to implement that API and maintain all their types. Existing code usingInputPin
would continue to work, but it would be a breaking change if the new method is required. - Adding a new
InvertedInputPin
would avoid a breaking change, but any piece of code polymorphic overInputPin
would have to be modified in order to useInvertedInputPin
.
kurtjd
Metadata
Metadata
Assignees
Labels
No labels