[sdiy] Beware Magic Numbers!`
Byron G. Jacquot
thescum at surfree.com
Thu Dec 28 02:12:16 CET 2017
>The proper way of doing it is use defines (C) or EQUs (asm) in a header file
>and not use numbers directly in the code.
You can take that one step further, too.
If you're on a platform with C++ support (don't laugh, even the AVR has C++ these days), use an enum to define named values. It also defines a type, which you can use to declare and pass items of that type. It'll also give you some compile-time type checking -- it likely would have caught the mixup between 0 and SPI_MODE_0.
More information about the Synth-diy