Destide@feddit.uk to Programmer Humor@lemmy.mlEnglish · 1 day agoInfallible Codelemmy.mlimagemessage-square140fedilinkarrow-up1404arrow-down121
arrow-up1383arrow-down1imageInfallible Codelemmy.mlDestide@feddit.uk to Programmer Humor@lemmy.mlEnglish · 1 day agomessage-square140fedilink
minus-squarexthexder@l.sw0.comlinkfedilinkarrow-up5·edit-214 hours 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·12 hours 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-squareJackbyDev@programming.devlinkfedilinkEnglisharrow-up1·5 hours 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.
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.
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.