Difference between revisions of "Example io demo UPDATE 2019"

From wiki.emacinc.com
Jump to: navigation, search
 
(70 intermediate revisions by the same user not shown)
Line 9: Line 9:
 
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.
  
 +
GPIO control is accomplished through use of the libgpiod driver, as a result only the libgpiod library will be covered in this tutorial. For manipulation of non-GPIO peripherals use sysfs.
 +
 +
 
 
===Hardware Requirements===
 
===Hardware Requirements===
 
 
To use the '''io demo''' program you will need the following target hardware.
 
To use the '''io demo''' program you will need the following target hardware.
  
 
* An EMAC 150 series carrier board with a compatible SoM <br />
 
* An EMAC 150 series carrier board with a compatible SoM <br />
OR <br />
+
'''OR''' <br />
 
* An EMAC 200 series carrier board with a compatible SoM <br />
 
* An EMAC 200 series carrier board with a compatible SoM <br />
OR
+
'''OR'''
* an IPAC <br />
+
* An IPAC single board computer <br />
AND
+
'''AND'''
 
* additional components to establish to serial and Ethernet connections for your target hardware <br />
 
* additional components to establish to serial and Ethernet connections for your target hardware <br />
  
Line 33: Line 35:
  
 
== GPIO manipulation  through Linux Terminal ==  
 
