From e5f4a278f1158174878d82a0473524d4d6251f8c Mon Sep 17 00:00:00 2001 From: Florian Pose Date: Fri, 28 Oct 2011 11:31:54 +0200 Subject: [PATCH] Added coding style document. --- CodingStyle.txt | 44 ++++++++++++++++++++++++++++++++++++++++++++ README | 28 ++++++++++++++++++---------- 2 files changed, 62 insertions(+), 10 deletions(-) create mode 100644 CodingStyle.txt diff --git a/CodingStyle.txt b/CodingStyle.txt new file mode 100644 index 00000000..c34c34b8 --- /dev/null +++ b/CodingStyle.txt @@ -0,0 +1,44 @@ +$Id$ + +vim: spelllang=en tw=78 + +This is a short introduction to the coding style that shall be used. The below +rules are applicable for all C source files, except the Ethernet drivers, for +which the Linux Kernel coding style shall be used to minimize the +differences). + +* Lines shall not exceed 78 characters. + +* Indentation shall be done using 4 space characters + +* No whitespace shall be left at the end of a line. + +* After a comma, a single space shall be placed (if not followed by a + line break). + +* Braces shall be placed in the following way (K&R style): + + if (...) { + ... + } else if (...) { + ... + } else { + ... + } + + int function(...) + { + ... + } + +* Macros shall be named in CAPITAL letters. If a macro contains multiple + statements, they should be enclosed by a 'do {} while (0)' loop. Macro + parameters shall also be capital letters and shall be enclosed py parantheses + if necessary. + + #define MACRO(A, B) \ + do { \ + if ((A) == 1) { \ + statement(B); \ + } while (0) + diff --git a/README b/README index 777712f2..0a30e8e3 100644 --- a/README +++ b/README @@ -1,4 +1,4 @@ -------------------------------------------------------------------------------- +------------------------------------------------------------------------------ This is the README file of the IgH EtherCAT Master. @@ -6,7 +6,7 @@ $Id$ vim: spelllang=en spell tw=78 -------------------------------------------------------------------------------- +------------------------------------------------------------------------------ Contents: 1) General Information @@ -14,8 +14,9 @@ Contents: 3) Building and installing 4) Realtime & Tuning 5) License +6) Coding Style -------------------------------------------------------------------------------- +------------------------------------------------------------------------------ 1) General Information ====================== @@ -33,7 +34,7 @@ Heinz-Baecker-Str. 34 D-45356 Essen http://igh-essen.com -------------------------------------------------------------------------------- +------------------------------------------------------------------------------ 2) Requirements =============== @@ -48,27 +49,27 @@ master. A table of supported hardware can be found at http://etherlab.org/en/ethercat/hardware.php. -------------------------------------------------------------------------------- +------------------------------------------------------------------------------ 3) Building and installing ========================== See the INSTALL file. -------------------------------------------------------------------------------- +------------------------------------------------------------------------------ 4) Realtime & Tuning ==================== Realtime patches for the Linux kernel are supported, but not required. The realtime processing has to be done by the calling module (see API -documentation). The EtherCAT master code itself is passive (except for the idle -mode and EoE). +documentation). The EtherCAT master code itself is passive (except for the +idle mode and EoE). To avoid frame timeouts, deactivating DMA access for hard drives is recommended (hdparm -d0 ). -------------------------------------------------------------------------------- +------------------------------------------------------------------------------ 5) License ========== @@ -96,4 +97,11 @@ The license mentioned above concerns the source code only. Using the EtherCAT technology and brand is only permitted in compliance with the industrial property and similar rights of Beckhoff Automation GmbH. -------------------------------------------------------------------------------- +------------------------------------------------------------------------------ + +6) Coding Style +=============== + +Developers shall use the coding style rules in the CodingStyle.txt file. + +------------------------------------------------------------------------------