📄 apci1710_82x54.c
字号:
/***********************/ /* Test the timer mode */ /***********************/ if (b_TimerMode <= 5) { //BEGIN JK 27.10.2003 : Add the possibility to use a 40 Mhz quartz /*********************************/ /* Test te imput clock selection */ /*********************************/ /* if (((b_TimerNbr == 0) && (b_InputClockSelection == 0)) || ((b_TimerNbr != 0) && ((b_InputClockSelection == 0) || (b_InputClockSelection == 1)))) */ if (((b_TimerNbr == 0) && (b_InputClockSelection == APCI1710_PCI_BUS_CLOCK)) || ((b_TimerNbr == 0) && (b_InputClockSelection == APCI1710_10MHZ)) || ((b_TimerNbr != 0) && ((b_InputClockSelection == APCI1710_PCI_BUS_CLOCK) || (b_InputClockSelection == APCI1710_FRONT_CONNECTOR_INPUT) || (b_InputClockSelection == APCI1710_10MHZ)))) //END JK 27.10.2003 : Add the possibility to use a 40 Mhz quartz { //BEGIN JK 27.10.2003 : Add the possibility to use a 40 Mhz quartz if (((b_InputClockSelection == APCI1710_10MHZ) && ((devpriv->s_BoardInfos.dw_MolduleConfiguration [b_ModulNbr] & 0x0000FFFFUL) >= 0x3131)) || (b_InputClockSelection != APCI1710_10MHZ)) { //END JK 27.10.2003 : Add the possibility to use a 40 Mhz quartz /****************************************/ /* Test the input clock level selection */ /****************************************/ if ((b_InputClockLevel == 0) || (b_InputClockLevel == 1)) { /*****************************************/ /* Test the output clock level selection */ /*****************************************/ if ((b_OutputLevel == 0) || (b_OutputLevel == 1)) { /******************************************/ /* Test the hardware gate level selection */ /******************************************/ if ((b_HardwareGateLevel == 0) || (b_HardwareGateLevel == 1)) { //BEGIN JK 27.10.03 : Add the possibility to use a 40 Mhz quartz /*****************************************************/ /* Test if version > 1.1 and clock selection = 10MHz */ /*****************************************************/ if ((b_InputClockSelection == APCI1710_10MHZ) && ((devpriv->s_BoardInfos.dw_MolduleConfiguration [b_ModulNbr] & 0x0000FFFFUL) > 0x3131)) { /*********************************/ /* Test if 40MHz quartz on board */ /*********************************/ dw_Test = inl (devpriv->s_BoardInfos.ui_Address + (16 + (b_TimerNbr * 4) + (64 * b_ModulNbr))); dw_Test = (dw_Test >> 16) & 1; } else { dw_Test = 1; } /************************/ /* Test if detection OK */ /************************/ if (dw_Test == 1) { //END JK 27.10.03 : Add the possibility to use a 40 Mhz quartz /*********************/ /* Initialisation OK */ /*********************/ devpriv->s_ModuleInfo [b_ModulNbr]. s_82X54ModuleInfo. s_82X54TimerInfo [b_TimerNbr]. b_82X54Init = 1; /**********************************/ /* Save the input clock selection */ /**********************************/ devpriv->s_ModuleInfo [b_ModulNbr]. s_82X54ModuleInfo. s_82X54TimerInfo [b_TimerNbr]. b_InputClockSelection = b_InputClockSelection; /******************************/ /* Save the input clock level */ /******************************/ devpriv->s_ModuleInfo [b_ModulNbr]. s_82X54ModuleInfo. s_82X54TimerInfo [b_TimerNbr]. b_InputClockLevel = ~b_InputClockLevel & 1; /*************************/ /* Save the output level */ /*************************/ devpriv->s_ModuleInfo [b_ModulNbr]. s_82X54ModuleInfo. s_82X54TimerInfo [b_TimerNbr]. b_OutputLevel = ~b_OutputLevel & 1; /***********************/ /* Save the gate level */ /***********************/ devpriv->s_ModuleInfo [b_ModulNbr]. s_82X54ModuleInfo. s_82X54TimerInfo [b_TimerNbr]. b_HardwareGateLevel = b_HardwareGateLevel; /****************************************************/ /* Set the configuration word and disable the timer */ /****************************************************/ //BEGIN JK 27.10.03 : Add the possibility to use a 40 Mhz quartz /* devpriv->s_ModuleInfo [b_ModulNbr]. s_82X54ModuleInfo. s_82X54TimerInfo [b_TimerNbr]. dw_ConfigurationWord = (DWORD) (((b_HardwareGateLevel << 0) & 0x1) | ((b_InputClockLevel << 1) & 0x2) | (((~b_OutputLevel & 1) << 2) & 0x4) | ((b_InputClockSelection << 4) & 0x10)); */ /**************************/ /* Test if 10MHz selected */ /**************************/ if (b_InputClockSelection == APCI1710_10MHZ) { b_InputClockSelection = 2; } devpriv->s_ModuleInfo [b_ModulNbr]. s_82X54ModuleInfo. s_82X54TimerInfo [b_TimerNbr]. dw_ConfigurationWord = (DWORD) (((b_HardwareGateLevel << 0) & 0x1) | ((b_InputClockLevel << 1) & 0x2) | (((~b_OutputLevel & 1) << 2) & 0x4) | ((b_InputClockSelection << 4) & 0x30)); //END JK 27.10.03 : Add the possibility to use a 40 Mhz quartz outl(devpriv->s_ModuleInfo [b_ModulNbr]. s_82X54ModuleInfo.s_82X54TimerInfo [b_TimerNbr]. dw_ConfigurationWord, devpriv->s_BoardInfos. ui_Address + 32 + (b_TimerNbr * 4) + (64 * b_ModulNbr)); /******************************/ /* Initialise the 82X54 Timer */ /******************************/ outl((DWORD) b_TimerMode,devpriv->s_BoardInfos. ui_Address + 16 + (b_TimerNbr * 4) + (64 * b_ModulNbr)); /**************************/ /* Write the reload value */ /**************************/ outl(ul_ReloadValue,devpriv->s_BoardInfos. ui_Address + 0 + (b_TimerNbr * 4) + (64 * b_ModulNbr)); //BEGIN JK 27.10.03 : Add the possibility to use a 40 Mhz quartz } // if (dw_Test == 1) else { /****************************************/ /* Input timer clock selection is wrong */ /****************************************/ i_ReturnValue = -6; } // if (dw_Test == 1) //END JK 27.10.03 : Add the possibility to use a 40 Mhz quartz } // if ((b_HardwareGateLevel == 0) || (b_HardwareGateLevel == 1)) else { /***********************************************/ /* Selection from hardware gate level is wrong */ /***********************************************/ DPRINTK("Selection from hardware gate level is wrong\n"); i_ReturnValue = -9; } // if ((b_HardwareGateLevel == 0) || (b_HardwareGateLevel == 1)) } // if ((b_OutputLevel == 0) || (b_OutputLevel == 1)) else { /**********************************************/ /* Selection from output clock level is wrong */ /**********************************************/ DPRINTK("Selection from output clock level is wrong\n"); i_ReturnValue = -8; } // if ((b_OutputLevel == 0) || (b_OutputLevel == 1)) } // if ((b_InputClockLevel == 0) || (b_InputClockLevel == 1)) else { /*********************************************/ /* Selection from input clock level is wrong */ /*********************************************/ DPRINTK("Selection from input clock level is wrong\n"); i_ReturnValue = -7; } // if ((b_InputClockLevel == 0) || (b_InputClockLevel == 1)) } else { /****************************************/ /* Input timer clock selection is wrong */ /****************************************/ DPRINTK("Input timer clock selection is wrong\n"); i_ReturnValue = -6; } } else { /****************************************/ /* Input timer clock selection is wrong */ /****************************************/ DPRINTK("Input timer clock selection is wrong\n"); i_ReturnValue = -6; } } // if ((b_TimerMode >= 0) && (b_TimerMode <= 5)) else { /*********************************/ /* Timer mode selection is wrong */ /*********************************/ DPRINTK("Timer mode selection is wrong\n"); i_ReturnValue = -5; } // if ((b_TimerMode >= 0) && (b_TimerMode <= 5)) } // if ((b_TimerNbr >= 0) && (b_TimerNbr <= 2)) else { /*************************/ /* Timer selection wrong */ /*************************/ DPRINTK("Timer selection wrong\n"); i_ReturnValue = -3; } // if ((b_TimerNbr >= 0) && (b_TimerNbr <= 2)) } else { /************************************/ /* The module is not a TIMER module */ /************************************/ DPRINTK("The module is not a TIMER module\n"); i_ReturnValue = -4; } } else { /***********************/ /* Module number error */ /***********************/ DPRINTK("Module number error\n"); i_ReturnValue = -2; } return (i_ReturnValue); }/*+----------------------------------------------------------------------------+| Function Name : _INT_ i_APCI1710_EnableTimer || (BYTE_ b_BoardHandle, || BYTE_ b_ModulNbr, || BYTE_ b_TimerNbr, || BYTE_ b_InterruptEnable) INT i_APCI1710_InsnWriteEnableDisableTimer(comedi_device *dev,comedi_subdevice *s, comedi_insn *insn,lsampl_t *data) |+----------------------------------------------------------------------------+| Task : Enable OR Disable the Timer (b_TimerNbr) from selected module || (b_ModulNbr). You must calling the || "i_APCI1710_InitTimer" function be for you call this || function. If you enable the timer interrupt, the timer || generate a interrupt after the timer value reach || the zero. See function "i_APCI1710_SetBoardIntRoutineX"|+----------------------------------------------------------------------------+| Input Parameters : BYTE_ b_BoardHandle : Handle of board || APCI-1710 || BYTE_ b_ModulNbr : Selected module number || (0 to 3) || BYTE_ b_TimerNbr : Timer number to enable || (0 to 2) || BYTE_ b_InterruptEnable : Enable or disable the || timer interrupt. || APCI1710_ENABLE : || Enable the timer interrupt || APCI1710_DISABLE : || Disable the timer interrupt|i_ReturnValue=insn->n; b_ModulNbr = (BYTE) CR_AREF(insn->chanspec); b_TimerNbr = (BYTE) CR_CHAN(insn->chanspec); b_ActionType = (BYTE) data[0]; // enable disable +----------------------------------------------------------------------------+| Output Parameters : - |+----------------------------------------------------------------------------+| Return Value : 0: No error || -1: The handle parameter of the board is wrong || -2: Module selection wrong |
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -