Skip to content

Coding Style

bombasticbob edited this page Oct 8, 2014 · 2 revisions

Coding Style

Coding style for this project is "readability". However, I prefer Allman Style with 2 character indents and no hard tabs.

Comments are welcome. Also you should use as few 'magic numbers' as possible. If you must use a magic number, comment it and reference a tech manual or spec sheet as to why you're doing it.

For CPU-specific things it's a good idea to review the cpu-specific header files. For the xmega64d4, the file name is 'iox64d4.h'. Nearly all of the bit and port definitions are in there someplace. It's best to use those whenever you can. If you just can't find the value, _BV(n) works for individual bits (just comment it, please).

A lot of the libraries and source were once written in K&R (or similar style). Code borrowed from the Arduino IDE is very likely "fixed" so that it's more readable (aka 'Allman Style', 2 character indents, no hard tabs). I'd like to keep this going so that the coding style is consistent (and I don't 'fix it' in a fit of rage on the next commit).

Because this is the 'libraries' directory, a lot of the files will be unmodified. At times I've gone through and updated the code to Allman Style in order to improve readability while making modifications. In general, however, if there's no need to make code fixes to support xmega, the file will be left 'as-is' in its original style.

Clone this wiki locally