📄 apci1710_tor.c
字号:
| Functions in the same way as || the quadruple mode, except that|| only one of the four edges is || analysed per period. || The gate input is used for the || signal B || || BYTE_ b_CycleMode : Selected the tor counter || acquisition mode || BYTE_ b_InterruptEnable : Enable or disable the || tor counter interrupt. || APCI1710_ENABLE: || Enable the tor counter || interrupt || APCI1710_DISABLE: || Disable the tor counter || interrupt |+----------------------------------------------------------------------------+| 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 tor counter module || -4: Tor counter selection is wrong || -5: Tor counter not initialised see function || "i_APCI1710_InitTorCounter" || -6: Tor input signal selection is wrong || -7: Extern gate signal mode is wrong || -8: Tor counter acquisition mode cycle is wrong || -9: Interrupt parameter is wrong || -10:Interrupt function not initialised. || See function "i_APCI1710_SetBoardIntRoutineX" |+----------------------------------------------------------------------------+*//*+----------------------------------------------------------------------------+| Function Name : _INT_ i_APCI1710_DisableTorCounter || (BYTE_ b_BoardHandle, || BYTE_ b_ModulNbr, || BYTE_ b_TorCounter) |+----------------------------------------------------------------------------+| Task : Disable the tor counter (b_TorCounter) from selected || module (b_ModulNbr). If you disable the tor counter || after a start cycle occur and you restart the tor || counter witch the " i_APCI1710_EnableTorCounter" || function, the status register is cleared |+----------------------------------------------------------------------------+| Input Parameters : BYTE_ b_BoardHandle : Handle of board APCI-1710 || BYTE_ b_ModulNbr : Selected module number (0 to 3) || BYTE_ b_TorCounter : Tor counter selection (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 tor counter module || -4: Tor counter selection is wrong || -5: Tor counter not initialised see function || "i_APCI1710_InitTorCounter" || -6: Tor counter not enabled see function || "i_APCI1710_EnableTorCounter" |+----------------------------------------------------------------------------+*/INT i_APCI1710_InsnWriteEnableDisableTorCounter (comedi_device *dev,comedi_subdevice *s, comedi_insn *insn,lsampl_t *data) { INT i_ReturnValue = 0; DWORD dw_Status; DWORD dw_DummyRead; DWORD dw_ConfigReg; BYTE b_ModulNbr,b_Action; BYTE b_TorCounter; BYTE b_InputMode; BYTE b_ExternGate; BYTE b_CycleMode; BYTE b_InterruptEnable; b_ModulNbr =(BYTE) CR_AREF(insn->chanspec); b_Action =(BYTE) data[0]; // enable or disable b_TorCounter =(BYTE) data[1]; b_InputMode =(BYTE) data[2] ; b_ExternGate =(BYTE) data[3] ; b_CycleMode =(BYTE) data[4] ; b_InterruptEnable =(BYTE) data[5] ; i_ReturnValue = insn->n; ; devpriv->tsk_Current=current; // Save the current process task structure /**************************/ /* Test the module number */ /**************************/ if (b_ModulNbr < 4) { /***********************/ /* Test if tor counter */ /***********************/ if ((devpriv->s_BoardInfos. dw_MolduleConfiguration [b_ModulNbr] & 0xFFFF0000UL) == APCI1710_TOR_COUNTER) { /**********************************/ /* Test the tor counter selection */ /**********************************/ if (b_TorCounter <= 1) { switch(b_Action)// Enable or Disable { case APCI1710_ENABLE : /***********************************/ /* Test if tor counter initialised */ /***********************************/ dw_Status =inl(devpriv->s_BoardInfos.ui_Address + 8 + (16 * b_TorCounter) + (64 * b_ModulNbr)); if (dw_Status & 0x10) { /******************************/ /* Test the input signal mode */ /******************************/ if (b_InputMode == 0 || b_InputMode == 1 || b_InputMode == APCI1710_TOR_SIMPLE_MODE || b_InputMode == APCI1710_TOR_DOUBLE_MODE || b_InputMode == APCI1710_TOR_QUADRUPLE_MODE) { /************************************/ /* Test the extern gate signal mode */ /************************************/ if (b_ExternGate == 0 || b_ExternGate == 1 || b_InputMode > 1) { /*********************************/ /* Test the cycle mode parameter */ /*********************************/ if ((b_CycleMode == APCI1710_SINGLE) || (b_CycleMode == APCI1710_CONTINUOUS)) { /***************************/ /* Test the interrupt flag */ /***************************/ if ((b_InterruptEnable == APCI1710_ENABLE) || (b_InterruptEnable == APCI1710_DISABLE)) { /***************************/ /* Save the interrupt mode */ /***************************/ devpriv->s_ModuleInfo [b_ModulNbr]. s_TorCounterModuleInfo. s_TorCounterInfo [b_TorCounter]. b_InterruptEnable = b_InterruptEnable; /*******************/ /* Get the command */ /*******************/ dw_ConfigReg = inl(devpriv->s_BoardInfos.ui_Address + 4 + (16 * b_TorCounter) + (64 * b_ModulNbr)); dw_ConfigReg = (dw_ConfigReg >> 4) & 0x30; /********************************/ /* Test if not direct mode used */ /********************************/ if (b_InputMode > 1) { /*******************************/ /* Extern gate can not be used */ /*******************************/ b_ExternGate = 0; /*******************************************/ /* Enable the extern gate for the Signal B */ /*******************************************/ dw_ConfigReg = dw_ConfigReg | 0x40; /***********************/ /* Test if simple mode */ /***********************/ if (b_InputMode == APCI1710_TOR_SIMPLE_MODE) { /**************************/ /* Enable the sinple mode */ /**************************/ dw_ConfigReg = dw_ConfigReg | 0x780; } // if (b_InputMode == APCI1710_TOR_SIMPLE_MODE) /***********************/ /* Test if double mode */ /***********************/ if (b_InputMode == APCI1710_TOR_DOUBLE_MODE) { /**************************/ /* Enable the double mode */ /**************************/ dw_ConfigReg = dw_ConfigReg | 0x180; } // if (b_InputMode == APCI1710_TOR_DOUBLE_MODE) b_InputMode = 0; } // if (b_InputMode > 1) /*******************/ /* Set the command */ /*******************/ dw_ConfigReg = dw_ConfigReg | b_CycleMode | (b_InterruptEnable * 2) | (b_InputMode * 4) | (b_ExternGate * 8); /*****************************/ /* Clear the status register */ /*****************************/ dw_DummyRead = inl(devpriv->s_BoardInfos. ui_Address + 0 + (16 * b_TorCounter) + (64 * b_ModulNbr)); /***************************************/ /* Clear the interrupt status register */ /***************************************/ dw_DummyRead=inl(devpriv->s_BoardInfos. ui_Address + 12 + (16 * b_TorCounter) + (64 * b_ModulNbr)); /********************/ /* Set the commando */ /********************/ outl(dw_ConfigReg,devpriv->s_BoardInfos. ui_Address + 4 + (16 * b_TorCounter) + (64 * b_ModulNbr)); /****************/ /* Set the gate */ /****************/ outl(1,devpriv->s_BoardInfos. ui_Address + 8 + (16 * b_TorCounter) + (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 = -9; } // if ((b_InterruptEnable == APCI1710_ENABLE) || (b_InterruptEnable == APCI1710_DISABLE)) } // if ((b_CycleMode == APCI1710_SINGLE) || (b_CycleMode == APCI1710_CONTINUOUS)) else { /***********************************************/ /* Tor counter acquisition mode cycle is wrong */ /***********************************************/ DPRINTK("Tor counter acquisition mode cycle is wrong\n"); i_ReturnValue = -8; } // if ((b_CycleMode == APCI1710_SINGLE) || (b_CycleMode == APCI1710_CONTINUOUS)) } // if (b_ExternGate >= 0 && b_ExternGate <= 1) else { /***********************************/ /* Extern gate input mode is wrong */ /***********************************/ DPRINTK("Extern gate input mode is wrong\n"); i_ReturnValue = -7; } // if (b_ExternGate >= 0 && b_ExternGate <= 1) } // if (b_InputMode >= 0 && b_InputMode <= 1) else { /***************************************/ /* Tor input signal selection is wrong */ /***************************************/ DPRINTK("Tor input signal selection is wrong\n"); i_ReturnValue = -6; } } else { /*******************************/ /* Tor counter not initialised */ /*******************************/ DPRINTK("Tor counter not initialised\n"); i_ReturnValue = -5; } break; case APCI1710_DISABLE : /***********************************/ /* Test if tor counter initialised */ /***********************************/ dw_Status = inl(devpriv->s_BoardInfos. ui_Address + 8 + (16 * b_TorCounter) + (64 * b_ModulNbr)); /*******************************/ /* Test if counter initialised */ /*******************************/ if (dw_Status & 0x10) { /***************************/ /* Test if counter enabled */ /***************************/ if (dw_Status & 0x1) { /****************************/ /* Clear the interrupt mode */ /****************************/ devpriv->s_ModuleInfo [b_ModulNbr]. s_TorCounterModuleInfo. s_TorCounterInfo [b_TorCounter]. b_InterruptEnable = APCI1710_DISABLE; /******************/ /* Clear the gate */ /******************/ outl(0,devpriv->s_BoardInfos.ui_Address + 8 + (16 * b_TorCounter) + (64 * b_ModulNbr)); } // if (dw_Status & 0x1) else { /***************************/ /* Tor counter not enabled */ /***************************/ DPRINTK("Tor counter not enabled \n"); i_ReturnValue = -6; } // if (dw_Status & 0x1) } // if (dw_Status & 0x10) else { /*******************************/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -