Xenomai  3.1
Channels and ranges



Channels More...

Collaboration diagram for Channels and ranges:

Data Structures

struct  a4l_channel
 Structure describing some channel's characteristics. More...
 
struct  a4l_channels_desc
 Structure describing a channels set. More...
 
struct  a4l_range
 Structure describing a (unique) range. More...
 

Macros

#define A4L_CHAN_GLOBAL   0x10
 Internal use flag (must not be used by driver developer)
 
#define A4L_RNG_GLOBAL   0x8
 Internal use flag (must not be used by driver developer)
 
#define RANGE(x, y)
 Macro to declare a (unique) range with no unit defined.
 
#define RANGE_V(x, y)
 Macro to declare a (unique) range in Volt.
 
#define RANGE_mA(x, y)
 Macro to declare a (unique) range in milliAmpere.
 
#define RANGE_ext(x, y)
 Macro to declare a (unique) range in some external reference.
 
#define A4L_RNG_GLOBAL_RNGDESC   0
 Constant to define a ranges descriptor as global (inter-channel)
 
#define A4L_RNG_PERCHAN_RNGDESC   1
 Constant to define a ranges descriptor as specific for a channel.
 
#define RNG_GLOBAL(x)
 Macro to declare a ranges global descriptor in one line.
 

Channel reference

Flags to define the channel's reference

#define A4L_CHAN_AREF_GROUND   0x1
 Ground reference.
 
#define A4L_CHAN_AREF_COMMON   0x2
 Common reference.
 
#define A4L_CHAN_AREF_DIFF   0x4
 Differential reference.
 
#define A4L_CHAN_AREF_OTHER   0x8
 Misc reference.
 

Channels declaration mode

Constant to define whether the channels in a descriptor are identical

#define A4L_CHAN_GLOBAL_CHANDESC   0
 Global declaration, the set contains channels with similar characteristics.
 
#define A4L_CHAN_PERCHAN_CHANDESC   1
 Per channel declaration, the decriptor gathers differents channels.
 

Detailed Description



Channels

According to the Analogy nomenclature, the channel is the elementary acquisition entity. One channel is supposed to acquire one data at a time. A channel can be:

Channels are defined by their type and by some other characteristics like:

Such parameters must be declared for each channel composing a subdevice. The structure a4l_channel (struct a4l_channel) is used to define one channel.

Another structure named a4l_channels_desc (struct a4l_channels_desc) gathers all channels for a specific subdevice. This latter structure also stores :

Usually the channels descriptor looks like this:

struct a4l_channels_desc example_chan = {
        mode: A4L_CHAN_GLOBAL_CHANDESC, -> Global declaration
                                              mode is set
        length: 8, -> 8 channels
        chans: {
                {A4L_CHAN_AREF_GROUND, 16}, -> Each channel is 16 bits
                                                  wide with the ground as
                                                  reference
        },
};

Ranges

So as to perform conversion from logical values acquired by the device to physical units, some range structure(s) must be declared on the driver side.

Such structures contain:

These range structures must be associated with the channels at subdevice registration time as a channel can work with many ranges. At configuration time (thanks to an Analogy command), one range will be selected for each enabled channel.

Consequently, for each channel, the developer must declare all the possible ranges in a structure called struct a4l_rngtab. Here is an example:

struct a4l_rngtab example_tab = {
    length: 2,
    rngs: {
        RANGE_V(-5,5),
        RANGE_V(-10,10),
    },
};

For each subdevice, a specific structure is designed to gather all the ranges tabs of all the channels. In this structure, called struct a4l_rngdesc, three fields must be filled:

Most of the time, the channels which belong to the same subdevice use the same set of ranges. So, there is no need to declare the same ranges for each channel. A macro is defined to prevent redundant declarations: RNG_GLOBAL().

Here is an example:

struct a4l_rngdesc example_rng = RNG_GLOBAL(example_tab);