== GPIO manipulation  through Linux Terminal ==  
GPIOs can be manipulated directly through the target devices serial terminal.
+
GPIOs can be manipulated directly through the target devices serial terminal. The Libgpiod libary is used for this purpose. Linux terminal commands are defined in the libgpiod github readme (https://git.kernel.org/pub/scm/libs/libgpiod/libgpiod.git/tree) and are listed here for convenience:
 +
 
 +
"There are currently six command-line tools available: <br />
 +
 
 +
'''gpiodetect''' - list all gpiochips present on the system, their names, labels and number of GPIO lines
 +
 
 +
'''gpioinfo'''  - list all lines of specified gpiochips, their names, consumers, direction, active state and additional flags
 +
 
 +
'''gpioget'''    - read values of specified GPIO lines
 +
 
 +
'''gpioset'''    - set values of specified GPIO lines, potentially keep the lines exported and wait until timeout, user input or signal
 +
 
 +
'''gpiofind'''  - find the gpiochip name and line offset given the line name
 +
 
 +
'''gpiomon'''    - wait for events on GPIO lines, specify which events to watch,how many events to process before exiting or if the events should be reported to the console"
  
 +
In libgpiod ports and pins correspond to gpiochips and lines respectively. GPIO chip numbers are assigned by the kernel, and are hardware depended.
 
== GPIO manipulation in C ==
 
== 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.
 
A more common manipulation of GPIOs is through a C program. The following example will demonstrated GPIO manipulation using the Libgpiod libary.
  
On the target device:
+
'''Program Setup''' <br \>
 +
 
 +
''On the target device'':
 
<cl>
 
<cl>
1. Login
+
1. Login, the default username and password is give below:
* Change the file to read write if required
+
<syntaxhighlight lang="text">
 +
username: root
 +
password: emac_inc
 +
</syntaxhighlight>
 +
* Change the file to read write by entering '''oemntrw''' into the device terminal.
 +
{{cli | oemntrw | hostname=somimx6ul}}
 +
 
 +
{{note|This will only change the root filesystem to read-write for the current boot.  When the system is rebooted, the root filesystem will once again be mounted read-only.}}
 +
* Obtain the device IP-address by entering '''ifconfig''' into the terminal. This is needed for device configuration in Qt Creator below.<br \>
 +
<syntaxhighlight lang=console highlight=3>
 +
root@emac-oe:~# ifconfig
 +
eth0      Link encap:Ethernet  HWaddr 00:50:C2:E6:60:F4
 +
          inet addr:10.0.2.100  Bcast:10.0.255.255  Mask:255.255.0.0
 +
          inet6 addr: fe80::5054:ff:feb1:f83e/64 Scope:Link
 +
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
 +
          RX packets:1825 errors:0 dropped:0 overruns:0 frame:0
 +
          TX packets:553 errors:0 dropped:0 overruns:0 carrier:0
 +
          collisions:0 txqueuelen:1000
 +
          RX bytes:139124 (135.8 KiB)  TX bytes:50603 (49.4 KiB)
 +
          Interrupt:25 Base address:0xc000
 +
 
 +
lo        Link encap:Local Loopback
 +
          inet addr:127.0.0.1  Mask:255.0.0.0
 +
          inet6 addr: ::1/128 Scope:Host
 +
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
 +
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
 +
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
 +
          collisions:0 txqueuelen:0
 +
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
 +
</syntaxhighlight>
 
</cl>
 
</cl>
<cl>
+
<br />
1. Open qt Creator
+
'''On development machine''': <br />
* Create a new project
+
<ol>
*select '+ New Project' on the 'Welcome' window, the New Project window will appear.
+
<li>Open Qt Creator</li>          <br />
*Under Projects select Non-Qt Project, Under the middle window select Plain C Application, Click 'Choose...', The Location window will appear.
+
</ol>
*Give your project a name, and choose a Create-in location, Click Next > to advance to the Build System window.
+
'''''Option 1:'''''
*On the Build System Window choose either the qmake or cmake option (both will be covered in this tutorial), Click Next > to advance to the Kits window.
+
 
*On the Kits window check only ARM Qt5, Click Next >  to advance to the Summary window
+
<ol start = 2>
*The options on the Summary window will default to <None>, Click Finish. Your Project will now be generated.
+
<li>Create a qmake project</li>
* Depending on whether you selected the qmake or cmake option the build files (project_name.pro and CMakeLists.txt respectively) will need to be configured.
+
*select '''+ New Project''' on the 'Welcome' window, the New Project window will appear.
*For the qmake option copy and paste the following into your .pro file.
+
*Under Projects select '''Non-Qt Project''', Under the middle window select '''Plain C Application''', Click '''Choose...''', The Location window will appear.
*For the cmake option copy and paste the following into your CMakeLists.txt file.
+
*Name your project '''LibGPIOd_example''', and choose a Create-in location, Click '''Next >''' to advance to the Build System window.
* Add the Libgpiod_example .h file
+
*On the Build System Window choose the '''qmake''' option, Click '''Next >''' to advance to the Kits window.
*With you project selected, click File->New Fileor Project, the New File or Project window will appear.
+
*On the Kits window check only '''ARM Qt5''', '''Click Next >''' to advance to the Summary window
*Under Files and Classes select General, and in the middle column select Empty file, Click Choose..., The Location window will appear
+
*The options on the Summary window will default to '''<None>'', Click '''Finish'''. Your Project will now be generated.
*Name the file Libgpiod_example.h and use the default Path, Click Next> to advance to the Summary window
+
<li>Modify the qmake the build file ('''project_name.pro''').</li>
*Click Finish, the file will now open.
+
*Copy and paste the following into your .pro file.
*Copy and paste the following into Libgpiod_example.h file
+
<syntaxhighlight lang="text">
*Save the file, by click File->Save All, the file will now be added to your project under Libgpiod_example->Headers
+
TEMPLATE = app
* Add the Libgpiod_example .c file
+
CONFIG += console
*repeat same steps as for the .h file, but replace the file name enter Libgpiod_example.c and Copy and paste the following
+
CONFIG -= app_bundle
*select File->Save All
+
CONFIG -= qt
* Open main.c under Libgpiod_example->Sources and copy and paste the following
+
LIBS +=  -lgpiod
The main.c program must be configured to run for your target device. In the main.c file select your target device by un-commenting the #define preprocessor directive corresponding to the device you're using. All other devices should be commented out.  
+
SOURCES += main.c \
 +
    EMAC_Libgpiod.c
 +
target.path=/home/developer
 +
INSTALLS += target
 +
HEADERS += \
 +
    EMAC_Libgpiod.h
 +
 
 +
</syntaxhighlight>
 +
<li>Add the EMAC_Libgpiod.h file</li>
 +
*With you project selected, click '''File->New File or Project''', the New File or Project window will appear.
 +
*Under Files and Classes select General, and in the middle column select '''Empty file''', Click '''Choose...''', The Location window will appear
 +
*Name the file '''EMAC_Libgpiod.h''' and choose your project location as the path, Click '''Next>''' to advance to the Summary window
 +
*Click '''Finish''', the file will now open.
 +
*Copy and paste the provided .h file, [http://git.emacinc.com/OE/qt-creator-example-projects/raw/master/libgpiod_io_example/EMAC_Libgpiod.h EMAC_Libgpiod.h] into
 +
*Save the file, by click '''File->Save All''', the file will now be added to your project under '''Libgpiod_example->Headers'''
 +
<li>Add the EMAC_Libgpiod.c file</li>
 +
*repeat same steps as for the .h file, but replace the file name enter '''EMAC_Libgpiod.c''' and Copy and paste the provided [http://git.emacinc.com/OE/qt-creator-example-projects/raw/master/libgpiod_io_example/EMAC_Libgpiod.c EMAC_Libgpiod.c file]
 +
*select '''File->Save All'''
 +
</ol>
 +
'''Option 2:'''
 +
<ol start = 2>
 +
<li>Create a cmake project</li>
 +
*select '''+ New Project''' on the 'Welcome' window, the New Project window will appear.
 +
*Under Projects select '''EMAC Project''', Under the middle window select '''EMAC C Project (CMake Build)''', Click '''Choose...''', The Location window will appear.
 +
*Name your project '''LibGPIOd_example''', and choose a Create-in location, Click '''Next >''' to advance to the Summary window.
 +
*The options on the Summary window will default to '''<None>'', Click '''Finish'''. Your Project will now be generated.
 +
*Click on the '''Projects''' tab, select only the '''Arm''' option and click '''Configure Project'''. A CMakeLists.txt file will now be generated under the project.
 +
<li>Add the EMAC_Libgpiod.h file</li>
 +
*Under the project folder right click on '''CMakeLists.txt''' and select '''Show Containing Folder''' to open the project directory.
 +
*Save this [http://git.emacinc.com/OE/qt-creator-example-projects/blob/master/libgpiod_io_example/EMAC_Libgpiod.h EMAC_Libgpiod.h file] to the project directory. Do this in git by right clicking on '''Raw''', selecting '''Save link as...''' and choosing the project directory.
 +
<li>Add the [http://git.emacinc.com/OE/qt-creator-example-projects/blob/master/libgpiod_io_example/EMAC_Libgpiod.c EMAC_Libgpiod.c file] in the same way.</li> 
 +
<li>Right click on the project folder and select '''Run CMake''' to add the files to the project.</li>
 +
</ol>
 +
<br />
 +
 
 +
'''End of Options, Continuing:'''<br />
 +
<ol start = 6>
 +
<li>Open main.c under '''LibGPIOd_example->Sources''' and copy and paste the provided [http://git.emacinc.com/OE/qt-creator-example-projects/raw/master/libgpiod_io_example/main.c main.c].</li>
 +
*Note, the program must be configured to run for your target device. In the main.c file select your target device by un-commenting the #define preprocessor directive corresponding to the device '''you're using'''. All other devices should be commented out. For this example we're using a 150ES carrier board so we'll select the '''CARRIER_BOARD_150'''.
 +
 
 +
<syntaxhighlight lang="c">
 +
//In main.c
 +
 
 +
#define CARRIER_BOARD_150
 +
//#define CARRIER_BOARD_200
 +
//#define IPAC               
 +
 
 +
</syntaxhighlight>
 +
 
 +
Similarly, 1 of 4 example programs can be selected to run, example 4 is selected by default, we'll continue with this option.
 +
<syntaxhighlight lang="c">
 +
//In main.c
 +
 
 +
//#define EXAMPLE_1
 +
//#define EXAMPLE_2
 +
//#define EXAMPLE_3
 +
#define EXAMPLE_4
 +
</syntaxhighlight>
  
Similarly, 1 of 4 example programs can be selected to run, choose example 4.
+
*select '''File->Save All''', All necessary files have now been added to the project
*select File->Save All, All necessary files have now been added to the project
+
<li>Configure build options</li>
* Configure build options
+
*Go to '''Tools->Options...''' to open the options window
*Go to Tools->Options... to open the options window
 
 
*Select Devices in the left hand column to open the Devices tab
 
*Select Devices in the left hand column to open the Devices tab
*From the Devices tab select Devices and Click Add... in the right hand column
+
*From the '''Devices''' tab select '''Devices''' sub-tab and Click '''Add...''' in the right hand column
 
*Select Generic Linux Device, then click '''Start Wizard'''.
 
*Select Generic Linux Device, then click '''Start Wizard'''.
  
Line 89: Line 193:
 
|}
 
|}
  
[[File:Device_connection.png|600px|left|thumb|Figure 7: Qt Creator Configuration Setup]]
+
[[File:Libgpiod_device_config_12.PNG]]
 
<br clear=all>
 
<br clear=all>
  
Line 99: Line 203:
  
 
[[File:Device_test.png|600px|left|thumb|Figure 8: Qt Creator Device Test]]
 
[[File:Device_test.png|600px|left|thumb|Figure 8: Qt Creator Device Test]]
 +
 +
 
<br clear=all>
 
<br clear=all>
  
Line 105: Line 211:
 
*Click '''Apply'''.
 
*Click '''Apply'''.
  
*Now, on the left side of Qt Creator, you will see the project icon, which looks like a monitor. Click this and make sure '''Arm Qt5''' is selected under '''Kit''', '''Release''' is selected under '''Build''', and the project is set to be run on the remote device under '''Run'''.
+
*Click '''OK'''.
  
[[File:Kitselection.png|600px|left|thumb|Figure 10: Selecting Qt Kit]]
+
<li>Now, on the left side of Qt Creator, you will see the project icon, which looks like a monitor. Click this and select '''Release''' or '''Debug''' under build.</li>
 +
 
 +
{{note|If multiple build options were selected three sub-menus will appear ('''Kit, Build''' and '''Run'''). Click this and make sure '''Arm Qt5''' is selected under '''Kit''', '''Release''' is selected under '''Build''', and the project is set to be run on the remote device under '''Run'''.
 +
}}
 +
 
 +
 
 +
[[File:Libgpiod_14.PNG|600px|left|thumb]]
 
<br clear=all>
 
<br clear=all>
  
Now, simply press the green play button. The program should run on the target device and yield an output.
+
<li>Now, simply press the green play button. The program should run on the target device and yield an output.</li>
 +
 
 +
</ol>
 +
== Examples ==
 +
As previously stated the main.c program must be configured to run for your target device. In the main.c file select your target device by un-commenting the '''#define''' preprocessor directive corresponding to the device you're using. All other devices should be commented out.
 +
 
  
</cl>
+
<syntaxhighlight lang="c">
 +
//In main.c
 +
 
 +
#define CARRIER_BOARD_150
 +
//#define CARRIER_BOARD_200
 +
//#define IPAC               
 +
 
 +
</syntaxhighlight>
 +
 
 +
Similarly, 1 of 4 example programs can be selected to run, un-comment 1 of the "example" '''#define''' preprocessor directives and leave the rest commented out. Changes these options will require rebuilding of the program (Simply press the green play button again, this should automatically rebuild and launch the project on the target device.)
 +
<syntaxhighlight lang="c">
 +
//In main.c
 +
 
 +
//#define EXAMPLE_1
 +
//#define EXAMPLE_2
 +
//#define EXAMPLE_3
 +
#define EXAMPLE_4
 +
</syntaxhighlight>
 +
 
 +
 
 +
All examples use the Libgpiod libary ('''#include <gpiod.h>'''), with example 4 using custom built functions provided in '''EMAC_Libgpiod.h'''. <br />
 +
 
 +
'''EXAMPLE_1''' demonstrates basic IO configuration using Libgpiod's contextless functions <br />
 +
'''EXAMPLE_2''' demonstrates basic IO configuration without contextless functions <br />
 +
'''EXAMPLE_3''' LED demo using only Libgpiod<br />
 +
'''EXAMPLE_4''' LED demo using custom built Libgpiod-based helper functions <br />

Latest revision as of 15:28, 19 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.

GPIO control is accomplished through use of the libgpiod driver, as a result only the libgpiod library will be covered in this tutorial. For manipulation of non-GPIO peripherals use sysfs.


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 single board computer

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. The Libgpiod libary is used for this purpose. Linux terminal commands are defined in the libgpiod github readme (https://git.kernel.org/pub/scm/libs/libgpiod/libgpiod.git/tree) and are listed here for convenience:

"There are currently six command-line tools available:

gpiodetect - list all gpiochips present on the system, their names, labels and number of GPIO lines

gpioinfo - list all lines of specified gpiochips, their names, consumers, direction, active state and additional flags

gpioget - read values of specified GPIO lines

gpioset - set values of specified GPIO lines, potentially keep the lines exported and wait until timeout, user input or signal

gpiofind - find the gpiochip name and line offset given the line name

gpiomon - wait for events on GPIO lines, specify which events to watch,how many events to process before exiting or if the events should be reported to the console"

In libgpiod ports and pins correspond to gpiochips and lines respectively. GPIO chip numbers are assigned by the kernel, and are hardware depended.

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.

Program Setup

On the target device:

  1. Login, the default username and password is give below:

    username: root
    password: emac_inc
    
  2. Change the file to read write by entering oemntrw into the device terminal.

    root@somimx6ul:~# oemntrw



    NOTE
    This will only change the root filesystem to read-write for the current boot. When the system is rebooted, the root filesystem will once again be mounted read-only.
  3. Obtain the device IP-address by entering ifconfig into the terminal. This is needed for device configuration in Qt Creator below.

    root@emac-oe:~# ifconfig
    eth0      Link encap:Ethernet  HWaddr 00:50:C2:E6:60:F4
              inet addr:10.0.2.100  Bcast:10.0.255.255  Mask:255.255.0.0
              inet6 addr: fe80::5054:ff:feb1:f83e/64 Scope:Link
              UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
              RX packets:1825 errors:0 dropped:0 overruns:0 frame:0
              TX packets:553 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:1000
              RX bytes:139124 (135.8 KiB)  TX bytes:50603 (49.4 KiB)
              Interrupt:25 Base address:0xc000
    
    lo        Link encap:Local Loopback
              inet addr:127.0.0.1  Mask:255.0.0.0
              inet6 addr: ::1/128 Scope:Host
              UP LOOPBACK RUNNING  MTU:16436  Metric:1
              RX packets:0 errors:0 dropped:0 overruns:0 frame:0
              TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:0
              RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
    


On development machine:

  1. Open Qt Creator

Option 1:

  1. Create a qmake project
    • select + New Project on the 'Welcome' window, the New Project window will appear.
    • Under Projects select Non-Qt Project, Under the middle window select Plain C Application, Click Choose..., The Location window will appear.
    • Name your project LibGPIOd_example, and choose a Create-in location, Click Next > to advance to the Build System window.
    • On the Build System Window choose the qmake option, Click Next > to advance to the Kits window.
    • On the Kits window check only ARM Qt5, Click Next > to advance to the Summary window
    • The options on the Summary window will default to <None>, Click Finish'. Your Project will now be generated.
  2. Modify the qmake the build file (project_name.pro).
    • Copy and paste the following into your .pro file.
    TEMPLATE = app
    CONFIG += console
    CONFIG -= app_bundle
    CONFIG -= qt
    LIBS +=  -lgpiod
    SOURCES += main.c \
        EMAC_Libgpiod.c
    target.path=/home/developer
    INSTALLS += target
    HEADERS += \
        EMAC_Libgpiod.h
    
  3. Add the EMAC_Libgpiod.h file
    • With you project selected, click File->New File or Project, the New File or Project window will appear.
    • Under Files and Classes select General, and in the middle column select Empty file, Click Choose..., The Location window will appear
    • Name the file EMAC_Libgpiod.h and choose your project location as the path, Click Next> to advance to the Summary window
    • Click Finish, the file will now open.
    • Copy and paste the provided .h file, EMAC_Libgpiod.h into
    • Save the file, by click File->Save All, the file will now be added to your project under Libgpiod_example->Headers
  4. Add the EMAC_Libgpiod.c file
    • repeat same steps as for the .h file, but replace the file name enter EMAC_Libgpiod.c and Copy and paste the provided EMAC_Libgpiod.c file
    • select File->Save All

Option 2:

  1. Create a cmake project
    • select + New Project on the 'Welcome' window, the New Project window will appear.
    • Under Projects select EMAC Project, Under the middle window select EMAC C Project (CMake Build), Click Choose..., The Location window will appear.
    • Name your project LibGPIOd_example, and choose a Create-in location, Click Next > to advance to the Summary window.
    • The options on the Summary window will default to <None>, Click Finish'. Your Project will now be generated.
    • Click on the Projects tab, select only the Arm option and click Configure Project. A CMakeLists.txt file will now be generated under the project.
  2. Add the EMAC_Libgpiod.h file
    • Under the project folder right click on CMakeLists.txt and select Show Containing Folder to open the project directory.
    • Save this EMAC_Libgpiod.h file to the project directory. Do this in git by right clicking on Raw, selecting Save link as... and choosing the project directory.
  3. Add the EMAC_Libgpiod.c file in the same way.
  4. Right click on the project folder and select Run CMake to add the files to the project.


End of Options, Continuing:

  1. Open main.c under LibGPIOd_example->Sources and copy and paste the provided main.c.
    • Note, the program must be configured to run for your target device. In the main.c file select your target device by un-commenting the #define preprocessor directive corresponding to the device you're using. All other devices should be commented out. For this example we're using a 150ES carrier board so we'll select the CARRIER_BOARD_150.
    //In main.c
    
    #define CARRIER_BOARD_150 
    //#define CARRIER_BOARD_200
    //#define IPAC
    

    Similarly, 1 of 4 example programs can be selected to run, example 4 is selected by default, we'll continue with this option.

    //In main.c
    
    //#define EXAMPLE_1
    //#define EXAMPLE_2
    //#define EXAMPLE_3
    #define EXAMPLE_4
    
    • select File->Save All, All necessary files have now been added to the project
  2. Configure build options
    • Go to Tools->Options... to open the options window
    • Select Devices in the left hand column to open the Devices tab
    • From the Devices tab select Devices sub-tab and Click Add... in the right hand column
    • Select Generic Linux Device, then click Start Wizard.
    Figure 6: Qt Creator Wizard Selection


    • Type in a name, the IP address, the user name, and the password for the device. Use the credentials below to sign in.
    Table 4: Default Login Credentials
    Username Password
    root emac_inc

    Libgpiod device config 12.PNG

    • Click Next.
    • Click Finish.
    • A connection will be established with the target device.
    Figure 8: Qt Creator Device Test



    • Click Close.
    • Click Apply.
    • Click OK.
  3. Now, on the left side of Qt Creator, you will see the project icon, which looks like a monitor. Click this and select Release or Debug under build.


  4. NOTE
    If multiple build options were selected three sub-menus will appear (Kit, Build and Run). Click this and make sure Arm Qt5 is selected under Kit, Release is selected under Build, and the project is set to be run on the remote device under Run.


    Libgpiod 14.PNG


  5. Now, simply press the green play button. The program should run on the target device and yield an output.

Examples

As previously stated the main.c program must be configured to run for your target device. In the main.c file select your target device by un-commenting the #define preprocessor directive corresponding to the device you're using. All other devices should be commented out.


//In main.c

#define CARRIER_BOARD_150 
//#define CARRIER_BOARD_200
//#define IPAC

Similarly, 1 of 4 example programs can be selected to run, un-comment 1 of the "example" #define preprocessor directives and leave the rest commented out. Changes these options will require rebuilding of the program (Simply press the green play button again, this should automatically rebuild and launch the project on the target device.)

//In main.c

//#define EXAMPLE_1
//#define EXAMPLE_2
//#define EXAMPLE_3
#define EXAMPLE_4


All examples use the Libgpiod libary (#include <gpiod.h>), with example 4 using custom built functions provided in EMAC_Libgpiod.h.

EXAMPLE_1 demonstrates basic IO configuration using Libgpiod's contextless functions
EXAMPLE_2 demonstrates basic IO configuration without contextless functions
EXAMPLE_3 LED demo using only Libgpiod
EXAMPLE_4 LED demo using custom built Libgpiod-based helper functions