- From: Ian Abbott <abbotti_at_mev.co.uk>
- Date: Mon, 31 Jul 2006 11:37:24 +0100
On 28/07/06 23:42, Farhan Rizwi wrote:
> On Fri, 28 Jul 2006 08:16 pm, you wrote:
>> Which driver are you using? I cannot see any driver in the standard
>> Comedi package that includes support for multiqpci. The closest match
>> is the multiq3 driver, but that one is for an ISA card, not a PCI card.
>
> A few years ago someone in my lab ported it from Windows. Its attached.
Do they still work there and can they fix it, or has it been dumped on
you to get working?
> // Standardized counter configuration options.
>
> typedef union {
> uint16_t wval;
> struct {
> // BITORDER == MSB_FIRST //--------------------------
> unsigned spare15 : 1; // spare.
> unsigned IntSrc : 2; // Interrupt source:
> unsigned LatchSrc : 2; // Latch trigger source.
> unsigned LoadSrc : 2; // Preload trigger source.
> unsigned IndexSrc : 2; // Index source.
> unsigned IndexPol : 1; // Index polarity.
> unsigned ClkSrc : 2; // Clock source.
> unsigned ClkPol : 1; // Clock polarity.
> unsigned ClkMult : 2; // Clock multiplier.
> unsigned ClkEnab : 1; // Clock enable (LSB)
> } bits;
> } COUNTER_SETUP;
>
> ///////////////////////////////////////////////////////////////////////////
> // Counter control register data structures.
>
> // Layout of CRA register.
> typedef union {
> uint16_t wval;
> struct {
> //#elif BITORDER == MSB_FIRST //---------------------------
> unsigned BIndexSrc : 2; // B index source.
> unsigned BClkSrc : 2; // B clock source.
> unsigned AIndexPol : 1; // A index polarity.
> unsigned ALoadSrc : 2; // A preload trigger source.
> unsigned AClkMult : 2; // A clock multiplier.
> unsigned AIntSrc : 2; // A interrupt source.
> unsigned AClkPol : 1; // A clock polarity.
> unsigned AIndexSrc : 2; // A index source.
> unsigned AClkSrc : 2; // A clock source (LSB).
> } bits;
> } CRA_LAYOUT;
>
> // Layout of CRB register. Note that this is the write layout; the read
> // layout differs because the most significant 3 bits have differing read
> // and write definitions.
> typedef union {
> uint16_t wval;
> struct {
> unsigned ClrSelInt : 1; // Clear selected interrupts.
> unsigned BSelInt : 1; // B interrupt reset enable.
> unsigned ASelInt : 1; // A interrupt reset enable.
> unsigned AClkEnab : 1; // A clock enable.
> unsigned BIntSrc : 2; // B interrupt source.
> unsigned LatchSrc : 2; // Latch source select for A and B.
> unsigned BLoadSrc : 2; // B preload trigger source.
> unsigned BClrOnOvrA : 1; // B resets on A overflow.
> unsigned BClkMult : 2; // B clock multiplier.
> unsigned BClkEnab : 1; // B clock enable.
> unsigned BIndexPol : 1; // B index polarity.
> unsigned BClkPol : 1; // B clock polarity (LSB).
> } bits;
> } CRB_LAYOUT;
I suggest you rewrite the parts of the driver that use the above types
COUNTER_SETUP, CRB_LAYOUT, and CRA_LAYOUT to avoid the use of
bit-fields. Using bit-fields to describe hardware register layouts is
not a good idea because they are inherently non-portable for externally
defined layouts. In fact, the order of the bits in the above types
appears to be the reverse of what it should be for gcc on i386. Perhaps
it was originally ported to an architecture that lays the bit-fields out
MSB-first. Besides, the driver code currently uses a confusing mixture
of bit-fields and bit-wise logical and shift operations, so changing the
code to avoid bit-fields would make it easier to understand.
--
-=( Ian Abbott _at_ MEV Ltd. E-mail: <abbotti_at_mev.co.uk> )=-
-=( Tel: +44 (0)161 477 1898 FAX: +44 (0)161 718 3587 )=-
Received on 2006-07-31Z09:37:24