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

📄 apci1710_82x54.c

📁 最新版comedi的源码
💻 C
📖 第 1 页 / 共 5 页
字号:
/**@verbatimCopyright (C) 2004,2005  ADDI-DATA GmbH for the source code of this module.                 ADDI-DATA GmbH         Dieselstrasse 3         D-77833 Ottersweier         Tel: +19(0)7223/9493-0         Fax: +49(0)7223/9493-92         http://www.addi-data-com         info@addi-data.com This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USAYou shoud also find the complete GPL in the COPYING file accompanying this source code.@endverbatim*//*      +-----------------------------------------------------------------------+  | (C) ADDI-DATA GmbH          Dieselstraße 3       D-77833 Ottersweier  |  +-----------------------------------------------------------------------+  | Tel : +49 (0) 7223/9493-0     | email    : info@addi-data.com         |  | Fax : +49 (0) 7223/9493-92    | Internet : http://www.addi-data.com   |  +-----------------------------------------------------------------------+  | Project     : API APCI1710    | Compiler : gcc                        |  | Module name : 82X54.C         | Version  : 2.96                       |  +-------------------------------+---------------------------------------+  | Project manager: Eric Stolz   | Date     :  02/12/2002                |  +-----------------------------------------------------------------------+  | Description :   APCI-1710 82X54 timer module                          |  |                                                                       |  |                                                                       |  +-----------------------------------------------------------------------+  |                             UPDATES                                   |  +-----------------------------------------------------------------------+  |   Date   |   Author  |          Description of updates                |  +----------+-----------+------------------------------------------------+  | 29/06/98 | S. Weber  | Digital input / output implementation          |  |----------|-----------|------------------------------------------------|  | 08/05/00 | Guinot C  | - 0400/0228 All Function in RING 0             |  |          |           |   available                                    |  +-----------------------------------------------------------------------+  | 27.10.03 | J. Krauth |  Add the possibility to use a 40 Mhz quartz    |  |          |           |                                                |  +-----------------------------------------------------------------------+*//*+----------------------------------------------------------------------------+|                               Included files                               |+----------------------------------------------------------------------------+*/#include "APCI1710_82x54.h"/*+----------------------------------------------------------------------------+| Function Name     : _INT_     i_APCI1710_InitTimer                         ||                               (BYTE_   b_BoardHandle,                      ||                                BYTE_   b_ModulNbr,                         ||                                BYTE_   b_TimerNbr,                         ||                                BYTE_   b_TimerMode,                        ||                                ULONG_ ul_ReloadValue,                      ||                                BYTE_   b_InputClockSelection,              ||                                BYTE_   b_InputClockLevel,                  ||                                BYTE_   b_OutputLevel,                      ||                                BYTE_   b_HardwareGateLevel)INT i_InsnConfig_InitTimer(comedi_device *dev,comedi_subdevice *s,	comedi_insn *insn,lsampl_t *data)|	+----------------------------------------------------------------------------+| Task              : Configure the Timer (b_TimerNbr) operating mode        ||                     (b_TimerMode) from selected module (b_ModulNbr).       ||                     You must calling this function be for you call any     ||                     other function witch access of the timer.              ||                                                                            ||                                                                            ||                       Timer mode description table                         ||                                                                            ||+--------+-----------------------------+--------------+--------------------+|||Selected+      Mode description       +u_ReloadValue | Hardware gate input||||  mode  |                             |  description |      action        |||+--------+-----------------------------+--------------+--------------------+|||        |Mode 0 is typically used     |              |                    ||||        |for event counting. After    |              |                    ||||        |the initialisation, OUT      |              |                    ||||        |is initially low, and        |              |                    ||||   0    |will remain low until the    |Start counting|   Hardware gate    ||||        |counter reaches zero.        |   value      |                    ||||        |OUT then goes high and       |              |                    ||||        |remains high until a new     |              |                    ||||        |count is written. See        |              |                    ||||        |"i_APCI1710_WriteTimerValue" |              |                    ||||        |function.                    |              |                    |||+--------+-----------------------------+--------------+--------------------+|||        |Mode 1 is similar to mode 0  |              |                    ||||        |except for the gate input    |              |                    ||||   1    |action. The gate input is not|Start counting|  Hardware trigger  ||||        |used for enabled or disabled |   value      |                    ||||        |the timer.                   |              |                    ||||        |The gate input is used for   |              |                    ||||        |triggered the timer.         |              |                    |||+--------+-----------------------------+--------------+--------------------+|||        |This mode functions like a   |              |                    ||||        |divide-by-ul_ReloadValue     |              |                    ||||        |counter. It is typically used|              |                    ||||        |to generate a real time clock|              |                    ||||        |interrupt. OUT will initially|              |                    ||||   2    |be high after the            |   Division   |  Hardware gate     ||||        |initialisation. When the     |    factor    |                    ||||        |initial count has decremented|              |                    ||||        |to 1, OUT goes low for one   |              |                    ||||        |CLK pule. OUT then goes high |              |                    ||||        |again, the counter reloads   |              |                    ||||        |the initial count            |              |                    ||||        |(ul_ReloadValue) and the     |              |                    ||||        |process is repeated.         |              |                    ||||        |This action can generated a  |              |                    ||||        |interrupt. See function      |              |                    ||||        |"i_APCI1710_SetBoardInt-     |              |                    ||||        |RoutineX"                    |              |                    ||||        |and "i_APCI1710_EnableTimer" |              |                    |||+--------+-----------------------------+--------------+--------------------+|||        |Mode 3 is typically used for |              |                    ||||        |baud rate generation. This   |              |                    ||||        |mode is similar to mode 2    |              |                    ||||        |except for the duty cycle of |              |                    ||||   3    |OUT. OUT will initially be   |  Division    |   Hardware gate    ||||        |high after the initialisation|   factor     |                    ||||        |When half the initial count  |              |                    ||||        |(ul_ReloadValue) has expired,|              |                    ||||        |OUT goes low for the         |              |                    ||||        |remainder of the count. The  |              |                    ||||        |mode is periodic; the        |              |                    ||||        |sequence above is repeated   |              |                    ||||        |indefinitely.                |              |                    |||+--------+-----------------------------+--------------+--------------------+|||        |OUT will be initially high   |              |                    ||||        |after the initialisation.    |              |                    ||||        |When the initial count       |              |                    ||||   4    |expires OUT will go low for  |Start counting|  Hardware gate     ||||        |one CLK pulse and then go    |    value     |                    ||||        |high again.                  |              |                    ||||        |The counting sequences is    |              |                    ||||        |triggered by writing a new   |              |                    ||||        |value. See                   |              |                    ||||        |"i_APCI1710_WriteTimerValue" |              |                    ||||        |function. If a new count is  |              |                    ||||        |written during counting,     |              |                    ||||        |it will be loaded on the     |              |                    ||||        |next CLK pulse               |              |                    |||+--------+-----------------------------+--------------+--------------------+|||        |Mode 5 is similar to mode 4  |              |                    ||||        |except for the gate input    |              |                    ||||        |action. The gate input is not|              |                    ||||   5    |used for enabled or disabled |Start counting|  Hardware trigger  ||||        |the timer. The gate input is |    value     |                    ||||        |used for triggered the timer.|              |                    |||+--------+-----------------------------+--------------+--------------------+||                                                                            ||                                                                            ||                                                                            ||                      Input clock selection table                           ||                                                                            ||  +--------------------------------+------------------------------------+   ||  |       b_InputClockSelection    |           Description              |   ||  |           parameter            |                                    |   ||  +--------------------------------+------------------------------------+   ||  |    APCI1710_PCI_BUS_CLOCK      | For the timer input clock, the PCI |   ||  |                                | bus clock / 4 is used. This PCI bus|   ||  |                                | clock can be 30MHz or 33MHz. For   |   ||  |                                | Timer 0 only this selection are    |   ||  |                                | available.                         |   ||  +--------------------------------+------------------------------------+   ||  | APCI1710_ FRONT_CONNECTOR_INPUT| Of the front connector you have the|   ||  |                                | possibility to inject a input clock|   ||  |                                | for Timer 1 or Timer 2. The source |   ||  |                                | from this clock can eat the output |   ||  |                                | clock from Timer 0 or any other    |   ||  |                                | clock source.                      |   ||  +--------------------------------+------------------------------------+   ||                                                                            |+----------------------------------------------------------------------------+| Input Parameters  : BYTE_   b_BoardHandle        : Handle of board         ||                                                    APCI-1710               ||                     BYTE_   b_ModulNbr           : Module number to        ||                                                    configure (0 to 3)      ||                     BYTE_   b_TimerNbr           : Timer number to         ||                                                    configure (0 to 2)      ||                     BYTE_   b_TimerMode          : Timer mode selection    ||                                                    (0 to 5)                ||                                                    0: Interrupt on terminal||                                                       count                ||                                                    1: Hardware             ||                                                       retriggerable one-   ||                                                       shot                 ||                                                    2: Rate generator       ||                                                    3: Square wave mode     ||                                                    4: Software triggered   ||                                                       strobe               ||                                                    5: Hardware triggered   ||                                                       strobe               ||                                                       See timer mode       ||                                                       description table.   ||                     ULONG_ ul_ReloadValue         : Start counting value   ||                                                     or division factor     ||                                                     See timer mode         ||                                                     description table.     ||                     BYTE_   b_InputClockSelection : Selection from input   ||                                                     timer clock.           ||                                                     See input clock        ||                                                     selection table.       ||                     BYTE_   b_InputClockLevel     : Selection from input   ||                                                     clock level.           ||                                                     0 : Low active         ||                                                         (Input inverted)   ||                                                     1 : High active        ||                     BYTE_   b_OutputLevel,        : Selection from output  ||                                                     clock level.           ||                                                     0 : Low active         ||                                                     1 : High active        ||                                                         (Output inverted)  ||                     BYTE_   b_HardwareGateLevel   : Selection from         ||                                                     hardware gate level.   ||                                                     0 : Low active         ||                                                         (Input inverted)   ||                                                     1 : High active        ||                                                     If you will not used   ||                                                     the hardware gate set  ||                                                     this value to 0.       |b_ModulNbr        = (BYTE) CR_AREF(insn->chanspec);	b_TimerNbr		  = (BYTE) CR_CHAN(insn->chanspec);	b_TimerMode		  = (BYTE) data[0];	ul_ReloadValue	  = (ULONG) data[1];	b_InputClockSelection	=(BYTE) data[2];	b_InputClockLevel		=(BYTE) data[3];	b_OutputLevel			=(BYTE) data[4];	b_HardwareGateLevel		=(BYTE) data[5];+----------------------------------------------------------------------------+| Output Parameters : -                                                      |+----------------------------------------------------------------------------+| Return Value      : 0: No error                                            ||                    -1: The handle parameter of the board is wrong          ||                    -2: Module selection wrong                              ||                    -3: Timer selection wrong                               ||                    -4: The module is not a TIMER module                    ||                    -5: Timer mode selection is wrong                       ||                    -6: Input timer clock selection is wrong                ||                    -7: Selection from input clock level is wrong           ||                    -8: Selection from output clock level is wrong          ||                    -9: Selection from hardware gate level is wrong         |+----------------------------------------------------------------------------+*/INT i_APCI1710_InsnConfigInitTimer(comedi_device *dev,comedi_subdevice *s,	comedi_insn *insn,lsampl_t *data)	{	INT i_ReturnValue = 0;		BYTE   b_ModulNbr;	BYTE   b_TimerNbr;	BYTE   b_TimerMode;	ULONG  ul_ReloadValue;	BYTE   b_InputClockSelection;	BYTE   b_InputClockLevel;	BYTE   b_OutputLevel;	BYTE   b_HardwareGateLevel;        //BEGIN JK 27.10.2003 : Add the possibility to use a 40 Mhz quartz	DWORD dw_Test = 0;	//END JK 27.10.2003 : Add the possibility to use a 40 Mhz quartz	i_ReturnValue=insn->n;	b_ModulNbr        = (BYTE) CR_AREF(insn->chanspec);	b_TimerNbr		  = (BYTE) CR_CHAN(insn->chanspec);	b_TimerMode		  = (BYTE) data[0];	ul_ReloadValue	  = (ULONG) data[1];	b_InputClockSelection	=(BYTE) data[2];	b_InputClockLevel		=(BYTE) data[3];	b_OutputLevel			=(BYTE) data[4];	b_HardwareGateLevel		=(BYTE) data[5];		/**************************/	/* Test the module number */	/**************************/       	if (b_ModulNbr < 4)	   {	   /***********************/	   /* Test if 82X54 timer */	   /***********************/	   if ((devpriv->s_BoardInfos.		dw_MolduleConfiguration [b_ModulNbr] & 0xFFFF0000UL) == APCI1710_82X54_TIMER)	      {	      /*************************/	      /* Test the timer number */	      /*************************/	      if (b_TimerNbr <= 2)		 {

⌨️ 快捷键说明

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