📄 apci1710_tor.c
字号:
/* Tor counter not initialised */ /*******************************/ DPRINTK("Tor counter not initialised\n"); i_ReturnValue = -5; } // // if (dw_Status & 0x10) } // switch } // if (b_TorCounter <= 1) else { /**********************************/ /* Tor counter selection is wrong */ /**********************************/ DPRINTK("Tor counter selection is wrong\n"); i_ReturnValue = -4; } // if (b_TorCounter <= 1) } else { /******************************************/ /* The module is not a tor counter module */ /******************************************/ DPRINTK("The module is not a tor counter 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_GetTorCounterInitialisation || (BYTE_ b_BoardHandle, || BYTE_ b_ModulNbr, || BYTE_ b_TorCounter, || PBYTE_ pb_TimingUnit, || PULONG_ pul_TimingInterval, || PBYTE_ pb_InputMode, || PBYTE_ pb_ExternGate, || PBYTE_ pb_CycleMode, || PBYTE_ pb_Enable, || PBYTE_ pb_InterruptEnable)|+----------------------------------------------------------------------------+| Task : Enable the tor counter (b_TorCounter) from selected || module (b_ModulNbr). You must calling the || "i_APCI1710_InitTorCounter" function be for you call || this function. || If you enable the tor counter interrupt, the || tor counter generate a interrupt after the timing cycle|| See function "i_APCI1710_SetBoardIntRoutineX" and the || Interrupt mask description chapter from this manual. || The b_CycleMode parameter determine if you will || measured a single or more cycle. |+----------------------------------------------------------------------------+| 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) b_ModulNbr = CR_AREF(insn->chanspec); b_TorCounter = CR_CHAN(insn->chanspec);. |+----------------------------------------------------------------------------+| Output Parameters : PBYTE_ pb_TimingUnit : Base timing unit (0 to 4) || 0 : ns || 1 : µs || 2 : ms || 3 : s || 4 : mn || PULONG_ pul_TimingInterval : Base timing value. || PBYTE_ pb_InputMode : Input signal level || selection || 0 : Tor count each low level || 1 : Tor count each high level|| PBYTE_ pb_ExternGate : Extern gate action || selection || 0 : Extern gate signal not || used || 1 : Extern gate signal used|| PBYTE_ pb_CycleMode : Tor counter acquisition || mode || PBYTE_ pb_Enable : Indicate if the tor counter|| is enabled or no || 0 : Tor counter disabled || 1 : Tor counter enabled || PBYTE_ pb_InterruptEnable : Enable or disable the || tor counter interrupt. || APCI1710_ENABLE: || Enable the tor counter || interrupt || APCI1710_DISABLE: || Disable the tor counter || interrupt pb_TimingUnit = (PBYTE) &data[0]; pul_TimingInterval = (PULONG) &data[1]; pb_InputMode = (PBYTE) &data[2]; pb_ExternGate = (PBYTE) &data[3]; pb_CycleMode = (PBYTE) &data[4]; pb_Enable = (PBYTE) &data[5]; pb_InterruptEnable = (PBYTE) &data[6]; |+----------------------------------------------------------------------------+| 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" |+----------------------------------------------------------------------------+*/INT i_APCI1710_InsnReadGetTorCounterInitialisation(comedi_device *dev,comedi_subdevice *s, comedi_insn *insn,lsampl_t *data) { INT i_ReturnValue = 0; DWORD dw_Status; BYTE b_ModulNbr; BYTE b_TorCounter; PBYTE pb_TimingUnit; PULONG pul_TimingInterval; PBYTE pb_InputMode; PBYTE pb_ExternGate; PBYTE pb_CycleMode; PBYTE pb_Enable; PBYTE pb_InterruptEnable ; i_ReturnValue = insn->n; b_ModulNbr = CR_AREF(insn->chanspec); b_TorCounter = CR_CHAN(insn->chanspec); pb_TimingUnit = (PBYTE) &data[0]; pul_TimingInterval = (PULONG) &data[1]; pb_InputMode = (PBYTE) &data[2]; pb_ExternGate = (PBYTE) &data[3]; pb_CycleMode = (PBYTE) &data[4]; pb_Enable = (PBYTE) &data[5]; pb_InterruptEnable = (PBYTE) &data[6]; /**************************/ /* 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) { /***********************************/ /* Test if tor counter initialised */ /***********************************/ dw_Status = inl(devpriv->s_BoardInfos. ui_Address + 8 + (16 * b_TorCounter) + (64 * b_ModulNbr)); if (dw_Status & 0x10) { *pb_Enable = dw_Status & 1; /********************/ /* Get the commando */ /********************/ dw_Status=inl(devpriv->s_BoardInfos. ui_Address + 4 + (16 * b_TorCounter) + (64 * b_ModulNbr)); *pb_CycleMode = (BYTE) ((dw_Status >> 4) & 1); *pb_InterruptEnable = (BYTE) ((dw_Status >> 5) & 1); /******************************************************/ /* Test if extern gate used for clock or for signal B */ /******************************************************/ if (dw_Status & 0x600) { /*****************************************/ /* Test if extern gate used for signal B */ /*****************************************/ if (dw_Status & 0x400) { /***********************/ /* Test if simple mode */ /***********************/ if ((dw_Status & 0x7800) == 0x7800) { *pb_InputMode = APCI1710_TOR_SIMPLE_MODE; } /***********************/ /* Test if double mode */ /***********************/ if ((dw_Status & 0x7800) == 0x1800) { *pb_InputMode = APCI1710_TOR_DOUBLE_MODE; } /**************************/ /* Test if quadruple mode */ /**************************/ if ((dw_Status & 0x7800) == 0x0000) { *pb_InputMode = APCI1710_TOR_QUADRUPLE_MODE; } } // if (dw_Status & 0x400) else { *pb_InputMode = 1; } // // if (dw_Status & 0x400) /************************/ /* Extern gate not used */ /************************/ *pb_ExternGate = 0; } // if (dw_Status & 0x600) else { *pb_InputMode = (BYTE) ((dw_Status >> 6) & 1); *pb_ExternGate = (BYTE) ((dw_Status >> 7) & 1); } // if (dw_Status & 0x600) *pb_TimingUnit = devpriv->s_ModuleInfo [b_ModulNbr]. s_TorCounterModuleInfo. s_TorCounterInfo [b_TorCounter]. b_TimingUnit; *pul_TimingInterval = devpriv->s_ModuleInfo [b_ModulNbr]. s_TorCounterModuleInfo. s_TorCounterInfo [b_TorCounter]. ul_RealTimingInterval; } else { /*******************************/ /* Tor counter not initialised */ /*******************************/ DPRINTK("Tor counter not initialised\n"); i_ReturnValue = -5; } } // if (b_TorCounter <= 1) else { /**********************************/ /* Tor counter selection is wrong */ /**********************************/ DPRINTK("Tor counter selection is wrong \n"); i_ReturnValue = -4; } // if (b_TorCounter <= 1) } else { /******************************************/ /* The module is not a tor counter module */ /******************************************/ DPRINTK("The module is not a tor counter 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_ReadTorCounterValue || (BYTE_ b_BoardHandle, || BYTE_ b_ModulNbr, || BYTE_ b_TorCounter, || UINT_ ui_TimeOut, || PBYTE_ pb_TorCounterStatus, || PULONG_ pul_TorCounterValue) |+----------------------------------------------------------------------------+| Task case APCI1710_TOR_GETPROGRESSSTATUS: Return the tor counter (b_TorCounter) status (pb_TorCounterStatus) from selected tor counter || module (b_ModulNbr). case APCI1710_TOR_GETCOUNTERVALUE : Return the tor counter (b_TorCounter) status || (pb_TorCounterStatus) and the timing value || (pul_TorCounterValue) after a conting cycle stop || from selected tor counter module (b_ModulNbr). |+----------------------------------------------------------------------------+| 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). b_ModulNbr = CR_AREF(insn->chanspec); b_ReadType = (BYTE) data[0]; b_TorCounter = (BYTE) data[1]; ui_TimeOut = (UINT) data[2]; |+----------------------------------------------------------------------------+| Output Parameters : PBYTE_ pb_TorCounterStatus : Return the tor counter || status. || 0 : Conting cycle not started|| Software gate not set. || 1 : Conting cycle started. || Software gate set. || 2 : Conting cycle stopped. || The conting cycle is || terminate. || 3 : A overflow occur. You || must change the base || timing witch the || function || "i_APCI1710_InitTorCounter"|| 4 : Timeeout occur || PULONG pul_TorCounterValue : Tor counter value.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -