Destide@feddit.uk to Programmer Humor@lemmy.mlEnglish · 4 months agoInfallible Codelemmy.mlimagemessage-square151fedilinkarrow-up1470arrow-down126
arrow-up1444arrow-down1imageInfallible Codelemmy.mlDestide@feddit.uk to Programmer Humor@lemmy.mlEnglish · 4 months agomessage-square151fedilink
minus-squareCroquette@sh.itjust.workslinkfedilinkarrow-up6·4 months 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-squarexthexder@l.sw0.comlinkfedilinkarrow-up6·edit-24 months 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-squareCroquette@sh.itjust.workslinkfedilinkarrow-up2·4 months 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.
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:
// Set high PORTB |= 1 << PINB5; // Set low PORTB &= ~(1 << PINB5);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
gpio_write(PIN_X, true)and it always stood out to me.