This is a guide to the
egpc C example project included in the EMAC OE SDK.
egpc is an application for reading/writing/configuring gpio character devices. Specifically, it will read/write/configure the 3 ports (ports A, B and C) on the GPIO header.
egpc project builds one executable:
Opening, Building and Uploading the Project Files
For information on opening the project from within Eclipse, please see Importing the EMAC OE SDK Projects with Eclipse. Then, follow Using the EMAC OE SDK Projects with Eclipse for information on how to build, upload and execute the example.
Makefile can be used with the
make command from the commandline to build and upload the example. For more information on this method, please see Using EMAC OE SDK Example Projects.
Usage and Behavior
egpc reads/writes/configures the GPIO ports.
egpc C example project will run on any EMAC carrier board which has one or more GPIO.
./egpc device [d/c/i] arg
d/c/i specifies the port command :
c (configure) or
arg is either a port index or a bitmask. The bitmask is in hex format, range
Usage Example. Port Configuration
./egpc device c [mask]
If a mask is specified, it configures the pins for input/output.
If no mask is specified, it returns the current configuration.
mask is an input/output bitmask.
For example, this sets every other pin on Port A to be an output.
./egpc /dev/porta c 0xaa
...and this reads the current pin configuration state of Port A.
./egpc /dev/porta c 0xaa
Usage Example: Port Data
./egpc device d [mask]
If a mask is specified then it sets each bit's corresponding pin output latch to high/low accordingly.
If a mask is not specified then the current pin state is retrieved.
For example, this writes pin output latches on Port C to alternating high and low.
./egpc /dev/portc d 0x55
This flips the pins, writing all the pins that were set low in the previous command to high, and vice-versa:
./egpc /dev/portc d 0xaa
This reads the current pin data state of Port C.
./egps /dev/portc d
The pin values for Port C are displayed on the board's strip of 8 LEDs. Observe that the LEDs change state when a new value is written to Port C. This only works for Port C, however. Ports A and B must be read with an oscilloscope, multimeter, logic analyzer or similar device.
Usage Example. Port Index
./egpc device i (index)
If an index is specified then it sets the port's index
If an index is not specified then the port's current index is retrieved.
For example, this sets the index of Port A to 1
./egpc /dev/porta i 1
...and this reads the current index of Port A
./egpc /dev/porta i
egpc is an application which demonstrates reading, writing and configuring the GPIO ports.