REG_EEC
};
-typedef struct {
+struct counter_mode_register_t {
unsigned short coutSource:1;
unsigned short coutPolarity:1;
unsigned short autoLoadResetRcap:3;
unsigned short outputRegLatchCtrl:1;
unsigned short preloadRegSel:1;
unsigned short reserved:1;
-} counter_mode_register_t;
+};
union {
- counter_mode_register_t reg;
+ struct counter_mode_register_t reg;
unsigned short value;
} cmReg;
/* Different Application Classes for GPCT Subdevices */
/* The list is not exhaustive and needs discussion! */
-typedef enum {
+enum S526_GPCT_APP_CLASS {
CountingAndTimeMeasurement,
SinglePulseGeneration,
PulseTrainGeneration,
PositionMeasurement,
Miscellaneous
-} S526_GPCT_APP_CLASS;
+};
/* Config struct for different GPCT subdevice Application Classes and
their options
*/
-typedef struct s526GPCTConfig {
- S526_GPCT_APP_CLASS app;
+struct s526GPCTConfig {
+ enum S526_GPCT_APP_CLASS app;
int data[MAX_GPCT_CONFIG_DATA];
-} s526_gpct_config_t;
+};
/*
* Board descriptions for two imaginary boards. Describing the
* boards in this way is optional, and completely driver-dependent.
* Some drivers use arrays such as this, other do not.
*/
-typedef struct s526_board_struct {
+struct s526_board {
const char *name;
int gpct_chans;
int gpct_bits;
int da_chans;
int da_bits;
int have_dio;
-} s526_board;
+};
-static const s526_board s526_boards[] = {
+static const struct s526_board s526_boards[] = {
{
name: "s526",
gpct_chans:4,
/*
* Useful for shorthand access to the particular board structure
*/
-#define thisboard ((const s526_board *)dev->board_ptr)
+#define thisboard ((const struct s526_board *)dev->board_ptr)
/* this structure is for data unique to this hardware driver. If
several hardware drivers keep similar information in this structure,
- feel free to suggest moving the variable to the comedi_device struct. */
-typedef struct {
+ feel free to suggest moving the variable to the struct comedi_device struct. */
+struct s526_private {
+
int data;
/* would be useful for a PCI device */
struct pci_dev *pci_dev;
/* Used for AO readback */
- lsampl_t ao_readback[2];
+ unsigned int ao_readback[2];
- s526_gpct_config_t s526_gpct_config[4];
+ struct s526GPCTConfig s526_gpct_config[4];
unsigned short s526_ai_config;
-} s526_private;
+};
+
/*
* most drivers define the following macro to make it easy to
* access the private structure.
*/
-#define devpriv ((s526_private *)dev->private)
+#define devpriv ((struct s526_private *)dev->private)
/*
- * The comedi_driver structure tells the Comedi core module
+ * The struct comedi_driver structure tells the Comedi core module
* which functions to call to configure/deconfigure (attach/detach)
* the board, and also about the kernel module that contains
* the device code.
*/
-static int s526_attach(comedi_device * dev, comedi_devconfig * it);
-static int s526_detach(comedi_device * dev);
-static comedi_driver driver_s526 = {
+static int s526_attach(struct comedi_device * dev, struct comedi_devconfig * it);
+static int s526_detach(struct comedi_device * dev);
+static struct comedi_driver driver_s526 = {
driver_name:"s526",
module:THIS_MODULE,
attach:s526_attach,
* devices are such boards.
*/
board_name:&s526_boards[0].name,
- offset:sizeof(s526_board),
- num_names:sizeof(s526_boards) / sizeof(s526_board),
+ offset:sizeof(struct s526_board),
+ num_names:sizeof(s526_boards) / sizeof(struct s526_board),
};
-static int s526_gpct_rinsn(comedi_device * dev, comedi_subdevice * s,
- comedi_insn * insn, lsampl_t * data);
-static int s526_gpct_insn_config(comedi_device * dev, comedi_subdevice * s,
- comedi_insn * insn, lsampl_t * data);
-static int s526_gpct_winsn(comedi_device * dev, comedi_subdevice * s,
- comedi_insn * insn, lsampl_t * data);
-static int s526_ai_insn_config(comedi_device * dev, comedi_subdevice * s,
- comedi_insn * insn, lsampl_t * data);
-static int s526_ai_rinsn(comedi_device * dev, comedi_subdevice * s,
- comedi_insn * insn, lsampl_t * data);
-static int s526_ao_winsn(comedi_device * dev, comedi_subdevice * s,
- comedi_insn * insn, lsampl_t * data);
-static int s526_ao_rinsn(comedi_device * dev, comedi_subdevice * s,
- comedi_insn * insn, lsampl_t * data);
-static int s526_dio_insn_bits(comedi_device * dev, comedi_subdevice * s,
- comedi_insn * insn, lsampl_t * data);
-static int s526_dio_insn_config(comedi_device * dev, comedi_subdevice * s,
- comedi_insn * insn, lsampl_t * data);
+static int s526_gpct_rinsn(struct comedi_device * dev, struct comedi_subdevice * s,
+ struct comedi_insn * insn, unsigned int * data);
+static int s526_gpct_insn_config(struct comedi_device * dev, struct comedi_subdevice * s,
+ struct comedi_insn * insn, unsigned int * data);
+static int s526_gpct_winsn(struct comedi_device * dev, struct comedi_subdevice * s,
+ struct comedi_insn * insn, unsigned int * data);
+static int s526_ai_insn_config(struct comedi_device * dev, struct comedi_subdevice * s,
+ struct comedi_insn * insn, unsigned int * data);
+static int s526_ai_rinsn(struct comedi_device * dev, struct comedi_subdevice * s,
+ struct comedi_insn * insn, unsigned int * data);
+static int s526_ao_winsn(struct comedi_device * dev, struct comedi_subdevice * s,
+ struct comedi_insn * insn, unsigned int * data);
+static int s526_ao_rinsn(struct comedi_device * dev, struct comedi_subdevice * s,
+ struct comedi_insn * insn, unsigned int * data);
+static int s526_dio_insn_bits(struct comedi_device * dev, struct comedi_subdevice * s,
+ struct comedi_insn * insn, unsigned int * data);
+static int s526_dio_insn_config(struct comedi_device * dev, struct comedi_subdevice * s,
+ struct comedi_insn * insn, unsigned int * data);
/*
* Attach is called by the Comedi core to configure the driver
* in the driver structure, dev->board_ptr contains that
* address.
*/
-static int s526_attach(comedi_device * dev, comedi_devconfig * it)
+static int s526_attach(struct comedi_device * dev, struct comedi_devconfig * it)
{
- comedi_subdevice *s;
+ struct comedi_subdevice *s;
int iobase;
int i, n;
-// sampl_t value;
+// short value;
// int subdev_channel = 0;
printk("comedi%d: s526: ", dev->minor);
* Allocate the private structure area. alloc_private() is a
* convenient macro defined in comedidev.h.
*/
- if (alloc_private(dev, sizeof(s526_private)) < 0)
+ if (alloc_private(dev, sizeof(struct s526_private)) < 0)
return -ENOMEM;
/*
printk("Read back mode reg=0x%04x\n", inw(ADDR_CHAN_REG(REG_C0M, n)));
// Load the pre-laod register high word
-// value = (sampl_t) (0x55);
+// value = (short) (0x55);
// outw(value, ADDR_CHAN_REG(REG_C0H, n));
// Load the pre-laod register low word
-// value = (sampl_t)(0xaa55);
+// value = (short)(0xaa55);
// outw(value, ADDR_CHAN_REG(REG_C0L, n));
// Write the Counter Control Register
* allocated by _attach(). dev->private and dev->subdevices are
* deallocated automatically by the core.
*/
-static int s526_detach(comedi_device * dev)
+static int s526_detach(struct comedi_device * dev)
{
printk("comedi%d: s526: remove\n", dev->minor);
return 0;
}
-static int s526_gpct_rinsn(comedi_device * dev, comedi_subdevice * s,
- comedi_insn * insn, lsampl_t * data)
+static int s526_gpct_rinsn(struct comedi_device * dev, struct comedi_subdevice * s,
+ struct comedi_insn * insn, unsigned int * data)
{
int i; // counts the Data
int counter_channel = CR_CHAN(insn->chanspec);
return i;
}
-static int s526_gpct_insn_config(comedi_device * dev, comedi_subdevice * s,
- comedi_insn * insn, lsampl_t * data)
+static int s526_gpct_insn_config(struct comedi_device * dev, struct comedi_subdevice * s,
+ struct comedi_insn * insn, unsigned int * data)
{
int subdev_channel = CR_CHAN(insn->chanspec); // Unpack chanspec
int i;
- sampl_t value;
+ short value;
// printk("s526: GPCT_INSN_CONFIG: Configuring Channel %d\n", subdev_channel);
cmReg.reg.autoLoadResetRcap = 4; // Auto load with INDEX^
// Set Counter Mode Register
- cmReg.value = (sampl_t) (insn->data[1] & 0xFFFF);
+ cmReg.value = (short) (insn->data[1] & 0xFFFF);
outw(cmReg.value, ADDR_CHAN_REG(REG_C0M, subdev_channel));
// Load the pre-laod register high word
- value = (sampl_t) ((insn->data[2] >> 16) & 0xFFFF);
+ value = (short) ((insn->data[2] >> 16) & 0xFFFF);
outw(value, ADDR_CHAN_REG(REG_C0H, subdev_channel));
// Load the pre-laod register low word
- value = (sampl_t) (insn->data[2] & 0xFFFF);
+ value = (short) (insn->data[2] & 0xFFFF);
outw(value, ADDR_CHAN_REG(REG_C0L, subdev_channel));
// Write the Counter Control Register
if (insn->data[3] != 0) {
- value = (sampl_t) (insn->data[3] & 0xFFFF);
+ value = (short) (insn->data[3] & 0xFFFF);
outw(value, ADDR_CHAN_REG(REG_C0C, subdev_channel));
}
// Reset the counter if it is software preload
SinglePulseGeneration;
// Set Counter Mode Register
- cmReg.value = (sampl_t) (insn->data[1] & 0xFFFF);
+ cmReg.value = (short) (insn->data[1] & 0xFFFF);
cmReg.reg.preloadRegSel = 0; // PR0
outw(cmReg.value, ADDR_CHAN_REG(REG_C0M, subdev_channel));
// Load the pre-laod register 0 high word
- value = (sampl_t) ((insn->data[2] >> 16) & 0xFFFF);
+ value = (short) ((insn->data[2] >> 16) & 0xFFFF);
outw(value, ADDR_CHAN_REG(REG_C0H, subdev_channel));
// Load the pre-laod register 0 low word
- value = (sampl_t) (insn->data[2] & 0xFFFF);
+ value = (short) (insn->data[2] & 0xFFFF);
outw(value, ADDR_CHAN_REG(REG_C0L, subdev_channel));
// Set Counter Mode Register
- cmReg.value = (sampl_t) (insn->data[1] & 0xFFFF);
+ cmReg.value = (short) (insn->data[1] & 0xFFFF);
cmReg.reg.preloadRegSel = 1; // PR1
outw(cmReg.value, ADDR_CHAN_REG(REG_C0M, subdev_channel));
// Load the pre-laod register 1 high word
- value = (sampl_t) ((insn->data[3] >> 16) & 0xFFFF);
+ value = (short) ((insn->data[3] >> 16) & 0xFFFF);
outw(value, ADDR_CHAN_REG(REG_C0H, subdev_channel));
// Load the pre-laod register 1 low word
- value = (sampl_t) (insn->data[3] & 0xFFFF);
+ value = (short) (insn->data[3] & 0xFFFF);
outw(value, ADDR_CHAN_REG(REG_C0L, subdev_channel));
// Write the Counter Control Register
if (insn->data[3] != 0) {
- value = (sampl_t) (insn->data[3] & 0xFFFF);
+ value = (short) (insn->data[3] & 0xFFFF);
outw(value, ADDR_CHAN_REG(REG_C0C, subdev_channel));
}
break;
PulseTrainGeneration;
// Set Counter Mode Register
- cmReg.value = (sampl_t) (insn->data[1] & 0xFFFF);
+ cmReg.value = (short) (insn->data[1] & 0xFFFF);
cmReg.reg.preloadRegSel = 0; // PR0
outw(cmReg.value, ADDR_CHAN_REG(REG_C0M, subdev_channel));
// Load the pre-laod register 0 high word
- value = (sampl_t) ((insn->data[2] >> 16) & 0xFFFF);
+ value = (short) ((insn->data[2] >> 16) & 0xFFFF);
outw(value, ADDR_CHAN_REG(REG_C0H, subdev_channel));
// Load the pre-laod register 0 low word
- value = (sampl_t) (insn->data[2] & 0xFFFF);
+ value = (short) (insn->data[2] & 0xFFFF);
outw(value, ADDR_CHAN_REG(REG_C0L, subdev_channel));
// Set Counter Mode Register
- cmReg.value = (sampl_t) (insn->data[1] & 0xFFFF);
+ cmReg.value = (short) (insn->data[1] & 0xFFFF);
cmReg.reg.preloadRegSel = 1; // PR1
outw(cmReg.value, ADDR_CHAN_REG(REG_C0M, subdev_channel));
// Load the pre-laod register 1 high word
- value = (sampl_t) ((insn->data[3] >> 16) & 0xFFFF);
+ value = (short) ((insn->data[3] >> 16) & 0xFFFF);
outw(value, ADDR_CHAN_REG(REG_C0H, subdev_channel));
// Load the pre-laod register 1 low word
- value = (sampl_t) (insn->data[3] & 0xFFFF);
+ value = (short) (insn->data[3] & 0xFFFF);
outw(value, ADDR_CHAN_REG(REG_C0L, subdev_channel));
// Write the Counter Control Register
if (insn->data[3] != 0) {
- value = (sampl_t) (insn->data[3] & 0xFFFF);
+ value = (short) (insn->data[3] & 0xFFFF);
outw(value, ADDR_CHAN_REG(REG_C0C, subdev_channel));
}
break;
return insn->n;
}
-static int s526_gpct_winsn(comedi_device * dev, comedi_subdevice * s,
- comedi_insn * insn, lsampl_t * data)
+static int s526_gpct_winsn(struct comedi_device * dev, struct comedi_subdevice * s,
+ struct comedi_insn * insn, unsigned int * data)
{
int subdev_channel = CR_CHAN(insn->chanspec); // Unpack chanspec
- sampl_t value;
+ short value;
printk("s526: GPCT_INSN_WRITE on channel %d\n", subdev_channel);
cmReg.value = inw(ADDR_CHAN_REG(REG_C0M, subdev_channel));
return -EINVAL;
}
- value = (sampl_t) ((*data >> 16) & 0xFFFF);
+ value = (short) ((*data >> 16) & 0xFFFF);
outw(value, ADDR_CHAN_REG(REG_C0H, subdev_channel));
- value = (sampl_t) (*data & 0xFFFF);
+ value = (short) (*data & 0xFFFF);
outw(value, ADDR_CHAN_REG(REG_C0L, subdev_channel));
break;
default: // Impossible
}
#define ISR_ADC_DONE 0x4
-static int s526_ai_insn_config(comedi_device * dev, comedi_subdevice * s,
- comedi_insn * insn, lsampl_t * data)
+static int s526_ai_insn_config(struct comedi_device * dev, struct comedi_subdevice * s,
+ struct comedi_insn * insn, unsigned int * data)
{
int result = -EINVAL;
* "instructions" read/write data in "one-shot" or "software-triggered"
* mode.
*/
-static int s526_ai_rinsn(comedi_device * dev, comedi_subdevice * s,
- comedi_insn * insn, lsampl_t * data)
+static int s526_ai_rinsn(struct comedi_device * dev, struct comedi_subdevice * s,
+ struct comedi_insn * insn, unsigned int * data)
{
int n, i;
int chan = CR_CHAN(insn->chanspec);
return n;
}
-static int s526_ao_winsn(comedi_device * dev, comedi_subdevice * s,
- comedi_insn * insn, lsampl_t * data)
+static int s526_ao_winsn(struct comedi_device * dev, struct comedi_subdevice * s,
+ struct comedi_insn * insn, unsigned int * data)
{
int i;
int chan = CR_CHAN(insn->chanspec);
/* AO subdevices should have a read insn as well as a write insn.
* Usually this means copying a value stored in devpriv. */
-static int s526_ao_rinsn(comedi_device * dev, comedi_subdevice * s,
- comedi_insn * insn, lsampl_t * data)
+static int s526_ao_rinsn(struct comedi_device * dev, struct comedi_subdevice * s,
+ struct comedi_insn * insn, unsigned int * data)
{
int i;
int chan = CR_CHAN(insn->chanspec);
* useful to applications if you implement the insn_bits interface.
* This allows packed reading/writing of the DIO channels. The
* comedi core can convert between insn_bits and insn_read/write */
-static int s526_dio_insn_bits(comedi_device * dev, comedi_subdevice * s,
- comedi_insn * insn, lsampl_t * data)
+static int s526_dio_insn_bits(struct comedi_device * dev, struct comedi_subdevice * s,
+ struct comedi_insn * insn, unsigned int * data)
{
if (insn->n != 2)
return -EINVAL;
return 2;
}
-static int s526_dio_insn_config(comedi_device * dev, comedi_subdevice * s,
- comedi_insn * insn, lsampl_t * data)
+static int s526_dio_insn_config(struct comedi_device * dev, struct comedi_subdevice * s,
+ struct comedi_insn * insn, unsigned int * data)
{
int chan = CR_CHAN(insn->chanspec);
- sampl_t value;
+ short value;
printk("S526 DIO insn_config\n");