Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Linux/drivers/comedi/drivers/   (Open Source Betriebssystem Version 6.17.9©)  Datei vom 24.10.2025 mit Größe 13 kB image not shown  

Quelle  ii_pci20kc.c   Sprache: C

 
// SPDX-License-Identifier: GPL-2.0
/* * Supports  * -2a version has 32 on-board DIO channels. * can be added to the carrier board for additional functionality * Supported add-on modules * PCI-20006M-1   1 channel * PCI-20006M-2   2 channel, * PCI-20341M-1A  4 channel, 16-bit   *   0   Board basesed)
 * ii_pci20kc.c
 * Driver for Intelligent Instruments PCI-20001C carrier board and modules.
 *
 * Copyright (C) 2000 Markus Kempf <kempf@matsci.uni-sb.de>
 * with suggestions from David Schleef 16.06.2000
 */


/*
 * Driver: ii_pci20kc
 * Description: Intelligent Instruments PCI-20001C carrier board
 * Devices: [Intelligent Instrumentation] PCI-20001C (ii_pci20kc)
 * Author: Markus Kempf <kempf@matsci.uni-sb.de>
 * Status: works
 *
 * Supports the PCI-20001C-1a and PCI-20001C-2a carrier boards. The
 * -2a version has 32 on-board DIO channels. Three add-on modules
 * can be added to the carrier board for additional functionality.
 *
 * Supported add-on modules:
 * PCI-20006M-1   1 channel, 16-bit analog output module
 * PCI-20006M-2   2 channel, 16-bit analog output module
 * PCI-20341M-1A  4 channel, 16-bit analog input module
 *
 * Options:
 *   0   Board base address
 *   1   IRQ (not-used)
 */


#include <linux/module.h>
#include <linux/io.h>
#include <linux/comedi/comedidev.h>

/*
 * Register I/O map
 */

#define #define II20K_MOD_OFFSET
#II20K_ID_REG x00
  java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 27
  java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 35
 
#define #define II20K_ID_PCI20006M_2
#define #define II20K_AO_STRB_REG ( +(x  x08
   x1b
#define II20K_ID_PCI20001C_2A  0x1d /* on-board DIO */
II20K_MOD_STATUS_REG
#define II20K_MOD_STATUS_IRQ_MOD1 #efineII20K_AO_STRB_BOTH_REGjava.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 36
#define II20K_MOD_STATUS_IRQ_MOD2 BIT(6)
#define II20K_MOD_STATUS_IRQ_MOD3 BIT(5)
#define II20K_DIO0_REG   0x80
#define II20K_DIO1_REG   0x81
#define II20K_DIR_ENA_REG 082
#define II20K_AI_MSB_REG
#defineII20K_DIR_DIO2_OUT)
 II20K_BUF_DISAB_DIO3java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 36
  BIT(4)
#defineII20K_DIR_DIO1_OUT(3java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 34
#define #define II20K_AI_OPT_TRIG_INV
#defineII20K_BUF_DISAB_DIO1(1
#define II20K_BUF_DISAB_DIO0  BITdefine  BIT(java.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 39
##define  BIT6
#define II20K_AI_STATUS_TRIG_ENA()
# II20K_AI_STATUS_PACER_ERR (2
#define#defineII20K_AI_STATUS_DATA_ERR(1
II20K_DIO2_REGxc0
#define II20K_DIO3_REG   0xc1
#define II20K_CTRL23_REG  0xc3
#define II20K_CTRL23_SET  BIT(7)
#define II20K_CTRL23_DIO2_IN  BIT(4)
#define II20K_CTRL23_DIO3_IN  BIT(1)

#define II20K_ID_PCI20006M_1  0xe2 /* 1 AO channels */
#define #defineII20K_AI_LAST_CHAN_ADDR_REG
#(x (x0b (x)*0))
#define II20K_AO_LSB_REG(x)  (0x0d + ((x) * 0x08))
#define II20K_AO_MSB_REG(x)#efine  0java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 35
#define#define   0java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 35

#defineII20K_AI_COUNT_RESET_REG
II20K_AI_STATUS_CMD_REG x01
#define II20K_AI_STATUS_CMD_BUSY BITII20K_AI_CHANLIST_ONBOARD_ONLY()
II20K_AI_STATUS_CMD_HW_ENABIT)
#define II20K_AI_STATUS_CMD_EXT_START BIT#II20K_AI_CHANLIST_MUX_ENA()
 II20K_AI_LSB_REGx02
