?? rt_com.lyx
字號:
#This file was created by <jochen> Wed Jul 28 14:03:03 1999#LyX 1.0 (C) 1995-1999 Matthias Ettrich and the LyX Team\lyxformat 2.15\textclass linuxdoc\language english\inputencoding latin1\fontscheme default\graphics default\paperfontsize 12\spacing single \papersize Default\paperpackage a4\use_geometry 0\use_amsmath 0\paperorientation portrait\secnumdepth 3\tocdepth 3\paragraph_separation indent\defskip medskip\quotes_language english\quotes_times 2\papercolumns 1\papersides 1\paperpagestyle default\layout Title\added_space_top vfill \added_space_bottom vfill rt_com\layout AuthorJochen K黳per\layout Date$Date: 2003/03/01 11:48:24 $\layout SectionDevice Driver Support\layout Standard$Id: rt_com.lyx,v 1.1.1.1 2003/03/01 11:48:24 hofrat Exp $\layout Subsectionrt_com - serial port driver\layout Standard\emph on author\emph default : Jochen K黳per <jochen@uni-duesseldorf.de>\layout Standard\noindent \emph on last\emph default \emph on changed\emph default : $Date: 2003/03/01 11:48:24 $\layout StandardThis manual is intended to describe \family typewriter rt_com\family default version 0.3, but is not fully updated to match that version yet. The interface should be right, though.\layout SubsubsectionIntroduction\layout StandardThis chapter of the manual describes the \family typewriter rt_com\family default kernel module. That module provides a reasonable easy software interface (driver) to the standard serial ports of the PCs. There are a small number of user functions that provide an interface to the port, as well as several functions internally used to communicate with the hardware. \layout SubsubsectionInstallation\layout StandardThe rt_com package should contain the source code (\family typewriter rt_com.h\family default , \family typewriter rt_com.c\family default , \family typewriter rt_comP.h\family default ), makefiles (\family typewriter Makefile.am\family default , \family typewriter Makefile.standalone\family default ), some informational files (\family typewriter COPYING\family default , \family typewriter License\family default , \family typewriter README\family default ) and this documentation in various formats. The master file is \family typewriter rt_com.lyx\family default , there are also html and Postscript versions of it available.\layout StandardThe module works with RT-Linux v1 and v2. In order to run it on an v1 system (Linux kernel 2.0.x) you need to define \family typewriter RTLINUX_V1\family default at compile time.\layout SubsubsectionInterface functions\layout ParagraphSetting up a serial port\layout StandardThis is to set up the port for use by your module by providing some initialization data. The function is declared as\layout Codevoid rt_com_setup( unsigned int com, unsigned baud, unsigned parity, unsigned stopbits, unsigned wordlength)\layout Standardwhere com is the entry number from the\family typewriter rt_com_table\family default (see paragraph \begin_inset LatexCommand \ref[rt_com_table]{rt_com_table}\end_inset ), baud is the Baud rate the port shall be operated at, parity determines the parity policy to use (possible values are \family typewriter RT_COM_PARITY_EVEN\family default , \family typewriter RT_COM_PARITY_NONE\family default , \family typewriter RT_COM_PARITY_ODD\family default - these are defined in \family typewriter rt_com.h\family default ), stopbits and wordlength are self explanatory and take the immediate value these flags shall be set at.\layout ParagraphWriting data to a port \layout StandardTo write data to a port you need to call the function\family typewriter rt_com_write\family default , which is declared as\layout Codevoid rt_com_write( unsigned int com, char *buf, int cnt )\layout Standardwhere com is the entry number from the \family typewriter rt_com_table\family default (see paragraph \begin_inset LatexCommand \ref[rt_com_table]{rt_com_table}\end_inset ), buf is the memory address of the data to write to the port, cnt is the number of bytes that shall be written.\layout ParagraphReading data from a port\layout StandardTo read data from a port you need to call the function rt_com_read, which is declared as\layout Codeint rt_com_read( unsigned int com, char *buf, int cnt )\layout Standardwhere com is the entry number from the\family typewriter rt_com_table\family default (see paragraph \begin_inset LatexCommand \ref[rt_com_table]{rt_com_table}\end_inset ), buf is the memory address the data read shall be put in, cnt is the maximum number of bytes that shall be read. The function returns the number of bytes that really have been read.\layout SubsubsectionInternals\layout ParagraphLoading the module into memory\begin_inset LatexCommand \label{init_module}\end_inset \layout StandardWhen the module gets loaded it requests the port memory and registers the interrupt service routine (ISR) for each member of the rt_com_table (see paragraph \begin_inset LatexCommand \ref[rt_com_table]{rt_com_table}\end_inset ). Moreover it initializes all ports.\layout StandardOn success it reports the loading of the module, otherwise it releases all resources, reports the failure and exits without the module beeing loaded. \layout ParagraphRemoving the module\layout StandardBefore the module is removed from memory, the function cleanup_module frees all allocated resources.\layout SubsubsectionData Structures\layout Paragraphrt_buf_struct\begin_inset LatexCommand \label{rt_buf_struct}\end_inset \layout StandardStructure to implement software FIFOs. Used for buffering of the data that needs to be written to the port and data read from hardware that needs to be read by the user. The FIFO size is given by the define \family typewriter RT_COM_BUF_SIZ\family default ; it has to be a power of two.\layout Paragraphrt_com_struct\layout StandardDefines the hardware parameter of one serial port. The members of this structure are a magic number (not used yet), the base rate of the port (115200 for standard ports), the port number, the interrupt number (IRQ) of the port, the flags set for this port, the ISR (see paragraph \begin_inset LatexCommand \ref[init_module]{init_module}\end_inset ) the type and a copy of the IER register. Moreover it contains two FIFOs as defined by the \family typewriter rt_buf_struc\family default (see paragraph \begin_inset LatexCommand \ref[rt_buf_struct]{rt_buf_struct}\end_inset ), one for reading from the port and one for writing to it, respectively.\layout Paragraphrt_com_table\begin_inset LatexCommand \label{rt_com_table}\end_inset \layout StandardThis array holds a rt_com_struct for each serial port to be handled by the module.\layout SubsubsectionAvailability\layout StandardThe package is available at the \begin_inset LatexCommand \url[rt_com homepage]{http://www-public.rz.uni-duesseldorf.de/~jochen/computer/software/rt_com/}\end_inset and the \begin_inset LatexCommand \url[RT-Linux homepage]{http://www.rtlinux.org}\end_inset .\layout SubsubsectionBugs\layout StandardPlease report bugs to \begin_inset LatexCommand \url[Jochen K黳per]{mailto:jochen@uni-duesseldorf.de}\end_inset and the \begin_inset LatexCommand \url[RT-Linux maiing list]{mailto:rtl@rtlinux.cs.nmt.edu}\end_inset .\layout StandardThere are no known bugs right now. \layout SubsubsectionAcknowledgment\layout StandardThanks to Jens Michaelsen for providing his code.\the_end
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -