Hacker News new | ask | show | jobs
by jabot 3040 days ago
Well, _if_ you need that feature, you can wrap the trait into another trait that allows a write to the pin, but discards it.

However, by default, nonsensical operations should not be possible.

1 comments

AVR microcontrollers use the same register to define the pin value when it's set as an output, and define the state of the internal pullups when it's set as an input.

I haven't seen that in ARM microcontrollers, but as peripherals vary across manufacturers I don't think you can assume that it's not done this way.

Wouldn't you then write two sets of functions? set_high, set_low, enable_pullup, disable_pullup. Now internally set_high and enable_pullup might do the exact same thing, but externally they signal intent and prevent you from trying to set a pullup on an output for example.