Difference between revisions of "Example io demo UPDATE 2019"

From wiki.emacinc.com
Jump to: navigation, search
Line 7: Line 7:
 
|description=This is a guide to the <code>io_demo</code> C example project included in the EMAC OE SDK.
 
|description=This is a guide to the <code>io_demo</code> C example project included in the EMAC OE SDK.
 
}}
 
}}
This demo covers basic gpio usage for the IPAC single board computer, and 150 and 200 series carrier boards. This demo first cover gpio manipulation through the Linux terminal and then demonstrates gpio usage in a C program using an io example program.
+
This demo covers basic GPIO usage for the IPAC single board computer, and 150 and 200 series carrier boards. This demo first cover GPIO manipulation through the Linux terminal and then demonstrates gpio usage in a C program using an io example program.
  
 
===Hardware Requirements===
 
===Hardware Requirements===
Line 30: Line 30:
  
 
=== Setup ===
 
=== Setup ===
If you haven't already, please review the EMAC_OE_SDK [[Getting_Started_with_the_EMAC_OE_SDK| "getting started page"]]
+
If you haven't already, please review the EMAC_OE_SDK [[Getting_Started_with_the_EMAC_OE_SDK| "getting started" page]]. EMAC_OE_SDK will need to be installed and serial and network connections will need to be established between the developer machine and the target device.See the [[Serial Connections]] or [[Network Connections]] page for more information on how to connect to the target EMAC product using a serial port or Ethernet connection.
See the [[Serial Connections]] or [[Network Connections]] page for more information on how to connect to the target EMAC product using a serial port or Ethernet connection.
 
  
== Usage and Behavior ==
+
== GPIO manipulation  through Linux Terminal ==  
 +
GPIOs can be manipulated directly through the target devices serial terminal.
 +
 
 +
== GPIO manipulation in C ==
 +
A more common manipulation of GPIOs is through a C program. The following example will demonstrated GPIO manipulation using the Libgpiod libary.
 +
 
 +
<cl>
 +
1. In a terminal, navigate to the base directory of the project.
 +
{{note | If the target board being used is <tt>x86</tt>, then change all occurrences of <tt>arm</tt> in the following sections below to <tt>x86</tt>.}}
 +
* Create a build directory for cross compiling.
 +
{{cli | username=developer | hostname=ldc | pwd=~/projects/hello_emac | mkdir hello_emac-build-arm }}
 +
* Change directories into the newly created directory.
 +
{{cli | username=developer | hostname=ldc | pwd=~/projects/hello_emac | cd hello_emac-build-arm }}
 +
* Run cmake using the target architecture.
 +
{{cli | username=developer | hostname=ldc | pwd=~/projects/hello_emac/hello_emac-build-arm | 1 = cmake .. -DARCH:STRING=arm }}
 +
* Compile the code using make.
 +
{{cli | username=developer | hostname=ldc | pwd=~/projects/hello_emac/hello_emac-build-arm | make }}
 +
 
 +
The <code> make </code> command creates the target executable in the <code> hello_emac-build-arm </code> directory.
 +
* Now copy the executable to the target board. For information on copying the executable file, see the [[ #Transferring_Files | Transferring Files ]] section.
 +
</cl>
 
[[ #Transferring_Files | Transferring Files ]]
 
[[ #Transferring_Files | Transferring Files ]]
 
[[Getting_Started_with_the_EMAC_OE_SDK Transferring_Files | SDK Install]]
 
[[Getting_Started_with_the_EMAC_OE_SDK Transferring_Files | SDK Install]]

Revision as of 10:34, 3 July 2019

TODO: {{#todo:SEOKWREV (01.03.14-16:47->JG+);(01.03.14-17:35->MD+);(04.07.14-09:45->BS+);(04.09.14-16:15->BS+)|Jgreene|oe 4,oe 5,jg,md,SEOKWREV,ky,bs}}

This demo covers basic GPIO usage for the IPAC single board computer, and 150 and 200 series carrier boards. This demo first cover GPIO manipulation through the Linux terminal and then demonstrates gpio usage in a C program using an io example program.

Hardware Requirements

To use the io demo program you will need the following target hardware.

  • An EMAC 150 series carrier board with a compatible SoM

OR

  • An EMAC 200 series carrier board with a compatible SoM

OR

  • an IPAC

AND

  • additional components to establish to serial and Ethernet connections for your target hardware

Software Requirments

These tools should already be installed if you installed the EMAC SDK using the automatic installer.

Setup

If you haven't already, please review the EMAC_OE_SDK "getting started" page. EMAC_OE_SDK will need to be installed and serial and network connections will need to be established between the developer machine and the target device.See the Serial Connections or Network Connections page for more information on how to connect to the target EMAC product using a serial port or Ethernet connection.

GPIO manipulation through Linux Terminal

GPIOs can be manipulated directly through the target devices serial terminal.

GPIO manipulation in C

A more common manipulation of GPIOs is through a C program. The following example will demonstrated GPIO manipulation using the Libgpiod libary.


  1. In a terminal, navigate to the base directory of the project.



    NOTE
    If the target board being used is x86, then change all occurrences of arm in the following sections below to x86.
  2. Create a build directory for cross compiling.

    developer@ldc:~/projects/hello_emac# mkdir hello_emac-build-arm
  3. Change directories into the newly created directory.

    developer@ldc:~/projects/hello_emac# cd hello_emac-build-arm
  4. Run cmake using the target architecture.

    developer@ldc:~/projects/hello_emac/hello_emac-build-arm# cmake .. -DARCH:STRING=arm
  5. Compile the code using make.

    developer@ldc:~/projects/hello_emac/hello_emac-build-arm# make

    The make command creates the target executable in the hello_emac-build-arm directory.

  6. Now copy the executable to the target board. For information on copying the executable file, see the Transferring Files section.

Transferring Files SDK Install