Difference between revisions of "Example egpc"

From wiki.emacinc.com
Jump to: navigation, search
(Usage Example. Port Data)
Line 36: Line 36:
 
===Using <code>egpc</code>===
 
===Using <code>egpc</code>===
  
  ./egpc device d/c/i (mask)
+
  ./egpc device d/c/i (arg)
  
 
'''device''' is /dev/porta, /dev/portb or /dev/portc<br />
 
'''device''' is /dev/porta, /dev/portb or /dev/portc<br />
Line 64: Line 64:
 
If a mask is specified then it sets each bit's corresponding pin output latch to high/low accordingly.<br />
 
If a mask is specified then it sets each bit's corresponding pin output latch to high/low accordingly.<br />
 
If a mask is not specified then the current pin state is retrieved.<br />
 
If a mask is not specified then the current pin state is retrieved.<br />
For example, this writes all pin ouput latches on PortC to high.
+
For example, this writes pin output latches on PortC to alternating high and low.
  
  ./egpc /dev/portc d 0xff
+
  ./egpc /dev/portc d 0x55
 +
 
 +
...and this flips the pins; writing all the pins that we just set to low to high and vice-versa.
 +
 
 +
./egpc /dev/portc d 0xaa
  
...and this reads the current pin data state of PortC
+
...and this reads the current pin data state of PortC.
  
 
  ./egps /dev/portc d
 
  ./egps /dev/portc d
Line 74: Line 78:
 
'''Note''' The pin values for Port C are displayed on the board's strip of 8 LEDs. Observe that the LEDs change state when we write to Port C. This only works for Port C, however. Ports A and B must be read with an oscilloscope or multimeter.
 
'''Note''' The pin values for Port C are displayed on the board's strip of 8 LEDs. Observe that the LEDs change state when we write to Port C. This only works for Port C, however. Ports A and B must be read with an oscilloscope or multimeter.
  
===Usage Example. Writing to Port C===
+
===Usage Example. Port Index===
  
We write a data bitmask to Port C. The values are rendered in our LED strip. (note that only PortC is displayed in the LED strip. Ports A or B would require kind of device to read them; a multimeter or oscilloscope or something like that.)
+
./egpc device i (index)
  
./egpc /dev/portc d 0x55
+
If an index is specified then it sets the port's index<br />
 +
If an index is not specified then the port's current index is retrieved.<br />
 +
For example, this sets the index of PortA to 1
  
LEDs 1-8 are lit: 10101010
+
./egpc /dev/porta i 1
  
'''MIKE I was thinking that maybe we could have some kind of general purpose "know your board" images (I have created a few) or wiki pages. They would point out things like the GPIO header and the LED strip.'''
+
...and this reads the current index of PortA
 
 
./egpc /dev/portc d 0xaa
 
  
LEDs 1-8 are lit: 01010101
+
./egpc /dev/porta i

Revision as of 14:18, 27 December 2013

TODO: {{#todo:InProgress(11.13.13-14:31->JG+)|Jgreene|oe 4,oe 5,jg,md,InProgress}}

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, we read/write/configure the 3 ports (ports A, B and C) on the GPIO header.

The egpc project builds one executable: egpc.

Opening, Building and Uploading the Project Files

1. Open the C/C++ editing perspective.

stub

2. Open the project files.

stub

3. Build the project.

stub

4. Upload the executables to the target system.

stub

Usage and Behavior

egpc reads/writes/configures the GPIO ports.

Hardware Requirements

The egpc C example project will run on any EMAC carrier board.

VERIFY THIS

Using egpc

./egpc device d/c/i (arg)

device is /dev/porta, /dev/portb or /dev/portc
d/c/i specifies the port command : d(data), c(configure) or i(index)
mask is a bitmask in hex format in range [0x0,0xff].

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. 1=output and 0=input.
For example, this sets every other pin on PortA to be an output.

./egpc /dev/porta c 0xaa

...and this reads the current pin configuration state of PortA.

./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 PortC to alternating high and low.

./egpc /dev/portc d 0x55

...and this flips the pins; writing all the pins that we just set to low to high and vice-versa.

./egpc /dev/portc d 0xaa

...and this reads the current pin data state of PortC.

./egps /dev/portc d

Note The pin values for Port C are displayed on the board's strip of 8 LEDs. Observe that the LEDs change state when we write to Port C. This only works for Port C, however. Ports A and B must be read with an oscilloscope or multimeter.

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 PortA to 1

./egpc /dev/porta i 1

...and this reads the current index of PortA

./egpc /dev/porta i