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

📄 hwdrv_apci1500.c

📁 最新版comedi的源码
💻 C
📖 第 1 页 / 共 5 页
字号:
         }//switch(ui_NoOfChannels)        outw(data[0],devpriv->i_IobaseAddon+APCI1500_DIGITAL_OP);     }// if(data[1]==1)   else     {     printk("\nSpecified channel not supported\n");     }//else if(data[1]==1)   }//elseif(data[1]==0) }//if(data[3]==0)else   {    if(data[3]==1)       {        if(data[1]==0)          {          data[0]=~data[0]&0x1;          ui_Temp1=1;          ui_Temp1=ui_Temp1<<ui_NoOfChannel;          ui_Temp=ui_Temp|ui_Temp1;            data[0]=(data[0] << ui_NoOfChannel)^0xffffffff;          data[0]=data[0]& ui_Temp;           outw(data[0],devpriv->i_IobaseAddon+APCI1500_DIGITAL_OP);            }//if(data[1]==0)         else          {          if(data[1]==1)             {              switch( ui_NoOfChannel)	       {	       case 2: data[0]=~data[0]&0x3;                        ui_Temp1=3;                       ui_Temp1=ui_Temp1<<2*data[2];                       ui_Temp=ui_Temp|ui_Temp1;                          data[0]=((data[0] << (2*data[2]))^0xffffffff)& ui_Temp; 	               break;	       case 4:data[0]=~data[0]&0xf;                      ui_Temp1=15;                      ui_Temp1=ui_Temp1<<4*data[2];                      ui_Temp=ui_Temp|ui_Temp1;                          data[0]=((data[0] << (4*data[2]))^0xffffffff)&ui_Temp;	              break;	        case 8:data[0]=~data[0]&0xff;                       ui_Temp1=255;                       ui_Temp1=ui_Temp1<<8*data[2];                       ui_Temp=ui_Temp|ui_Temp1;                           data[0]=((data[0] << (8*data[2]))^0xffffffff)&ui_Temp;  	               break;                 case 15:break;                                                      default: 	              comedi_error(dev," chan spec wrong");		      return -EINVAL;   // "sorry channel spec wrong "                                }//switch(ui_NoOfChannels)               outw(data[0],devpriv->i_IobaseAddon+APCI1500_DIGITAL_OP);            }// if(data[1]==1)         else           {            printk("\nSpecified channel not supported\n");           }//else if(data[1]==1)         }//elseif(data[1]==0)      }//if(data[3]==1);   else      {       printk("\nSpecified functionality does not exist\n");       return -EINVAL;      }//if else data[3]==1)   }//if else data[3]==0)  ui_Temp=data[0];      return (insn->n);;}/*+----------------------------------------------------------------------------+| Function   Name   : int i_APCI1500_ConfigCounterTimerWatchdog(comedi_device                   *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data)||				                                                     |+----------------------------------------------------------------------------+| Task              : Configures The Watchdog                                |+----------------------------------------------------------------------------+| Input Parameters  : comedi_device *dev      : Driver handle                ||                     comedi_subdevice *s,   :pointer to subdevice structure                      comedi_insn *insn      :pointer to insn structure      ||                     lsampl_t *data         : Data Pointer to read status                                                       data[0]                : 2     APCI1500_1_8_KHZ           		|                                              1     APCI1500_3_6_KHZ        |   		|                                              0     APCI1500_115_KHZ                          data[1]                : 0     Counter1/Timer1                                                1     Counter2/Timer2                                                2     Counter3/Watchdog                         data[2]                : 0     Counter                                               1     Timer/Watchdog                         data[3]                :         This parameter has    ||                                                      two meanings.         ||                                                    - If the counter/timer  ||                                                      is used as a counter  ||                                                      the limit value of    ||                                                      the counter is given  ||                                                                            ||                                                    - If the counter/timer  ||                                                      is used as a timer,   ||                                                      the divider factor    ||                                                      for the output is     ||                                                      given.                         data[4]                 : 0    APCI1500_CONTINUOUS                                                  1    APCI1500_SINGLE                          data[5]                 : 0    Software Trigger                                                 1    Hardware Trigger                                                                                    data[6]                  :0    Software gate                                                 1    Hardware gate                         data[7]                  :0    Interrupt Disable                                                 1    Interrupt Enable                +----------------------------------------------------------------------------+| Output Parameters :	--													 |+----------------------------------------------------------------------------+| Return Value      : TRUE  : No error occur                                 ||		            : FALSE : Error occur. Return the error          ||			                                                         |+----------------------------------------------------------------------------+*/int i_APCI1500_ConfigCounterTimerWatchdog(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data){int  i_TimerCounterMode,i_MasterConfiguration; devpriv->tsk_Current=current;        //Selection of the input clockif(data[0]==0||data[0]==1||data[0]==2)   {    outw(data[0],devpriv->i_IobaseAddon+APCI1500_CLK_SELECT);     }// if(data[0]==0||data[0]==1||data[0]==2)else    {     if(data[0]!=3)        {         printk("\nThe option for input clock selection does not exist\n");         return -EINVAL;         }// if(data[0]!=3)     }//elseif(data[0]==0||data[0]==1||data[0]==2) //Select the counter/timerswitch(data[1])   {   case COUNTER1:                         //selecting counter or timer                        switch(data[2])                           {	                    case 0: data[2]=APCI1500_COUNTER ;                                    break;                            case 1: data[2]=APCI1500_TIMER;                                    break;                            default:printk("\nThis choice is not a timer nor a counter\n");                                    return -EINVAL;                            }// switch(data[2])                                                   //Selecting  single or continuous mode                           switch(data[4])                           {	                    case 0: data[4]= APCI1500_CONTINUOUS;                                    break;                            case 1: data[4]= APCI1500_SINGLE;                                    break;                             default:printk("\nThis option for single/continuous mode does not exist\n");                                    return -EINVAL;                           }// switch(data[4])                                                                                 i_TimerCounterMode = data[2]|data[4]|7;                         /*************************/		         /* Test the reload value */		         /*************************/                                               if ((data[3]>= 0) && (data[3] <= 65535))                            {                            if(data[7]== APCI1500_ENABLE ||data[7]== APCI1500_DISABLE)                                {                                                               /************************************************/		                /* Selects the mode register of timer/counter 1 */		                /************************************************/                                outb(APCI1500_RW_CPT_TMR1_MODE_SPECIFICATION,devpriv->iobase+APCI1500_Z8536_CONTROL_REGISTER);                                  /***********************/		                /* Writes the new mode */		                /***********************/                                 outb(i_TimerCounterMode,devpriv->iobase+APCI1500_Z8536_CONTROL_REGISTER);                                /****************************************************/		                /* Selects the constant register of timer/counter 1 */		                /****************************************************/                                                             outb(APCI1500_RW_CPT_TMR1_TIME_CST_LOW,devpriv->iobase+APCI1500_Z8536_CONTROL_REGISTER);                                  /*************************/		                  /* Writes the low value  */		                  /*************************/                                  outb(	data[3],devpriv->iobase+APCI1500_Z8536_CONTROL_REGISTER);                                                                     /****************************************************/		                   /* Selects the constant register of timer/counter 1 */		                   /****************************************************/                                 outb( APCI1500_RW_CPT_TMR1_TIME_CST_HIGH,devpriv->iobase+APCI1500_Z8536_CONTROL_REGISTER);                                  /**************************/		                  /* Writes the high value  */		                  /**************************/                                  data[3]=data[3]>>8;                                  outb(data[3],devpriv->iobase+APCI1500_Z8536_CONTROL_REGISTER);                                     /*********************************************/		                     /* Selects the master configuration register */		                     /*********************************************/                                     outb(APCI1500_RW_MASTER_CONFIGURATION_CONTROL,devpriv->iobase+APCI1500_Z8536_CONTROL_REGISTER);                                       /**********************/		                     /* Reads the register */		                     /**********************/                                                                         i_MasterConfiguration=inb(devpriv->iobase+APCI1500_Z8536_CONTROL_REGISTER);                                                  /********************************************************/		                       /* Enables timer/counter 1 and triggers timer/counter 1 */		                       /********************************************************/		                    i_MasterConfiguration =  i_MasterConfiguration | 0x40;		                    /*********************************************/		                    /* Selects the master configuration register */		                    /*********************************************/                                     outb(APCI1500_RW_MASTER_CONFIGURATION_CONTROL,devpriv->iobase+APCI1500_Z8536_CONTROL_REGISTER);                                        /********************************/		                      /* Writes the new configuration */		                      /********************************/                                     outb(i_MasterConfiguration,devpriv->iobase+APCI1500_Z8536_CONTROL_REGISTER);     

⌨️ 快捷键说明

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