User`s manual
80 www.rabbit.com Applications Programming
static const Flex_IOPin *leds[] = {
&flex_digout32,
&flex_digout34,
&flex_digout36,
&flex_digout38,
FLEX_GROUP_END
};
To use I/O groups, we must first create the groups. The switches[] and leds[] arrays contain point-
ers to each of the Flex_IOPin structures for the switches and the LEDs, respectively. Note that these are
arrays of Flex_IOPin pointers. Also note that each group is terminated by FLEX_GROUP_END; this
macro allows the I/O group API functions to know when they have reached the end of the I/O group.
Note the flexibility that I/O groups allow. To change which inputs you want to use, you can simply change
the members of the switches I/O group. Once this change has been made, it is not necessary to change any
other code in the sample.
We will now skip through the sample to just before the main while() loop.
// Initialize the output LEDs to turn off
flexDigOutGroup16(leds, 0x0f);
Remember how we individually initialized each of the LEDs in the previous section? With the “leds” I/O
group, we can initialize the LEDs in a single statement. Both the flexDigOutGroup16() and
flexDigInGroup16() functions expect an array of Flex_IOPin pointers as the first argument. The
second parameter in flexDigOutGroup16() is an unsigned integer. This integer provides the values
that will be output to the pins in the group. The least significant bit in the integer provides the value for the
first output in the group; the next least significant bit provides the value for the second output in the group,
etc:
0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1
&flex_digout32
FLEX_GROUP_END
&flex_digout34
&flex_digout36
&flex_digout38