rppal icon indicating copy to clipboard operation
rppal copied to clipboard

Warn when input_pulldown is attemped on GPIO pins that do not support input_pulldown

Open clay53 opened this issue 2 years ago • 1 comments

GPIO pins 2 & 3 do not support being pulled down. They are fixed pulled up pinout.xyz. I did not know this and have been going a little crazy for the past hour. There should be a warning when things like this are attempted (I don't know if an external resistor can be used but I still feel like there should be something to distinguish things).

clay53 avatar Nov 15 '21 01:11 clay53

Thanks for posting this suggestion. Technically RPPAL will still properly configure the GPIO pin internally, but obviously the external pull-up resistor messes things up as you mentioned.

While it would be easy to say this is the user's responsibility, the external resistors are part of the board, which is why I agree RPPAL should warn users when certain configuration options have unintended consequences. The most logical solution would be to return an error when some of the Pin::into_... methods are called, although for the sake of consistency perhaps they should all return a Result. This will also require board identification and per-board GPIO pin details, as some boards (namely the Compute modules) don't have these pull-up resistors.

EDIT: Or alternatively, remove into_input_pulldown and into_input_pullup, add set_pullupdown back to InputPin, and return a Result.

golemparts avatar Nov 17 '21 12:11 golemparts