Destide to Programmer [email protected]English • 12 days agoInfallible Codefeddit.ukimagemessage-square165fedilinkarrow-up1470cross-posted to: [email protected]
arrow-up1470imageInfallible Codefeddit.ukDestide to Programmer [email protected]English • 12 days agomessage-square165fedilinkcross-posted to: [email protected]
minus-square@[email protected]linkfedilink6•11 days agoI am working with C in embedded designs and I still use 1 or 0 for a bool certain situations, mostly lines level. For whatever pea-brained reason, it feels yucky to me to set a gpio to true/false instead of a 1/0.
minus-square@[email protected]linkfedilink5•edit-211 days agoGPIOs are usually controlled by a single bit of a register anyway. Most likely you need to do something like: // Set high PORTB |= 1 << PINB5; // Set low PORTB &= ~(1 << PINB5);
minus-square@[email protected]linkfedilink2•11 days agoI am a lazy dev (not really, clients always want fast code), so I use the provided HAL libraries 99.9% of the time. But I have seen code where someone would write something like gpio_write(PIN_X, true) and it always stood out to me.
minus-squareJackbyDevlinkfedilinkEnglish1•11 days agoDefine on as true or something? Or maybe that’s more confusing. I’m not a C dev so I’m not gonna pretend to understand idiomatic microcontroller code lol.
minus-square@[email protected]linkfedilink1•11 days agoSometimes, people do that. But using 0/1 is explicit enough since you can refer to a line as ‘1’ or ‘0’ for high/low on the hardware as well
I am working with C in embedded designs and I still use 1 or 0 for a bool certain situations, mostly lines level.
For whatever pea-brained reason, it feels yucky to me to set a gpio to true/false instead of a 1/0.
GPIOs are usually controlled by a single bit of a register anyway. Most likely you need to do something like:
I am a lazy dev (not really, clients always want fast code), so I use the provided HAL libraries 99.9% of the time.
But I have seen code where someone would write something like
and it always stood out to me.
Define on as true or something? Or maybe that’s more confusing. I’m not a C dev so I’m not gonna pretend to understand idiomatic microcontroller code lol.
Sometimes, people do that. But using 0/1 is explicit enough since you can refer to a line as ‘1’ or ‘0’ for high/low on the hardware as well