Re: Change of state interrupts

Ian Abbott wrote:
> On 11/10/2007 02:31, Frank Mori Hess wrote:
>> On Wednesday 10 October 2007 04:23, Robin Cornelius wrote:
>>> Hi everyone,
>>>
>>> I've just started using comedi and I am using a adlink pci7348 card
>>> (which is not supported) so i hacked up the PCI-7296 driver go get it
>>> working, which it does :-) (Infact no modification for basic DIO, just
>>> swap all "adl_pci7296" for "adl_pci7348" and its a go (infact this
>>> should also work perfectly with the adl_pci7396).
>>
>> If the boards are essentially the same programming-wise, they should
>> both be supported by the same driver, as opposed to adding a second
>> nearly identical one.
>
> The register layout differences between PCI-72xx and PCI-73xx look
> substantial enough to make a separate driver, and the PCI-73xx doesn't
> even pretend to behave like a bunch of 8255 chips.
The PCI7348 and PCI7396 does behave as 2 or 4 8255 Chips. I am using the
7296 driver with code ripped from 7296. The 73XX has 4 8255 chips at
base_address +

#define PORT1A 0x00
#define PORT2A 0x10
#define PORT3A 0x20
#define PORT4A 0x30

And i am initalising them all with

 s = dev->subdevices + 0;
                        subdev_8255_init(dev, s, NULL, (unsigned
long)(dev->iobase + PORT1A));

                        s = dev->subdevices + 1;
                        subdev_8255_init(dev, s, NULL, (unsigned
long)(dev->iobase + PORT2A));


And that works perfectly with comedi for digital INs and outs, i set and
get data no problem from userspace.

I admit it is not a contigous IO block to access the 4 8255s but it does
work with the 8255 driver.

The main difference at this level is the address of the 4 8255's on the
7296 they are

#define PORT1A 0
#define PORT2A 4
#define PORT3A 8
#define PORT4A 12

which ARE a contigous block

Looking at the code further to simply things it probably is a very good
idea to keep the 7348/96 as a separate driver.

>
> However, it should be straightforward to add support for PCI-7248 and
> PCI-7224 to the adl_pci7296 driver (and possibly rename it?).  These
> cards also have an 8254 counter/timer chip with one channel clocked
> from an external input and two cascaded channels clocked from a 2 MHz
> clock.  The first channel with an external clock input would be useful
> to support, the other two are not that useful for Comedi, except for
> generating interrupts at a regular rate.  They also have a strange
> interrupt multiplexer arrangement, with six interrupt sources,
> partitioned into two groups of three, with up to one interrupt source
> selectable from each group.
>
As far as i can tell having 24/48 or 96 channels does not seem to bother
the drivers, although it should be detected for good practice I have
seen no trouble initalising 4 8255's even though I only have 2. So its
pretty trival to group the cards together as with the 7224/7248/7296,
these should indeed be a 72xx driver supporting all 3 cards. If the
driver supports all 3 options it will know from device ID how many
channels it actually has fitted to the card. Same applies for the
7348/96 I am playing with, one driver does both cards.

Yes the interrupt sources are interesting, perhapses it would be useful
to support some of them, COS and the trigger on particular ports are
pretty useful!

>>> Anyway the 7348 supports a change of state (COS) interrupt. I have
>>> implemented the IQR handler but I am unsure what to do next. I have
>>> read
>>> the documentation other examples but I do not fully understand the
>>> (comedi) driver level concepts still. How should i handle the COS
>>> event.
>>> Ideally when this happens the event needs to trigger a call back
>>> ASAP to
>>> minimise latency. I see mention of callbacks but can't see exactly what
>>> I want. Can someone give me some pointers on the correct way to handle
>>> this and pass the event back through comedi. Should i be using the
>>> s->events->async stuff?
>>
>> The way it's been done before is to add support for an input command,
>> that generates a bogus sample every time the event occurs.
>
> E.g. the comedi_parport driver, the amplc_pc236 driver, or for a
> slightly more complicated version, the amplc_dio200 driver.

Great, thanks!
>
>>> One final problem is that I seem to be getting continuous interrupts
>>> from the card, I believe I am setting the interrupt masks correctly and
>>> I am ACKing the interrupt correctly but it fires of at a enormous rate.
>>
>> PCI interrupts can be shared, could it be another device generating
>> the interrupts?  You might also check if there is a second bit in a
>> register somewhere you need to use to clear the interrupt, like in
>> the pci chip.
>
> The cards have a "clear interrupt" register that needs to be written to.
>
> (I don't have any of these cards, btw. I was just curious and
> downloaded the manuals!)
yea thats the one i am writing to when i mean i am ACKing the interrupt.
I have set all the COS masks to 0 to disable change of state interrupts
but they just keep coming!.

Thanks

Robin




-- 
Dr Robin Cornelius
Design Engineer
Hirst Magnetic Instruments Ltd
(UK Magnetics Society management committee member)

Tel: +44 (0) 1326 372734      www.hirst-magnetics.com
Fax: +44 (0) 1326 378069      www.gaussmeter.co.uk

Tesla House, Tregoniggie Industrial Estate
Falmouth, Cornwall, TR11 4SN, U.K.

Reg No: 1564814 England
VAT Registered: GB730 0277 74 

Received on 2007-10-11Z09:11:02