Gadget wrote:
LatiosXT wrote:
Plus some coding habits I found can lead to some extra bits of code. For instance, when I'm writing something to control an LED, I have an explicit "LED_On" and "LED_Off" function, rather than "LED_State(bool Enable)".
Putting the software engineering aspects aside (but I tend to agree that LED_On and LED_Off are clearer and less error prone), I would have thought that the difference in memory consumption would be negligible. Did you do some testing that confirmed a difference? If so, what was the cause?
I haven't done any explicit research on it, but I doubt there's any real impact on something simple like this. Given my experience with the MSP430 I used, which is probably how RISC works in general, I could see a single function looks like this when compiled:
Code:
LED_State
MOV LED_GPIO, R0 ;assuming R0 holds the state that's passed through
RET
Versus this
Code:
LED_On
MOV LED_GPIO, 1
RET
LED Off
MOV LED_GPIO, 0
RET
So you're doubling the code space from two instructions to four. This also consumes no memory anyway since the value is either in a register or is immediate.
For something more complex, say a periph_setup function versus a periph_init and a periph_deinit function, there wouldn't be much impact I would think. But it really depends on what the complimenting functions are trying to do.