Next revision | Previous revision |
wiki:conventions [2017/03/25 14:23] – created zdimension | wiki:conventions [2017/06/16 16:28] (current) – zdimension |
---|
===== Casing ===== | ===== Casing ===== |
* **Macros** : ''SCREAMING_SNAKE_CASE'' | * **Macros** : ''SCREAMING_SNAKE_CASE'' |
* **Structures / Classes / Types** : ''PascalCase'' | * **Structures / Types / Constants / Enum members** : ''PascalCase'' |
* **Variables / Fields** : ''camelCase'' | * **Variables / Fields** : ''camelCase'' |
| |
===== Indentation ===== | ===== Indentation ===== |
| |
Thou shalt in all your code use the Allman's style brace indentation. | Thou shalt in all of thy code let ye Allman's style brace indentation be used (i.e. braces should always be on their own line, no matter if ''struct'', ''if'', ''while'', etc.) |
<code cpp> | <code cpp> |
struct MyStruct | struct MyStruct |
| |
^Specifier^Signing^Bits^Bytes^Minimum Value^Maximum Value^ | ^Specifier^Signing^Bits^Bytes^Minimum Value^Maximum Value^ |
^''int8_t''|Signed| 8| 1|−2<sup>7</sup> which equals −128|2<sup>7</sup> − 1 which is equal to 127| | ^ ''int8_t''|Signed| 8| 1|−2<sup>7</sup> which equals −128|2<sup>7</sup> − 1 which is equal to 127| |
^''uint8_t''|Unsigned| 8| 1|0|2<sup>8</sup> − 1 which equals 255| | ^ ''uint8_t''|Unsigned| 8| 1|0|2<sup>8</sup> − 1 which equals 255| |
^''int16_t''|Signed| 16| 2|−2<sup>15</sup> which equals −32,768|2<sup>15</sup> − 1 which equals 32,767| | ^ ''int16_t''|Signed| 16| 2|−2<sup>15</sup> which equals −32,768|2<sup>15</sup> − 1 which equals 32,767| |
^''uint16_t''|Unsigned| 16| 2|0|2<sup>16</sup> − 1 which equals 65,535| | ^ ''uint16_t''|Unsigned| 16| 2|0|2<sup>16</sup> − 1 which equals 65,535| |
^''int32_t''|Signed| 32| 4|−2<sup>31</sup> which equals −2,147,483,648|2<sup>31</sup> − 1 which equals 2,147,483,647| | ^ ''int32_t''|Signed| 32| 4|−2<sup>31</sup> which equals −2,147,483,648|2<sup>31</sup> − 1 which equals 2,147,483,647| |
^''uint32_t''|Unsigned| 32| 4|0|2<sup>32</sup> − 1 which equals 4,294,967,295| | ^ ''uint32_t''|Unsigned| 32| 4|0|2<sup>32</sup> − 1 which equals 4,294,967,295| |
^''int64_t''|Signed| 64| 8|−2<sup>63</sup> which equals −9,223,372,036,854,775,808|2<sup>63</sup> − 1 which equals 9,223,372,036,854,775,807| | ^ ''int64_t''|Signed| 64| 8|−2<sup>63</sup> which equals −9,223,372,036,854,775,808|2<sup>63</sup> − 1 which equals 9,223,372,036,854,775,807| |
^''uint64_t''|Unsigned| 64| 8|0|2<sup>64</sup> − 1 which equals 18,446,744,073,709,551,615| | ^ ''uint64_t''|Unsigned| 64| 8|0|2<sup>64</sup> − 1 which equals 18,446,744,073,709,551,615| |
| |
| Also, when defining pointer fields, the ''*'' must be on the right-side: |
| <code cpp> |
| uint32_t *fieldName; |
| </code> |
| instead of |
| <code cpp> |
| uint32_t* fieldName; |
| </code> |
| |
| ===== Bit fields ===== |
| |
| ==== Horizontal (long descriptions) ==== |
| |
| === 8-bit === |
| |
| ^ Hex ^ Bit ^ Description ^ |
| ^ ''0x0001'' ^ 0 | text | |
| ^ ''0x0002'' ^ 1 | text | |
| ^ ''0x0004'' ^ 2 | text | |
| ^ ''0x0008'' ^ 3 | text | |
| ^ ''0x0010'' ^ 4 | {{:icons:tr4.png?nolink|TR4 only}} Example of double line | |
| ^ ::: ^ ::: | {{:icons:tr5.png?nolink|TR5 only}} Example of double line | |
| ^ ''0x0020'' ^ 5 | text | |
| ^ ''0x0040'' ^ 6 | text | |
| ^ ''0x0080'' ^ 7 | text | |
| |
| === 16-bit === |
| |
| ^ Hex ^ Bit ^ Description ^ |
| ^ ''0x0001'' ^ 0 | text | |
| ^ ''0x0002'' ^ 1 | text | |
| ^ ''0x0004'' ^ 2 | text | |
| ^ ''0x0008'' ^ 3 | text | |
| ^ ''0x0010'' ^ 4 | {{:icons:tr4.png?nolink|TR4 only}} Example of double line | |
| ^ ::: ^ ::: | {{:icons:tr5.png?nolink|TR5 only}} Example of double line | |
| ^ ''0x0020'' ^ 5 | text | |
| ^ ''0x0040'' ^ 6 | text | |
| ^ ''0x0080'' ^ 7 | text | |
| ^ ''0x0100'' ^ 8 | text | |
| ^ ''0x0200'' ^ 9 | text | |
| ^ ''0x0400'' ^ 10 | text | |
| ^ ''0x0800'' ^ 11 | text | |
| ^ ''0x1000'' ^ 12 | text | |
| ^ ''0x2000'' ^ 13 | text | |
| ^ ''0x4000'' ^ 14 | text | |
| ^ ''0x8000'' ^ 15 | text | |
| |
| ==== Vertical (field names only) ==== |
| |
| ^ Hex value ^ ''%%0x8000%%'' ^ ''%%0x7F00%%'' ^^^^^^^ ^^^ ''%%0x001F%%'' ^^^^^ |
| ^ Bit ^ 15 ^ 14 ^ 13 ^ 12 ^ 11 ^ 10 ^ 9 ^ 8 ^ 7 ^ 6 ^ 5 ^ 4 ^ 3 ^ 2 ^ 1 ^ 0 ^ |
| ^ Field | ''%%Field1%%'' | ''%%Field2%%'' ||||||| ||| ''%%Field3%%'' ||||| |