Become a leader in the IoT community!
Join our community of embedded and IoT practitioners to contribute experience, learn new skills and collaborate with other developers with complementary skillsets.
Join our community of embedded and IoT practitioners to contribute experience, learn new skills and collaborate with other developers with complementary skillsets.
Hey everyone, I’m working in Microchip Studio to create a custom communication function for a few PIC16F84A microcontrollers. I know there are built-in options like SPI, but I’m going the DIY route to learn more about the nitty-gritty of how this all works. Here’s what I’ve come up with so far:
void sendMessage(uint8_t node, uint8_t data);
Now, my setup only supports up to 4 nodes, so I want to make sure the `node` parameter doesn’t go above 4. Right now, I just have a simple runtime check:
if (node > 4) { return; }
But I’m thinking it’d be better to enforce this at compile time instead of waiting for runtime. This could make the code safer, maybe even run a bit faster. I haven’t tried anything specific yet, but I’m curious if there are any cool tricks or language features I could use for this, like static assertions or compile-time constants.
Anyone out there tried something similar or have any tips?
CONTRIBUTE TO THIS THREAD