-
Notifications
You must be signed in to change notification settings - Fork 234
4th digital::IoPin
proposal from #29
#73
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
Conversation
@astro Hm, we had a discussion somewhere (can't remember where exactly) where we discussed a slightly different variant with composable traits. I think @austinglaser made a nice proposal based on a discussion we had. The "problem" I see with your approach is that switching modes between input and output might not be all the much useful and be quite a bit of overhead since that actually requires changing the GPIO mode (which also has some side effects like electrically switching from a set low/high level into high impedance mode) where usually one might only want to check the logic state of the pin (i.e. what do the registers say) or the real hardware state (what is the actual voltage level at the pin), both of which may or may not actually be implementable on some MCUs. |
I don't understand. Changing the GPIO mode is what this is about? |
The previous But maybe my understanding of your proposal is just inaccurate? |
#72 is separate from this. This one is about change the mode. It does not touch |
I understand what it does. I don't understand why and kind of assumed it was so one could use |
|
This (in a nutshell) is a dangerous (and potentially expensive) version of a If bidirectional communication is needed there're special operating modes, e.g. open drain which need to be setup exactly once and require special consideration in their use. Same goes for a Please give some real world examples (and yes, there should be more than one to make it suitable for |
Thank you for your renewed attempts at trying to make me understand. I understand that you wish for more configuration options, eg. output type, output speed, pull-up/down, alternate functions… which are already modelled in some #29 was originally about pins that can configure as either input or output. That's what My use-case is the linked DHT22 application, so for 1-wire this works. |
Indirectly, yes.
My concern is that a pin should be configured exactly once and then stay at this configuration for the runtime of the application. Typically the hardware cannot change during runtime so if there's a need to reconfigure pins to properly, it's most likely that something is wrong. I can see that many very hardware specific DHT22 drivers exist out there which simply flip a register to switch from After a brief look into the Chenglish data sheet, I believe what you really need for your driver is a |
Discussion here has stalled. @therealprof has made a convincing argument against the approach taken here and has suggested a different abstraction ( @astro Do you have any objections to closing this pull request? |
73: Raise minimum dependency versions to enforce using a newer nix r=posborne a=eldruin Doing this for 0.3.x is not possible due to a raise in the MSRV. Closes rust-embedded#70 Co-authored-by: Diego Barrios Romero <[email protected]>
This is Jorge Aparicio's most recent
IoPin
proposal from #29. It leverages the type system for representing the output state. It does not automatically (unintentionally) switch modes. It avoids closures.I've implemented it in a proof of concept. The only issue regarding ergonomics is the additional
IoPin
implementation that is required for bothInputPin
andOutputPin
: