2

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?

closed as primarily opinion-based by user22815, gnat, user40980, Doval, GlenH7 Feb 4 '15 at 17:55

Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 3
    On the troubles of naming and terminology – user22815 Feb 4 '15 at 16:28
  • 1
    @Snowman: I have read that meta question. The top answer says that these types of questions are on-topic. I'm not sure if there's another quality issue that I'm missing here. – Greg d'Eon Feb 4 '15 at 17:08
  • 1
    Could an affix help? E.g. setX says I make output X active, and setXNeg says that I make output X active and the active level is low. Using set/reset is the lowest possible level of abstraction; if you can, use @karl-bielefeldt advice and name the function on the board, not just pin of the crystal. – 9000 Feb 4 '15 at 17:37
  • Pick a naming convention and stick with it across your projects. Using more descriptive names may help as well. – GlenH7 Feb 4 '15 at 17:56
6

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.

Not the answer you're looking for? Browse other questions tagged or ask your own question.