This has the following effect:
• Peripheral Reset line (PRESET) is pulsed low,
• PCTL line is placed in the clear state,
• If the DOUT CLEAR jumper is installed, the Data Out lines are all
cleared (set to logical 0),
• Interrupts from the controlled interface are disabled on Series 300
systems.
Lines that are left unchanged are:
• CTLO and CTL1 output lines,
• I/O line,
• Data Out lines if the DOUT CLEAR jumper is not installed.
Performing Data Transfers
The
read
and
write
system calls are used to transfer ASCII data to and from
the GPIO interface. The following code segment illustrates how to use these
routines to write 16 bytes to the interface, then read 16 bytes back in.
#include <fcntl.h>
#include <errno.h>
mainO
{
}
int
eid;
/*entity identifier*/
char read_buffer [16] , write_buffer [16] ; /*buffers to hold data*/
if «eid
=
open(" /dev/raw_gpio",
O_RDWR»
==
-1) {
printf("open failed, errno
=
%d\n", errno);
exit (2) ;
}
io_reset(eid);
write_buffer
=
"message to write";
write( eid,write_buffer, 16);
read( eid, read_buffer, 16);
printf("%s", read_buffer);
/*data message to send*/
/*send message*/
/*receive message*/
/*print received message*/
4-4
Controlling the GPIO Interface