To illustrate:
int eid;
/*entity identifier*/
int value, bits;
eid
=
open (II/dev/raw_gpioll, O_RDWR);
/*open interface file*/
value
=
gpio_get_status(eid);
/*look at STIO and STI1*/
bits
=
value
&
03 /*clear all but the 2 least significant bits*/
if (bits
==
3)
/*and see if they are both set*/
/*insert code that handles case when both STIO and STI1 are asserted*/
else if (bits
==
1)
/*only STIO is asserted*/
/*insert code that handles case when STIO is asserted*/
else if (bits
2)
/*only STI1 is asserted*/
/*insert code that handles case when STI1 is asserted*/
else
/*neither are asserted*/
/*insert code that handles case when neither STIO nor STI1 is asserted*/
Controlling Data Path Width
DIL subroutine
io_width_ctl
is used to specify 8-bit or 16-bit data path
widths for the GPIO interface. The call has the following form:
where eid is the entity identifier for an open GPIO interface file and width is
either 8 or 16. If any other width value is specified,
io_width_ctl
returns -1
and sets errno to
EINVAL.
The GPIO interface is set to a default 8-bit path
width when the interface file is opened.
Controlling the GPIO Interface
4-7