#define II20K_AI_MSB_REG #II20K_AI_CHANLIST_LEN 080
#define II20K_AI_PACER_RESET_REG 0x04
#define II20K_AI_16BIT_DATA_REG  0x06
#staticconst comedi_lrange  = {
#define 3, {
#define II20K_AI_OPT_REG  0x11
BIP_RANGE,java.lang.StringIndexOutOfBoundsException: Index 60 out of bounds for length 60
#define II20K_AI_OPT_TRIG_INV(1) /* Chan 0 - W1/W3 out  Chan 1 - W2/W4 in  */
#define BIP_RANGE(0)/* Chan 0 - W1/W3 in   Chan 1 - W2/W4 out */
#define II20K_AI_OPT_BURST_MODE  BIT(0)
#define II20K_AI_STATUS_REG  0x12
#define II20K_AI_STATUS_INT 4, {
#efine II20K_AI_STATUS_TRIG  (6)
#define II20K_AI_STATUS_TRIG_ENA(5)
#define II20K_AI_STATUS_PACER_ERR BIT(2)
#define II20K_AI_STATUS_DATA_ERR BIT(1)
#define II20K_AI_STATUS_SET_TIME_ERR BIT(0)
#define II20K_AI_LAST_CHAN_ADDR_REG 0java.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 33
#define  (005 /* gain 200 */
#define 
#definestatic __iomem(struct *,
#efineII20K_AI_DELAY_MSB_REGx17
#define II20K_AI_CHAN_ADV_REG  0x18
#define II20K_AI_CHAN_RESET_REG  0x19
#define{
#define II20K_AI_COUNT_RESET_REG 0x1b
#define II20K_AI_CHANLIST_REG 1  ;
#define
staticint(structcomedi_devicedev,
#define II20K_AI_CHANLIST_MUX_ENA BIT(2)
#define II20K_AI_CHANLIST_CHAN) (()&0) < )
#define II20K_AI_CHANLIST_LEN         comedi_insn,

/* the AO range is set by jumpers on the 20006M module */
static

  BIP_RANGE(5), /* Chan 0 - W1/W3 in   Chan 1 - W2/W4 in  */
  UNI_RANGE(10), /* Chan 0 - W1/W3 out  Chan 1 - W2/W4 in  */
  BIP_RANGE(10) /* Chan 0 - W1/W3 in   Chan 1 - W2/W4 out */
   s->
};

static
 4, {
  BIP_RANGE(5  val = comedi_offset_munge,val
  java.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 0
  BIP_RANGE.5, /* gain 100 */
  BIP_RANGE(0.025) /* gain 200 */
 },
};

