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

📄 apci1710_pwm.c

📁 最新版comedi的源码
💻 C
📖 第 1 页 / 共 5 页
字号:
	   /***************/	   /* Test if PWM */	   /***************/	   if ((devpriv->		s_BoardInfos.		dw_MolduleConfiguration [b_ModulNbr] & 0xFFFF0000UL) == APCI1710_PWM)	      {	      /**************************/	      /* Test the PWM selection */	      /**************************/	      if (b_PWM <= 1)		 {		 /***************************/		 /* Test if PWM initialised */		 /***************************/		 dw_Status=	 inl(devpriv->s_BoardInfos.			ui_Address + 12 + (20 * b_PWM) + (64 * b_ModulNbr));		 if (dw_Status & 0x10)		    {		    /**********************************/		    /* Test the start level selection */		    /**********************************/		    if (b_StartLevel <= 1)		       {		       /**********************/		       /* Test the stop mode */		       /**********************/		       if (b_StopMode <= 1)			  {			  /***********************/			  /* Test the stop level */			  /***********************/			  if (b_StopLevel <= 2)			     {			     /*****************************/			     /* Test the extern gate mode */			     /*****************************/			     if (b_ExternGate <= 1)				{				/*****************************/				/* Test the interrupt action */				/*****************************/				if (b_InterruptEnable == APCI1710_ENABLE || b_InterruptEnable == APCI1710_DISABLE)				   {				   /******************************************/				   /* Test if interrupt function initialised */				   /******************************************/				      /********************/				      /* Read the command */				      /********************/					    dw_Command=inl(devpriv->s_BoardInfos.					     ui_Address + 8 + (20 * b_PWM) + (64 * b_ModulNbr));				      dw_Command = dw_Command & 0x80;				      /********************/				      /* Make the command */				      /********************/				      dw_Command = dw_Command | b_StopMode | (b_InterruptEnable << 3) | (b_ExternGate << 4) | (b_StartLevel << 5);				      if (b_StopLevel & 3)					 {					 dw_Command = dw_Command | 2;					 if (b_StopLevel & 2)					    {					    dw_Command = dw_Command | 4;					    }					 }				      devpriv->				      s_ModuleInfo [b_ModulNbr].				      s_PWMModuleInfo.				      s_PWMInfo [b_PWM].				      b_InterruptEnable = b_InterruptEnable;				      /*******************/				      /* Set the command */				      /*******************/					  outl(dw_Command,devpriv->s_BoardInfos.					      ui_Address + 8 + (20 * b_PWM) + (64 * b_ModulNbr));				      /******************/				      /* Enable the PWM */				      /******************/					  outl(1,devpriv->s_BoardInfos.					      ui_Address + 12 + (20 * b_PWM) + (64 * b_ModulNbr));				   } // if (b_InterruptEnable == APCI1710_ENABLE || b_InterruptEnable == APCI1710_DISABLE)				else				   {				   /********************************/				   /* Interrupt parameter is wrong */				   /********************************/                           DPRINTK("Interrupt parameter is wrong\n");				   i_ReturnValue = -10;				   } // if (b_InterruptEnable == APCI1710_ENABLE || b_InterruptEnable == APCI1710_DISABLE)				} // if (b_ExternGate >= 0 && b_ExternGate <= 1)			     else				{				/*****************************************/				/* Extern gate signal selection is wrong */				/*****************************************/				DPRINTK("Extern gate signal selection is wrong\n");				i_ReturnValue = -9;				} // if (b_ExternGate >= 0 && b_ExternGate <= 1)			     } // if (b_StopLevel >= 0 && b_StopLevel <= 2)			  else			     {			     /*************************************/			     /* PWM stop level selection is wrong */			     /*************************************/				 DPRINTK("PWM stop level selection is wrong\n");			     i_ReturnValue = -8;			     } // if (b_StopLevel >= 0 && b_StopLevel <= 2)			  } // if (b_StopMode >= 0 && b_StopMode <= 1)		       else			  {			  /************************************/			  /* PWM stop mode selection is wrong */			  /************************************/			  DPRINTK("PWM stop mode selection is wrong\n");				  i_ReturnValue = -7;			  } // if (b_StopMode >= 0 && b_StopMode <= 1)		       } // if (b_StartLevel >= 0 && b_StartLevel <= 1)		    else		       {		       /**************************************/		       /* PWM start level selection is wrong */		       /**************************************/			   DPRINTK("PWM start level selection is wrong\n");	  		       i_ReturnValue = -6;		       } // if (b_StartLevel >= 0 && b_StartLevel <= 1)		    } // if (dw_Status & 0x10)		 else		    {		    /***********************/		    /* PWM not initialised */		    /***********************/			DPRINTK("PWM not initialised\n");		    i_ReturnValue = -5;		    } // if (dw_Status & 0x10)		 } // if (b_PWM >= 0 && b_PWM <= 1)	      else		 {		 /******************************/		 /* Tor PWM selection is wrong */		 /******************************/		 DPRINTK("Tor PWM selection is wrong\n");		 i_ReturnValue = -4;		 } // if (b_PWM >= 0 && b_PWM <= 1)	      }	   else	      {	      /**********************************/	      /* The module is not a PWM module */	      /**********************************/	      DPRINTK("The module is not a PWM module\n");		      i_ReturnValue = -3;	      }	   }	else	   {	   /***********************/	   /* Module number error */	   /***********************/	   DPRINTK("Module number error\n");		   i_ReturnValue = -2;	   }	return (i_ReturnValue);	}/*+----------------------------------------------------------------------------+| Function Name     : _INT_ i_APCI1710_DisablePWM (BYTE_  b_BoardHandle,     ||                                                  BYTE_  b_ModulNbr,        ||                                                  BYTE_  b_PWM)             |+----------------------------------------------------------------------------+| Task              : Disable the selected PWM (b_PWM) from selected module  ||                     (b_ModulNbr). The output signal level depend of the    ||                     initialisation by the "i_APCI1710_EnablePWM".          ||                     See the b_StartLevel, b_StopMode and b_StopLevel       ||                     parameters from this function.                         |+----------------------------------------------------------------------------+| Input Parameters  :BYTE_ b_BoardHandle : Handle of board APCI-1710         ||                    BYTE_ b_ModulNbr    : Selected module number (0 to 3)   ||                    BYTE_ b_PWM         : Selected PWM (0 or 1)             |+----------------------------------------------------------------------------+| Output Parameters : -                                                      |+----------------------------------------------------------------------------+| Return Value      :  0: No error                                           ||                     -1: The handle parameter of the board is wrong         ||                     -2: Module selection wrong                             ||                     -3: The module is not a PWM module                     ||                     -4: PWM selection is wrong                             ||                     -5: PWM not initialised see function                   ||                         "i_APCI1710_InitPWM"                               ||                     -6: PWM not enabled see function                       ||                         "i_APCI1710_EnablePWM"                             |+----------------------------------------------------------------------------+*/INT   i_APCI1710_DisablePWM   (comedi_device *dev,				 BYTE  b_ModulNbr,				 BYTE  b_PWM)	{	INT    i_ReturnValue = 0;	DWORD dw_Status;	/**************************/	/* Test the module number */	/**************************/	if (b_ModulNbr < 4)	   {	   /***************/	   /* Test if PWM */	   /***************/	   if ((devpriv->s_BoardInfos.		dw_MolduleConfiguration [b_ModulNbr] & 0xFFFF0000UL) == APCI1710_PWM)	      {	      /**************************/	      /* Test the PWM selection */	      /**************************/	      if (b_PWM <= 1)		 {		 /***************************/		 /* Test if PWM initialised */		 /***************************/           dw_Status=inl(devpriv->s_BoardInfos.			ui_Address + 12 + (20 * b_PWM) + (64 * b_ModulNbr));		 if (dw_Status & 0x10)		    {		    /***********************/		    /* Test if PWM enabled */		    /***********************/		    if (dw_Status & 0x1)		       {		       /*******************/		       /* Disable the PWM */		       /*******************/				outl(0,devpriv->s_BoardInfos.			       ui_Address + 12 + (20 * b_PWM) + (64 * b_ModulNbr));		       } // if (dw_Status & 0x1)		    else		       {		       /*******************/		       /* PWM not enabled */		       /*******************/			   DPRINTK("PWM not enabled\n");			       i_ReturnValue = -6;		       } // if (dw_Status & 0x1)		    } // if (dw_Status & 0x10)		 else		    {		    /***********************/		    /* PWM not initialised */		    /***********************/			DPRINTK(" PWM not initialised\n");		    i_ReturnValue = -5;		    } // if (dw_Status & 0x10)		 } // if (b_PWM >= 0 && b_PWM <= 1)	      else		 {		 /******************************/		 /* Tor PWM selection is wrong */		 /******************************/		 DPRINTK("Tor PWM selection is wrong\n");			 i_ReturnValue = -4;		 } // if (b_PWM >= 0 && b_PWM <= 1)	      }	   else	      {	      /**********************************/	      /* The module is not a PWM module */	      /**********************************/	      DPRINTK("The module is not a PWM module\n");		      i_ReturnValue = -3;	      }	   }	else	   {	   /***********************/	   /* Module number error */	   /***********************/	   DPRINTK("Module number error\n");	   i_ReturnValue = -2;	   }	return (i_ReturnValue);	}/*+----------------------------------------------------------------------------+| Function Name     : _INT_ i_APCI1710_SetNewPWMTiming                       ||                                       (BYTE_     b_BoardHandle,            ||                                        BYTE_     b_ModulNbr,               ||                                        BYTE_     b_PWM,                    ||                                        BYTE_     b_ClockSelection,         ||                                        BYTE_     b_TimingUnit,             ||                                        ULONG_   ul_LowTiming,              ||                                        ULONG_   ul_HighTiming)             |+----------------------------------------------------------------------------+| Task              : Set a new timing. The ul_LowTiming, ul_HighTiming and  ||                     ul_TimingUnit determine the low/high timing base for   ||                     the period.                                            |+------------------------------------------------

⌨️ 快捷键说明

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