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

📄 hwdrv_apci3xxx.c

📁 最新版comedi的源码
💻 C
📖 第 1 页 / 共 5 页
字号:
	/************************/	/* Test the buffer size */	/************************/		if (insn->n >= 1)	   {	   /***************************/	   /* Test the channel number */	   /***************************/	                    if (b_Channel < devpriv->ps_BoardInfo->i_NbrAoChannel)	      {	      /**********************************/	      /* Test the channel configuration */	      /**********************************/	   	      if (b_Range < 2)	         {	         /***************************/	         /* Set the range selection */	         /***************************/	   	         writel(b_Range, (void *) (devpriv->dw_AiBase + 96));	   	         /**************************************************/	         /* Write the analog value to the selected channel */	         /**************************************************/	   	         writel((data[0] << 8) | b_Channel, (void *) (devpriv->dw_AiBase + 100));	   	         /****************************/	         /* Wait the end of transfer */	         /****************************/	   	         do	            {	            dw_Status = readl ((void *) (devpriv->dw_AiBase + 96));	            }	         while ((dw_Status & 0x100) != 0x100);	         }	      else	         {	         /***************************/	         /* Channel not initialised */	         /***************************/	            	         i_ReturnValue = -4;	         printk ("Channel %d range %d selection error\n", b_Channel, b_Range);	         }	      }	   else	      {	      /***************************/	      /* Channel selection error */	      /***************************/	            	      i_ReturnValue = -3;	      printk ("Channel %d selection error\n", b_Channel);	      }	   }	else	   {	   /*******************/	   /* Data size error */	   /*******************/	       	   printk("Buffer size error\n");	   i_ReturnValue = -101;	   }		return (i_ReturnValue);	}/*+----------------------------------------------------------------------------+|                              TTL FUNCTIONS                                 |+----------------------------------------------------------------------------+*//*+----------------------------------------------------------------------------+| Function Name     : INT   i_APCI3XXX_InsnConfigInitTTLIO                   ||                          (comedi_device    *dev,                           ||                           comedi_subdevice *s,                             ||                           comedi_insn      *insn,                          ||                           lsampl_t         *data)                          |+----------------------------------------------------------------------------+| Task           You must calling this function be                           ||                for you call any other function witch access of TTL.        ||                APCI3XXX_TTL_INIT_DIRECTION_PORT2(user inputs for direction)|+----------------------------------------------------------------------------+| Input Parameters  : b_InitType    = (BYTE) data[0];                        ||                     b_Port2Mode   = (BYTE) data[1];                        |+----------------------------------------------------------------------------+| Output Parameters : -                                                      |+----------------------------------------------------------------------------+| Return Value      :>0: No error                                            ||                    -1: Port 2 mode selection is wrong                      ||                    ....                                                    ||                    -100 : Config command error                             ||                    -101 : Data size error                                  |+----------------------------------------------------------------------------+*/int   i_APCI3XXX_InsnConfigInitTTLIO(comedi_device    *dev,                                     comedi_subdevice *s,                                     comedi_insn      *insn,                                     lsampl_t         *data) 	{	INT        i_ReturnValue = insn->n;	BYTE       b_Command     = 0;	/************************/	/* Test the buffer size */	/************************/		if (insn->n >= 1)	   {	   /*******************/	   /* Get the command */	   /* *****************/	   	   b_Command = (BYTE) data[0];	   	   /********************/	   /* Test the command */	   /********************/	   	   if (b_Command == APCI3XXX_TTL_INIT_DIRECTION_PORT2)	      {	      /***************************************/	      /* Test the initialisation buffer size */	      /***************************************/	      	      if ((b_Command == APCI3XXX_TTL_INIT_DIRECTION_PORT2) && (insn->n != 2))	         {	         /*******************/	         /* Data size error */	         /*******************/	         	         printk("Buffer size error\n");	         i_ReturnValue = -101;	         }	      }	   else	      {	      /************************/	      /* Config command error */	      /************************/	      	      printk("Command selection error\n");	      i_ReturnValue = -100;	      }	   }	else	   {	   /*******************/	   /* Data size error */	   /*******************/	       	   printk("Buffer size error\n");	   i_ReturnValue = -101;	   }	   	   	/*********************************************************************************/	/* Test if no error occur and APCI3XXX_TTL_INIT_DIRECTION_PORT2 command selected */	/*********************************************************************************/		if ((i_ReturnValue >= 0) && (b_Command == APCI3XXX_TTL_INIT_DIRECTION_PORT2))	   {	   /**********************/	   /* Test the direction */	   /**********************/	      	   if ((data[1] == 0) || (data[1] == 0xFF))	      {	      /**************************/	      /* Save the configuration */	      /**************************/		      devpriv->ul_TTLPortConfiguration[0] = devpriv->ul_TTLPortConfiguration[0] | data[1];	      }	   else	      {	      /************************/	      /* Port direction error */	      /************************/	                 	      printk("Port 2 direction selection error\n");	      i_ReturnValue = - 1;	      }	   }	   	/**************************/	/* Test if no error occur */	/**************************/		if (i_ReturnValue >= 0)	   {	   /***********************************/	   /* Test if TTL port initilaisation */	   /***********************************/	   	   if (b_Command == APCI3XXX_TTL_INIT_DIRECTION_PORT2)	      {	      /*************************/	      /* Set the configuration */	      /*************************/		      outl(data[1],devpriv->iobase + 224);	      }	   }		return (i_ReturnValue);	}/*+----------------------------------------------------------------------------+|                        TTL INPUT FUNCTIONS                                 |+----------------------------------------------------------------------------+*//*+----------------------------------------------------------------------------+| Function Name     : INT     i_APCI3XXX_InsnBitsTTLIO                       ||                          (comedi_device    *dev,                           ||                           comedi_subdevice *s,                             ||                           comedi_insn      *insn,                          ||                           lsampl_t         *data)                          |+----------------------------------------------------------------------------+| Task              : Write the selected output mask and read the status from| |                     all TTL channles                                       |+----------------------------------------------------------------------------+| Input Parameters  : dw_ChannelMask = data [0];                             ||                     dw_BitMask     = data [1];                             |+----------------------------------------------------------------------------+| Output Parameters : data[1] : All TTL channles states                      |+----------------------------------------------------------------------------+| Return Value      : >0  : No error                                         ||                    -4   : Channel mask error                               ||                    -101 : Data size error                                  |+----------------------------------------------------------------------------+*/int  i_APCI3XXX_InsnBitsTTLIO   (comedi_device    *dev,                                 comedi_subdevice *s,	                         comedi_insn      *insn,	                         lsampl_t         *data)	{	INT        i_ReturnValue = insn->n;	BYTE       b_ChannelCpt  = 0;	DWORD     dw_ChannelMask = 0;	DWORD     dw_BitMask     = 0;	DWORD     dw_Status      = 0;	/************************/	/* Test the buffer size */	/************************/		if (insn->n >= 2)	   {	   /*******************************/	   /* Get the channe and bit mask */	   /*******************************/	   	   dw_ChannelMask = data [0];	   dw_BitMask     = data [1];	   	   /*************************/	   /* Test the channel mask */	   /*************************/	   	   if (((dw_ChannelMask & 0XFF00FF00) == 0) &&	       (((devpriv->ul_TTLPortConfiguration[0] & 0xFF) == 0xFF) ||	       (((devpriv->ul_TTLPortConfiguration[0] & 0xFF) == 0) && ((dw_ChannelMask & 0XFF0000) == 0))))	      {	      /*********************************/	      /* Test if set/reset any channel */	      /*********************************/	   	      if (dw_ChannelMask)	         {	         /****************************************/	         /* Test if set/rest any port 0 channels */	         /****************************************/	      	         if (dw_ChannelMask & 0xFF)	            {	            /*******************************************/	            /* Read port 0 (first digital output port) */	            /*******************************************/	      	            dw_Status = inl(devpriv->iobase + 80);	      	            for (b_ChannelCpt = 0; b_ChannelCpt < 8; b_ChannelCpt ++)	               {	               if ((dw_ChannelMask >> b_ChannelCpt) & 1)	                  {	                  dw_Status = (dw_Status & (0xFF - (1 << b_ChannelCpt))) | (dw_BitMask & (1 << b_ChannelCpt));	                  }	               }	      	            outl (dw_Status, devpriv->iobase + 80);	            }	   	         /****************************************/	         /* Test if set/rest any port 2 channels */	         /****************************************/	      	         if (dw_ChannelMask & 0xFF0000)	            {	            dw_BitMask     = dw_BitMask     >> 16;	            dw_ChannelMask = dw_ChannelMask >> 16;	         	            /********************************************/	            /* Read port 2 (second digital output port) */	            /********************************************/	      	            dw_Status = inl(devpriv->iobase + 112);	      	            for (b_ChannelCpt = 0; b_ChannelCpt < 8; b_ChannelCpt ++)	               {	               if ((dw_ChannelMask >> b_ChannelCpt) & 1)	                  {	                  dw_Status = (dw_Status & (0xFF - (1 << b_ChannelCpt))) | (dw_BitMask & (1 << b_ChannelCpt));	                  }	               }	      	            outl (dw_Status, devpriv->iobase + 112);	            }	         }	         	      /*******************************************/	      /* Read port 0 (first digital output port) */	      /*******************************************/	         	      data [1] = inl(devpriv->iobase + 80);	      	      /******************************************/	      /* Read port 1 (first digital input port) */	      /******************************************/	         

⌨️ 快捷键说明

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