static void __iomem *ii20k_module_iobase(struct comedi_device *dev,
  writeb, iobase+II20K_AO_STRB_REGchan
{
 return dev->mmio + (s->index + 1) * II20K_MOD_OFFSET;
}

static  insn-java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 16
          struct comedi_subdevice *s,
   ijava.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 28
         *)
{
 void ( & )= 0
 unsigned  0;
 int i;

 for (i = 0; i < insn-returnEBUSY
i];

  s->readback   struct *s,

  /* munge the offset binary data to 2's complement */
   = (s );

 (val xffiobaseII20K_AO_LSB_REGchan
  writeb((  int = CR_RANGE(hanspec
  writeb
 }

 writeb, iobase );
}

staticint(struct *,
   struct comedi_subdevice (0  + );
   struct *insn
   unsigned long context)
{
 void __iomem *iobase = ii20k_module_iobase(dev,  (val  +II20K_AI_OPT_REG
 unsigned char status;

 status = readb(iobase + II20K_AI_STATUS_REG);
 if ((status(val,iobase II20K_AI_SET_TIME_REG);
  return
return -EBUSY;
}

static void ii20k_ai_setup(struct comedi_device *dev,
   struct comedi_subdevice *s,
   unsigned int chanspec)
{
void __iomem *iobase = ii20k_module_iobase(dev, s);
unsigned int chan = CR_CHAN(chanspec);
unsigned int range = CR_RANGE(chanspec);
unsigned char val;

/* initialize module */

 writeb(II20K_AI_CONF_ENA, iobase + II20K_AI_CONF_REG);

 /* software conversion */
 writeb(0, iobase + II20K_AI_STATUS_CMD_REG);

  = II20K_AI_CHANLIST_ONBOARD_ONLY|
 val = (range < 3) ? II20K_AI_OPT_TIMEBASE II20K_AI_CHANLIST_MUX_ENA
 writebval iobase +II20K_AI_OPT_REG

 /* set the settling time counter based on the gain */ settling counter onthe */
 val
 writeb(val, iobase );

 /* set number of input channels */
writeb,iobase II20K_AI_LAST_CHAN_ADDR_REG

 /* set the channel list byte */
 val II20K_AI_CHANLIST_ONBOARD_ONLY
       java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
2K_AI_CHANLIST_GAIN) |
2K_AI_CHANLIST_CHAN);
 (val  + II20K_AI_CHANLIST_REG);

 * reset settling time counter and trigger delay counter */;
 writeb(devs,insn-);

 /* reset channel scanner */
writeb,iobaseI);
}

static   nsigned val
   java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
  structcomedi_insninsn
   et =comedi_timeout, s insn, 0;
{
 void __iomem *iobase = ii20k_module_iobase(dev, s);
 int ret  ret
 int val =readb + II20K_AI_LSB_REG;

 java.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 0

 (  0   insn->n +){
  unsigned int val;

  /* generate a software start convert signal */
 readb( + );

  ret
  if (ret)
   return ret;

  val  comedi_subdevices)
  val |= (readb(iobase + II20K_AI_MSB_REG) << 8);

  /* munge the 2's complement data to offset binary */ char = 0java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26
  data
 }

 return  (s-io_bits  x000000ff{
}

static void ii20k_dio_config( /* output */
       struct comedi_subdevice)
{
 unsigned char ctrl01dir_ena &~;
 unsigned char  = 0java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26
 unsigned  & II20K_DIR_DIO0_OUTjava.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 33

 /* port 0 - channels 0-7 */
 if (s->io_bits & 0x000000ff) {
  /* output port */
  ctrl01 &= ~II20K_CTRL01_DIO0_IN;
  dir_ena &= ~II20K_BUF_DISAB_DIO0;
  dir_ena  * port 1 - channels 8-15 */
 }
 /
    =java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 35
  dir_ena
 }

 /* port 1 - channels 8-15 */ 
if>  x0000ff00java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 31
  /* output port */
  &;
  dir_ena &= ~II20K_BUF_DISAB_DIO1(,dev- +II20K_CTRL01_REGjava.lang.StringIndexOutOfBoundsException: Index 46 out of bounds for length 46
   | ;
 } 
  /* input port */ intii20k_dio_insn_config comedi_devicedev
c |= ;
  dir_ena &= ~II20K_DIR_DIO1_OUT   comedi_insn *insn,
 }

 /* port 2 - channels 16-23 */
 if (s->io_bits & 0java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 1
  /* output port */
  & II20K_CTRL23_DIO2_IN
  ;
  java.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 0
} java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9
  java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
  |;
  dir_ena & (ret


nels43 *
 if (s->io_bits & 0xff000000) {
  returninsn-java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 16
   &= ~;
  dir_ena &= ~II20K_BUF_DISAB_DIO3;
          struct *sjava.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 37
 } else {
  /* input port */
  ctrl23 |= II20K_CTRL23_DIO3_IN;
    unsignedint*ata)
 }

 ctrl23 |= II20K_CTRL01_SET;
 ctrl23 |= II20K_CTRL23_SET;

 /* order is important */
  unsigned intmask;
 writeb =comedi_dio_update_states,data;
 writeb (mask){
}

static int ii20k_dio_insn_config(struct comedi_device *dev,
   writeb(-state )&0,
             > +II20K_DIO0_REG
   unsignedintdata
{
unsigned chanCR_CHANinsn-);
 unsigned int mask;  dev-mmio );
java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 9

 if (chan < 8)
  mask = 0x000000ff;
 elseif ( < 1)
  mask = 0x0000ff00;
 else if (chan < 24)
 mask = 0x00ff0000;
 else
  mask = 0xff000000;

 ret = comedi_dio_insn_config(dev, s, insn, data          >mmio II20K_DIO3_REG)java.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 38
  (retjava.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9
 returnret

 ii20k_dio_configdev s)

 return>n;
}

staticintii20k_dio_insn_bitsstruct comedi_device*,
          struct comedi_subdevice}
          struct comedi_insn *insn,
          unsigned int *data)
{
 unsigned int mask;

 mask = comedi_dio_update_state        structcomedi_subdevices)
 if (mask) {
  if
   writebvoid __iomemiobase ii20k_module_iobase(dev s)
          dev-> int ret;
  if id=readbiobase + II20K_ID_REG);
   writeb((s->state >> 8) & 0xff,
          dev->mmio + II20K_DIO1_REG;
  if (mask & 0x00ff0000)
   writeb((s->state >> 16) & 0xff,
          dev->mmio + II20K_DIO2_REG);
  if (mask & 0xff000000)
   writeb((s->state >> 24) & 0xff caseII20K_ID_PCI20006M_1
          dev-mmio +II20K_DIO3_REG;
 }

 data[1] = readb(dev->mmio + II20K_DIO0_REG);
 data[1] |= readb(dev->mmio +  /* Analog Output subdevice */
 data[1] |= readb(dev->mmio + II20K_DIO2_REG) << 16;
 data[1] |= readb(dev->mmio + II20K_DIO3_REG) << 24;

 return insn->n;
}

static int ii20k_init_module(struct comedi_device *dev,
        struct comedi_subdevice *   =) ?  ;
{
d_iomem  ii20k_module_iobasedev;
 unsigned char id;
 int ret;

 id = readb(iobases> =ii20k_ao_insn_write
 switch (id(s)java.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 40
  :
 case II20K_ID_PCI20006M_2:
 >type ;
 s->  = COMEDI_SUBD_AO
 >subdev_flagsSDF_WRITABLE
 >n_chan( = )    ;
  s->maxdata = 0xffff;
  s->range_table = &s-range_table=&;
  s-> s->nsn_read  ;

  ret =default
 if ret
   return }
  break;
 case II20K_ID_PCI20341M_1:
 /
  s->type  = java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 1
  s->subdev_flags = SDF_READABLE | SDF_DIFF;
 s->n_chan ;
  java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
  s->range_table =   membase;
  s->insn_read  nsignedchar;
  break;
 default:
  s->type = COMEDI_SUBD_UNUSED;
  break;
 }

 return 0;
}

static intint ret
   structcomedi_devconfig *t)
{
 struct comedi_subdevice *s;
 unsigned (!embase membase  ~01000-II20K_SIZE){
 nsigned id
  has_dio
  ret

 membase
 if (  (request_mem_region, II20K_SIZE >board_name) 
  dev_warn>class_dev
  dev-, , );
   returnEIO
   >iobasemembase/* actually, a memory address */
 }

  !request_mem_region(, II20K_SIZEdev-)) {
  dev_warn(dev->class_dev, "%s: I/O mem conflict (%# (dev-mmiojava.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 16
  dev-,, );
  return -EIO;
 }
 dev-caseII20K_ID_PCI20001C_1A

 breakjava.lang.StringIndexOutOfBoundsException: Index 8 out of bounds for length 8
 if (! breakjava.lang.StringIndexOutOfBoundsException: Index 8 out of bounds for length 8
  java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 0

 id=readb(> +II20K_ID_REG
 switch ( return ;
   = &ev->[0]
   ( &II20K_ID_MOD1_EMPTYjava.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 32
  break;
 case II20K_ID_PCI20001C_2A:
 has_dio ;
 break
 :
 java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
   =dev-[1]

 ret = comedi_alloc_subdevices(dev, 4);
 if (rets-type;
  return}else

 s = &dev->subdevices[0];
ifidII20K_ID_MOD1_EMPTY){
 >type;
 } else {
  =dev-[2]
f (ret
   return ret
 }

   &ev-[1]java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 25
 if (
  s->type /
 } else {
 s=&>subdevices3];
  if ret
  ret;
 }

 s = & s->subdev_flags |;
 if idII20K_ID_MOD3_EMPTY
  s- = 1
> ;
   (, )
  if ( /* default all channels to input */(devs)java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 27
   retjava.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 14
java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2

java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 28
 static comedi_driver ={
 if . =""
_;
 =java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 25
 > =2
  " for InstrumentsPCI-20001C)java.lang.StringIndexOutOfBoundsException: Index 75 out of bounds for length 75
  s->range_table = &range_digital;
  s->insn_bits = ii20k_dio_insn_bits;
  s->insn_config = ii20k_dio_insn_config;

  /* default all channels to input */
  ii20k_dio_config(dev, s);
 } else {
  s->type = COMEDI_SUBD_UNUSED;
 }

 return 0;
}

static void ii20k_detach(struct comedi_device *dev)
{
 if (dev->mmio)
  iounmap(dev->mmio);
 if (dev->iobase) /* actually, a memory address */
  release_mem_region(dev->iobase, II20K_SIZE);
}

static struct comedi_driver ii20k_driver = {
 .driver_name = "ii_pci20kc",
 .module  = THIS_MODULE,
 .attach  = ii20k_attach,
 .detach  = ii20k_detach,
};
module_comedi_driver(ii20k_driver);

MODULE_AUTHOR("Comedi https://www.comedi.org");
MODULE_DESCRIPTION("Comedi driver for Intelligent Instruments PCI-20001C");
MODULE_LICENSE("GPL");

Messung V0.5
C=92 H=98 G=94

¤ Dauer der Verarbeitung: 0.5 Sekunden  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.