⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 manual.tex~

📁 安装comedi板卡驱动之后的测试程序
💻 TEX~
📖 第 1 页 / 共 2 页
字号:
      \caption{COMEDI applications structure}      \label{f1}    \end{figure}  \chapter{User case setup}    Advantech provides user cases' source codes, which should be    compiled by users. This section introduces compilation of    source codes and other configurations of user cases package.      \section{Compilation}      \subsection{Specify your hardware}        \begin{notes}          BY DEFAULT, ALL USER CASES USE DEVICE FILE          \texttt{/dev/coemdi0}        \end{notes}        If hardware is identified other than as        \texttt{/dev/comedi0}, it's necessary to modify the        example cases and recompile.        For example, \texttt{di\_insn.c}:        \lstinputlisting[            firstline=40,            lastline=47,            caption={Modify device},            frame=trBL,            ]{../../di_insn.c}        You should modify \texttt{/dev/comedi0} to whatever your        hardware was configured as.      \subsection{Compile}      You could choose to compile all use cases or to compile only      PCI-1784 cases. To do this, change directory to      corresponding position, then type      \begin{verse}        \texttt{\#make}      \end{verse}      to compile the source code to executable objects, or type      \begin{verse}        \texttt{\#make clean}      \end{verse}      to erase all binary files made by the compiling      consequences.      \subsection{Usage of user cases}      Since executable files have been produced by the last step,      you were able to use these cases simply by typing:      \begin{verse}        \texttt{\#cd comeditest/1784/}        \texttt{\#./di\_insn}      \end{verse}    \chapter{PCI-1784 User Cases}      \section{Introduction}      User cases for Advantech PCI-1784 Linux driver are written      in \texttt{c}.      \begin{table}[h]        \begin{tabular}{|c|c|c|}            \hline            % after \\: \hline or \cline{col1-col2} \cline{col3-col4} ...            \textbf{Case Name} & \textbf{subdevice} & \textbf{Description} \\            \hline            \texttt{counter.c} & 6 & Utility to change counter mode \\            \texttt{cntrst.c} & 6 & Reset counter to default values \\            \texttt{di\_insn.c} & 2 & Digital input in instruction mode \\            \texttt{do\_insn.c} & 3 & Digital output in instruction mode \\            \texttt{do\_indicated.c} & 3 & Digital output control \\            \texttt{rdcnt.c} & 6 & Read counter latch value \\            \texttt{readcp.c} & 7 & Read counter compare register value \\            \texttt{interrupt.c} & 15 & Change interrupt setting \\            \texttt{int\_1784.c} & 15 & Interrupt handler in \texttt{cmd} mode \\            \texttt{signal.c} & 15 & Interrupt handler using signal \\            \hline        \end{tabular}        \caption{User cases list}      \end{table}      \section{How to write a case}      User cases use COMEDILIB interfaces. There are two ways of      COMEDILIB, \texttt{insn} mode and \texttt{cmd} mode. Please      refer to \emph{Advantech Linux Driver user manual} for      detailed information.      A case first open a COMEDI device file      using \texttt{comedi\_open()}, filling up \texttt{insn}      or \texttt{cmd} structures which give the driver information      of I/O modes, call \texttt{comedi\_do\_insn()} or      \texttt{comedi\_do\_cmd()} to perform the specified operation.      Finally call \texttt{comedi\_close()} to close the device      file and end the sequence.      For your convenience, Here is a skeleton codes for writing      COMEDILIB cases in \texttt{insn} mode:      \begin{lstlisting}[frame=trBL]{}        #include <stdio.h>        #include <stdlib.h>        #include <comedilib.h>        #include <fcntl.h>        #include <unistd.h>        #include <sys/ioctl.h>        #include <errno.h>        #include <getopt.h>        #include <ctype.h>        #include <math.h>        #include <sys/time.h>        #include <string.h>        #define N_SAMPLE 2        char *filename="/dev/comedi0";        int verbose_flag; comedi_t *device;        int channel =1;        int range = 0;        int subdev = 2;        int main(void) {            lsampl_t data[N_SAMPLE];            int save_errno;            int ret,n_channels;            comedi_insn insn;            char argument;            device = comedi_open(filename);            if(!device){                printf("E: comedi_open(\"%s\"): %s\n",filename,strerror(errno));                return 1;            }            memset(&insn,0,sizeof(insn));            memset(&data,0,sizeof(data));            n_channels = comedi_get_n_channels(device, subdev);            insn.subdev = subdev;            insn.insn = INSN_READ;            insn.n = N_SAMPLE;            insn.data = data;            ret = comedi_do_insn(device,&insn);     //sample data            save_errno = errno;            if(ret<0){                comedi_perror(filename);            exit(0);            comedi_close(device);            return 1;        }      \end{lstlisting}      \section{User cases specification}      \subsection{\texttt{counter.c}}      This case is to set counter mode and latch mode for specific      counter channel.       \subsection{\texttt{cntrst.c} and \texttt{cntlock.c}}      Counter default value could be \texttt{0x80000000} or      \texttt{0}. This is selectable in \texttt{cntrst.c} for      specific channel.      If \texttt{cntlock} is called, the setting of counter      locking would be changed to over flow lock, under flow lock      or continues counting.      \subsection{\texttt{clkctrl.c}}      This case is to set timer control register, including      sampling clock selecting, timer divider and timer base.      \subsection{\texttt{compare.c}}      This case is to set counter's compare register. Counter      channel should be first specified.      \subsection{\texttt{di\_insn.c} and \texttt{do\_insn.c}}      These two cases are used to perform di and do operations in      \texttt{insn} mode. In \texttt{do\_insn.c} User should enter channel      mask and value both in hex value.      For example, do at channel 2, mask would be $0x4$ and value      should be \texttt{0x4} or \texttt{0xf}.      \subsection{\texttt{do\_indicated.c}}      Digital output options are configured here, including enable      counter over compare digital output, counter under compare      digital output, do level control and mode control.      \subsection{\texttt{rdcnt.c} and \texttt{readcp.c}}      \texttt{rdcnt.c} simply is to read counter latch register      back. Counter channel should be specified first.      \textbf{NOTE} If you read a counter channel before any counter       mode had been set, the pci1784 driver would prompt      ``Please enable counter first'' and quit. So remember to enable       counter first.      \texttt{readcp.c} is to read counter compare register      back. Counter channel should be specified first.      \subsection{\texttt{interrupt.c}}      This is a utility to generate interrupt control register.      Totally 25 interrupt sources could be enabled to generate      interrupt.       Counter compare register could be set here.      If timer interrupt is also enabled, sampling clock, timer divider       and timer base should be selected.      \subsection{\texttt{int\_1784.c}}      This is the main way for interrupt handling, using COMEDILIB      \texttt{cmd} mode. The driver would put its interrupt status      register value into user's space when interrupt handles,      thus the case should recognize the interrupt type and print      it out. Totally 25 interrupt sources have been checked every      time interrupt occurs, and each one has a counter to      calculate the number of interrupts.      \textbf{Note} that \texttt{interrupt.c} must be called to generate      interrupt control modes, otherwise interrupt would be      disabled.      \subsection{\texttt{signal.c}}      Not all of 25 interrupt sources could be able to handled in      this way. Since \texttt{cmd} mode interrupt is the main way      of interrupt handling, examples here is just able to handle      interrupts from \texttt{DI0}, \texttt{DI1}, \texttt{DI2},      \texttt{DI3}, \texttt{OV0},\texttt{OV1} and \texttt{TM}. To      enable other interrupt sources, you should edit the      \texttt{signal.c} to add extra signal handler functions.\end{document}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -