?? hwdrv_apci1710.c
字號:
/**@verbatimCopyright (C) 2004,2005 ADDI-DATA GmbH for the source code of this module. ADDI-DATA GmbH Dieselstrasse 3 D-77833 Ottersweier Tel: +19(0)7223/9493-0 Fax: +49(0)7223/9493-92 http://www.addi-data-com info@addi-data.com This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USAYou shoud also find the complete GPL in the COPYING file accompanying this source code.@endverbatim*//* +-----------------------------------------------------------------------+ | (C) ADDI-DATA GmbH Dieselstra?e 3 D-77833 Ottersweier | +-----------------------------------------------------------------------+ | Tel : +49 (0) 7223/9493-0 | email : info@addi-data.com | | Fax : +49 (0) 7223/9493-92 | Internet : http://www.addi-data.com | +-------------------------------+---------------------------------------+ | Project : APCI-1710 | Compiler : GCC | | Module name : hwdrv_apci1710.c| Version : 2.96 | +-------------------------------+---------------------------------------+ | Project manager: Eric Stolz | Date : 02/12/2002 | +-------------------------------+---------------------------------------+ | Description : Hardware Layer Acces For APCI-1710 | +-----------------------------------------------------------------------+ | UPDATES | +----------+-----------+------------------------------------------------+ | Date | Author | Description of updates | +----------+-----------+------------------------------------------------+ | | | | | | | | | | | | +----------+-----------+------------------------------------------------+*/ #include "hwdrv_APCI1710.h" #include "APCI1710_Inp_cpt.c" #include "APCI1710_Ssi.c" #include "APCI1710_Tor.c" #include "APCI1710_Ttl.c" #include "APCI1710_Dig_io.c" #include "APCI1710_82x54.c" #include "APCI1710_Chrono.c" #include "APCI1710_Pwm.c" #include "APCI1710_INCCPT.c"void i_ADDI_AttachPCI1710 (comedi_device *dev) { comedi_subdevice *s; int ret = 0; int n_subdevices = 9; //Update-0.7.57->0.7.68dev->n_subdevices = 9; if((ret=alloc_subdevices(dev,n_subdevices))<0) return; // Allocate and Initialise Timer Subdevice Structures s = dev->subdevices + 0; s->type = COMEDI_SUBD_TIMER; s->subdev_flags = SDF_WRITEABLE|SDF_RT|SDF_GROUND|SDF_COMMON; s->n_chan = 3; s->maxdata = 0; s->len_chanlist = 3; s->range_table = &range_digital; s->insn_write=i_APCI1710_InsnWriteEnableDisableTimer; s->insn_read=i_APCI1710_InsnReadAllTimerValue; s->insn_config=i_APCI1710_InsnConfigInitTimer; s->insn_bits=i_APCI1710_InsnBitsTimer; // Allocate and Initialise DIO Subdevice Structures s = dev->subdevices + 1; s->type = COMEDI_SUBD_DIO; s->subdev_flags = SDF_WRITEABLE|SDF_READABLE|SDF_RT|SDF_GROUND|SDF_COMMON; s->n_chan = 7; s->maxdata = 1; s->len_chanlist = 7; s->range_table = &range_digital; s->insn_config=i_APCI1710_InsnConfigDigitalIO; s->insn_read= i_APCI1710_InsnReadDigitalIOChlValue; s->insn_bits=i_APCI1710_InsnBitsDigitalIOPortOnOff; s->insn_write=i_APCI1710_InsnWriteDigitalIOChlOnOff; // Allocate and Initialise Chrono Subdevice Structures s = dev->subdevices + 2; s->type = COMEDI_SUBD_CHRONO; s->subdev_flags = SDF_WRITEABLE|SDF_RT|SDF_GROUND|SDF_COMMON; s->n_chan = 4; s->maxdata = 0; s->len_chanlist = 4; s->range_table = &range_digital; s->insn_write=i_APCI1710_InsnWriteEnableDisableChrono; s->insn_read=i_APCI1710_InsnReadChrono; s->insn_config=i_APCI1710_InsnConfigInitChrono; s->insn_bits=i_APCI1710_InsnBitsChronoDigitalIO; // Allocate and Initialise PWM Subdevice Structures s = dev->subdevices + 3; s->type = COMEDI_SUBD_PWM; s->subdev_flags = SDF_WRITEABLE|SDF_READABLE|SDF_RT|SDF_GROUND|SDF_COMMON; s->n_chan = 3; s->maxdata = 1; s->len_chanlist = 3; s->range_table = &range_digital; s->io_bits=0; //all bits input s->insn_config = i_APCI1710_InsnConfigPWM; s->insn_read = i_APCI1710_InsnReadGetPWMStatus; s->insn_write = i_APCI1710_InsnWritePWM; s->insn_bits = i_APCI1710_InsnBitsReadPWMInterrupt; // Allocate and Initialise TTLIO Subdevice Structures s = dev->subdevices + 4; s->type = COMEDI_SUBD_TTLIO; s->subdev_flags = SDF_WRITEABLE|SDF_READABLE|SDF_RT|SDF_GROUND|SDF_COMMON; s->n_chan = 8; s->maxdata = 1; s->len_chanlist = 8; s->range_table = &range_apci1710_ttl; // to pass arguments in range s->insn_config = i_APCI1710_InsnConfigInitTTLIO; s->insn_bits = i_APCI1710_InsnBitsReadTTLIO; s->insn_write = i_APCI1710_InsnWriteSetTTLIOChlOnOff; s->insn_read = i_APCI1710_InsnReadTTLIOAllPortValue; // Allocate and Initialise TOR Subdevice Structures s = dev->subdevices + 5; s->type = COMEDI_SUBD_TOR; s->subdev_flags = SDF_WRITEABLE|SDF_READABLE|SDF_RT|SDF_GROUND|SDF_COMMON; s->n_chan = 8; s->maxdata = 1; s->len_chanlist = 8; s->range_table = &range_digital; s->io_bits=0; //all bits input s->insn_config = i_APCI1710_InsnConfigInitTorCounter; s->insn_read = i_APCI1710_InsnReadGetTorCounterInitialisation; s->insn_write = i_APCI1710_InsnWriteEnableDisableTorCounter; s->insn_bits = i_APCI1710_InsnBitsGetTorCounterProgressStatusAndValue; // Allocate and Initialise SSI Subdevice Structures s = dev->subdevices + 6; s->type = COMEDI_SUBD_SSI; s->subdev_flags = SDF_WRITEABLE|SDF_READABLE|SDF_RT|SDF_GROUND|SDF_COMMON; s->n_chan =4; s->maxdata = 1; s->len_chanlist = 4; s->range_table = &range_apci1710_ssi; s->insn_config = i_APCI1710_InsnConfigInitSSI; s->insn_read = i_APCI1710_InsnReadSSIValue; s->insn_bits = i_APCI1710_InsnBitsSSIDigitalIO; // Allocate and Initialise PULSEENCODER Subdevice Structures s = dev->subdevices + 7; s->type = COMEDI_SUBD_PULSEENCODER; s->subdev_flags = SDF_WRITEABLE|SDF_READABLE|SDF_RT|SDF_GROUND|SDF_COMMON; s->n_chan = 4; s->maxdata = 1; s->len_chanlist = 4; s->range_table = &range_digital; s->insn_config = i_APCI1710_InsnConfigInitPulseEncoder; s->insn_write = i_APCI1710_InsnWriteEnableDisablePulseEncoder; s->insn_bits = i_APCI1710_InsnBitsReadWritePulseEncoder; s->insn_read = i_APCI1710_InsnReadInterruptPulseEncoder; // Allocate and Initialise INCREMENTALCOUNTER Subdevice Structures s = dev->subdevices + 8; s->type = COMEDI_SUBD_INCREMENTALCOUNTER; s->subdev_flags = SDF_WRITEABLE|SDF_READABLE|SDF_RT|SDF_GROUND|SDF_COMMON; s->n_chan = 500; s->maxdata = 1; s->len_chanlist = 500; s->range_table = &range_apci1710_inccpt; s->insn_config = i_APCI1710_InsnConfigINCCPT; s->insn_write = i_APCI1710_InsnWriteINCCPT; s->insn_read = i_APCI1710_InsnReadINCCPT; s->insn_bits = i_APCI1710_InsnBitsINCCPT; } int i_APCI1710_Reset(comedi_device *dev);VOID v_APCI1710_Interrupt(int irq, void *d, struct pt_regs *regs) ;//for 1710 int i_APCI1710_Reset(comedi_device *dev){ int ret; DWORD dw_Dummy; /*********************************/ /* Read all module configuration */ /*********************************/ ret=inl(devpriv->s_BoardInfos.ui_Address+60); devpriv->s_BoardInfos.dw_MolduleConfiguration [0]=ret; ret=inl(devpriv->s_BoardInfos.ui_Address+124); devpriv->s_BoardInfos.dw_MolduleConfiguration [1]=ret; ret=inl(devpriv->s_BoardInfos.ui_Address+188); devpriv->s_BoardInfos.dw_MolduleConfiguration [2]=ret; ret=inl(devpriv->s_BoardInfos.ui_Address+252); devpriv->s_BoardInfos.dw_MolduleConfiguration [3]=ret; // outl(0x80808082,devpriv->s_BoardInfos.ui_Address+0x60); outl(0x83838383,devpriv->s_BoardInfos.ui_Address+0x60); devpriv->s_BoardInfos.b_BoardVersion = 1; // Enable the interrupt for the controler dw_Dummy = inl(devpriv->s_BoardInfos.ui_Address+ 0x38); outl(dw_Dummy | 0x2000,devpriv->s_BoardInfos.ui_Address+0x38); return 0;}/*+----------------------------------------------------------------------------+| Function's Name : __VOID__ v_APCI1710_InterruptFunction || (BYTE b_Interrupt, __CPPARGS) |+----------------------------------------------------------------------------+| Task : APCI-1710 interrupt function |+----------------------------------------------------------------------------+| Input Parameters : BYTE b_Interrupt : Interrupt number |+----------------------------------------------------------------------------+| Output Parameters : - |+----------------------------------------------------------------------------+| Return Value : 0 : OK || -1 : Error |+----------------------------------------------------------------------------+*/ VOID v_APCI1710_Interrupt(int irq, void *d, struct pt_regs *regs) { comedi_device *dev = d; BYTE b_ModuleCpt = 0; BYTE b_InterruptFlag = 0; BYTE b_PWMCpt = 0; BYTE b_TorCounterCpt = 0; BYTE b_PulseIncoderCpt = 0; UINT ui_16BitValue; ULONG ul_InterruptLatchReg = 0; ULONG ul_LatchRegisterValue = 0; ULONG ul_82X54InterruptStatus; ULONG ul_StatusRegister; str_ModuleInfo * ps_ModuleInfo; printk("APCI1710 Interrupt\n"); for (b_ModuleCpt = 0; b_ModuleCpt < 4; b_ModuleCpt ++, ps_ModuleInfo ++) { /**************************/ /* 1199/0225 to 0100/0226 */ /**************************/ ps_ModuleInfo = &devpriv->s_ModuleInfo [b_ModuleCpt]; /***********************/ /* Test if 82X54 timer */ /***********************/ if ((devpriv-> s_BoardInfos. dw_MolduleConfiguration [b_ModuleCpt] & 0xFFFF0000UL) == APCI1710_82X54_TIMER) { //printk("TIMER Interrupt Occurred\n"); ul_82X54InterruptStatus= inl(devpriv->s_BoardInfos. ui_Address + 12 + (64 * b_ModuleCpt)); /***************************/ /* Test if interrupt occur */ /***************************/ if ((ul_82X54InterruptStatus & ps_ModuleInfo-> s_82X54ModuleInfo. b_InterruptMask) != 0) { devpriv-> s_InterruptParameters. s_FIFOInterruptParameters [devpriv-> s_InterruptParameters. ui_Write]. ul_OldInterruptMask = (ul_82X54InterruptStatus & ps_ModuleInfo-> s_82X54ModuleInfo. b_InterruptMask) << 4; devpriv-> s_InterruptParameters. s_FIFOInterruptParameters [devpriv-> s_InterruptParameters. ui_Write]. b_OldModuleMask = 1 << b_ModuleCpt; devpriv-> s_InterruptParameters. s_FIFOInterruptParameters [devpriv-> s_InterruptParameters. ui_Write]. ul_OldCounterLatchValue = 0; devpriv-> s_InterruptParameters. ul_InterruptOccur ++; /****************************/ /* Increment the write FIFO */ /****************************/ devpriv-> s_InterruptParameters. ui_Write = (devpriv-> s_InterruptParameters. ui_Write + 1) % APCI1710_SAVE_INTERRUPT; b_InterruptFlag = 1; /**********************/ /* Call user function */ /**********************/ //Send a signal to from kernel to user space send_sig(SIGIO,devpriv->tsk_Current,0); } // if ((ul_82X54InterruptStatus & 0x7) != 0) } // 82X54 timer /***************************/ /* Test if increm. counter */ /***************************/ if ((devpriv-> s_BoardInfos. dw_MolduleConfiguration [b_ModuleCpt] & 0xFFFF0000UL) == APCI1710_INCREMENTAL_COUNTER) { ul_InterruptLatchReg=inl(devpriv->s_BoardInfos. ui_Address + (64 * b_ModuleCpt)); /*********************/ /* Test if interrupt */ /*********************/ if ((ul_InterruptLatchReg & 0x22) && (ps_ModuleInfo-> s_SiemensCounterInfo. s_ModeRegister. s_ByteModeRegister. b_ModeRegister2 & 0x80)) { /************************************/ /* Test if strobe latch I interrupt */ /************************************/ if (ul_InterruptLatchReg & 2) { ul_LatchRegisterValue=inl(devpriv->s_BoardInfos. ui_Address + 4 + (64 * b_ModuleCpt)); devpriv-> s_InterruptParameters. s_FIFOInterruptParameters [devpriv-> s_InterruptParameters. ui_Write]. ul_OldInterruptMask = 1UL; devpriv-> s_InterruptParameters. s_FIFOInterruptParameters [devpriv-> s_InterruptParameters. ui_Write]. b_OldModuleMask = 1 << b_ModuleCpt; devpriv-> s_InterruptParameters. s_FIFOInterruptParameters [devpriv-> s_InterruptParameters. ui_Write]. ul_OldCounterLatchValue = ul_LatchRegisterValue; devpriv-> s_InterruptParameters. ul_InterruptOccur ++; /****************************/ /* 0899/0224 to 1199/0225 */ /****************************/ /* Increment the write FIFO */ /****************************/ devpriv-> s_InterruptParameters. ui_Write = (devpriv-> s_InterruptParameters. ui_Write + 1) % APCI1710_SAVE_INTERRUPT;
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -