Difference between revisions of "Example egpc"

From wiki.emacinc.com
Jump to: navigation, search
(Using egpc)
(Using egpc)
Line 34: Line 34:
 
===Using <code>egpc</code>===
 
===Using <code>egpc</code>===
  
  ./egpc device d/c/i (writearg)
+
  ./egpc device d/c/i (mask)
  
 
'''device''' is /dev/porta, /dev/portb or /dev/portc<br />
 
'''device''' is /dev/porta, /dev/portb or /dev/portc<br />
'''d/c/i''' specifies the port command : d(data), c(configure), i(index)<br />
+
'''d/c/i''' specifies the port command : d(data), c(configure) or i(index)<br />
'''writearg''' is a bitmask in hex format.  
+
'''mask''' is a bitmask in hex format in range [0x0,0xff].  
  
If '''bitmask''' is specified then we write that value to the specified port using the specified port command. If it isn't then we read the port and print it's value.
+
Our three commands work like this:
 +
 
 +
'''c''' (mask)                     
 +
Configures the pins for input/output if a mask is specified.
 +
Returns the current configuration if no mask is specified.  
 +
mask is input/output bitmask                 
 +
1 = output 0 = input                         
 +
ex:                                         
 +
./egpc /dev/porta c 0xaa                     
 +
sets every other pin on PortA to be an output.       
 +
./egpc /dev/porta c                           
 +
reads the current pin configuration state of PortA.
  
 
===Usage Example. Writing to Port C===
 
===Usage Example. Writing to Port C===

Revision as of 13:32, 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.

Using egpc

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

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].

Our three commands work like this:

c (mask) Configures the pins for input/output if a mask is specified. Returns the current configuration if no mask is specified. mask is input/output bitmask 1 = output 0 = input ex:

./egpc /dev/porta c 0xaa                       

sets every other pin on PortA to be an output.

./egpc /dev/porta c                            

reads the current pin configuration state of PortA.

Usage Example. Writing to Port C

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 /dev/portc d 0x55

LEDs 1-8 are lit: 10101010

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.

./egpc /dev/portc d 0xaa

LEDs 1-8 are lit: 01010101