From: David Schleef Date: Wed, 5 Sep 2001 23:34:27 +0000 (+0000) Subject: Generic hacking X-Git-Tag: r0_7_61~121 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=a5a4ed46eebf355cf4689af7cf80c797603ce522;p=comedi.git Generic hacking --- diff --git a/comedi/drivers/mpc8260cpm.c b/comedi/drivers/mpc8260cpm.c index bed1f4e4..3434fc0d 100644 --- a/comedi/drivers/mpc8260cpm.c +++ b/comedi/drivers/mpc8260cpm.c @@ -36,6 +36,8 @@ #include +extern unsigned long mpc8260_dio_reserved[4]; + typedef struct{ int data; @@ -50,6 +52,7 @@ comedi_driver driver_mpc8260cpm={ attach: mpc8260cpm_attach, detach: mpc8260cpm_detach, }; +COMEDI_INITCLEANUP(driver_mpc8260cpm); static int mpc8260cpm_dio_config(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data); static int mpc8260cpm_dio_bits(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data); @@ -93,23 +96,67 @@ static int mpc8260cpm_detach(comedi_device *dev) return 0; } +static unsigned long *cpm_pdat(int port) +{ + switch(port){ + case 0: + return &io->iop_pdata; + case 1: + return &io->iop_pdatb; + case 2: + return &io->iop_pdatc; + case 3: + return &io->iop_pdatd; + } +} + static int mpc8260cpm_dio_config(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data) { int n; unsigned int d; + unsigned int mask; + int port; + if(insn->n!=1)return -EINVAL; - return 2; + port = (int)s->private; + mask = 1<chanspec); + if(mask&cpm_reserved_bits[port]){ + return -EINVAL; + } + + switch(data[0]){ + case COMEDI_OUTPUT: + s->io_bits |= mask; + break; + case COMEDI_INPUT: + s->io_bits &= ~mask; + break; + default: + return -EINVAL; + } + + switch(port){ + case 0: return &io->iop_pdira; + case 1: return &io->iop_pdirb; + case 2: return &io->iop_pdirc; + case 3: return &io->iop_pdird; + } + + + return 1; } static int mpc8260cpm_dio_bits(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data) { - int n; - unsigned int d; + int port; + unsigned long *p; + + p = cpm_pdat((int)s->private); + + return 2; } -COMEDI_INITCLEANUP(driver_mpc8260cpm); -