Correct some typos. Add IDs to headings. Add some hints about commenting.
This commit is contained in:
@@ -19,6 +19,11 @@ Be sure to read <xref linkend="programming"/> and <xref linkend="driver-api"/>
|
|||||||
as well.
|
as well.
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
As a starting point you may take a look at the debug driver. It is available
|
||||||
|
as <filename>server/drivers/debug.c</filename>.
|
||||||
|
</para>
|
||||||
|
|
||||||
</sect1>
|
</sect1>
|
||||||
|
|
||||||
|
|
||||||
@@ -32,7 +37,7 @@ driver to be included in LCDproc's code some conditions have to be met:</para>
|
|||||||
<orderedlist>
|
<orderedlist>
|
||||||
<listitem>
|
<listitem>
|
||||||
<para>The hardware (display or enclosing product) is publicly sold
|
<para>The hardware (display or enclosing product) is publicly sold
|
||||||
<emphasis>OR</emphasis> the schematics and firmware (if required) are publicy
|
<emphasis>OR</emphasis> the schematics and firmware (if required) are publicly
|
||||||
available.
|
available.
|
||||||
<footnote><para>Therefore I will not commit drivers for displays ripped out
|
<footnote><para>Therefore I will not commit drivers for displays ripped out
|
||||||
from an old telephone for your private hardware project and are not
|
from an old telephone for your private hardware project and are not
|
||||||
@@ -47,27 +52,27 @@ driver to be included in LCDproc's code some conditions have to be met:</para>
|
|||||||
<para>The submitter is or is acting on behalf of the original driver
|
<para>The submitter is or is acting on behalf of the original driver
|
||||||
developer.
|
developer.
|
||||||
<footnote><para>I will not submit drivers found somewhere on the internet and
|
<footnote><para>I will not submit drivers found somewhere on the internet and
|
||||||
submitted without the original developer's acknowledgement.</para></footnote>
|
submitted without the original developer's written acknowledgement.</para></footnote>
|
||||||
</para>
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
<listitem>
|
<listitem>
|
||||||
<para>The driver describtion contains a valid email address for contacting
|
<para>The driver description contains a valid email address for contacting
|
||||||
the submitter or developer.</para>
|
the submitter or developer.</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
<listitem>
|
<listitem>
|
||||||
<para>The code is commented <emphasis>AND</emphasis> includes appropriate
|
<para>The code is commented <emphasis>AND</emphasis> includes appropriate
|
||||||
Doxygen comments, especially for private / non-API functions.</para>
|
Doxygen comments, especially for internal / non-API functions.</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
<listitem>
|
<listitem>
|
||||||
<para>End user documentation (updates to man pages <emphasis>AND</emphasis>
|
<para>End user documentation (updates to man pages <emphasis>AND</emphasis>
|
||||||
user-guide in docbook) is available.</para>
|
User's Guide in docbook format) is available.</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
<listitem>
|
<listitem>
|
||||||
<para>Driver options are described in the end user documentation
|
<para>Driver options are described in the end user documentation
|
||||||
<emphasis>AND</emphasis> <filename>LCDd.conf</filename>.</para>
|
<emphasis>AND</emphasis> <filename>LCDd.conf</filename>.</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
<listitem>
|
<listitem>
|
||||||
<para>The driver adhere the style guide as described in <xref linkend="code-style"/>.</para>
|
<para>The driver adheres to the style guide as described in <xref linkend="code-style"/>.</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
</orderedlist>
|
</orderedlist>
|
||||||
|
|
||||||
@@ -271,6 +276,34 @@ Please do not forget to also add the required documentation,
|
|||||||
so that your driver can be used from others as well.
|
so that your driver can be used from others as well.
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
|
<sect2 id="documentation-source">
|
||||||
|
<title>Within the source code</title>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
We use Doxygen to document functions and data types. The doxygen documentation
|
||||||
|
can be created anytime by changing to the <filename>docs/</filename> directory
|
||||||
|
and running <command>doxygen</command>.
|
||||||
|
</para>
|
||||||
|
<para>
|
||||||
|
When documenting your driver's API functions you may use a short hand version
|
||||||
|
and add 'API:' to the beginning of your comment and leave out the parameter
|
||||||
|
and return value description (as we know what the API is doing). If you use
|
||||||
|
some clever algorithm inside a function please add a few words about it.
|
||||||
|
</para>
|
||||||
|
<note>
|
||||||
|
<para>
|
||||||
|
Always document functions internal to the driver! We do know what the API
|
||||||
|
does (or is expected to do) but we don't know about what your driver does
|
||||||
|
internally.
|
||||||
|
</para>
|
||||||
|
<para>
|
||||||
|
Read <xref linkend="code-style-comments"/> on how for format comments.
|
||||||
|
</para>
|
||||||
|
</note>
|
||||||
|
|
||||||
|
</sect2>
|
||||||
|
|
||||||
|
|
||||||
<sect2 id="documentation-LCDd.conf">
|
<sect2 id="documentation-LCDd.conf">
|
||||||
<title>The configuration file, LCDd.conf</title>
|
<title>The configuration file, LCDd.conf</title>
|
||||||
|
|
||||||
|
|||||||
@@ -21,9 +21,9 @@ dedicated chapter in this book.
|
|||||||
<title>port.h : Parallel port I/O</title>
|
<title>port.h : Parallel port I/O</title>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
The file port.h, located in the server/drivers/ directory provide Input/Output
|
The file <filename>port.h</filename>, located in the <filename>server/drivers/</filename>
|
||||||
and port permissions for the PC compatible parallel port, also known as the
|
directory provide Input/Output and port permissions for the PC compatible
|
||||||
LPT port.
|
parallel port, also known as the LPT port.
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
@@ -32,7 +32,15 @@ has parallel port! In these situations, the configure script will see this and
|
|||||||
disable drivers that need a parallel port.
|
disable drivers that need a parallel port.
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
<para>port.h file defines 6 static inline functions for port I/O:</para>
|
<para>
|
||||||
|
The functions in <filename>port.h</filename> are defined and as 'static inline'.
|
||||||
|
Therefore each driver including this header file gets its own copy of the
|
||||||
|
functions and they are inlined into the driver's code. As a result calls to
|
||||||
|
port_in() and port_out() are directly translated to inb() or outb() or
|
||||||
|
assembly code by the compiler. There is less to no overhead in using them.
|
||||||
|
</para>
|
||||||
|
|
||||||
|
<para><filename>port.h</filename> file defines 6 static inline functions for port I/O:</para>
|
||||||
|
|
||||||
<sect3 id="port-in">
|
<sect3 id="port-in">
|
||||||
<title>Read a byte from port</title>
|
<title>Read a byte from port</title>
|
||||||
@@ -130,17 +138,18 @@ disable drivers that need a parallel port.
|
|||||||
<screen>
|
<screen>
|
||||||
#include "port.h"
|
#include "port.h"
|
||||||
|
|
||||||
/* Get access to these 3 ports:
|
/*
|
||||||
0x378 (CONTROL),
|
* Get access to these 3 ports:
|
||||||
0x379 (STATUS) and
|
* 0x378 (CONTROL),
|
||||||
0x37A (DATA)
|
* 0x379 (STATUS) and
|
||||||
|
* 0x37A (DATA)
|
||||||
*/
|
*/
|
||||||
if ( -1 == port_access_multiple(0x378,3) ) {
|
if (port_access_multiple(0x378, 3) == -1) {
|
||||||
/* Access denied, do something */
|
/* Access denied, do something */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Write a 'A' to the control port */
|
/* Write a 'A' to the control port */
|
||||||
ort_out(0x378, 'A');
|
port_out(0x378, 'A');
|
||||||
|
|
||||||
/* Read from the status port */
|
/* Read from the status port */
|
||||||
char status = port_in(0x379);
|
char status = port_in(0x379);
|
||||||
|
|||||||
@@ -114,7 +114,7 @@ should look like.
|
|||||||
</para>
|
</para>
|
||||||
</note>
|
</note>
|
||||||
|
|
||||||
<sect2>
|
<sect2 id="code-style-indention">
|
||||||
<title>File format and indention</title>
|
<title>File format and indention</title>
|
||||||
<itemizedlist mark="opencircle">
|
<itemizedlist mark="opencircle">
|
||||||
<listitem>
|
<listitem>
|
||||||
@@ -140,7 +140,7 @@ should look like.
|
|||||||
<para>
|
<para>
|
||||||
<emphasis>Indention: </emphasis>Tab indention shall be used (with tab
|
<emphasis>Indention: </emphasis>Tab indention shall be used (with tab
|
||||||
width set to 8 characters). Only exception are switch labels which are
|
width set to 8 characters). Only exception are switch labels which are
|
||||||
indented a half tab (4 characters).
|
indented a half tab (4 spaces).
|
||||||
</para>
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
<listitem>
|
<listitem>
|
||||||
@@ -153,14 +153,15 @@ should look like.
|
|||||||
</itemizedlist>
|
</itemizedlist>
|
||||||
</sect2>
|
</sect2>
|
||||||
|
|
||||||
<sect2>
|
<sect2 id="code-style-naming">
|
||||||
<title>Naming conventions</title>
|
<title>Naming conventions</title>
|
||||||
<itemizedlist mark="opencircle">
|
<itemizedlist mark="opencircle">
|
||||||
<listitem>
|
<listitem>
|
||||||
<para>
|
<para>
|
||||||
<emphasis>Function names:</emphasis>
|
<emphasis>Function names:</emphasis>
|
||||||
Function names shall be lowercase. We do not use CamelCase. Multiple words
|
Function names shall be lowercase. We do not use CamelCase (some
|
||||||
are separated by underscore.
|
historical exceptions may exist). Multiple words are separated by
|
||||||
|
underscore.
|
||||||
</para>
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
<listitem>
|
<listitem>
|
||||||
@@ -198,7 +199,7 @@ unsigned char HD44780_scankeypad(PrivateData *p);
|
|||||||
</example>
|
</example>
|
||||||
</sect2>
|
</sect2>
|
||||||
|
|
||||||
<sect2>
|
<sect2 id="code-style-comments">
|
||||||
<title>Comments</title>
|
<title>Comments</title>
|
||||||
<itemizedlist mark="opencircle">
|
<itemizedlist mark="opencircle">
|
||||||
<listitem>
|
<listitem>
|
||||||
@@ -248,7 +249,7 @@ unsigned char HD44780_scankeypad(PrivateData *p);
|
|||||||
</itemizedlist>
|
</itemizedlist>
|
||||||
</sect2>
|
</sect2>
|
||||||
|
|
||||||
<sect2>
|
<sect2 id="code-style-statements">
|
||||||
<title>Statement style</title>
|
<title>Statement style</title>
|
||||||
<itemizedlist mark="opencircle">
|
<itemizedlist mark="opencircle">
|
||||||
<listitem>
|
<listitem>
|
||||||
@@ -309,7 +310,7 @@ y--;
|
|||||||
<listitem>
|
<listitem>
|
||||||
<para><emphasis>Function calls:</emphasis></para>
|
<para><emphasis>Function calls:</emphasis></para>
|
||||||
<para>
|
<para>
|
||||||
There shall be no space between the function call and the opening '(' of
|
There shall be no space between the function call and the opening brace '(' of
|
||||||
the parameter list. Within the parameter list a space shall be after each
|
the parameter list. Within the parameter list a space shall be after each
|
||||||
parameter.
|
parameter.
|
||||||
</para>
|
</para>
|
||||||
|
|||||||
Reference in New Issue
Block a user