I’m writing some software for an embedded system. I am trying to think of clear names for my single pin output functions.
Normally, when I’m working with active-high outputs (ON = 1, OFF = 0), I am happy to call these functions “setX” and “resetX”, where X is a more descriptive name for the output that I’m working with. However, some of my outputs are active-low (ON = 0, OFF = 1), and it seems bizarre to make my “setX” make the output 0.
Is there a standard naming convention for (re)setting values that are on when they’re 0?
4
Your software is an abstraction over the hardware. Whether a particular signal is active low or not is a detail you are supposed to abstract away. You should choose names to reflect that. set
and reset
probably feel odd because they aren’t abstract enough. Try other verbs, such as as enable/disable, activate/deactivate, or select/deselect for a chip select pin. If the pin has another specific purpose, use appropriate terms for that, such as transmit/receive, sleep/wake, forward/reverse, etc.