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

📄 hwdrv_apci035.c

📁 最新版comedi的源码
💻 C
📖 第 1 页 / 共 2 页
字号:
/**@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     : APCI-035        | Compiler   : GCC                      |  | Module name : hwdrv_apci035.c | Version    : 2.96                     |  +-------------------------------+---------------------------------------+  | Project manager: Eric Stolz   | Date       :  02/12/2002              |  +-------------------------------+---------------------------------------+  | Description :   Hardware Layer Acces For APCI-035                     |  +-----------------------------------------------------------------------+  |                             UPDATES                                   |  +----------+-----------+------------------------------------------------+  |   Date   |   Author  |          Description of updates                |  +----------+-----------+------------------------------------------------+  |          |           |                                                |  |          |           |                                                |  |          |           |                                                |  +----------+-----------+------------------------------------------------+*//*+----------------------------------------------------------------------------+|                               Included files                               |+----------------------------------------------------------------------------+*/#include "hwdrv_apci035.h"INT i_WatchdogNbr=0;INT i_Temp=0;INT i_Flag=1;/*+----------------------------------------------------------------------------+| Function   Name   : int i_APCI035_ConfigTimerWatchdog                      ||			  (comedi_device *dev,comedi_subdevice *s,               | |                      comedi_insn *insn,lsampl_t *data)                     |+----------------------------------------------------------------------------+| Task              : Configures The Timer , Counter or Watchdog             |+----------------------------------------------------------------------------+| Input Parameters  : comedi_device *dev : Driver handle                     ||                     UINT *data         : Data Pointer contains             ||                                          configuration parameters as below ||                                                                            | |					  data[0]            : 0 Configure As Timer      | 	|										   1 Configure As Watchdog   |                               data[1]            : Watchdog number                                         |					  data[2]            : Time base Unit            ||					  data[3]			 : Reload Value			     |                               data[4]            : External Trigger          |                                                   1:Enable                                                   0:Disable                                                data[5]            :External Trigger Level                                                  00 Trigger Disabled                                                  01 Trigger Enabled (Low level)                                                  10 Trigger Enabled (High Level)                                                  11 Trigger Enabled (High/Low level)                                 data[6]            : External Gate            |                                                   1:Enable                                                   0:Disable                                      data[7]            : External Gate level                                                  00 Gate Disabled                                                  01 Gate Enabled (Low level)                                                  10 Gate Enabled (High Level)                              data[8]            :Warning Relay                                                  1: ENABLE                                                  0: DISABLE                                data[9]            :Warning Delay available                              data[10]           :Warning Relay Time unit                              data[11]           :Warning Relay Time Reload value                              data[12]           :Reset Relay                                                  1 : ENABLE                                                  0 : DISABLE                                data[13]           :Interrupt                                                  1 : ENABLE                                                  0 : DISABLE  |					+----------------------------------------------------------------------------+| Output Parameters :	--													 |+----------------------------------------------------------------------------+| Return Value      : TRUE  : No error occur                                 ||		            : FALSE : Error occur. Return the error          ||			                                                         |+----------------------------------------------------------------------------+*/INT i_APCI035_ConfigTimerWatchdog(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data){UINT ui_Status=0;UINT ui_Command=0;UINT ui_Mode=0;i_Temp=0;devpriv->tsk_Current=current;devpriv->b_TimerSelectMode=data[0];i_WatchdogNbr=data[1];if(data[0]==0)   {   ui_Mode=2;   }else   {   ui_Mode=0;   }  //ui_Command = inl(devpriv->iobase+((i_WatchdogNbr-1)*32)+12);ui_Command=0;//ui_Command = ui_Command & 0xFFFFF9FEUL;outl(ui_Command,devpriv->iobase+((i_WatchdogNbr-1)*32)+12);ui_Command=0;ui_Command = inl(devpriv->iobase+((i_WatchdogNbr-1)*32)+12);/************************//* Set the reload value *//************************/outl( data[3],devpriv->iobase+((i_WatchdogNbr-1)*32) + 4);/*********************//* Set the time unit *//*********************/ outl(data[2],devpriv->iobase+((i_WatchdogNbr-1)*32) + 8);if (data[0] == ADDIDATA_TIMER)   {                                  /******************************/                 /* Set the mode :             */                 /* - Disable the hardware     */                 /* - Disable the counter mode */                 /* - Disable the warning      */                 /* - Disable the reset        */                 /* - Enable the timer mode    */                 /* - Set the timer mode       */                 /******************************/                    ui_Command = (ui_Command & 0xFFF719E2UL) | ui_Mode << 13UL | 0x10UL;   }//if (data[0] == ADDIDATA_TIMER) else   {      if(data[0]==ADDIDATA_WATCHDOG)         {                            /******************************/                 /* Set the mode :             */                 /* - Disable the hardware     */                 /* - Disable the counter mode */                 /* - Disable the warning      */                 /* - Disable the reset        */                 /* - Disable the timer mode   */                 /******************************/                             ui_Command = ui_Command & 0xFFF819E2UL;         }       else          {         printk("\n The parameter for Timer/watchdog selection is in error\n");         return -EINVAL;         }    }outl(ui_Command,devpriv->iobase+((i_WatchdogNbr-1)*32)+12);ui_Command=0;ui_Command = inl(devpriv->iobase+((i_WatchdogNbr-1)*32)+12);/********************************//* Disable the hardware trigger *//********************************/ui_Command = ui_Command & 0xFFFFF89FUL;   if (data[4] == ADDIDATA_ENABLE)    {    /**********************************/    /* Set the hardware trigger level */    /**********************************/               ui_Command = ui_Command |  ( data[5] << 5);    }           outl(ui_Command,devpriv->iobase+((i_WatchdogNbr-1)*32)+12);ui_Command=0;ui_Command = inl(devpriv->iobase+((i_WatchdogNbr-1)*32)+12); /*****************************//* Disable the hardware gate *//*****************************/   ui_Command = ui_Command & 0xFFFFF87FUL; if (data[6] == ADDIDATA_ENABLE)   {/*******************************//* Set the hardware gate level *//*******************************/                ui_Command = ui_Command |( data[7] << 7);   }outl(ui_Command,devpriv->iobase+((i_WatchdogNbr-1)*32)+12);           ui_Command=0;ui_Command = inl(devpriv->iobase+((i_WatchdogNbr-1)*32)+12);             /*******************************//* Disable the hardware output *//*******************************/ui_Command = ui_Command & 0xFFFFF9FBUL;           /*********************************//* Set the hardware output level *//*********************************/ui_Command = ui_Command |( data[8] << 2);          outl(ui_Command,devpriv->iobase+((i_WatchdogNbr-1)*32)+12); if(data[9]==ADDIDATA_ENABLE)     {    /************************/   /* Set the reload value */   /************************/            outl (data[11],devpriv->iobase+((i_WatchdogNbr-1)*32) + 24);   /**********************/   /* Set the time unite */   /**********************/    outl(data[10],devpriv->iobase+((i_WatchdogNbr-1)*32)+ 28);   }    ui_Command=0;    ui_Command = inl(devpriv->iobase+((i_WatchdogNbr-1)*32)+12);               /*******************************/ /* Disable the hardware output */ /*******************************/            ui_Command = ui_Command & 0xFFFFF9F7UL;             /*********************************/   /* Set the hardware output level */   /*********************************/ ui_Command = ui_Command |( data[12] << 3);            outl(ui_Command,devpriv->iobase+((i_WatchdogNbr-1)*32)+12);  /*************************************/ /**  Enable the watchdog interrupt  **/ /*************************************/ ui_Command=0;ui_Command = inl(devpriv->iobase+((i_WatchdogNbr-1)*32)+12);  /*******************************//* Set the interrupt selection *//*******************************/ui_Status =inl(devpriv->iobase+((i_WatchdogNbr-1)*32) + 16);ui_Command = (ui_Command & 0xFFFFF9FDUL) |  ( data[13] << 1);outl(ui_Command,devpriv->iobase+((i_WatchdogNbr-1)*32)+12); return insn->n;}/*+----------------------------------------------------------------------------+| Function   Name   : int i_APCI035_StartStopWriteTimerWatchdog              ||			  (comedi_device *dev,comedi_subdevice *s,               | |                      comedi_insn *insn,lsampl_t *data)                     |+----------------------------------------------------------------------------+| Task              : Start / Stop The Selected Timer , or Watchdog  |+----------------------------------------------------------------------------+| Input Parameters  : comedi_device *dev : Driver handle                     ||                     UINT *data         : Data Pointer contains             ||                                          configuration parameters as below ||					                                                 ||					  data[0] : 0 - Stop Selected Timer/Watchdog     ||					            1 - Start Selected Timer/Watchdog    ||					            2 - Trigger Selected Timer/Watchdog  ||					            3 - Stop All Timer/Watchdog          ||					            4 - Start All Timer/Watchdog         ||					            5 - Trigger All Timer/Watchdog       ||					                                                 |+----------------------------------------------------------------------------+| Output Parameters :	--													 |+----------------------------------------------------------------------------+| Return Value      : TRUE  : No error occur                                 ||		            : FALSE : Error occur. Return the error			 | |					                                                 |+----------------------------------------------------------------------------+*/INT i_APCI035_StartStopWriteTimerWatchdog(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data){   UINT  ui_Command = 0;    INT i_Count=0;      if  (data[0]==1)          {          ui_Command = inl(devpriv->iobase+((i_WatchdogNbr-1)*32)+12);         /**********************/         /* Start the hardware */         /**********************/         ui_Command = (ui_Command & 0xFFFFF9FFUL) | 0x1UL;         outl(ui_Command,devpriv->iobase+((i_WatchdogNbr-1)*32)+12);          } // if  (data[0]==1)      if(data[0]==2)         {         ui_Command = inl(devpriv->iobase+((i_WatchdogNbr-1)*32)+12);          /***************************/         /* Set the trigger command */         /***************************/         ui_Command = (ui_Command & 0xFFFFF9FFUL) | 0x200UL;         outl(ui_Command,devpriv->iobase+((i_WatchdogNbr-1)*32)+12);            }                  if (data[0]==0) //Stop The Watchdog 

⌨️ 快捷键说明

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