<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.emacinc.com/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Nperkins</id>
	<title>wiki.emacinc.com - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.emacinc.com/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Nperkins"/>
	<link rel="alternate" type="text/html" href="https://wiki.emacinc.com/wiki/Special:Contributions/Nperkins"/>
	<updated>2026-05-08T20:27:45Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.31.6</generator>
	<entry>
		<id>https://wiki.emacinc.com/index.php?title=LED_example&amp;diff=15129</id>
		<title>LED example</title>
		<link rel="alternate" type="text/html" href="https://wiki.emacinc.com/index.php?title=LED_example&amp;diff=15129"/>
		<updated>2022-11-30T19:23:03Z</updated>

		<summary type="html">&lt;p&gt;Nperkins: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{#seo:&lt;br /&gt;
|title=Example ipac_led&lt;br /&gt;
|titlemode=append&lt;br /&gt;
|keywords=Example,ipac,demo,EMAC C example project&lt;br /&gt;
|description=This is a guide to the &amp;lt;code&amp;gt;ipac_led&amp;lt;/code&amp;gt; C example project included in the EMAC OE SDK.&lt;br /&gt;
}}&lt;br /&gt;
This is a guide to the &amp;lt;code&amp;gt;ipac_led&amp;lt;/code&amp;gt; C example project included in the EMAC OE SDK.&lt;br /&gt;
&lt;br /&gt;
This project demonstrated the use of the iPac9x25's GPIOs to designate the LEDs output.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;ipac_led&amp;lt;/code&amp;gt; project builds one executable: &amp;lt;code&amp;gt;ipac_led_demo&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Opening, Building and Uploading the Project Files ==&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
Alternatively, the &amp;lt;code&amp;gt;Makefile&amp;lt;/code&amp;gt; can be used with the &amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt; command from the commandline to build and upload the example.  For information on this method, please see [[Using EMAC OE SDK Example Projects]].&lt;br /&gt;
&lt;br /&gt;
====EMAC SDK 5.X====&lt;br /&gt;
&lt;br /&gt;
For information on opening the project from within QtCreator, please see [[Getting_Started_With_Qt_Creator#Adding_Source_Files | QtCreator: Adding Source Files]].  Then, follow [[Getting Started With Qt Creator]] for information on how to build, upload and execute the example.&lt;br /&gt;
&lt;br /&gt;
Alternatively, the &amp;lt;code&amp;gt;CMakefile.txt&amp;lt;/code&amp;gt; can be used with the &amp;lt;code&amp;gt;cmake&amp;lt;/code&amp;gt; command from the commandline to build and upload the example.  For information on this method, please see [[Getting_Started_with_the_EMAC_OE_SDK#Target_Machine_Compiling | Getting Started with the EMAC OE SDK]].&lt;br /&gt;
&lt;br /&gt;
Code can be found at http://git.emacinc.com/OE/example-projects&lt;br /&gt;
==Usage and Behavior==&lt;br /&gt;
&lt;br /&gt;
===Hardware Requirements===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;ipac_led&amp;lt;/code&amp;gt; C example project will run on the iPac9x25 device.&lt;br /&gt;
&lt;br /&gt;
===Using &amp;lt;code&amp;gt;ipac_led_demo&amp;lt;/code&amp;gt;===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;ipac_led_demo&amp;lt;/code&amp;gt; program is executed from the console. It takes no parameters.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;code&amp;gt;./ipac_led_demo&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The program has 3 examples that illuminate the 8 LED on the iPac9x25 in different orders.&lt;br /&gt;
&lt;br /&gt;
===Usage Example===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
root@ipac9x25:~# ./ipac_led_demo&lt;br /&gt;
&lt;br /&gt;
Select the number of the example you would like to see.&lt;br /&gt;
1. Turn all on, then off.&lt;br /&gt;
2. Single light up the line, then back down.&lt;br /&gt;
3. Alternate back and forth.&lt;br /&gt;
Enter 0 to exit.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Enter the number into the command line to see the example run on the iPac9x25.&lt;br /&gt;
&lt;br /&gt;
==Summary==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;ipac_led&amp;lt;/code&amp;gt; C example project demonstrates use of GPIOs with the iPac9x25 LEDs.&lt;/div&gt;</summary>
		<author><name>Nperkins</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.emacinc.com/index.php?title=Example_watchdog&amp;diff=15126</id>
		<title>Example watchdog</title>
		<link rel="alternate" type="text/html" href="https://wiki.emacinc.com/index.php?title=Example_watchdog&amp;diff=15126"/>
		<updated>2022-11-30T19:22:51Z</updated>

		<summary type="html">&lt;p&gt;Nperkins: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{todo|Complete (01.03.14-11:32-&amp;gt;JG+);(01.03.14-11:42-&amp;gt;MD-);(02.04.14-19:30-&amp;gt;MD);(02.06.14-17:32-&amp;gt;BS+);(02.06.14-19:15-&amp;gt;MD+);(04.07.14-10:15-&amp;gt;BS+);(04.10.14-11:50-&amp;gt;BS+);(11.10.15-15:30-&amp;gt;MG+)|Brian Serrano|project=oe 4,oe 5,bs,md,SEOKWREV,Complete}}&lt;br /&gt;
&lt;br /&gt;
{{#seo:&lt;br /&gt;
|title=Example watchdog&lt;br /&gt;
|titlemode=append&lt;br /&gt;
|keywords=Example watchdog,watchdog timer,watchdog test,Linux watchdog&lt;br /&gt;
|description=This is a guide to the &amp;lt;code&amp;gt;watchdog&amp;lt;/code&amp;gt; C example project included in the EMAC OE SDK.&lt;br /&gt;
}}&lt;br /&gt;
This is a guide to the &amp;lt;code&amp;gt;watchdog&amp;lt;/code&amp;gt; C example project included in the EMAC OE SDK.&lt;br /&gt;
&lt;br /&gt;
A '''watchdog timer''' (WDT) is a hardware circuit that can reset the computer system in case of a software fault. This is an example test for the Linux watchdog API. &lt;br /&gt;
&lt;br /&gt;
For more information about the protocol see the following page: http://en.wikipedia.org/wiki/Watchdog_timer&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;watchdog&amp;lt;/code&amp;gt; project builds one executable: &amp;lt;code&amp;gt;watchdog-test&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Opening, Building and Uploading the Project Files ==&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
Alternatively, the &amp;lt;code&amp;gt;Makefile&amp;lt;/code&amp;gt; can be used with the &amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt; command from the commandline to build and upload the example.  For information on this method, please see [[Using EMAC OE SDK Example Projects]].&lt;br /&gt;
&lt;br /&gt;
====EMAC SDK 5.X====&lt;br /&gt;
&lt;br /&gt;
For information on opening the project from within QtCreator, please see [[Getting_Started_With_Qt_Creator#Adding_Source_Files | QtCreator: Adding Source Files]].  Then, follow [[Getting Started With Qt Creator]] for information on how to build, upload and execute the example.&lt;br /&gt;
&lt;br /&gt;
Alternatively, the &amp;lt;code&amp;gt;CMakefile.txt&amp;lt;/code&amp;gt; can be used with the &amp;lt;code&amp;gt;cmake&amp;lt;/code&amp;gt; command from the commandline to build and upload the example.  For information on this method, please see [[Getting_Started_with_the_EMAC_OE_SDK#Target_Machine_Compiling | Getting Started with the EMAC OE SDK]].&lt;br /&gt;
&lt;br /&gt;
Code can be found at http://git.emacinc.com/OE/example-projects&lt;br /&gt;
==Usage and Behavior==&lt;br /&gt;
&lt;br /&gt;
A '''watchdog timer''' is a hardware circuit that can reset the computer system in case of a software fault.  The &amp;lt;code&amp;gt;watchdog-test&amp;lt;/code&amp;gt; application can enable, disable, activate, configure and interrupt the '''watchdog timer'''. &lt;br /&gt;
{{note| Activating watchdog invokes system reset (after timeout)}}&lt;br /&gt;
&lt;br /&gt;
===Hardware Requirements===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;watchdog&amp;lt;/code&amp;gt; will run on any system for which it can be compiled and implements the standard Linux &amp;lt;code&amp;gt;watchdog&amp;lt;/code&amp;gt; API.&lt;br /&gt;
&lt;br /&gt;
===&amp;lt;code&amp;gt;watchdog&amp;lt;/code&amp;gt; Usage===&lt;br /&gt;
&lt;br /&gt;
{{cli | ./watchdog-test [-det] | hostname=emac-oe}}&lt;br /&gt;
&lt;br /&gt;
;-d:Disable watchdog.&lt;br /&gt;
;-e:Enable watchdog.&lt;br /&gt;
;-t:Set the watchdog timeout (to a value specified in code. Default is five seconds).&lt;br /&gt;
&lt;br /&gt;
===Usage Example. Activating &amp;lt;code&amp;gt;watchdog&amp;lt;/code&amp;gt; with a periodic interrupt===&lt;br /&gt;
&lt;br /&gt;
This will activate &amp;lt;code&amp;gt;watchdog&amp;lt;/code&amp;gt; and initiate a periodic interrupt to keep it from timing out.&lt;br /&gt;
&lt;br /&gt;
{{clo}}&lt;br /&gt;
{{clio | pwd=/tmp | hostname=emac-oe | ./watchdog-test }}&lt;br /&gt;
Watchdog Ticking Away!&lt;br /&gt;
{{clos}}&lt;br /&gt;
Every second &amp;lt;code&amp;gt;watchdog-test&amp;lt;/code&amp;gt; is sending an IOCTL to the watchdog driver, which in turn ticks &amp;lt;code&amp;gt;watchdog&amp;lt;/code&amp;gt; to reset its internal timer so it doesn't timeout and trigger a system reset.&lt;br /&gt;
&lt;br /&gt;
Now we will stop interrupting &amp;lt;code&amp;gt;watchdog&amp;lt;/code&amp;gt; and let it trigger a computer reset by pressing ''Ctrl+C''.&lt;br /&gt;
&lt;br /&gt;
===Usage Example. Disabling &amp;lt;code&amp;gt;watchdog&amp;lt;/code&amp;gt;===&lt;br /&gt;
&lt;br /&gt;
{{clo}}&lt;br /&gt;
{{clio | pwd=/tmp | hostname=emac-oe | ./watchdog-test -d }}&lt;br /&gt;
Watchdog card disabled.&lt;br /&gt;
{{clos}}&lt;br /&gt;
&lt;br /&gt;
After running the &amp;lt;code&amp;gt;./watchdog-test -d&amp;lt;/code&amp;gt; command, the program exits normally.&lt;br /&gt;
&lt;br /&gt;
===Usage Example. Enabling &amp;lt;code&amp;gt;watchdog&amp;lt;/code&amp;gt;===&lt;br /&gt;
&lt;br /&gt;
This will enable and activate &amp;lt;code&amp;gt;watchdog&amp;lt;/code&amp;gt; but it won't perform a periodic timeout interrupt (see the first usage example, above). So when you run it the program activates &amp;lt;code&amp;gt;watchdog&amp;lt;/code&amp;gt; and then &amp;lt;code&amp;gt;watchdog&amp;lt;/code&amp;gt; resets the system.&lt;br /&gt;
&lt;br /&gt;
{{clo}}&lt;br /&gt;
{{clio | pwd=/tmp | hostname=emac-oe | ./watchdog-test -e }}&lt;br /&gt;
Watchdog card enabled.&lt;br /&gt;
{{clos}}&lt;br /&gt;
&lt;br /&gt;
After running the &amp;lt;code&amp;gt;./watchdog-test -e&amp;lt;/code&amp;gt; command, the system resets.&lt;br /&gt;
&lt;br /&gt;
===Usage Example. Setting &amp;lt;code&amp;gt;watchdog&amp;lt;/code&amp;gt; timeout===&lt;br /&gt;
&lt;br /&gt;
This will activate &amp;lt;code&amp;gt;watchdog&amp;lt;/code&amp;gt; and set it to timeout in 5 seconds.&lt;br /&gt;
&lt;br /&gt;
{{clo}}&lt;br /&gt;
{{clio | pwd=/tmp | hostname=emac-oe | ./watchdog-test -t }}&lt;br /&gt;
Watchdog timeout set to 5 seconds!&lt;br /&gt;
&lt;br /&gt;
{{clos}}&lt;br /&gt;
&lt;br /&gt;
After running the &amp;lt;code&amp;gt;./watchdog-test -t&amp;lt;/code&amp;gt; command, the program exits normally. Once it exits, 5 seconds will elapse, and then the system resets.&lt;br /&gt;
&lt;br /&gt;
==Summary==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;watchdog&amp;lt;/code&amp;gt; C example project demonstrates how to use the '''watchdog timer'''. The '''watchdog timer''' is there to help ensure that your system will return to a functional state should your program get stuck while executing.&lt;br /&gt;
&lt;br /&gt;
EMAC provides examples of how to enable, disable, activate, configure and interrupt the &amp;lt;code&amp;gt;watchdog&amp;lt;/code&amp;gt; hardware circuit. To use &amp;lt;code&amp;gt;watchdog&amp;lt;/code&amp;gt; peripheral in Linux you will need a &amp;lt;code&amp;gt;watchdog&amp;lt;/code&amp;gt; driver, and a &amp;lt;code&amp;gt;watchdog&amp;lt;/code&amp;gt; device file. A device file is a special kind of virtual file which marks the device node in your root filesystem. Normally it's called &amp;lt;code&amp;gt;/dev/watchdog&amp;lt;/code&amp;gt; .&lt;/div&gt;</summary>
		<author><name>Nperkins</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.emacinc.com/index.php?title=Example_timer&amp;diff=15123</id>
		<title>Example timer</title>
		<link rel="alternate" type="text/html" href="https://wiki.emacinc.com/index.php?title=Example_timer&amp;diff=15123"/>
		<updated>2022-11-30T19:22:41Z</updated>

		<summary type="html">&lt;p&gt;Nperkins: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{todo|SEOKWREV (01.02.14-12:45-&amp;gt;JG+);(01.02.14-14:25-&amp;gt;MD+);(01.02.14-15:40-&amp;gt;MG+);(04.07.14-10:15-&amp;gt;BS+);(04.10.14-11:35-&amp;gt;BS+)|Jgreene|project=oe 4,oe 5,jg,md,SEOKWREV,bs}}&lt;br /&gt;
&lt;br /&gt;
{{#seo:&lt;br /&gt;
|title=Example timer&lt;br /&gt;
|titlemode=append&lt;br /&gt;
|keywords=Example timer,Timer C,Software Timer&lt;br /&gt;
|description=This is a guide to the &amp;lt;code&amp;gt;timer&amp;lt;/code&amp;gt; C example project included in the EMAC OE SDK.&lt;br /&gt;
}}&lt;br /&gt;
This is a guide to the &amp;lt;code&amp;gt;timer&amp;lt;/code&amp;gt; C example project included in the EMAC OE SDK.&lt;br /&gt;
&lt;br /&gt;
This project demonstrates how to use the software timer.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;timer&amp;lt;/code&amp;gt; project builds one executable: &amp;lt;code&amp;gt;timer&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Opening, Building and Uploading the Project Files ==&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
Alternatively, the &amp;lt;code&amp;gt;Makefile&amp;lt;/code&amp;gt; can be used with the &amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt; command from the commandline to build and upload the example.  For information on this method, please see [[Using EMAC OE SDK Example Projects]].&lt;br /&gt;
&lt;br /&gt;
====EMAC SDK 5.X====&lt;br /&gt;
&lt;br /&gt;
For information on opening the project from within QtCreator, please see [[Getting_Started_With_Qt_Creator#Adding_Source_Files | QtCreator: Adding Source Files]].  Then, follow [[Getting Started With Qt Creator]] for information on how to build, upload and execute the example.&lt;br /&gt;
&lt;br /&gt;
Alternatively, the &amp;lt;code&amp;gt;CMakefile.txt&amp;lt;/code&amp;gt; can be used with the &amp;lt;code&amp;gt;cmake&amp;lt;/code&amp;gt; command from the commandline to build and upload the example.  For information on this method, please see [[Getting_Started_with_the_EMAC_OE_SDK#Target_Machine_Compiling | Getting Started with the EMAC OE SDK]].&lt;br /&gt;
&lt;br /&gt;
Code can be found at http://git.emacinc.com/OE/example-projects&lt;br /&gt;
==Usage and Behavior==&lt;br /&gt;
&lt;br /&gt;
===Hardware Requirements===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;timer&amp;lt;/code&amp;gt; C example project will run just fine on any system for which it can be compiled.&lt;br /&gt;
&lt;br /&gt;
===Using &amp;lt;code&amp;gt;timer&amp;lt;/code&amp;gt;===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;timer&amp;lt;/code&amp;gt; program is executed from the console. It takes a single parameter.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;code&amp;gt;./timer frequency&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Where ''frequency'' specifies the frequency of the timer's tick cycle. &amp;lt;br /&amp;gt;&lt;br /&gt;
It reports the delay between ticks, running until it is manually halted with a CTRL-C.&lt;br /&gt;
&lt;br /&gt;
===Usage Example===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
root@som9g20:/tmp# ./timer 1     &lt;br /&gt;
Starting timer at 1 HZ&lt;br /&gt;
delay : 1002  ms &lt;br /&gt;
delay : 1000  ms &lt;br /&gt;
delay : 1000  ms &lt;br /&gt;
.&lt;br /&gt;
.&lt;br /&gt;
.&lt;br /&gt;
delay : 1000  ms &lt;br /&gt;
delay : 1000  ms &lt;br /&gt;
^C&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Specifying 1 as our tick freqency, the timer cycles at a sedate 1000 ms (1 s) until we hit CTRL-C.&lt;br /&gt;
&lt;br /&gt;
==Summary==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;timer&amp;lt;/code&amp;gt; C example project demonstrates how to use the software timer.&lt;/div&gt;</summary>
		<author><name>Nperkins</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.emacinc.com/index.php?title=Example_SPI_test&amp;diff=15120</id>
		<title>Example SPI test</title>
		<link rel="alternate" type="text/html" href="https://wiki.emacinc.com/index.php?title=Example_SPI_test&amp;diff=15120"/>
		<updated>2022-11-30T19:22:30Z</updated>

		<summary type="html">&lt;p&gt;Nperkins: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{todo|Buggy (2.21.14-17:40-&amp;gt;BS+);(2.24.14-13:00-&amp;gt;MD-)(2.28.14-17:48-&amp;gt;BS+)(03.10.14-13:30-&amp;gt;MD-)(08.27.14-16:55-&amp;gt;BS+)(09.09.14-17:20-&amp;gt;MD-)(09.10.14-17:00-&amp;gt;BS+)(09.13.14-21:40-&amp;gt;MD+) |Brian Serrano|project=oe 4,md,Complete,bs}}&lt;br /&gt;
&lt;br /&gt;
This is a guide to the &amp;lt;code&amp;gt;spi_test&amp;lt;/code&amp;gt; example project included in the EMAC OE SDK.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;SPI&amp;lt;/code&amp;gt; protocol works in a master/slave setup. The master is responsible for sending the clock pulses. At each clock pulse, data will be sent and received.  The rising or the falling clock edge will be used to synchronize the transfer depending on the CPOL setting.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;SPI&amp;lt;/code&amp;gt; devices have a slave select pin. Every device will share the &amp;lt;code&amp;gt;MISO&amp;lt;/code&amp;gt; (Master Input Slave Output), &amp;lt;code&amp;gt;MOSI&amp;lt;/code&amp;gt; (Master Output Slave Input), and &amp;lt;code&amp;gt;Clock&amp;lt;/code&amp;gt; pins, but each device will have its own slave select pin (also know as chip select). The slave select pin is used to set one device to be active on the bus while deactivating the rest.  Theoretically, this means a virtually unlimited number of devices can be used on the same &amp;lt;code&amp;gt;SPI&amp;lt;/code&amp;gt; bus; in practice, the number is limited by a number of factors, such as required transaction rates, mechanisms (GPIO pins, bus expanders, etc) available for selecting specific devices, and physical routing constraints.  The slave select pin can be active high or active low depending on the device.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;SPI&amp;lt;/code&amp;gt; protocol defines four signal lines, but only requires three to operate properly. The fourth line is only required if you have more than one device on the SPI bus; otherwise, you can hard-wire the chip select pin of the only device on the &amp;lt;code&amp;gt;SPI&amp;lt;/code&amp;gt; bus so that it is always selected. &lt;br /&gt;
&lt;br /&gt;
This procedure provides an overview of how to compile and run the &amp;lt;code&amp;gt;spi_test&amp;lt;/code&amp;gt; C example project. This is an example test interface for sending a transaction to an EMAC &amp;lt;code&amp;gt;SPI&amp;lt;/code&amp;gt; device interface. It is only relevant if the EMAC &amp;lt;code&amp;gt;SPI&amp;lt;/code&amp;gt; device interface is enabled for an external &amp;lt;code&amp;gt;SPI&amp;lt;/code&amp;gt; device that is connected to the bus. It assumes familiarity with the C programming language and is intended to be used by experienced programmers who are looking to learn the EMAC SDK.&lt;br /&gt;
&lt;br /&gt;
For more information about the &amp;lt;code&amp;gt;SPI&amp;lt;/code&amp;gt; protocol, see the following page: http://en.wikipedia.org/wiki/Serial_Peripheral_Interface_Bus&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;spi_test&amp;lt;/code&amp;gt; project builds one executable: &amp;lt;code&amp;gt;spi_test&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Opening, Building and Uploading the Project Files ==&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
Alternatively, the &amp;lt;code&amp;gt;Makefile&amp;lt;/code&amp;gt; can be used with the &amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt; command from the commandline to build and upload the example.  For information on this method, please see [[Using EMAC OE SDK Example Projects]].&lt;br /&gt;
&lt;br /&gt;
====EMAC SDK 5.X====&lt;br /&gt;
&lt;br /&gt;
For information on opening the project from within QtCreator, please see [[Getting_Started_With_Qt_Creator#Adding_Source_Files | QtCreator: Adding Source Files]].  Then, follow [[Getting Started With Qt Creator]] for information on how to build, upload and execute the example.&lt;br /&gt;
&lt;br /&gt;
Alternatively, the &amp;lt;code&amp;gt;CMakefile.txt&amp;lt;/code&amp;gt; can be used with the &amp;lt;code&amp;gt;cmake&amp;lt;/code&amp;gt; command from the commandline to build and upload the example.  For information on this method, please see [[Getting_Started_with_the_EMAC_OE_SDK#Target_Machine_Compiling | Getting Started with the EMAC OE SDK]].&lt;br /&gt;
&lt;br /&gt;
Code can be found at http://git.emacinc.com/OE/example-projects&lt;br /&gt;
== Usage and Behavior ==&lt;br /&gt;
===Hardware Requirements===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;spi_test&amp;lt;/code&amp;gt; C example project will run on any EMAC carrier board which has an &amp;lt;code&amp;gt;SPI&amp;lt;/code&amp;gt; interface (see also the [http://wikidev.emacinc.com/wiki/EMAC_SPI_Programming EMAC SPI Programming] page).&lt;br /&gt;
&lt;br /&gt;
=== Using indexed_atod_test ===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;indexed_atod_test&amp;lt;/code&amp;gt; program is executed from the console. It takes two parameters. &lt;br /&gt;
&lt;br /&gt;
 root@emac-oe~:$ ./indexed_atod_test device channel&lt;br /&gt;
&lt;br /&gt;
:* &amp;lt;code&amp;gt;device&amp;lt;/code&amp;gt;: Name of the &amp;lt;code&amp;gt;indexed_atod&amp;lt;/code&amp;gt; device node.&lt;br /&gt;
:* &amp;lt;code&amp;gt;channel&amp;lt;/code&amp;gt;: Number of &amp;lt;code&amp;gt;indexed_atod&amp;lt;/code&amp;gt; channels to be displayed.&lt;br /&gt;
&lt;br /&gt;
{|style=&amp;quot;margin: 0 auto;&amp;quot;&lt;br /&gt;
| [[File:Potentiometer3.jpg|left|thumb|300px|alt=A potentiometer circuit.|Figure 1: Potentiometer Circuit]]&lt;br /&gt;
| [[File:Hdr8_chan1.jpg|right|thumb|250px|alt=HDR8 Analog I/O|Figure 2: HDR8 ANALOG I/O]]&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
This example command was run on an EMAC SoM-150ES carrier board with a SoM-9G20M. This test uses a potentiometer for input to the A/D. You will be communicating with the mcp3208 chip, which is an 8-channel 12-bit A/D converter with SPI Serial Interface. Figure 1 provides a potentiometer test circuit for help on connection to the SoM-150ES carrier board.  A circuit like this is recommended for familiarizing oneself with the A/D code before connecting the actual device to be measured by the A/D.&lt;br /&gt;
&lt;br /&gt;
Before running the command in the terminal, you will need to connect the potentiometer to the carrier board as diagrammed. Figure 2 shows where to connect the potentiometer on Header 8 of the SoM-150ES. You will be focusing on CARR_ANL_1 for this example. &lt;br /&gt;
&lt;br /&gt;
Turn the potentiometer counter-clockwise as far as it goes. You'll see the results when you run the command below. Test results will be displayed in the terminal.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=console&amp;gt;&lt;br /&gt;
root@emac-oe~:$ ./indexed_atod_test /dev/mcp3208-gpio 4&lt;br /&gt;
[0] = 83&lt;br /&gt;
[1] = 4094&lt;br /&gt;
[2] = 61&lt;br /&gt;
[3] = 267&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The results that are displayed from the terminal show channel 1 analog value at 4094. All the other results are just noise coming from the mcp3208 chip.  This noise can be virtually eliminated by grounding the unused A/D inputs.&lt;br /&gt;
&lt;br /&gt;
For the second example, turn the potentiometer clockwise as far as it goes. You'll see how channel 1 results will change when running the command below. Test results will be displayed in the terminal.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=console&amp;gt;&lt;br /&gt;
root@emac-oe~:$ ./indexed_atod_test /dev/mcp3208-gpio 4&lt;br /&gt;
[0] = 62&lt;br /&gt;
[1] = 0&lt;br /&gt;
[2] = 10&lt;br /&gt;
[3] = 95&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here, the results show channel 1 analog value at zero. Your results may vary, depending on the characteristics of your potentiometer and the ADC noise present.  You can alter the value by turning the potentiometer to different positions. &lt;br /&gt;
&lt;br /&gt;
[[File:Hdr8_chan6.jpg|center|thumb|250px|alt=HDR8 Analog I/O|Figure 3: HDR8 ANALOG I/O]]&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Before doing example 3, you'll want to put the wiper (B) wire on pin 9 of the SoM-150ES carrier board. Figure 3 shows that pin 9 is CARR_ANL_6. Turn the potentiometer counter-clockwise about half way. You will see how the values on channel 6 will change when running the command below. Test results will be displayed in the terminal.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=console&amp;gt;&lt;br /&gt;
root@emac-oe~:$ ./indexed_atod_test /dev/mcp3208-gpio 7&lt;br /&gt;
[0] = 53&lt;br /&gt;
[1] = 0&lt;br /&gt;
[2] = 56&lt;br /&gt;
[3] = 0&lt;br /&gt;
[4] = 29&lt;br /&gt;
[5] = 43&lt;br /&gt;
[6] = 2044&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The results show the channel 6 analog value at 2044, which is about half way (4095/2). You can change any of the channels value with the potentiometer as long as you put the wiper pin on the channel you want to change.&lt;br /&gt;
&lt;br /&gt;
Due to ADC noise, you may see the values fluctuate slightly from one run to the next.  This is normal behavior.  This fluctuation can be more severe with some potentiometers than it is with others; some potentiometers are more prone to picking up noise.  The noise will also be more severe with longer wires, due to transmission line effects.  Eliminating noise is typically the greatest challenge in high resolution A/D conversion (especially at 18 bit and above), so you should expect to see some noise when performing an informal test such as this.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Updates for iPac9x25==&lt;br /&gt;
In order to run these examples on the board, either follow the schematic from figure 4 or use part MIKROE-304. &lt;br /&gt;
{|style=&amp;quot;margin: 0 auto;&amp;quot;&lt;br /&gt;
|[[File:Spi Test Schematic.png|thumb|Figure 4: Schematic used to set up spi test for iPac9x25]]&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Summary ==&lt;br /&gt;
The &amp;lt;code&amp;gt;indexed_atod_test&amp;lt;/code&amp;gt; C example project demonstrates how to use a 12 bit A/D converter chip (mcp3208) with SPI Serial Interface. &amp;lt;code&amp;gt;SPI&amp;lt;/code&amp;gt; is simply a way to send data from device to device in a serial fashion (bit by bit). &amp;lt;code&amp;gt;SPI&amp;lt;/code&amp;gt; provides good support for communication with peripheral devices that are accessed intermittently.&lt;/div&gt;</summary>
		<author><name>Nperkins</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.emacinc.com/index.php?title=Example_socket&amp;diff=15115</id>
		<title>Example socket</title>
		<link rel="alternate" type="text/html" href="https://wiki.emacinc.com/index.php?title=Example_socket&amp;diff=15115"/>
		<updated>2022-11-30T19:22:02Z</updated>

		<summary type="html">&lt;p&gt;Nperkins: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{todo|SEOKWREV (01.03.14-12:37-&amp;gt;JG+);(01.03.14-14:00-&amp;gt;MD+);(01.03.14-15:35-&amp;gt;KY+);(04.07.14-10:10-&amp;gt;BS+);(04.10.14-11:30-&amp;gt;BS+)|Jgreene|project=oe 4,oe 5,jg,md,SEOKWREV,ky,bs}}&lt;br /&gt;
&lt;br /&gt;
{{#seo:&lt;br /&gt;
|title=Example socket&lt;br /&gt;
|titlemode=append&lt;br /&gt;
|keywords=Example socket,Socket Server,Ethernet Network,Socket Client&lt;br /&gt;
|description=This is a guide to the &amp;lt;code&amp;gt;socket&amp;lt;/code&amp;gt; C example project included in the EMAC OE SDK.&lt;br /&gt;
}}&lt;br /&gt;
This is a guide to the &amp;lt;code&amp;gt;socket&amp;lt;/code&amp;gt; C example project included in the EMAC OE SDK.&lt;br /&gt;
&lt;br /&gt;
This application demonstrates how to set up sockets for host and client nodes on an ethernet network.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;socket&amp;lt;/code&amp;gt; project builds one executable: &amp;lt;code&amp;gt;socket&amp;lt;/code&amp;gt;.&lt;br /&gt;
== Opening, Building and Uploading the Project Files ==&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
Alternatively, the &amp;lt;code&amp;gt;Makefile&amp;lt;/code&amp;gt; can be used with the &amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt; command from the commandline to build and upload the example.  For information on this method, please see [[Using EMAC OE SDK Example Projects]].&lt;br /&gt;
&lt;br /&gt;
====EMAC SDK 5.X====&lt;br /&gt;
&lt;br /&gt;
For information on opening the project from within QtCreator, please see [[Getting_Started_With_Qt_Creator#Adding_Source_Files | QtCreator: Adding Source Files]].  Then, follow [[Getting Started With Qt Creator]] for information on how to build, upload and execute the example.&lt;br /&gt;
&lt;br /&gt;
Alternatively, the &amp;lt;code&amp;gt;CMakefile.txt&amp;lt;/code&amp;gt; can be used with the &amp;lt;code&amp;gt;cmake&amp;lt;/code&amp;gt; command from the commandline to build and upload the example.  For information on this method, please see [[Getting_Started_with_the_EMAC_OE_SDK#Target_Machine_Compiling | Getting Started with the EMAC OE SDK]].&lt;br /&gt;
&lt;br /&gt;
Code can be found at http://git.emacinc.com/OE/example-projects&lt;br /&gt;
==Usage and Behavior==&lt;br /&gt;
&lt;br /&gt;
===Hardware Requirements===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;socket&amp;lt;/code&amp;gt; C example project will run just fine on any system for which it can be compiled.&lt;br /&gt;
&lt;br /&gt;
===Using &amp;lt;code&amp;gt;socket&amp;lt;/code&amp;gt;===&lt;br /&gt;
&lt;br /&gt;
 ./socket -sc [ADDRESS] PORT&lt;br /&gt;
&lt;br /&gt;
;-s:Create a ''server'', specify the PORT to listen to.  &lt;br /&gt;
;-c:Create a ''client'', specify the server's ADDRESS and PORT.&lt;br /&gt;
&lt;br /&gt;
For our demonstration we create a ''server'' and a ''client''. Upon activation the server waits for a connection. Upon activation the client connects with the server. When the server detects the client's connection it sends a message to the client. Then the client sends that message right back to the server. The server compares the message it sent to the client with the message it just got from the client. If they match then we have performed a successful transmission.&lt;br /&gt;
&lt;br /&gt;
===Usage Example. One machine===&lt;br /&gt;
&lt;br /&gt;
We're going to create a ''server'' and ''client'' on the same machine. The machine will talk to itself.&lt;br /&gt;
&lt;br /&gt;
Create the server&lt;br /&gt;
&lt;br /&gt;
'''Note''' We're using port ''9999''. It's arbitrarily chosen and assumed to be free.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
root@som9g20:/tmp# ./socket -s 9999&lt;br /&gt;
&lt;br /&gt;
Starting server&lt;br /&gt;
Making socket&lt;br /&gt;
Binding to port 9999opened socket as fd (3) on port (9999) for stream i/o&lt;br /&gt;
Server&lt;br /&gt;
			sin_family        = 2&lt;br /&gt;
			sin_addr.s_addr   = 0&lt;br /&gt;
			sin_port          = 9999&lt;br /&gt;
&lt;br /&gt;
Making a listen queue of 5 elements&lt;br /&gt;
Waiting for a connection&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
...and it's waiting for a connection. Note that you can't do anything else in this console because it's occupied with the &amp;lt;code&amp;gt;socket&amp;lt;/code&amp;gt; program. So open another console and, if necessary, log-on.&lt;br /&gt;
&lt;br /&gt;
Create the client.&lt;br /&gt;
&lt;br /&gt;
'''Note''' We're using port ''9999'', the same port for which the server is configured; and the localhost address: 127.0.0.1&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
root@som9g20:/tmp# ./socket -c 127.0.0.1 9999&lt;br /&gt;
&lt;br /&gt;
Making a socket&lt;br /&gt;
Connecting to 127.0.0.1 on port 9999&lt;br /&gt;
Received &amp;quot;Message from the socket server&amp;quot; from server&lt;br /&gt;
&lt;br /&gt;
Writing &amp;quot;Message from the socket server&amp;quot; to server&lt;br /&gt;
Closing socket&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is what happened: The server started up and waited for a connection. Then we started the client and it immediately connected to the server. The server noticed that connection and sent a message to the client: &amp;quot;Message from the socket server&amp;quot;. The client received the message and sent it right back to the server. The server compared the two messages to check the accuracy of the transmission. The messages matched so the transmission was successful.&lt;br /&gt;
&lt;br /&gt;
===Usage Example. Two machines===&lt;br /&gt;
&lt;br /&gt;
Get 2 machines.  In this example, a SoM9g20 and a SoM 9g45 are used. These machines will be referred to as ''MACHINE0'' and ''MACHINE1''.&amp;lt;br \&amp;gt;&lt;br /&gt;
Compile and upload the &amp;lt;code&amp;gt;socket&amp;lt;/code&amp;gt; executable to each of them.&amp;lt;br \&amp;gt;&lt;br /&gt;
Connect them both to the same ethernet network.&amp;lt;br \&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''On MACHINE0 run the &amp;lt;code&amp;gt;socket&amp;lt;/code&amp;gt; program.'''&lt;br /&gt;
 som9g45:/tmp# ./socket -s 9999&lt;br /&gt;
Note that '''-s''' was specified, thus configuring MACHINE0 as a server. ''9999'' is an arbitrarily chosen (and assumed to be free) port address on the host machine.&lt;br /&gt;
&lt;br /&gt;
MACHINE0 has now been configured as a server and is waiting for a connection.&lt;br /&gt;
&lt;br /&gt;
'''On MACHINE1, run the &amp;lt;code&amp;gt;socket&amp;lt;/code&amp;gt; program.'''&lt;br /&gt;
 som9g20:/tmp# ./socket -c 10.0.2.204 9999&lt;br /&gt;
Note that the '''-c''' argument was specified, thus configuring MACHINE1 as a '''client'''. ''10.0.2.204'' is the host machine's address (this will need to be determined. Use ''minicom'' or a similar terminal program). ''9999'' is the port address on the host machine.&lt;br /&gt;
&lt;br /&gt;
'''On MACHINE0, you will see something like this:'''&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
som9g45:/tmp# ./socket -s 9999&lt;br /&gt;
&lt;br /&gt;
Starting server&lt;br /&gt;
Making socket&lt;br /&gt;
Binding to port 9999opened socket as fd (3) on port (9999) for stream i/o&lt;br /&gt;
Server&lt;br /&gt;
                        sin_family        = 2&lt;br /&gt;
                        sin_addr.s_addr   = 0&lt;br /&gt;
                        sin_port          = 9999&lt;br /&gt;
&lt;br /&gt;
Making a listen queue of 5 elements&lt;br /&gt;
Waiting for a connection&lt;br /&gt;
&lt;br /&gt;
Got a connection&lt;br /&gt;
Sending &amp;quot;Message from the socket server&amp;quot; to client&lt;br /&gt;
The messages match&lt;br /&gt;
Closing the socket&lt;br /&gt;
Waiting for a connection&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''On MACHINE1, you will see something like this:'''&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
root@som9g20:/tmp# ./socket -c 10.0.2.204 9999&lt;br /&gt;
&lt;br /&gt;
Making a socket&lt;br /&gt;
Connecting to 10.0.2.204 on port 9999&lt;br /&gt;
Received &amp;quot;Message from the socket server&amp;quot; from server&lt;br /&gt;
&lt;br /&gt;
Writing &amp;quot;Message from the socket server&amp;quot; to server&lt;br /&gt;
Closing socket&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is what happened: MACHINE0 (the server) was configured as a server and waited for a connection. MACHINE1 (the client) connected to MACHINE0. MACHINE0 noticed the connection and sent a message to MACHINE1: &amp;quot;Message from the socket server&amp;quot;. MACHINE1 received the message and sent it right back. MACHINE0 compared the two messages to check the accuracy of the transmission. The messages matched so the transmission was successful.&lt;br /&gt;
&lt;br /&gt;
==Summary==&lt;br /&gt;
The &amp;lt;code&amp;gt;socket&amp;lt;/code&amp;gt; C example project demonstrates how to set up host and client node sockets on an ethernet network.&lt;/div&gt;</summary>
		<author><name>Nperkins</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.emacinc.com/index.php?title=Example_serial&amp;diff=15112</id>
		<title>Example serial</title>
		<link rel="alternate" type="text/html" href="https://wiki.emacinc.com/index.php?title=Example_serial&amp;diff=15112"/>
		<updated>2022-11-30T19:21:51Z</updated>

		<summary type="html">&lt;p&gt;Nperkins: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{todo|SEOKWREV (12.31.13-14:56-&amp;gt;JG+);(1.2.14-11:20-&amp;gt;MD+);(1.2.14-15:35-&amp;gt;MG+);(04.07.14-10:00-&amp;gt;BS+);(04.10.14-11:20-&amp;gt;BS+)|Jgreene|project=oe 4,oe 5,jg,md,SEOKWREV,mg,bs}}&lt;br /&gt;
&lt;br /&gt;
{{#seo:&lt;br /&gt;
|title=serial test&lt;br /&gt;
|titlemode=append&lt;br /&gt;
|keywords=Serial Test,Serial Port,Asynchronous&lt;br /&gt;
|description=This is a guide to the &amp;lt;code&amp;gt;serial&amp;lt;/code&amp;gt; C example project included in the EMAC OE SDK.&lt;br /&gt;
}}&lt;br /&gt;
This is a guide to the &amp;lt;code&amp;gt;serial&amp;lt;/code&amp;gt; C example project included in the EMAC OE SDK.&lt;br /&gt;
&lt;br /&gt;
This application sets up and tests asynchronous IO on a serial port using '''poll()''' and '''fasync()'''.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;serial&amp;lt;/code&amp;gt; project builds one executable: &amp;lt;code&amp;gt;serial_test&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Opening, Building and Uploading the Project Files ==&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
Alternatively, the &amp;lt;code&amp;gt;Makefile&amp;lt;/code&amp;gt; can be used with the &amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt; command from the commandline to build and upload the example.  For information on this method, please see [[Using EMAC OE SDK Example Projects]].&lt;br /&gt;
&lt;br /&gt;
====EMAC SDK 5.X====&lt;br /&gt;
&lt;br /&gt;
For information on opening the project from within QtCreator, please see [[Getting_Started_With_Qt_Creator#Adding_Source_Files | QtCreator: Adding Source Files]].  Then, follow [[Getting Started With Qt Creator]] for information on how to build, upload and execute the example.&lt;br /&gt;
&lt;br /&gt;
Alternatively, the &amp;lt;code&amp;gt;CMakefile.txt&amp;lt;/code&amp;gt; can be used with the &amp;lt;code&amp;gt;cmake&amp;lt;/code&amp;gt; command from the commandline to build and upload the example.  For information on this method, please see [[Getting_Started_with_the_EMAC_OE_SDK#Target_Machine_Compiling | Getting Started with the EMAC OE SDK]].&lt;br /&gt;
&lt;br /&gt;
Code can be found at http://git.emacinc.com/OE/example-projects&lt;br /&gt;
==Usage and Behavior==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;serial_test&amp;lt;/code&amp;gt; performs an asynchronous IO test on the specified serial device using either '''poll''' or '''FASYNC''' mode. It performs the test, reports, tests, report, etc. It will keep running until it is stopped manually via '''CTRL-C'''.&lt;br /&gt;
&lt;br /&gt;
===Hardware Requirements===&lt;br /&gt;
&lt;br /&gt;
It should run just fine on any device with a serial port. &lt;br /&gt;
&lt;br /&gt;
===Using &amp;lt;code&amp;gt;serial_test&amp;lt;/code&amp;gt;===&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;code&amp;gt;./serial_test DEVICE -[p] [-f]&amp;lt;/code&amp;gt; &lt;br /&gt;
&lt;br /&gt;
;DEVICE: The serial device to use&lt;br /&gt;
;-p: Use '''poll''' mode for asynchronous IO&lt;br /&gt;
;-f: Use '''FASYNC''' mode for asynchronous IO&lt;br /&gt;
&lt;br /&gt;
===Usage Example: Test asynchronous IO using the '''poll''' mode===&lt;br /&gt;
&lt;br /&gt;
Perform the test on device &amp;lt;code&amp;gt;/dev/ttyS1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
root@som9g20:/tmp# ./serial_test /dev/ttyS1 -p&lt;br /&gt;
Testing on /dev/ttyS1 using poll() &lt;br /&gt;
Received: : 21&lt;br /&gt;
Received: : 11&lt;br /&gt;
Received: : 6&lt;br /&gt;
Received: : 2&lt;br /&gt;
Received: : 1&lt;br /&gt;
Received: : 1&lt;br /&gt;
.&lt;br /&gt;
.&lt;br /&gt;
.&lt;br /&gt;
Received: : 1&lt;br /&gt;
Received: : 1&lt;br /&gt;
Received: : 1&lt;br /&gt;
^C&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Hit CTRL-C to stop testing. In this example, no errors were reported.&lt;br /&gt;
&lt;br /&gt;
===Usage Example. Test asynchronous IO using the '''FASYNC''' mode===&lt;br /&gt;
&lt;br /&gt;
Perform the test on device &amp;lt;code&amp;gt;/dev/ttyS1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
root@som9g20:/tmp# ./serial_test /dev/ttyS1 -f&lt;br /&gt;
Testing on /dev/ttyS1 using FASYNC &lt;br /&gt;
Received SIGIO signal.&lt;br /&gt;
: : 21&lt;br /&gt;
Received SIGIO signal.&lt;br /&gt;
: : 11&lt;br /&gt;
Received SIGIO signal.&lt;br /&gt;
: : 6&lt;br /&gt;
Received SIGIO signal.&lt;br /&gt;
: : 2&lt;br /&gt;
Received SIGIO signal.&lt;br /&gt;
: : 1&lt;br /&gt;
Received SIGIO signal.&lt;br /&gt;
: : 1&lt;br /&gt;
Received SIGIO signal.&lt;br /&gt;
: : 1&lt;br /&gt;
.&lt;br /&gt;
.&lt;br /&gt;
.&lt;br /&gt;
Received SIGIO signal.&lt;br /&gt;
: : 1&lt;br /&gt;
Received SIGIO signal.&lt;br /&gt;
: : 1&lt;br /&gt;
Received SIGIO signal.&lt;br /&gt;
: : 1&lt;br /&gt;
^C&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Hit CTRL-C to stop testing. In this example, no errors were reported.&lt;br /&gt;
&lt;br /&gt;
==Summary==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;serial&amp;lt;/code&amp;gt; C example project application performs an asynchronous IO test on the specified serial device using either '''poll''' or '''FASYNC''' mode.&lt;/div&gt;</summary>
		<author><name>Nperkins</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.emacinc.com/index.php?title=Example_pthread_demo&amp;diff=15109</id>
		<title>Example pthread demo</title>
		<link rel="alternate" type="text/html" href="https://wiki.emacinc.com/index.php?title=Example_pthread_demo&amp;diff=15109"/>
		<updated>2022-11-30T19:21:39Z</updated>

		<summary type="html">&lt;p&gt;Nperkins: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{todo|SEOKWREV;(12.11.13-12:03-&amp;gt;JG+);(12.11.13-17:25-&amp;gt;MD-);(12.12.13-11:25-&amp;gt;JG+);(12.31.13-12:45-&amp;gt;MD+);(04.07.14-09:50-&amp;gt;BS+);(04.10.14-11:00-&amp;gt;BS+)|Jgreene|project=oe 4,oe 5,jg,md,SEOKWREV,mg,bs}}&lt;br /&gt;
&lt;br /&gt;
{{#seo:&lt;br /&gt;
|title=pthread demo&lt;br /&gt;
|titlemode=append&lt;br /&gt;
|keywords=pthread,pthread example&lt;br /&gt;
|description=This is a guide to the &amp;lt;code&amp;gt;pthread_demo&amp;lt;/code&amp;gt; C example project included in the EMAC OE SDK.&lt;br /&gt;
}}&lt;br /&gt;
This is a guide to the &amp;lt;code&amp;gt;pthread_demo&amp;lt;/code&amp;gt; C example project included in the EMAC OE SDK.&lt;br /&gt;
&lt;br /&gt;
This is a simple pthreads example application. A single thread is created to generate random data that is read by a specified number of reader threads.&lt;br /&gt;
&lt;br /&gt;
The term ''pthread'' refers to [http://en.wikipedia.org/wiki/PThread POSIX Threads], a [http://en.wikipedia.org/wiki/POSIX POSIX] standard for threads.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;pthread_demo&amp;lt;/code&amp;gt; project builds one executable: &amp;lt;code&amp;gt;p_thread_demo&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Opening, Building and Uploading the Project Files ==&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
Alternatively, the &amp;lt;code&amp;gt;Makefile&amp;lt;/code&amp;gt; can be used with the &amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt; command from the commandline to build and upload the example.  For information on this method, please see [[Using EMAC OE SDK Example Projects]].&lt;br /&gt;
&lt;br /&gt;
====EMAC SDK 5.X====&lt;br /&gt;
&lt;br /&gt;
For information on opening the project from within QtCreator, please see [[Getting_Started_With_Qt_Creator#Adding_Source_Files | QtCreator: Adding Source Files]].  Then, follow [[Getting Started With Qt Creator]] for information on how to build, upload and execute the example.&lt;br /&gt;
&lt;br /&gt;
Alternatively, the &amp;lt;code&amp;gt;CMakefile.txt&amp;lt;/code&amp;gt; can be used with the &amp;lt;code&amp;gt;cmake&amp;lt;/code&amp;gt; command from the commandline to build and upload the example.  For information on this method, please see [[Getting_Started_with_the_EMAC_OE_SDK#Target_Machine_Compiling | Getting Started with the EMAC OE SDK]].&lt;br /&gt;
&lt;br /&gt;
Code can be found at http://git.emacinc.com/OE/example-projects&lt;br /&gt;
==Usage and Behavior== &lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;pthread_demo&amp;lt;/code&amp;gt; project is an example of multithreaded code for generating and interacting with an arbitrary number of ''pthreads''. Within the '''pthread_demo.c''' C source file can be found demonstrations of how to, specifically:&amp;lt;br /&amp;gt;&lt;br /&gt;
*Create pthreads, line 90.&lt;br /&gt;
*Write to pthreads, line 141.&lt;br /&gt;
*Read from pthreads, line 127.&lt;br /&gt;
*Terminate and clean up after pthreads, line 119.&lt;br /&gt;
&lt;br /&gt;
===Hardware Requirements===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;pthread_demo&amp;lt;/code&amp;gt; C example project has no special hardware requirements. It should run just fine on any system for which the project files can be successfully compiled.&lt;br /&gt;
&lt;br /&gt;
===Using &amp;lt;code&amp;gt;pthread_demo&amp;lt;/code&amp;gt;===&lt;br /&gt;
&lt;br /&gt;
 ./pthread_demo n&lt;br /&gt;
where '''n''' is the number of threads&lt;br /&gt;
&lt;br /&gt;
===Usage Example===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
root@PPCE7:/tmp# ./pthread_demo 3&lt;br /&gt;
generating new random data&lt;br /&gt;
generating new random data&lt;br /&gt;
    reader: count = 0, data = 693451072&lt;br /&gt;
generating new random data&lt;br /&gt;
    reader: count = 1, data = 1195545710&lt;br /&gt;
generating new random data&lt;br /&gt;
    reader: count = 2, data = 462104121&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Usage and Behavior for Ipac-9x25 Examples== &lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;p_hello&amp;lt;/code&amp;gt; project is an example of multithreaded code for generating and interacting with an arbitrary number of ''pthreads''. Within the '''p_hello.c''' C source file can be found demonstrations using the '''pthread''' library.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Using &amp;lt;code&amp;gt;p_hello&amp;lt;/code&amp;gt;===&lt;br /&gt;
&lt;br /&gt;
 ./p_hello n&lt;br /&gt;
where '''n''' is the number of threads&lt;br /&gt;
&lt;br /&gt;
===Usage Example===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
root@PPCE7:/tmp# ./p_hello 3&lt;br /&gt;
Hello from node 0&lt;br /&gt;
Hello from node 1&lt;br /&gt;
Hello from node 2&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Summary==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;pthread_demo&amp;lt;/code&amp;gt; C example project demonstrates how to use pthreads. For another example of pthread usage see [[Example pthread hello]].&lt;/div&gt;</summary>
		<author><name>Nperkins</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.emacinc.com/index.php?title=Example_i2c_test&amp;diff=15106</id>
		<title>Example i2c test</title>
		<link rel="alternate" type="text/html" href="https://wiki.emacinc.com/index.php?title=Example_i2c_test&amp;diff=15106"/>
		<updated>2022-11-30T19:21:00Z</updated>

		<summary type="html">&lt;p&gt;Nperkins: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{todo|Buggy (11.14.13-13:25-&amp;gt;JG+);(11.14.13-15:45-&amp;gt;MD-);(01.30.14-16:20-&amp;gt;BS+);(01.30.14-18:30-&amp;gt;MD-);(11.10.2015-12:50-&amp;gt;MD+)|Brian Serrano|project=oe 4,oe 5,md,Buggy,bs}}&lt;br /&gt;
&lt;br /&gt;
This is a guide to the &amp;lt;code&amp;gt;i2c_test&amp;lt;/code&amp;gt; example project included in the EMAC OE SDK.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;I²C&amp;lt;/code&amp;gt; is a two wire serial interface used to connect to a variety of sensor and I/O devices. The interface uses only two bi-directional open-drain I/Os, Serial Data Line (SDA) and Serial Clock (SCL), to communicate to devices based on an address encoded within the data transmission. SDA is a data signal which sends and receives serially transmitted data. SCL is a clock signal which is used to determine when to latch data from the SDA line.&lt;br /&gt;
&lt;br /&gt;
This procedure provides an overview of how to compile and run the &amp;lt;code&amp;gt;i2c_test&amp;lt;/code&amp;gt; C example project. This is an example test interface for reading/writing to the Linux &amp;lt;code&amp;gt;I²C&amp;lt;/code&amp;gt; device interface. It is only relevant if the &amp;lt;code&amp;gt;I²C&amp;lt;/code&amp;gt; device interface is enabled and an external &amp;lt;code&amp;gt;I²C&amp;lt;/code&amp;gt; device is connected to the bus. It assumes familiarity with the C programming language and is intended to be used by experienced programmers who are looking to learn the EMAC SDK.&lt;br /&gt;
&lt;br /&gt;
For more information about the protocol see the following page: http://www.nxp.com/documents/user_manual/UM10204.pdf&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;i2c_test&amp;lt;/code&amp;gt; project builds one executable: &amp;lt;code&amp;gt;i2c_test&amp;lt;/code&amp;gt;.&lt;br /&gt;
== Opening, Building and Uploading the Project Files ==&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
Alternatively, the &amp;lt;code&amp;gt;Makefile&amp;lt;/code&amp;gt; can be used with the &amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt; command from the commandline to build and upload the example.  For information on this method, please see [[Using EMAC OE SDK Example Projects]].&lt;br /&gt;
&lt;br /&gt;
====EMAC SDK 5.X====&lt;br /&gt;
&lt;br /&gt;
For information on opening the project from within QtCreator, please see [[Getting_Started_With_Qt_Creator#Adding_Source_Files | QtCreator: Adding Source Files]].  Then, follow [[Getting Started With Qt Creator]] for information on how to build, upload and execute the example.&lt;br /&gt;
&lt;br /&gt;
Alternatively, the &amp;lt;code&amp;gt;CMakefile.txt&amp;lt;/code&amp;gt; can be used with the &amp;lt;code&amp;gt;cmake&amp;lt;/code&amp;gt; command from the commandline to build and upload the example.  For information on this method, please see [[Getting_Started_with_the_EMAC_OE_SDK#Target_Machine_Compiling | Getting Started with the EMAC OE SDK]].&lt;br /&gt;
&lt;br /&gt;
Code can be found at http://git.emacinc.com/OE/example-projects&lt;br /&gt;
== Usage and Behavior ==&lt;br /&gt;
=== Hardware Requirements ===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;i2c_test&amp;lt;/code&amp;gt; C example project will run on any EMAC carrier board which has an &amp;lt;code&amp;gt;I²C&amp;lt;/code&amp;gt; interface (see also the [[EMAC_I²C_Programming | EMAC I²C Programming]] page).&lt;br /&gt;
&lt;br /&gt;
===Using i2c_test===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;i2c_test&amp;lt;/code&amp;gt; program is executed from the console. If using the iPac9x25 it takes an optional argument which is the string representing the device path. By default, &amp;quot;/dev/i2c-1&amp;quot; is set, but if another device path needs to be used, append that to the command. &lt;br /&gt;
&lt;br /&gt;
{{cli |./i2c_test &amp;lt;optional device_path&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
A menu will appear in the terminal:&lt;br /&gt;
&lt;br /&gt;
{{clop}}&amp;lt;nowiki&amp;gt;&lt;br /&gt;
Select a function to test:&lt;br /&gt;
    a: Set slave address&lt;br /&gt;
    b: Write byte to register&lt;br /&gt;
    c: Write 2 bytes to register&lt;br /&gt;
    d: Read byte from register&lt;br /&gt;
    e: Read 2 bytes from register&lt;br /&gt;
    q: Quit&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
{{closp}}&lt;br /&gt;
&lt;br /&gt;
Select a function (a,b,c,d,e) to test or q to quit. You will be prompted for read, write and register values as appropriate. Test results will be displayed in the terminal.&lt;br /&gt;
&lt;br /&gt;
==== Test Options ====&lt;br /&gt;
&amp;lt;!--&amp;lt;cl&amp;gt;--&amp;gt;&lt;br /&gt;
* '''Set Slave Address'''&amp;lt;br /&amp;gt;Press the ''A'' key to select the Set slave address function, then press ''Enter''.&lt;br /&gt;
{{clop | indent=1 }}&amp;lt;nowiki&amp;gt;&lt;br /&gt;
Select a function to test:&lt;br /&gt;
    a: Set slave address&lt;br /&gt;
    b: Write byte to register&lt;br /&gt;
    c: Write 2 bytes to register&lt;br /&gt;
    d: Read byte from register&lt;br /&gt;
    e: Read 2 bytes from register&lt;br /&gt;
    q: Quit&lt;br /&gt;
&amp;gt;&amp;gt; a&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Enter the slave address (in hex): 48&lt;br /&gt;
&lt;br /&gt;
Calling i2c_set_slave(3, 0x48)&lt;br /&gt;
i2c_set_slave reports success&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
{{closp}}&lt;br /&gt;
&amp;lt;p style=&amp;quot;margin-left:2%;&amp;quot;&amp;gt;&lt;br /&gt;
The slave address receives the clock and responds when addressed by the master.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p style=&amp;quot;margin-left:2%;&amp;quot;&amp;gt;This function is to set the slave address of the &amp;lt;code&amp;gt;I²C&amp;lt;/code&amp;gt; device. This only need to be done once to initialize the address and then each time that a new device is addressed.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* '''Write byte to register'''&amp;lt;br /&amp;gt;Press the ''B'' key to select the Write byte to register function, then press ''Enter''&lt;br /&gt;
{{clop | indent=1 }}&amp;lt;nowiki&amp;gt;&lt;br /&gt;
Select a function to test:&lt;br /&gt;
    a: Set slave address&lt;br /&gt;
    b: Write byte to register&lt;br /&gt;
    c: Write 2 bytes to register&lt;br /&gt;
    d: Read byte from register&lt;br /&gt;
    e: Read 2 bytes from register&lt;br /&gt;
    q: Quit&lt;br /&gt;
&amp;gt;&amp;gt; b&lt;br /&gt;
&lt;br /&gt;
Enter a byte to write (in hex): aa&lt;br /&gt;
Enter a register value to write (in hex): 01&lt;br /&gt;
&lt;br /&gt;
Calling i2c_write_cmd(3, 0x1, 0xAA)&lt;br /&gt;
i2c_write_cmd reports success&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
{{closp}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p style=&amp;quot;margin-left:2%;&amp;quot;&amp;gt;This function uses the Linux &amp;lt;code&amp;gt;write&amp;lt;/code&amp;gt; system call to write one byte to the selected register on the &amp;lt;code&amp;gt;I²C&amp;lt;/code&amp;gt; device. &amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* '''Write 2 bytes to register'''&amp;lt;br /&amp;gt;Press the ''C'' key to select the Write 2 bytes to register function, then press ''Enter''.&lt;br /&gt;
{{clop | indent=1 }}&amp;lt;nowiki&amp;gt;&lt;br /&gt;
Select a function to test:&lt;br /&gt;
    a: Set slave address&lt;br /&gt;
    b: Write byte to register&lt;br /&gt;
    c: Write 2 bytes to register&lt;br /&gt;
    d: Read byte from register&lt;br /&gt;
    e: Read 2 bytes from register&lt;br /&gt;
    q: Quit&lt;br /&gt;
&amp;gt;&amp;gt; c&lt;br /&gt;
&lt;br /&gt;
Enter a 2 byte number to write (in hex): aabb&lt;br /&gt;
Enter a register value to write (in hex): 01&lt;br /&gt;
&lt;br /&gt;
Calling i2c_write_cmd2(3, 0x1, 0xAABB)&lt;br /&gt;
i2c_write_cmd2 reports success&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
{{closp}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p style=&amp;quot;margin-left:2%;&amp;quot;&amp;gt;This function uses the same system call as the previous option, but writes 2 bytes to a register instead of just one.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* ''' Read byte from register '''&amp;lt;br /&amp;gt;Press the ''D'' key to select the Read byte from register function, then press ''Enter''.&lt;br /&gt;
{{clop | indent=1 }}&amp;lt;nowiki&amp;gt;&lt;br /&gt;
Select a function to test:&lt;br /&gt;
    a: Set slave address    &lt;br /&gt;
    b: Write byte to register    &lt;br /&gt;
    c: Write 2 bytes to register    &lt;br /&gt;
    d: Read byte from register    &lt;br /&gt;
    e: Read 2 bytes from register    &lt;br /&gt;
    q: Quit&lt;br /&gt;
&amp;gt;&amp;gt; d&lt;br /&gt;
&lt;br /&gt;
Enter a register value to read from (in hex): bb&lt;br /&gt;
&lt;br /&gt;
Calling i2c_read_reg(3, (__u8 *)&amp;amp;val, 0xBB)&lt;br /&gt;
i2c_read_reg reports success&lt;br /&gt;
Read value 0xB&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
{{closp}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p style=&amp;quot;margin-left:2%;&amp;quot;&amp;gt;This function uses the Linux &amp;lt;code&amp;gt;read&amp;lt;/code&amp;gt; system call to read a byte to the selected register on the &amp;lt;code&amp;gt;I²C&amp;lt;/code&amp;gt; device.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* '''Read 2 bytes from register'''&amp;lt;br /&amp;gt;Press the ''E'' key to select the Read 2 bytes from register function, then press ''Enter''.&lt;br /&gt;
{{clop | indent=1 }}&amp;lt;nowiki&amp;gt;&lt;br /&gt;
Select a function to test:&lt;br /&gt;
    a: Set slave address        &lt;br /&gt;
    b: Write byte to register        &lt;br /&gt;
    c: Write 2 bytes to register        &lt;br /&gt;
    d: Read byte from register        &lt;br /&gt;
    e: Read 2 bytes from register        &lt;br /&gt;
    q: Quit&lt;br /&gt;
&amp;gt;&amp;gt; e&lt;br /&gt;
&lt;br /&gt;
Enter a register value to read from (in hex): bbcc&lt;br /&gt;
&lt;br /&gt;
Calling i2c_read_reg2(3, &amp;amp;val, 0xBBCC)&lt;br /&gt;
i2c_read_reg2 reports success&lt;br /&gt;
Read value 0xB0B&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
{{closp}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p style=&amp;quot;margin-left:2%;&amp;quot;&amp;gt;This function uses the same system call as the previous option, but shifts to the right.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p style=&amp;quot;margin-left:2%;&amp;quot;&amp;gt;The &amp;lt;code&amp;gt;i2c_test&amp;lt;/code&amp;gt; example writes a byte to a selected register. The register then reads the byte, shifts the byte 8 bits to the right and then reads the address to the selected register on the &amp;lt;code&amp;gt;I²C&amp;lt;/code&amp;gt; device. &amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*'''Quit'''&amp;lt;br /&amp;gt;Press the ''Q'' key to quit out of the &amp;lt;code&amp;gt;i2c_test&amp;lt;/code&amp;gt; example, then press ''Enter''.&lt;br /&gt;
{{clop | indent=1 }}&amp;lt;nowiki&amp;gt;&lt;br /&gt;
Select a function to test:    &lt;br /&gt;
    a: Set slave address            &lt;br /&gt;
    b: Write byte to register            &lt;br /&gt;
    c: Write 2 bytes to register            &lt;br /&gt;
    d: Read byte from register            &lt;br /&gt;
    e: Read 2 bytes from register            &lt;br /&gt;
    q: Quit&lt;br /&gt;
&amp;gt;&amp;gt; q&lt;br /&gt;
Quiting...&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
{{closp}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p style=&amp;quot;margin-left:2%;&amp;quot;&amp;gt;This function exits you out of the &amp;lt;code&amp;gt;i2c_test&amp;lt;/code&amp;gt; example on the &amp;lt;code&amp;gt;I²C&amp;lt;/code&amp;gt; device.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;!--&amp;lt;/cl&amp;gt;--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Real-World Example ==&lt;br /&gt;
=== Hardware Requirements ===&lt;br /&gt;
The &amp;lt;code&amp;gt;i2c_test&amp;lt;/code&amp;gt; C Real-World example project will be running on an EMAC SOM-210ES carrier board. This example will be communicating with the RTC clock on the SOM-3517M.&lt;br /&gt;
&lt;br /&gt;
For more information about the RTC Clock see the following page for the data sheet: http://www.nxp.com/documents/data_sheet/PCA8565.pdf&lt;br /&gt;
&lt;br /&gt;
=== Using Real-World Example i2c_test ===&lt;br /&gt;
&lt;br /&gt;
Just like before, the &amp;lt;code&amp;gt;i2c_test&amp;lt;/code&amp;gt; program is executed from the console. It takes no parameters.&lt;br /&gt;
&lt;br /&gt;
{{cli |./i2c_test}}&lt;br /&gt;
&lt;br /&gt;
A menu will appear in the terminal:&lt;br /&gt;
{{clop}}&amp;lt;nowiki&amp;gt;&lt;br /&gt;
Select a function to test:&lt;br /&gt;
    a: Set slave address&lt;br /&gt;
    b: Write byte to register&lt;br /&gt;
    c: Write 2 bytes to register&lt;br /&gt;
    d: Read byte from register&lt;br /&gt;
    e: Read 2 bytes from register&lt;br /&gt;
    q: Quit&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
{{closp}}&lt;br /&gt;
&lt;br /&gt;
==== Test Options ====&lt;br /&gt;
&lt;br /&gt;
* '''Set Slave Address'''&amp;lt;br /&amp;gt;Press the ''A'' key to select the Set slave address function, then press ''Enter''.&lt;br /&gt;
&lt;br /&gt;
The RTC Clock slave address in binary is 1010001 (58 in Hexadecimal).&lt;br /&gt;
&lt;br /&gt;
{{note | The slave address must be shifted to the right one bit. }}&lt;br /&gt;
&lt;br /&gt;
{{clop}}&amp;lt;nowiki&amp;gt;&lt;br /&gt;
Select a function to test:&lt;br /&gt;
    a: Set slave address&lt;br /&gt;
    b: Write byte to register&lt;br /&gt;
    c: Write 2 bytes to register&lt;br /&gt;
    d: Read byte from register&lt;br /&gt;
    e: Read 2 bytes from register&lt;br /&gt;
    q: Quit&lt;br /&gt;
&amp;gt;&amp;gt; a&lt;br /&gt;
&lt;br /&gt;
Enter the slave address (in hex): 28&lt;br /&gt;
&lt;br /&gt;
Calling i2c_set_slave(3, 0x48)&lt;br /&gt;
i2c_set_slave reports success&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
{{closp}}&lt;br /&gt;
&lt;br /&gt;
== Summary ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;i2c_test&amp;lt;/code&amp;gt; C example project writes and reads bytes to a selected register on the &amp;lt;code&amp;gt;I²C&amp;lt;/code&amp;gt; device.&lt;/div&gt;</summary>
		<author><name>Nperkins</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.emacinc.com/index.php?title=Example_hello&amp;diff=15103</id>
		<title>Example hello</title>
		<link rel="alternate" type="text/html" href="https://wiki.emacinc.com/index.php?title=Example_hello&amp;diff=15103"/>
		<updated>2022-11-30T19:20:38Z</updated>

		<summary type="html">&lt;p&gt;Nperkins: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{todo|SEOKWREV (01.02.14-14:09-&amp;gt;JG+);(01.02.14-14:30-&amp;gt;MD+);(01.02.14-16:15-&amp;gt;MG+);(04.04.14-15:40-&amp;gt;BS+)|Jgreene|project=oe 4,oe 5,jg,md,SEOKWREV,mg,bs}}&lt;br /&gt;
&lt;br /&gt;
{{#seo:&lt;br /&gt;
|title=Example hello&lt;br /&gt;
|titlemode=append&lt;br /&gt;
|keywords=Example hello,Using hello,EMAC C example project&lt;br /&gt;
|description=This is a guide to the &amp;lt;code&amp;gt;hello&amp;lt;/code&amp;gt; C example project included in the EMAC OE SDK.&lt;br /&gt;
}}&lt;br /&gt;
This is a guide to the &amp;lt;code&amp;gt;hello&amp;lt;/code&amp;gt; C example project included in the EMAC OE SDK.&lt;br /&gt;
&lt;br /&gt;
This is a basic &amp;quot;hello world&amp;quot; project.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;hello&amp;lt;/code&amp;gt; project builds one executable: &amp;lt;code&amp;gt;hello&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Opening, Building and Uploading the Project Files ==&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
Alternatively, the &amp;lt;code&amp;gt;Makefile&amp;lt;/code&amp;gt; can be used with the &amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt; command from the commandline to build and upload the example.  For information on this method, please see [[Using EMAC OE SDK Example Projects]].&lt;br /&gt;
&lt;br /&gt;
====EMAC SDK 5.X====&lt;br /&gt;
&lt;br /&gt;
For information on opening the project from within QtCreator, please see [[Getting_Started_With_Qt_Creator#Adding_Source_Files | QtCreator: Adding Source Files]].  Then, follow [[Getting Started With Qt Creator]] for information on how to build, upload and execute the example.&lt;br /&gt;
&lt;br /&gt;
Alternatively, the &amp;lt;code&amp;gt;CMakefile.txt&amp;lt;/code&amp;gt; can be used with the &amp;lt;code&amp;gt;cmake&amp;lt;/code&amp;gt; command from the commandline to build and upload the example.  For information on this method, please see [[Getting_Started_with_the_EMAC_OE_SDK#Target_Machine_Compiling | Getting Started with the EMAC OE SDK]].&lt;br /&gt;
&lt;br /&gt;
Code can be found at http://git.emacinc.com/OE/example-projects&lt;br /&gt;
==Usage and Behavior==&lt;br /&gt;
&lt;br /&gt;
===Hardware Requirements===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;hello&amp;lt;/code&amp;gt; C example project will run on any system for which it can be compiled.&lt;br /&gt;
&lt;br /&gt;
===Using &amp;lt;code&amp;gt;hello&amp;lt;/code&amp;gt;===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;hello&amp;lt;/code&amp;gt; program is executed from the console. It takes no parameters.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;code&amp;gt;./hello&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The program prints a ''hello'' message to the console.&lt;br /&gt;
&lt;br /&gt;
===Usage Example===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
root@som9g20:/tmp# ./hello&lt;br /&gt;
Hello EMAC OE!&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Summary==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;hello&amp;lt;/code&amp;gt; C example project is your basic &amp;quot;hello world&amp;quot; project.&lt;/div&gt;</summary>
		<author><name>Nperkins</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.emacinc.com/index.php?title=Example_getkey&amp;diff=15100</id>
		<title>Example getkey</title>
		<link rel="alternate" type="text/html" href="https://wiki.emacinc.com/index.php?title=Example_getkey&amp;diff=15100"/>
		<updated>2022-11-30T19:20:24Z</updated>

		<summary type="html">&lt;p&gt;Nperkins: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{todo|SEOKWREV (11.14.13-11:41-&amp;gt;JG+);(11.14.13-15:30-&amp;gt;MD-);(11.21.13-14:06-&amp;gt;JG+);(11.21.13-16:15-&amp;gt;MD-);(12.03.13-14:21-&amp;gt;JG+);(01.04.14-17:01-&amp;gt;JG+);(01.03.14-17:15-&amp;gt;MD+);(01.03.14-17:35-&amp;gt;KY+);(04.03.14-16:20-&amp;gt;BS+)|Jgreene|project=oe 4,oe 5,jg,md,SEOKWREV,ky,bs}}&lt;br /&gt;
&lt;br /&gt;
{{#seo:&lt;br /&gt;
|title=Example getkey&lt;br /&gt;
|titlemode=append&lt;br /&gt;
|keywords=Example getkey,EMAC SOM-150ES,Using getkey,E020-21 Membrane hex style keypad&lt;br /&gt;
|description=This is a guide to the &amp;lt;code&amp;gt;getkey&amp;lt;/code&amp;gt; C example project included in the EMAC OE SDK.&lt;br /&gt;
}}&lt;br /&gt;
This is a guide to the &amp;lt;code&amp;gt;getkey&amp;lt;/code&amp;gt; C example project included in the EMAC OE SDK.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;getkey&amp;lt;/code&amp;gt; example C project demonstrates how to use a keypad with a SoM150ES carrier board. It provides examples of how to specify, inspect and test associations between character-data and keypad-keys. It demonstrates how to turn key-presses into character-data using the same techniques as the big keyboard on your PC. It's also a good introduction to the mysteries of matrix encoding (see [http://wikidev.emacinc.com/wiki/Example_getkey#A_Note_on_Matrix_Encoding A Note on Matrix Encoding, below]).&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;getkey&amp;lt;/code&amp;gt; C example project creates one executable: &amp;lt;code&amp;gt;getkey&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Opening, Building and Uploading the Project Files ==&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
Alternatively, the &amp;lt;code&amp;gt;Makefile&amp;lt;/code&amp;gt; can be used with the &amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt; command from the commandline to build and upload the example.  For information on this method, please see [[Using EMAC OE SDK Example Projects]].&lt;br /&gt;
&lt;br /&gt;
====EMAC SDK 5.X====&lt;br /&gt;
&lt;br /&gt;
For information on opening the project from within QtCreator, please see [[Getting_Started_With_Qt_Creator#Adding_Source_Files | QtCreator: Adding Source Files]].  Then, follow [[Getting Started With Qt Creator]] for information on how to build, upload and execute the example.&lt;br /&gt;
&lt;br /&gt;
Alternatively, the &amp;lt;code&amp;gt;CMakefile.txt&amp;lt;/code&amp;gt; can be used with the &amp;lt;code&amp;gt;cmake&amp;lt;/code&amp;gt; command from the commandline to build and upload the example.  For information on this method, please see [[Getting_Started_with_the_EMAC_OE_SDK#Target_Machine_Compiling | Getting Started with the EMAC OE SDK]].&lt;br /&gt;
&lt;br /&gt;
Code can be found at http://git.emacinc.com/OE/example-projects&lt;br /&gt;
==Usage and Behavior== &lt;br /&gt;
&lt;br /&gt;
===Hardware Requirements===&lt;br /&gt;
&lt;br /&gt;
To use the '''getkey''' program requires the following hardware.&lt;br /&gt;
&lt;br /&gt;
* A [http://www.emacinc.com/som/som150es.htm SOM-150ES carrier board] (Available from EMAC).&amp;lt;br /&amp;gt;&lt;br /&gt;
* A compatible SoM for that carrier board ([http://www.emacinc.com/products/system_on_module/SoM-9260M SOM-9260M], [http://www.emacinc.com/som/som9G20.htm SOM-9G20M] and [http://www.emacinc.com/som/som9x25.htm SOM-9X25] are all compatible and available from EMAC).&amp;lt;br /&amp;gt;&lt;br /&gt;
* A compatible keypad ([http://www.emacinc.com/sbc_microcontroller_addons.htm Available from EMAC], refer to item# E20-21 or E020-25. [https://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCsQFjAA&amp;amp;url=http%3A%2F%2Fwww.in2tec.com%2Flib%2Fdownloadfile.php%3Ffilename%3D4000_series_keypads_datasheet.pdf%26loc%3Ddocuments%2F%26ct%3Dpdf&amp;amp;ei=Wf-MUrGxO-nEyQGggoGgCg&amp;amp;usg=AFQjCNEQxIaiH6-gx6uTq4O66o1YVDunZw&amp;amp;bvm=bv.56643336,d.aWc Datasheet]). &lt;br /&gt;
&lt;br /&gt;
[[File:Som150 with keypad.JPG | 500px ]]&amp;lt;br /&amp;gt;&lt;br /&gt;
SOM-150ES carrier board with keypad&lt;br /&gt;
&lt;br /&gt;
===Plugging the Keypad into the SOM-150ES Carrier Board===&lt;br /&gt;
&lt;br /&gt;
Plug the keypad into the HDR5 KEYPAD header of the SOM-150ES Carrier Board.&amp;lt;br /&amp;gt;&lt;br /&gt;
[[File:Example getkey howtopluginthekeypad 0.png|500px]]&lt;br /&gt;
&lt;br /&gt;
Ensure that '''pin 0''' of the keypad's ribbon cable is lined up with '''pin 2''' on the header.&amp;lt;br /&amp;gt;&lt;br /&gt;
[[File:Example getkey howtopluginthekeypad 1.png|500px]]&lt;br /&gt;
&lt;br /&gt;
===The Keypad Matrix File===&lt;br /&gt;
&lt;br /&gt;
The keypad matrix file specifies associations between keypad-keys and characters. For each key in the keypad's grid of keys we specify a character in a grid of characters.&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; [[File:Example_getkey_minimalkeypad.png|200px]] &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; [[File: Example_getkey_matrixfile.png|150px]]&lt;br /&gt;
&lt;br /&gt;
In this example we see an E020-21 keypad on the left and an example keypad matrix file (&amp;lt;code&amp;gt;Key-E020-21&amp;lt;/code&amp;gt;, included in the project) opened in a text editor on the right. The character matrix may be freely edited to suit.&lt;br /&gt;
&lt;br /&gt;
====A Note on Matrix Encoding====&lt;br /&gt;
&lt;br /&gt;
Matrix Encoding is a technique for translating individual xy locations on a 2D matrix into unique integer values. Here we see locations in a 4x4 matrix being translated into an 8-bit value. Pins 0, 1, 2, 3 handle the key y coordinate; pins 4, 5, 6, 7 handle the x coordinate. Key '''A''' is at (7,0); '''B''':(6,0); '''K''':(5,2); Etc.&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; [[File:Matrix encoding.png]]&lt;br /&gt;
&lt;br /&gt;
Thus, when a key is pressed, we get a corresponding integer value on the header.&amp;lt;br /&amp;gt; &lt;br /&gt;
For example: Pressing the '''F''' key sets the values on pins '''1''' and '''6''' to 1. This gives us a binary value of 01000010. Integer value: 66 . So when the value at the header equals 66, we know that the '''F''' key was pressed.&amp;lt;br /&amp;gt;&lt;br /&gt;
'''Note:''' This is an abstract, general example of a keypad using matrix encoding. Your keypad will probably have different characters on it's keys and output slightly different values.&lt;br /&gt;
&lt;br /&gt;
===Using getkey===&lt;br /&gt;
&lt;br /&gt;
The '''getkey''' program is controlled from the console via command line parameters. You can specify the keypad device node, specify the keypad matrix file (see notes on the [http://wikidev.emacinc.com/wiki/Example_getkey#The_Keypad_Matrix_File keypad matrix file], above), display the current matrix in the console and test individual character-key associations.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;code&amp;gt;./getkey [-d device -b -g -s file]&amp;lt;/code&amp;gt; &lt;br /&gt;
&lt;br /&gt;
;-d:Specify the keypad device node. The default is &amp;lt;code&amp;gt;/dev/keypad&amp;lt;/code&amp;gt;&lt;br /&gt;
;-b:Test an individual key-character association (via &amp;quot;read blocking&amp;quot;). The program will sleep until a key on the keypad is pressed, then output that key's character to the console.&lt;br /&gt;
;-g:Outputs the current keypad matrix (see notes on the [http://wikidev.emacinc.com/wiki/Example_getkey#The_Keypad_Matrix_File keypad matrix file], above) to the console.&lt;br /&gt;
;-s:Specify the keypad matrix file. (see notes on the [http://wikidev.emacinc.com/wiki/Example_getkey#The_Keypad_Matrix_File keypad matrix file], above). If a keypad matrix file is not specified then the character associated with the last keypad key pressed is returned.&lt;br /&gt;
&lt;br /&gt;
'''Note on parameter order:''' Parameters are evaluated in order. If blocking ('''b''') or device specifications ('''d''') are used, they must be declared before the matrix arguments on the command line.&lt;br /&gt;
&lt;br /&gt;
===Usage Example. Mapping a Keypad Device Node to a Keypad Matrix File===&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;code&amp;gt;./getkey -d /dev/keypad0 -s /path/to/this/file/Key-E020-21&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The program will map the keypad at the device node &amp;lt;code&amp;gt;/dev/keypad0&amp;lt;/code&amp;gt; to the matrix file &amp;lt;code&amp;gt;Key-E020-21&amp;lt;/code&amp;gt;. This associates each character in the grid of characters in the matrix file (see notes on the [http://wikidev.emacinc.com/wiki/Example_getkey#The_Keypad_Matrix_File keypad matrix file], above) with a key in the grid of keys on the keypad.&lt;br /&gt;
&lt;br /&gt;
===Usage Example: Displaying the Character Presently Associated With a Key on the Keypad===&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;code&amp;gt;./getkey -d /dev/keypad0 -b&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The program will wait until a key is pressed on the keypad. When a key is pressed it will display the character associated with that pressed key, as specified in the keypad matrix file (see notes on the [http://wikidev.emacinc.com/wiki/Example_getkey#The_Keypad_Matrix_File keypad matrix file], above).&lt;br /&gt;
&lt;br /&gt;
For example:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
root@som9g20:/tmp# ./getkey -d /dev/keypad0 -b&lt;br /&gt;
5&lt;br /&gt;
root@som9g20:/tmp#&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
In this case, the '''5''' key on the keypad was pressed.&lt;br /&gt;
&lt;br /&gt;
===Usage Example. Displaying the Character Matrix Presently Associated with the Keypad===&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;code&amp;gt;./getkey -d /dev/keypad0 -g&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The program will display the character matrix (see notes on the [http://wikidev.emacinc.com/wiki/Example_getkey#The_Keypad_Matrix_File keypad matrix file], above) presently associated with the keypad at &amp;lt;code&amp;gt;/dev/keypad0''&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
root@som9g20:/tmp# ./getkey -d /dev/keypad0 -g&lt;br /&gt;
1 2 3 C   &lt;br /&gt;
4 5 6 D   &lt;br /&gt;
7 8 9 E   &lt;br /&gt;
A 0 B F   &lt;br /&gt;
root@som9g20:/tmp#&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The character matrix displayed here is that of the &amp;lt;code&amp;gt;Key-E020-21&amp;lt;/code&amp;gt; file.&lt;br /&gt;
&lt;br /&gt;
==Summary==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;getkey&amp;lt;/code&amp;gt; example C project demonstrates how to use a keypad with a SoM150ES carrier board.&lt;/div&gt;</summary>
		<author><name>Nperkins</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.emacinc.com/index.php?title=Example_fbench&amp;diff=15097</id>
		<title>Example fbench</title>
		<link rel="alternate" type="text/html" href="https://wiki.emacinc.com/index.php?title=Example_fbench&amp;diff=15097"/>
		<updated>2022-11-30T19:19:59Z</updated>

		<summary type="html">&lt;p&gt;Nperkins: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{todo|SEOKWREV (12.03.13-14:18-&amp;gt;JG+);(12.04.13-03:15-&amp;gt;MD-);(12.04.13-13:56-&amp;gt;JG+);(12.10.13-00:10-&amp;gt;MD+);(01.03.13-18:41-&amp;gt;MW+);(01.03.14-18:55-&amp;gt;MD+);(04.02.14-17:00-&amp;gt;BS+);(04.10.14-13:45-&amp;gt;BS+)|Jgreene|project=oe 4,oe 5,jg,md,SEOKWREV,mw,bs}}&lt;br /&gt;
&lt;br /&gt;
{{#seo:&lt;br /&gt;
|title=Example fbench&lt;br /&gt;
|titlemode=append&lt;br /&gt;
|keywords=Floating Point Operation,Floating Benchmark,Floating Point Unit&lt;br /&gt;
|description=This is a guide to the &amp;lt;code&amp;gt;fbench&amp;lt;/code&amp;gt; C example project included in the EMAC OE SDK.&lt;br /&gt;
}}&lt;br /&gt;
This is a guide to the &amp;lt;code&amp;gt;fbench&amp;lt;/code&amp;gt; C example project included in the EMAC OE SDK.&lt;br /&gt;
&lt;br /&gt;
The project contains a floating point benchmark which tests the accuracy and speed of floating point operations on the target systems. The testing application utilizes floating point intensive ray tracing  and Fast Fourier Transform algorithms to stress the processor. This project contains excerpts from the &amp;lt;code&amp;gt;fbench&amp;lt;/code&amp;gt; project by John Walker of Fourmilab. See [http://www.fourmilab.ch/fbench/ John Walker's '''Floating Point Benchmarks''' project homepage] for more information.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;fbench&amp;lt;/code&amp;gt; project builds two executables: &amp;lt;code&amp;gt;fbench&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;ffbench&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;fbench&amp;lt;/code&amp;gt; is a trigonometry intensive floating point benchmark. It is a complete optical design raytracing algorithm without the user interface.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;ffbench&amp;lt;/code&amp;gt; is a Fast Fourier Transform benchmark. It loops through a fast Fourier transform of a square matrix of complex numbers, reverses the transform and then checks the results.&lt;br /&gt;
&lt;br /&gt;
== Opening, Building and Uploading the Project Files ==&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
Alternatively, the &amp;lt;code&amp;gt;Makefile&amp;lt;/code&amp;gt; can be used with the &amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt; command from the commandline to build and upload the example.  For information on this method, please see [[Using EMAC OE SDK Example Projects]].&lt;br /&gt;
&lt;br /&gt;
====EMAC SDK 5.X====&lt;br /&gt;
&lt;br /&gt;
For information on opening the project from within QtCreator, please see [[Getting_Started_With_Qt_Creator#Adding_Source_Files | QtCreator: Adding Source Files]].  Then, follow [[Getting Started With Qt Creator]] for information on how to build, upload and execute the example.&lt;br /&gt;
&lt;br /&gt;
Alternatively, the &amp;lt;code&amp;gt;CMakefile.txt&amp;lt;/code&amp;gt; can be used with the &amp;lt;code&amp;gt;cmake&amp;lt;/code&amp;gt; command from the commandline to build and upload the example.  For information on this method, please see [[Getting_Started_with_the_EMAC_OE_SDK#Target_Machine_Compiling | Getting Started with the EMAC OE SDK]].&lt;br /&gt;
&lt;br /&gt;
Code can be found at http://git.emacinc.com/OE/example-projects&lt;br /&gt;
==Usage and Behavior== &lt;br /&gt;
&lt;br /&gt;
===Hardware Requirements===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;fbench&amp;lt;/code&amp;gt; project is intended for use on C implementations that define &amp;lt;code&amp;gt;int&amp;lt;/code&amp;gt; as 32 bits or longer and permit allocation and direct addressing of arrays larger than one megabyte.&lt;br /&gt;
&lt;br /&gt;
===Using fbench===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;fbench&amp;lt;/code&amp;gt; program is executed from the console. It takes a single optional parameter.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;code&amp;gt;./fbench &amp;lt;itercount&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Where &amp;lt;itercount&amp;gt; specifies the number of iterations to be performed, with 1,000 being the default.&amp;lt;br /&amp;gt;&lt;br /&gt;
For archival purposes you'll want to use a value slightly higher than 1,000.&lt;br /&gt;
&lt;br /&gt;
====Usage Example====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
root@som9g20:/tmp# ./fbench 2000&lt;br /&gt;
Ready to begin John Walker's floating point accuracy&lt;br /&gt;
and performance benchmark.  2000 iterations will be made.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Measured run time in seconds should be divided by 2&lt;br /&gt;
to normalise for reporting results.  For archival results,&lt;br /&gt;
adjust iteration count so the benchmark runs about five minutes.&lt;br /&gt;
&lt;br /&gt;
Press return to begin benchmark:&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After &amp;lt;code&amp;gt;fbench&amp;lt;/code&amp;gt; has finished it prompts the user to stop the timer (by pressing return).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
Stop the timer:&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Press return...&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
No errors in results.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
...and &amp;lt;code&amp;gt;fbench&amp;lt;/code&amp;gt; reports that no errors were found in the floating point operations.&lt;br /&gt;
&lt;br /&gt;
====A Note on Suspicious Systems====&lt;br /&gt;
&lt;br /&gt;
The default functionality as described above is for systems that can be trusted to be reliable. When working with a system that is suspected of having issues, &amp;lt;code&amp;gt;fbench&amp;lt;/code&amp;gt; can be compiled with &amp;lt;code&amp;gt;ACCURACY&amp;lt;/code&amp;gt; defined. This will generate a version that executes as an infinite loop, performs the ray trace and checks the results on every pass. All incorrect results will be reported. It will keep running until it is stopped manually (using, for instance, CTRL-C).&lt;br /&gt;
&lt;br /&gt;
===Using ffbench===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;ffbench&amp;lt;/code&amp;gt; program is executed from the console. It takes no parameters.&lt;br /&gt;
&lt;br /&gt;
 ./ffbench&lt;br /&gt;
&lt;br /&gt;
====Usage Example====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
root@som9g20:/tmp# ./ffbench&lt;br /&gt;
20 passes.  No errors in results.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It runs until it is finished and reports what it discovered. In this case it performed 20 passes (the default, specified in code) and found no errors.&amp;lt;br /&amp;gt;&lt;br /&gt;
The time that it takes for this benchmark to run is an indicator of the performance of the board running it. When running it from a Bash shell, the execution time can be measured thusly:&lt;br /&gt;
 &amp;lt;code&amp;gt;time ./fbench&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Summary==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;fbench&amp;lt;/code&amp;gt; floating point benchmark C example tests the speed and accuracy of your floating point operations, and is interactive by default. The &amp;lt;code&amp;gt;ffbench&amp;lt;/code&amp;gt; example, on the other hand, is non-interactive by default and can be readily used both for benchmarking a board's floating point performance and to test the accuracy of its FPU.&lt;/div&gt;</summary>
		<author><name>Nperkins</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.emacinc.com/index.php?title=Example_can&amp;diff=15094</id>
		<title>Example can</title>
		<link rel="alternate" type="text/html" href="https://wiki.emacinc.com/index.php?title=Example_can&amp;diff=15094"/>
		<updated>2022-11-30T19:18:24Z</updated>

		<summary type="html">&lt;p&gt;Nperkins: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{#seo:&lt;br /&gt;
|title=Example can&lt;br /&gt;
|titlemode=append&lt;br /&gt;
|keywords=Example can,Using can,EMAC C example project&lt;br /&gt;
|description=This is a guide to the &amp;lt;code&amp;gt;casn&amp;lt;/code&amp;gt; C example project included in the EMAC OE SDK.&lt;br /&gt;
}}&lt;br /&gt;
This is a guide to the &amp;lt;code&amp;gt;can&amp;lt;/code&amp;gt; C example project included in the EMAC OE SDK.&lt;br /&gt;
&lt;br /&gt;
A Controller Area Network (CAN bus) is a robust bus standard for in-vehicle networks. Originally designed for use in the automotive industry, CAN allows micro-controllers and devices to communicate through a message-based protocol with device priority and is used in many different applications to this day.&lt;br /&gt;
&lt;br /&gt;
This project serves as a demonstration of using the CAN bus.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;can&amp;lt;/code&amp;gt; project builds one executable: &amp;lt;code&amp;gt;can&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Opening, Building and Uploading the Project Files ==&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
Alternatively, the &amp;lt;code&amp;gt;Makefile&amp;lt;/code&amp;gt; can be used with the &amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt; command from the commandline to build and upload the example.  For information on this method, please see [[Using EMAC OE SDK Example Projects]].&lt;br /&gt;
&lt;br /&gt;
====EMAC SDK 5.X====&lt;br /&gt;
&lt;br /&gt;
For information on opening the project from within QtCreator, please see [[Getting_Started_With_Qt_Creator#Adding_Source_Files | QtCreator: Adding Source Files]].  Then, follow [[Getting Started With Qt Creator]] for information on how to build, upload and execute the example.&lt;br /&gt;
&lt;br /&gt;
Alternatively, the &amp;lt;code&amp;gt;CMakefile.txt&amp;lt;/code&amp;gt; can be used with the &amp;lt;code&amp;gt;cmake&amp;lt;/code&amp;gt; command from the commandline to build and upload the example.  For information on this method, please see [[Getting_Started_with_the_EMAC_OE_SDK#Target_Machine_Compiling | Getting Started with the EMAC OE SDK]].&lt;br /&gt;
&lt;br /&gt;
Code can be found at http://git.emacinc.com/OE/example-projects&lt;br /&gt;
==Usage and Behavior==&lt;br /&gt;
&lt;br /&gt;
===Hardware Requirements===&lt;br /&gt;
&lt;br /&gt;
It should run just fine on any device with a CAN interface. You will need:&lt;br /&gt;
* Two devices with a CAN interface&lt;br /&gt;
&lt;br /&gt;
===Using &amp;lt;code&amp;gt;can&amp;lt;/code&amp;gt;===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;can&amp;lt;/code&amp;gt; program is executed from the console. Requires either the argument &amp;quot;send&amp;quot; or &amp;quot;receive&amp;quot;&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;code&amp;gt;./can [send/recieve]&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The program will wait for data payload to be received (argument: &amp;quot;receive&amp;quot;) through CAN or send data payload (argument: &amp;quot;send&amp;quot;), 8 random hex bytes, through CAN. The payload will then be printed on the receive end.   &lt;br /&gt;
&lt;br /&gt;
===Usage Example===&lt;br /&gt;
Prepare Device 1 to receive:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
root@ipac9x25:~# ./can receive&lt;br /&gt;
.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Send Data from Device 2:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
root@somimx6ul:~# ./can send&lt;br /&gt;
root@somimx6ul:~#&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Device 1 received:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
root@ipac9x25:~# ./can receive&lt;br /&gt;
&amp;lt;0x001&amp;gt; [8] 87 5a 6a 37 7a 94 a4 01&lt;br /&gt;
root@ipac9x25:~#&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Usage Example for iPac9x25===&lt;br /&gt;
You must first go into code and change the ifname to the name of your can port. The default example will use &amp;quot;can0&amp;quot;. &lt;br /&gt;
Prepare Device 1 to receive:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
root@ipac9x25:~# ./can receive&lt;br /&gt;
.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Send Data from Device 2:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
root@somimx6ul:~# ./can send &amp;lt;data&amp;gt;&lt;br /&gt;
root@somimx6ul:~#&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Device 1 received:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
root@ipac9x25:~# ./can receive&lt;br /&gt;
&amp;lt;0x001&amp;gt; [8] 87 5a 6a 37 7a 94 a4 01&lt;br /&gt;
root@ipac9x25:~#&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Summary==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;can&amp;lt;/code&amp;gt; C example project demonstrates the use of the CAN bus.&lt;/div&gt;</summary>
		<author><name>Nperkins</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.emacinc.com/index.php?title=Example_SPI_test&amp;diff=15091</id>
		<title>Example SPI test</title>
		<link rel="alternate" type="text/html" href="https://wiki.emacinc.com/index.php?title=Example_SPI_test&amp;diff=15091"/>
		<updated>2022-10-14T17:28:27Z</updated>

		<summary type="html">&lt;p&gt;Nperkins: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{todo|Buggy (2.21.14-17:40-&amp;gt;BS+);(2.24.14-13:00-&amp;gt;MD-)(2.28.14-17:48-&amp;gt;BS+)(03.10.14-13:30-&amp;gt;MD-)(08.27.14-16:55-&amp;gt;BS+)(09.09.14-17:20-&amp;gt;MD-)(09.10.14-17:00-&amp;gt;BS+)(09.13.14-21:40-&amp;gt;MD+) |Brian Serrano|project=oe 4,md,Complete,bs}}&lt;br /&gt;
&lt;br /&gt;
This is a guide to the &amp;lt;code&amp;gt;spi_test&amp;lt;/code&amp;gt; example project included in the EMAC OE SDK.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;SPI&amp;lt;/code&amp;gt; protocol works in a master/slave setup. The master is responsible for sending the clock pulses. At each clock pulse, data will be sent and received.  The rising or the falling clock edge will be used to synchronize the transfer depending on the CPOL setting.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;SPI&amp;lt;/code&amp;gt; devices have a slave select pin. Every device will share the &amp;lt;code&amp;gt;MISO&amp;lt;/code&amp;gt; (Master Input Slave Output), &amp;lt;code&amp;gt;MOSI&amp;lt;/code&amp;gt; (Master Output Slave Input), and &amp;lt;code&amp;gt;Clock&amp;lt;/code&amp;gt; pins, but each device will have its own slave select pin (also know as chip select). The slave select pin is used to set one device to be active on the bus while deactivating the rest.  Theoretically, this means a virtually unlimited number of devices can be used on the same &amp;lt;code&amp;gt;SPI&amp;lt;/code&amp;gt; bus; in practice, the number is limited by a number of factors, such as required transaction rates, mechanisms (GPIO pins, bus expanders, etc) available for selecting specific devices, and physical routing constraints.  The slave select pin can be active high or active low depending on the device.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;SPI&amp;lt;/code&amp;gt; protocol defines four signal lines, but only requires three to operate properly. The fourth line is only required if you have more than one device on the SPI bus; otherwise, you can hard-wire the chip select pin of the only device on the &amp;lt;code&amp;gt;SPI&amp;lt;/code&amp;gt; bus so that it is always selected. &lt;br /&gt;
&lt;br /&gt;
This procedure provides an overview of how to compile and run the &amp;lt;code&amp;gt;spi_test&amp;lt;/code&amp;gt; C example project. This is an example test interface for sending a transaction to an EMAC &amp;lt;code&amp;gt;SPI&amp;lt;/code&amp;gt; device interface. It is only relevant if the EMAC &amp;lt;code&amp;gt;SPI&amp;lt;/code&amp;gt; device interface is enabled for an external &amp;lt;code&amp;gt;SPI&amp;lt;/code&amp;gt; device that is connected to the bus. It assumes familiarity with the C programming language and is intended to be used by experienced programmers who are looking to learn the EMAC SDK.&lt;br /&gt;
&lt;br /&gt;
For more information about the &amp;lt;code&amp;gt;SPI&amp;lt;/code&amp;gt; protocol, see the following page: http://en.wikipedia.org/wiki/Serial_Peripheral_Interface_Bus&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;spi_test&amp;lt;/code&amp;gt; project builds one executable: &amp;lt;code&amp;gt;spi_test&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Opening, Building and Uploading the Project Files ==&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
Alternatively, the &amp;lt;code&amp;gt;Makefile&amp;lt;/code&amp;gt; can be used with the &amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt; command from the commandline to build and upload the example.  For information on this method, please see [[Using EMAC OE SDK Example Projects]].&lt;br /&gt;
&lt;br /&gt;
====EMAC SDK 5.X====&lt;br /&gt;
&lt;br /&gt;
For information on opening the project from within QtCreator, please see [[Getting_Started_With_Qt_Creator#Adding_Source_Files | QtCreator: Adding Source Files]].  Then, follow [[Getting Started With Qt Creator]] for information on how to build, upload and execute the example.&lt;br /&gt;
&lt;br /&gt;
Alternatively, the &amp;lt;code&amp;gt;CMakefile.txt&amp;lt;/code&amp;gt; can be used with the &amp;lt;code&amp;gt;cmake&amp;lt;/code&amp;gt; command from the commandline to build and upload the example.  For information on this method, please see [[Getting_Started_with_the_EMAC_OE_SDK#Target_Machine_Compiling | Getting Started with the EMAC OE SDK]].&lt;br /&gt;
&lt;br /&gt;
== Usage and Behavior ==&lt;br /&gt;
===Hardware Requirements===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;spi_test&amp;lt;/code&amp;gt; C example project will run on any EMAC carrier board which has an &amp;lt;code&amp;gt;SPI&amp;lt;/code&amp;gt; interface (see also the [http://wikidev.emacinc.com/wiki/EMAC_SPI_Programming EMAC SPI Programming] page).&lt;br /&gt;
&lt;br /&gt;
=== Using indexed_atod_test ===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;indexed_atod_test&amp;lt;/code&amp;gt; program is executed from the console. It takes two parameters. &lt;br /&gt;
&lt;br /&gt;
 root@emac-oe~:$ ./indexed_atod_test device channel&lt;br /&gt;
&lt;br /&gt;
:* &amp;lt;code&amp;gt;device&amp;lt;/code&amp;gt;: Name of the &amp;lt;code&amp;gt;indexed_atod&amp;lt;/code&amp;gt; device node.&lt;br /&gt;
:* &amp;lt;code&amp;gt;channel&amp;lt;/code&amp;gt;: Number of &amp;lt;code&amp;gt;indexed_atod&amp;lt;/code&amp;gt; channels to be displayed.&lt;br /&gt;
&lt;br /&gt;
{|style=&amp;quot;margin: 0 auto;&amp;quot;&lt;br /&gt;
| [[File:Potentiometer3.jpg|left|thumb|300px|alt=A potentiometer circuit.|Figure 1: Potentiometer Circuit]]&lt;br /&gt;
| [[File:Hdr8_chan1.jpg|right|thumb|250px|alt=HDR8 Analog I/O|Figure 2: HDR8 ANALOG I/O]]&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
This example command was run on an EMAC SoM-150ES carrier board with a SoM-9G20M. This test uses a potentiometer for input to the A/D. You will be communicating with the mcp3208 chip, which is an 8-channel 12-bit A/D converter with SPI Serial Interface. Figure 1 provides a potentiometer test circuit for help on connection to the SoM-150ES carrier board.  A circuit like this is recommended for familiarizing oneself with the A/D code before connecting the actual device to be measured by the A/D.&lt;br /&gt;
&lt;br /&gt;
Before running the command in the terminal, you will need to connect the potentiometer to the carrier board as diagrammed. Figure 2 shows where to connect the potentiometer on Header 8 of the SoM-150ES. You will be focusing on CARR_ANL_1 for this example. &lt;br /&gt;
&lt;br /&gt;
Turn the potentiometer counter-clockwise as far as it goes. You'll see the results when you run the command below. Test results will be displayed in the terminal.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=console&amp;gt;&lt;br /&gt;
root@emac-oe~:$ ./indexed_atod_test /dev/mcp3208-gpio 4&lt;br /&gt;
[0] = 83&lt;br /&gt;
[1] = 4094&lt;br /&gt;
[2] = 61&lt;br /&gt;
[3] = 267&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The results that are displayed from the terminal show channel 1 analog value at 4094. All the other results are just noise coming from the mcp3208 chip.  This noise can be virtually eliminated by grounding the unused A/D inputs.&lt;br /&gt;
&lt;br /&gt;
For the second example, turn the potentiometer clockwise as far as it goes. You'll see how channel 1 results will change when running the command below. Test results will be displayed in the terminal.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=console&amp;gt;&lt;br /&gt;
root@emac-oe~:$ ./indexed_atod_test /dev/mcp3208-gpio 4&lt;br /&gt;
[0] = 62&lt;br /&gt;
[1] = 0&lt;br /&gt;
[2] = 10&lt;br /&gt;
[3] = 95&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here, the results show channel 1 analog value at zero. Your results may vary, depending on the characteristics of your potentiometer and the ADC noise present.  You can alter the value by turning the potentiometer to different positions. &lt;br /&gt;
&lt;br /&gt;
[[File:Hdr8_chan6.jpg|center|thumb|250px|alt=HDR8 Analog I/O|Figure 3: HDR8 ANALOG I/O]]&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Before doing example 3, you'll want to put the wiper (B) wire on pin 9 of the SoM-150ES carrier board. Figure 3 shows that pin 9 is CARR_ANL_6. Turn the potentiometer counter-clockwise about half way. You will see how the values on channel 6 will change when running the command below. Test results will be displayed in the terminal.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=console&amp;gt;&lt;br /&gt;
root@emac-oe~:$ ./indexed_atod_test /dev/mcp3208-gpio 7&lt;br /&gt;
[0] = 53&lt;br /&gt;
[1] = 0&lt;br /&gt;
[2] = 56&lt;br /&gt;
[3] = 0&lt;br /&gt;
[4] = 29&lt;br /&gt;
[5] = 43&lt;br /&gt;
[6] = 2044&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The results show the channel 6 analog value at 2044, which is about half way (4095/2). You can change any of the channels value with the potentiometer as long as you put the wiper pin on the channel you want to change.&lt;br /&gt;
&lt;br /&gt;
Due to ADC noise, you may see the values fluctuate slightly from one run to the next.  This is normal behavior.  This fluctuation can be more severe with some potentiometers than it is with others; some potentiometers are more prone to picking up noise.  The noise will also be more severe with longer wires, due to transmission line effects.  Eliminating noise is typically the greatest challenge in high resolution A/D conversion (especially at 18 bit and above), so you should expect to see some noise when performing an informal test such as this.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Updates for iPac9x25==&lt;br /&gt;
In order to run these examples on the board, either follow the schematic from figure 4 or use part MIKROE-304. &lt;br /&gt;
{|style=&amp;quot;margin: 0 auto;&amp;quot;&lt;br /&gt;
|[[File:Spi Test Schematic.png|thumb|Figure 4: Schematic used to set up spi test for iPac9x25]]&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Summary ==&lt;br /&gt;
The &amp;lt;code&amp;gt;indexed_atod_test&amp;lt;/code&amp;gt; C example project demonstrates how to use a 12 bit A/D converter chip (mcp3208) with SPI Serial Interface. &amp;lt;code&amp;gt;SPI&amp;lt;/code&amp;gt; is simply a way to send data from device to device in a serial fashion (bit by bit). &amp;lt;code&amp;gt;SPI&amp;lt;/code&amp;gt; provides good support for communication with peripheral devices that are accessed intermittently.&lt;/div&gt;</summary>
		<author><name>Nperkins</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.emacinc.com/index.php?title=Example_SPI_test&amp;diff=15088</id>
		<title>Example SPI test</title>
		<link rel="alternate" type="text/html" href="https://wiki.emacinc.com/index.php?title=Example_SPI_test&amp;diff=15088"/>
		<updated>2022-10-14T17:27:46Z</updated>

		<summary type="html">&lt;p&gt;Nperkins: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{todo|Buggy (2.21.14-17:40-&amp;gt;BS+);(2.24.14-13:00-&amp;gt;MD-)(2.28.14-17:48-&amp;gt;BS+)(03.10.14-13:30-&amp;gt;MD-)(08.27.14-16:55-&amp;gt;BS+)(09.09.14-17:20-&amp;gt;MD-)(09.10.14-17:00-&amp;gt;BS+)(09.13.14-21:40-&amp;gt;MD+) |Brian Serrano|project=oe 4,md,Complete,bs}}&lt;br /&gt;
&lt;br /&gt;
This is a guide to the &amp;lt;code&amp;gt;spi_test&amp;lt;/code&amp;gt; example project included in the EMAC OE SDK.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;SPI&amp;lt;/code&amp;gt; protocol works in a master/slave setup. The master is responsible for sending the clock pulses. At each clock pulse, data will be sent and received.  The rising or the falling clock edge will be used to synchronize the transfer depending on the CPOL setting.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;SPI&amp;lt;/code&amp;gt; devices have a slave select pin. Every device will share the &amp;lt;code&amp;gt;MISO&amp;lt;/code&amp;gt; (Master Input Slave Output), &amp;lt;code&amp;gt;MOSI&amp;lt;/code&amp;gt; (Master Output Slave Input), and &amp;lt;code&amp;gt;Clock&amp;lt;/code&amp;gt; pins, but each device will have its own slave select pin (also know as chip select). The slave select pin is used to set one device to be active on the bus while deactivating the rest.  Theoretically, this means a virtually unlimited number of devices can be used on the same &amp;lt;code&amp;gt;SPI&amp;lt;/code&amp;gt; bus; in practice, the number is limited by a number of factors, such as required transaction rates, mechanisms (GPIO pins, bus expanders, etc) available for selecting specific devices, and physical routing constraints.  The slave select pin can be active high or active low depending on the device.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;SPI&amp;lt;/code&amp;gt; protocol defines four signal lines, but only requires three to operate properly. The fourth line is only required if you have more than one device on the SPI bus; otherwise, you can hard-wire the chip select pin of the only device on the &amp;lt;code&amp;gt;SPI&amp;lt;/code&amp;gt; bus so that it is always selected. &lt;br /&gt;
&lt;br /&gt;
This procedure provides an overview of how to compile and run the &amp;lt;code&amp;gt;spi_test&amp;lt;/code&amp;gt; C example project. This is an example test interface for sending a transaction to an EMAC &amp;lt;code&amp;gt;SPI&amp;lt;/code&amp;gt; device interface. It is only relevant if the EMAC &amp;lt;code&amp;gt;SPI&amp;lt;/code&amp;gt; device interface is enabled for an external &amp;lt;code&amp;gt;SPI&amp;lt;/code&amp;gt; device that is connected to the bus. It assumes familiarity with the C programming language and is intended to be used by experienced programmers who are looking to learn the EMAC SDK.&lt;br /&gt;
&lt;br /&gt;
For more information about the &amp;lt;code&amp;gt;SPI&amp;lt;/code&amp;gt; protocol, see the following page: http://en.wikipedia.org/wiki/Serial_Peripheral_Interface_Bus&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;spi_test&amp;lt;/code&amp;gt; project builds one executable: &amp;lt;code&amp;gt;spi_test&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Opening, Building and Uploading the Project Files ==&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
Alternatively, the &amp;lt;code&amp;gt;Makefile&amp;lt;/code&amp;gt; can be used with the &amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt; command from the commandline to build and upload the example.  For information on this method, please see [[Using EMAC OE SDK Example Projects]].&lt;br /&gt;
&lt;br /&gt;
====EMAC SDK 5.X====&lt;br /&gt;
&lt;br /&gt;
For information on opening the project from within QtCreator, please see [[Getting_Started_With_Qt_Creator#Adding_Source_Files | QtCreator: Adding Source Files]].  Then, follow [[Getting Started With Qt Creator]] for information on how to build, upload and execute the example.&lt;br /&gt;
&lt;br /&gt;
Alternatively, the &amp;lt;code&amp;gt;CMakefile.txt&amp;lt;/code&amp;gt; can be used with the &amp;lt;code&amp;gt;cmake&amp;lt;/code&amp;gt; command from the commandline to build and upload the example.  For information on this method, please see [[Getting_Started_with_the_EMAC_OE_SDK#Target_Machine_Compiling | Getting Started with the EMAC OE SDK]].&lt;br /&gt;
&lt;br /&gt;
== Usage and Behavior ==&lt;br /&gt;
===Hardware Requirements===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;spi_test&amp;lt;/code&amp;gt; C example project will run on any EMAC carrier board which has an &amp;lt;code&amp;gt;SPI&amp;lt;/code&amp;gt; interface (see also the [http://wikidev.emacinc.com/wiki/EMAC_SPI_Programming EMAC SPI Programming] page).&lt;br /&gt;
&lt;br /&gt;
=== Using indexed_atod_test ===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;indexed_atod_test&amp;lt;/code&amp;gt; program is executed from the console. It takes two parameters. &lt;br /&gt;
&lt;br /&gt;
 root@emac-oe~:$ ./indexed_atod_test device channel&lt;br /&gt;
&lt;br /&gt;
:* &amp;lt;code&amp;gt;device&amp;lt;/code&amp;gt;: Name of the &amp;lt;code&amp;gt;indexed_atod&amp;lt;/code&amp;gt; device node.&lt;br /&gt;
:* &amp;lt;code&amp;gt;channel&amp;lt;/code&amp;gt;: Number of &amp;lt;code&amp;gt;indexed_atod&amp;lt;/code&amp;gt; channels to be displayed.&lt;br /&gt;
&lt;br /&gt;
{|style=&amp;quot;margin: 0 auto;&amp;quot;&lt;br /&gt;
| [[File:Potentiometer3.jpg|left|thumb|300px|alt=A potentiometer circuit.|Figure 1: Potentiometer Circuit]]&lt;br /&gt;
| [[File:Hdr8_chan1.jpg|right|thumb|250px|alt=HDR8 Analog I/O|Figure 2: HDR8 ANALOG I/O]]&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
This example command was run on an EMAC SoM-150ES carrier board with a SoM-9G20M. This test uses a potentiometer for input to the A/D. You will be communicating with the mcp3208 chip, which is an 8-channel 12-bit A/D converter with SPI Serial Interface. Figure 1 provides a potentiometer test circuit for help on connection to the SoM-150ES carrier board.  A circuit like this is recommended for familiarizing oneself with the A/D code before connecting the actual device to be measured by the A/D.&lt;br /&gt;
&lt;br /&gt;
Before running the command in the terminal, you will need to connect the potentiometer to the carrier board as diagrammed. Figure 2 shows where to connect the potentiometer on Header 8 of the SoM-150ES. You will be focusing on CARR_ANL_1 for this example. &lt;br /&gt;
&lt;br /&gt;
Turn the potentiometer counter-clockwise as far as it goes. You'll see the results when you run the command below. Test results will be displayed in the terminal.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=console&amp;gt;&lt;br /&gt;
root@emac-oe~:$ ./indexed_atod_test /dev/mcp3208-gpio 4&lt;br /&gt;
[0] = 83&lt;br /&gt;
[1] = 4094&lt;br /&gt;
[2] = 61&lt;br /&gt;
[3] = 267&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The results that are displayed from the terminal show channel 1 analog value at 4094. All the other results are just noise coming from the mcp3208 chip.  This noise can be virtually eliminated by grounding the unused A/D inputs.&lt;br /&gt;
&lt;br /&gt;
For the second example, turn the potentiometer clockwise as far as it goes. You'll see how channel 1 results will change when running the command below. Test results will be displayed in the terminal.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=console&amp;gt;&lt;br /&gt;
root@emac-oe~:$ ./indexed_atod_test /dev/mcp3208-gpio 4&lt;br /&gt;
[0] = 62&lt;br /&gt;
[1] = 0&lt;br /&gt;
[2] = 10&lt;br /&gt;
[3] = 95&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here, the results show channel 1 analog value at zero. Your results may vary, depending on the characteristics of your potentiometer and the ADC noise present.  You can alter the value by turning the potentiometer to different positions. &lt;br /&gt;
&lt;br /&gt;
[[File:Hdr8_chan6.jpg|center|thumb|250px|alt=HDR8 Analog I/O|Figure 3: HDR8 ANALOG I/O]]&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Before doing example 3, you'll want to put the wiper (B) wire on pin 9 of the SoM-150ES carrier board. Figure 3 shows that pin 9 is CARR_ANL_6. Turn the potentiometer counter-clockwise about half way. You will see how the values on channel 6 will change when running the command below. Test results will be displayed in the terminal.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=console&amp;gt;&lt;br /&gt;
root@emac-oe~:$ ./indexed_atod_test /dev/mcp3208-gpio 7&lt;br /&gt;
[0] = 53&lt;br /&gt;
[1] = 0&lt;br /&gt;
[2] = 56&lt;br /&gt;
[3] = 0&lt;br /&gt;
[4] = 29&lt;br /&gt;
[5] = 43&lt;br /&gt;
[6] = 2044&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The results show the channel 6 analog value at 2044, which is about half way (4095/2). You can change any of the channels value with the potentiometer as long as you put the wiper pin on the channel you want to change.&lt;br /&gt;
&lt;br /&gt;
Due to ADC noise, you may see the values fluctuate slightly from one run to the next.  This is normal behavior.  This fluctuation can be more severe with some potentiometers than it is with others; some potentiometers are more prone to picking up noise.  The noise will also be more severe with longer wires, due to transmission line effects.  Eliminating noise is typically the greatest challenge in high resolution A/D conversion (especially at 18 bit and above), so you should expect to see some noise when performing an informal test such as this.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Updates for iPac9x25==&lt;br /&gt;
In order to run these examples on the board, either follow the schematic from figure 4 or use part MIKROE-304. &lt;br /&gt;
{|style=&amp;quot;margin: 0 auto;&amp;quot;&lt;br /&gt;
| [[File:Potentiometer3.jpg|left|thumb|300px|alt=A potentiometer circuit.|Figure 1: Potentiometer Circuit]]&lt;br /&gt;
[[File:Spi Test Schematic.png|thumb|Schematic used to set up spi test for iPac9x25]]&lt;br /&gt;
&amp;lt;br clear=all&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Summary ==&lt;br /&gt;
The &amp;lt;code&amp;gt;indexed_atod_test&amp;lt;/code&amp;gt; C example project demonstrates how to use a 12 bit A/D converter chip (mcp3208) with SPI Serial Interface. &amp;lt;code&amp;gt;SPI&amp;lt;/code&amp;gt; is simply a way to send data from device to device in a serial fashion (bit by bit). &amp;lt;code&amp;gt;SPI&amp;lt;/code&amp;gt; provides good support for communication with peripheral devices that are accessed intermittently.&lt;/div&gt;</summary>
		<author><name>Nperkins</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.emacinc.com/index.php?title=File:Spi_Test_Schematic.png&amp;diff=15087</id>
		<title>File:Spi Test Schematic.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.emacinc.com/index.php?title=File:Spi_Test_Schematic.png&amp;diff=15087"/>
		<updated>2022-10-14T17:27:16Z</updated>

		<summary type="html">&lt;p&gt;Nperkins: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Schematic to be used to set up spi test on iPac9x25.&lt;/div&gt;</summary>
		<author><name>Nperkins</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.emacinc.com/index.php?title=Example_i2c_test&amp;diff=15084</id>
		<title>Example i2c test</title>
		<link rel="alternate" type="text/html" href="https://wiki.emacinc.com/index.php?title=Example_i2c_test&amp;diff=15084"/>
		<updated>2022-10-14T17:08:47Z</updated>

		<summary type="html">&lt;p&gt;Nperkins: /* Using i2c_test */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{todo|Buggy (11.14.13-13:25-&amp;gt;JG+);(11.14.13-15:45-&amp;gt;MD-);(01.30.14-16:20-&amp;gt;BS+);(01.30.14-18:30-&amp;gt;MD-);(11.10.2015-12:50-&amp;gt;MD+)|Brian Serrano|project=oe 4,oe 5,md,Buggy,bs}}&lt;br /&gt;
&lt;br /&gt;
This is a guide to the &amp;lt;code&amp;gt;i2c_test&amp;lt;/code&amp;gt; example project included in the EMAC OE SDK.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;I²C&amp;lt;/code&amp;gt; is a two wire serial interface used to connect to a variety of sensor and I/O devices. The interface uses only two bi-directional open-drain I/Os, Serial Data Line (SDA) and Serial Clock (SCL), to communicate to devices based on an address encoded within the data transmission. SDA is a data signal which sends and receives serially transmitted data. SCL is a clock signal which is used to determine when to latch data from the SDA line.&lt;br /&gt;
&lt;br /&gt;
This procedure provides an overview of how to compile and run the &amp;lt;code&amp;gt;i2c_test&amp;lt;/code&amp;gt; C example project. This is an example test interface for reading/writing to the Linux &amp;lt;code&amp;gt;I²C&amp;lt;/code&amp;gt; device interface. It is only relevant if the &amp;lt;code&amp;gt;I²C&amp;lt;/code&amp;gt; device interface is enabled and an external &amp;lt;code&amp;gt;I²C&amp;lt;/code&amp;gt; device is connected to the bus. It assumes familiarity with the C programming language and is intended to be used by experienced programmers who are looking to learn the EMAC SDK.&lt;br /&gt;
&lt;br /&gt;
For more information about the protocol see the following page: http://www.nxp.com/documents/user_manual/UM10204.pdf&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;i2c_test&amp;lt;/code&amp;gt; project builds one executable: &amp;lt;code&amp;gt;i2c_test&amp;lt;/code&amp;gt;.&lt;br /&gt;
== Opening, Building and Uploading the Project Files ==&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
Alternatively, the &amp;lt;code&amp;gt;Makefile&amp;lt;/code&amp;gt; can be used with the &amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt; command from the commandline to build and upload the example.  For information on this method, please see [[Using EMAC OE SDK Example Projects]].&lt;br /&gt;
&lt;br /&gt;
====EMAC SDK 5.X====&lt;br /&gt;
&lt;br /&gt;
For information on opening the project from within QtCreator, please see [[Getting_Started_With_Qt_Creator#Adding_Source_Files | QtCreator: Adding Source Files]].  Then, follow [[Getting Started With Qt Creator]] for information on how to build, upload and execute the example.&lt;br /&gt;
&lt;br /&gt;
Alternatively, the &amp;lt;code&amp;gt;CMakefile.txt&amp;lt;/code&amp;gt; can be used with the &amp;lt;code&amp;gt;cmake&amp;lt;/code&amp;gt; command from the commandline to build and upload the example.  For information on this method, please see [[Getting_Started_with_the_EMAC_OE_SDK#Target_Machine_Compiling | Getting Started with the EMAC OE SDK]].&lt;br /&gt;
== Usage and Behavior ==&lt;br /&gt;
=== Hardware Requirements ===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;i2c_test&amp;lt;/code&amp;gt; C example project will run on any EMAC carrier board which has an &amp;lt;code&amp;gt;I²C&amp;lt;/code&amp;gt; interface (see also the [[EMAC_I²C_Programming | EMAC I²C Programming]] page).&lt;br /&gt;
&lt;br /&gt;
===Using i2c_test===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;i2c_test&amp;lt;/code&amp;gt; program is executed from the console. If using the iPac9x25 it takes an optional argument which is the string representing the device path. By default, &amp;quot;/dev/i2c-1&amp;quot; is set, but if another device path needs to be used, append that to the command. &lt;br /&gt;
&lt;br /&gt;
{{cli |./i2c_test &amp;lt;optional device_path&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
A menu will appear in the terminal:&lt;br /&gt;
&lt;br /&gt;
{{clop}}&amp;lt;nowiki&amp;gt;&lt;br /&gt;
Select a function to test:&lt;br /&gt;
    a: Set slave address&lt;br /&gt;
    b: Write byte to register&lt;br /&gt;
    c: Write 2 bytes to register&lt;br /&gt;
    d: Read byte from register&lt;br /&gt;
    e: Read 2 bytes from register&lt;br /&gt;
    q: Quit&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
{{closp}}&lt;br /&gt;
&lt;br /&gt;
Select a function (a,b,c,d,e) to test or q to quit. You will be prompted for read, write and register values as appropriate. Test results will be displayed in the terminal.&lt;br /&gt;
&lt;br /&gt;
==== Test Options ====&lt;br /&gt;
&amp;lt;!--&amp;lt;cl&amp;gt;--&amp;gt;&lt;br /&gt;
* '''Set Slave Address'''&amp;lt;br /&amp;gt;Press the ''A'' key to select the Set slave address function, then press ''Enter''.&lt;br /&gt;
{{clop | indent=1 }}&amp;lt;nowiki&amp;gt;&lt;br /&gt;
Select a function to test:&lt;br /&gt;
    a: Set slave address&lt;br /&gt;
    b: Write byte to register&lt;br /&gt;
    c: Write 2 bytes to register&lt;br /&gt;
    d: Read byte from register&lt;br /&gt;
    e: Read 2 bytes from register&lt;br /&gt;
    q: Quit&lt;br /&gt;
&amp;gt;&amp;gt; a&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Enter the slave address (in hex): 48&lt;br /&gt;
&lt;br /&gt;
Calling i2c_set_slave(3, 0x48)&lt;br /&gt;
i2c_set_slave reports success&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
{{closp}}&lt;br /&gt;
&amp;lt;p style=&amp;quot;margin-left:2%;&amp;quot;&amp;gt;&lt;br /&gt;
The slave address receives the clock and responds when addressed by the master.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p style=&amp;quot;margin-left:2%;&amp;quot;&amp;gt;This function is to set the slave address of the &amp;lt;code&amp;gt;I²C&amp;lt;/code&amp;gt; device. This only need to be done once to initialize the address and then each time that a new device is addressed.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* '''Write byte to register'''&amp;lt;br /&amp;gt;Press the ''B'' key to select the Write byte to register function, then press ''Enter''&lt;br /&gt;
{{clop | indent=1 }}&amp;lt;nowiki&amp;gt;&lt;br /&gt;
Select a function to test:&lt;br /&gt;
    a: Set slave address&lt;br /&gt;
    b: Write byte to register&lt;br /&gt;
    c: Write 2 bytes to register&lt;br /&gt;
    d: Read byte from register&lt;br /&gt;
    e: Read 2 bytes from register&lt;br /&gt;
    q: Quit&lt;br /&gt;
&amp;gt;&amp;gt; b&lt;br /&gt;
&lt;br /&gt;
Enter a byte to write (in hex): aa&lt;br /&gt;
Enter a register value to write (in hex): 01&lt;br /&gt;
&lt;br /&gt;
Calling i2c_write_cmd(3, 0x1, 0xAA)&lt;br /&gt;
i2c_write_cmd reports success&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
{{closp}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p style=&amp;quot;margin-left:2%;&amp;quot;&amp;gt;This function uses the Linux &amp;lt;code&amp;gt;write&amp;lt;/code&amp;gt; system call to write one byte to the selected register on the &amp;lt;code&amp;gt;I²C&amp;lt;/code&amp;gt; device. &amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* '''Write 2 bytes to register'''&amp;lt;br /&amp;gt;Press the ''C'' key to select the Write 2 bytes to register function, then press ''Enter''.&lt;br /&gt;
{{clop | indent=1 }}&amp;lt;nowiki&amp;gt;&lt;br /&gt;
Select a function to test:&lt;br /&gt;
    a: Set slave address&lt;br /&gt;
    b: Write byte to register&lt;br /&gt;
    c: Write 2 bytes to register&lt;br /&gt;
    d: Read byte from register&lt;br /&gt;
    e: Read 2 bytes from register&lt;br /&gt;
    q: Quit&lt;br /&gt;
&amp;gt;&amp;gt; c&lt;br /&gt;
&lt;br /&gt;
Enter a 2 byte number to write (in hex): aabb&lt;br /&gt;
Enter a register value to write (in hex): 01&lt;br /&gt;
&lt;br /&gt;
Calling i2c_write_cmd2(3, 0x1, 0xAABB)&lt;br /&gt;
i2c_write_cmd2 reports success&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
{{closp}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p style=&amp;quot;margin-left:2%;&amp;quot;&amp;gt;This function uses the same system call as the previous option, but writes 2 bytes to a register instead of just one.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* ''' Read byte from register '''&amp;lt;br /&amp;gt;Press the ''D'' key to select the Read byte from register function, then press ''Enter''.&lt;br /&gt;
{{clop | indent=1 }}&amp;lt;nowiki&amp;gt;&lt;br /&gt;
Select a function to test:&lt;br /&gt;
    a: Set slave address    &lt;br /&gt;
    b: Write byte to register    &lt;br /&gt;
    c: Write 2 bytes to register    &lt;br /&gt;
    d: Read byte from register    &lt;br /&gt;
    e: Read 2 bytes from register    &lt;br /&gt;
    q: Quit&lt;br /&gt;
&amp;gt;&amp;gt; d&lt;br /&gt;
&lt;br /&gt;
Enter a register value to read from (in hex): bb&lt;br /&gt;
&lt;br /&gt;
Calling i2c_read_reg(3, (__u8 *)&amp;amp;val, 0xBB)&lt;br /&gt;
i2c_read_reg reports success&lt;br /&gt;
Read value 0xB&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
{{closp}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p style=&amp;quot;margin-left:2%;&amp;quot;&amp;gt;This function uses the Linux &amp;lt;code&amp;gt;read&amp;lt;/code&amp;gt; system call to read a byte to the selected register on the &amp;lt;code&amp;gt;I²C&amp;lt;/code&amp;gt; device.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* '''Read 2 bytes from register'''&amp;lt;br /&amp;gt;Press the ''E'' key to select the Read 2 bytes from register function, then press ''Enter''.&lt;br /&gt;
{{clop | indent=1 }}&amp;lt;nowiki&amp;gt;&lt;br /&gt;
Select a function to test:&lt;br /&gt;
    a: Set slave address        &lt;br /&gt;
    b: Write byte to register        &lt;br /&gt;
    c: Write 2 bytes to register        &lt;br /&gt;
    d: Read byte from register        &lt;br /&gt;
    e: Read 2 bytes from register        &lt;br /&gt;
    q: Quit&lt;br /&gt;
&amp;gt;&amp;gt; e&lt;br /&gt;
&lt;br /&gt;
Enter a register value to read from (in hex): bbcc&lt;br /&gt;
&lt;br /&gt;
Calling i2c_read_reg2(3, &amp;amp;val, 0xBBCC)&lt;br /&gt;
i2c_read_reg2 reports success&lt;br /&gt;
Read value 0xB0B&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
{{closp}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p style=&amp;quot;margin-left:2%;&amp;quot;&amp;gt;This function uses the same system call as the previous option, but shifts to the right.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p style=&amp;quot;margin-left:2%;&amp;quot;&amp;gt;The &amp;lt;code&amp;gt;i2c_test&amp;lt;/code&amp;gt; example writes a byte to a selected register. The register then reads the byte, shifts the byte 8 bits to the right and then reads the address to the selected register on the &amp;lt;code&amp;gt;I²C&amp;lt;/code&amp;gt; device. &amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*'''Quit'''&amp;lt;br /&amp;gt;Press the ''Q'' key to quit out of the &amp;lt;code&amp;gt;i2c_test&amp;lt;/code&amp;gt; example, then press ''Enter''.&lt;br /&gt;
{{clop | indent=1 }}&amp;lt;nowiki&amp;gt;&lt;br /&gt;
Select a function to test:    &lt;br /&gt;
    a: Set slave address            &lt;br /&gt;
    b: Write byte to register            &lt;br /&gt;
    c: Write 2 bytes to register            &lt;br /&gt;
    d: Read byte from register            &lt;br /&gt;
    e: Read 2 bytes from register            &lt;br /&gt;
    q: Quit&lt;br /&gt;
&amp;gt;&amp;gt; q&lt;br /&gt;
Quiting...&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
{{closp}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p style=&amp;quot;margin-left:2%;&amp;quot;&amp;gt;This function exits you out of the &amp;lt;code&amp;gt;i2c_test&amp;lt;/code&amp;gt; example on the &amp;lt;code&amp;gt;I²C&amp;lt;/code&amp;gt; device.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;!--&amp;lt;/cl&amp;gt;--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Real-World Example ==&lt;br /&gt;
=== Hardware Requirements ===&lt;br /&gt;
The &amp;lt;code&amp;gt;i2c_test&amp;lt;/code&amp;gt; C Real-World example project will be running on an EMAC SOM-210ES carrier board. This example will be communicating with the RTC clock on the SOM-3517M.&lt;br /&gt;
&lt;br /&gt;
For more information about the RTC Clock see the following page for the data sheet: http://www.nxp.com/documents/data_sheet/PCA8565.pdf&lt;br /&gt;
&lt;br /&gt;
=== Using Real-World Example i2c_test ===&lt;br /&gt;
&lt;br /&gt;
Just like before, the &amp;lt;code&amp;gt;i2c_test&amp;lt;/code&amp;gt; program is executed from the console. It takes no parameters.&lt;br /&gt;
&lt;br /&gt;
{{cli |./i2c_test}}&lt;br /&gt;
&lt;br /&gt;
A menu will appear in the terminal:&lt;br /&gt;
{{clop}}&amp;lt;nowiki&amp;gt;&lt;br /&gt;
Select a function to test:&lt;br /&gt;
    a: Set slave address&lt;br /&gt;
    b: Write byte to register&lt;br /&gt;
    c: Write 2 bytes to register&lt;br /&gt;
    d: Read byte from register&lt;br /&gt;
    e: Read 2 bytes from register&lt;br /&gt;
    q: Quit&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
{{closp}}&lt;br /&gt;
&lt;br /&gt;
==== Test Options ====&lt;br /&gt;
&lt;br /&gt;
* '''Set Slave Address'''&amp;lt;br /&amp;gt;Press the ''A'' key to select the Set slave address function, then press ''Enter''.&lt;br /&gt;
&lt;br /&gt;
The RTC Clock slave address in binary is 1010001 (58 in Hexadecimal).&lt;br /&gt;
&lt;br /&gt;
{{note | The slave address must be shifted to the right one bit. }}&lt;br /&gt;
&lt;br /&gt;
{{clop}}&amp;lt;nowiki&amp;gt;&lt;br /&gt;
Select a function to test:&lt;br /&gt;
    a: Set slave address&lt;br /&gt;
    b: Write byte to register&lt;br /&gt;
    c: Write 2 bytes to register&lt;br /&gt;
    d: Read byte from register&lt;br /&gt;
    e: Read 2 bytes from register&lt;br /&gt;
    q: Quit&lt;br /&gt;
&amp;gt;&amp;gt; a&lt;br /&gt;
&lt;br /&gt;
Enter the slave address (in hex): 28&lt;br /&gt;
&lt;br /&gt;
Calling i2c_set_slave(3, 0x48)&lt;br /&gt;
i2c_set_slave reports success&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
{{closp}}&lt;br /&gt;
&lt;br /&gt;
== Summary ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;i2c_test&amp;lt;/code&amp;gt; C example project writes and reads bytes to a selected register on the &amp;lt;code&amp;gt;I²C&amp;lt;/code&amp;gt; device.&lt;/div&gt;</summary>
		<author><name>Nperkins</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.emacinc.com/index.php?title=Example_can&amp;diff=15081</id>
		<title>Example can</title>
		<link rel="alternate" type="text/html" href="https://wiki.emacinc.com/index.php?title=Example_can&amp;diff=15081"/>
		<updated>2022-10-14T17:08:20Z</updated>

		<summary type="html">&lt;p&gt;Nperkins: /* Usage Example for Ipac-9x25 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{#seo:&lt;br /&gt;
|title=Example can&lt;br /&gt;
|titlemode=append&lt;br /&gt;
|keywords=Example can,Using can,EMAC C example project&lt;br /&gt;
|description=This is a guide to the &amp;lt;code&amp;gt;casn&amp;lt;/code&amp;gt; C example project included in the EMAC OE SDK.&lt;br /&gt;
}}&lt;br /&gt;
This is a guide to the &amp;lt;code&amp;gt;can&amp;lt;/code&amp;gt; C example project included in the EMAC OE SDK.&lt;br /&gt;
&lt;br /&gt;
A Controller Area Network (CAN bus) is a robust bus standard for in-vehicle networks. Originally designed for use in the automotive industry, CAN allows micro-controllers and devices to communicate through a message-based protocol with device priority and is used in many different applications to this day.&lt;br /&gt;
&lt;br /&gt;
This project serves as a demonstration of using the CAN bus.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;can&amp;lt;/code&amp;gt; project builds one executable: &amp;lt;code&amp;gt;can&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Opening, Building and Uploading the Project Files ==&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
Alternatively, the &amp;lt;code&amp;gt;Makefile&amp;lt;/code&amp;gt; can be used with the &amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt; command from the commandline to build and upload the example.  For information on this method, please see [[Using EMAC OE SDK Example Projects]].&lt;br /&gt;
&lt;br /&gt;
====EMAC SDK 5.X====&lt;br /&gt;
&lt;br /&gt;
For information on opening the project from within QtCreator, please see [[Getting_Started_With_Qt_Creator#Adding_Source_Files | QtCreator: Adding Source Files]].  Then, follow [[Getting Started With Qt Creator]] for information on how to build, upload and execute the example.&lt;br /&gt;
&lt;br /&gt;
Alternatively, the &amp;lt;code&amp;gt;CMakefile.txt&amp;lt;/code&amp;gt; can be used with the &amp;lt;code&amp;gt;cmake&amp;lt;/code&amp;gt; command from the commandline to build and upload the example.  For information on this method, please see [[Getting_Started_with_the_EMAC_OE_SDK#Target_Machine_Compiling | Getting Started with the EMAC OE SDK]].&lt;br /&gt;
&lt;br /&gt;
==Usage and Behavior==&lt;br /&gt;
&lt;br /&gt;
===Hardware Requirements===&lt;br /&gt;
&lt;br /&gt;
It should run just fine on any device with a CAN interface. You will need:&lt;br /&gt;
* Two devices with a CAN interface&lt;br /&gt;
&lt;br /&gt;
===Using &amp;lt;code&amp;gt;can&amp;lt;/code&amp;gt;===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;can&amp;lt;/code&amp;gt; program is executed from the console. Requires either the argument &amp;quot;send&amp;quot; or &amp;quot;receive&amp;quot;&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;code&amp;gt;./can [send/recieve]&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The program will wait for data payload to be received (argument: &amp;quot;receive&amp;quot;) through CAN or send data payload (argument: &amp;quot;send&amp;quot;), 8 random hex bytes, through CAN. The payload will then be printed on the receive end.   &lt;br /&gt;
&lt;br /&gt;
===Usage Example===&lt;br /&gt;
Prepare Device 1 to receive:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
root@ipac9x25:~# ./can receive&lt;br /&gt;
.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Send Data from Device 2:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
root@somimx6ul:~# ./can send&lt;br /&gt;
root@somimx6ul:~#&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Device 1 received:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
root@ipac9x25:~# ./can receive&lt;br /&gt;
&amp;lt;0x001&amp;gt; [8] 87 5a 6a 37 7a 94 a4 01&lt;br /&gt;
root@ipac9x25:~#&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Usage Example for iPac9x25===&lt;br /&gt;
You must first go into code and change the ifname to the name of your can port. The default example will use &amp;quot;can0&amp;quot;. &lt;br /&gt;
Prepare Device 1 to receive:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
root@ipac9x25:~# ./can receive&lt;br /&gt;
.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Send Data from Device 2:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
root@somimx6ul:~# ./can send &amp;lt;data&amp;gt;&lt;br /&gt;
root@somimx6ul:~#&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Device 1 received:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
root@ipac9x25:~# ./can receive&lt;br /&gt;
&amp;lt;0x001&amp;gt; [8] 87 5a 6a 37 7a 94 a4 01&lt;br /&gt;
root@ipac9x25:~#&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Summary==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;can&amp;lt;/code&amp;gt; C example project demonstrates the use of the CAN bus.&lt;/div&gt;</summary>
		<author><name>Nperkins</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.emacinc.com/index.php?title=Example_pthread_demo&amp;diff=15078</id>
		<title>Example pthread demo</title>
		<link rel="alternate" type="text/html" href="https://wiki.emacinc.com/index.php?title=Example_pthread_demo&amp;diff=15078"/>
		<updated>2022-10-14T17:06:27Z</updated>

		<summary type="html">&lt;p&gt;Nperkins: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{todo|SEOKWREV;(12.11.13-12:03-&amp;gt;JG+);(12.11.13-17:25-&amp;gt;MD-);(12.12.13-11:25-&amp;gt;JG+);(12.31.13-12:45-&amp;gt;MD+);(04.07.14-09:50-&amp;gt;BS+);(04.10.14-11:00-&amp;gt;BS+)|Jgreene|project=oe 4,oe 5,jg,md,SEOKWREV,mg,bs}}&lt;br /&gt;
&lt;br /&gt;
{{#seo:&lt;br /&gt;
|title=pthread demo&lt;br /&gt;
|titlemode=append&lt;br /&gt;
|keywords=pthread,pthread example&lt;br /&gt;
|description=This is a guide to the &amp;lt;code&amp;gt;pthread_demo&amp;lt;/code&amp;gt; C example project included in the EMAC OE SDK.&lt;br /&gt;
}}&lt;br /&gt;
This is a guide to the &amp;lt;code&amp;gt;pthread_demo&amp;lt;/code&amp;gt; C example project included in the EMAC OE SDK.&lt;br /&gt;
&lt;br /&gt;
This is a simple pthreads example application. A single thread is created to generate random data that is read by a specified number of reader threads.&lt;br /&gt;
&lt;br /&gt;
The term ''pthread'' refers to [http://en.wikipedia.org/wiki/PThread POSIX Threads], a [http://en.wikipedia.org/wiki/POSIX POSIX] standard for threads.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;pthread_demo&amp;lt;/code&amp;gt; project builds one executable: &amp;lt;code&amp;gt;p_thread_demo&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Opening, Building and Uploading the Project Files ==&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
Alternatively, the &amp;lt;code&amp;gt;Makefile&amp;lt;/code&amp;gt; can be used with the &amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt; command from the commandline to build and upload the example.  For information on this method, please see [[Using EMAC OE SDK Example Projects]].&lt;br /&gt;
&lt;br /&gt;
====EMAC SDK 5.X====&lt;br /&gt;
&lt;br /&gt;
For information on opening the project from within QtCreator, please see [[Getting_Started_With_Qt_Creator#Adding_Source_Files | QtCreator: Adding Source Files]].  Then, follow [[Getting Started With Qt Creator]] for information on how to build, upload and execute the example.&lt;br /&gt;
&lt;br /&gt;
Alternatively, the &amp;lt;code&amp;gt;CMakefile.txt&amp;lt;/code&amp;gt; can be used with the &amp;lt;code&amp;gt;cmake&amp;lt;/code&amp;gt; command from the commandline to build and upload the example.  For information on this method, please see [[Getting_Started_with_the_EMAC_OE_SDK#Target_Machine_Compiling | Getting Started with the EMAC OE SDK]].&lt;br /&gt;
&lt;br /&gt;
==Usage and Behavior== &lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;pthread_demo&amp;lt;/code&amp;gt; project is an example of multithreaded code for generating and interacting with an arbitrary number of ''pthreads''. Within the '''pthread_demo.c''' C source file can be found demonstrations of how to, specifically:&amp;lt;br /&amp;gt;&lt;br /&gt;
*Create pthreads, line 90.&lt;br /&gt;
*Write to pthreads, line 141.&lt;br /&gt;
*Read from pthreads, line 127.&lt;br /&gt;
*Terminate and clean up after pthreads, line 119.&lt;br /&gt;
&lt;br /&gt;
===Hardware Requirements===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;pthread_demo&amp;lt;/code&amp;gt; C example project has no special hardware requirements. It should run just fine on any system for which the project files can be successfully compiled.&lt;br /&gt;
&lt;br /&gt;
===Using &amp;lt;code&amp;gt;pthread_demo&amp;lt;/code&amp;gt;===&lt;br /&gt;
&lt;br /&gt;
 ./pthread_demo n&lt;br /&gt;
where '''n''' is the number of threads&lt;br /&gt;
&lt;br /&gt;
===Usage Example===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
root@PPCE7:/tmp# ./pthread_demo 3&lt;br /&gt;
generating new random data&lt;br /&gt;
generating new random data&lt;br /&gt;
    reader: count = 0, data = 693451072&lt;br /&gt;
generating new random data&lt;br /&gt;
    reader: count = 1, data = 1195545710&lt;br /&gt;
generating new random data&lt;br /&gt;
    reader: count = 2, data = 462104121&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Usage and Behavior for Ipac-9x25 Examples== &lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;p_hello&amp;lt;/code&amp;gt; project is an example of multithreaded code for generating and interacting with an arbitrary number of ''pthreads''. Within the '''p_hello.c''' C source file can be found demonstrations using the '''pthread''' library.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Using &amp;lt;code&amp;gt;p_hello&amp;lt;/code&amp;gt;===&lt;br /&gt;
&lt;br /&gt;
 ./p_hello n&lt;br /&gt;
where '''n''' is the number of threads&lt;br /&gt;
&lt;br /&gt;
===Usage Example===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
root@PPCE7:/tmp# ./p_hello 3&lt;br /&gt;
Hello from node 0&lt;br /&gt;
Hello from node 1&lt;br /&gt;
Hello from node 2&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Summary==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;pthread_demo&amp;lt;/code&amp;gt; C example project demonstrates how to use pthreads. For another example of pthread usage see [[Example pthread hello]].&lt;/div&gt;</summary>
		<author><name>Nperkins</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.emacinc.com/index.php?title=Example_i2c_test&amp;diff=15075</id>
		<title>Example i2c test</title>
		<link rel="alternate" type="text/html" href="https://wiki.emacinc.com/index.php?title=Example_i2c_test&amp;diff=15075"/>
		<updated>2022-10-14T16:59:44Z</updated>

		<summary type="html">&lt;p&gt;Nperkins: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{todo|Buggy (11.14.13-13:25-&amp;gt;JG+);(11.14.13-15:45-&amp;gt;MD-);(01.30.14-16:20-&amp;gt;BS+);(01.30.14-18:30-&amp;gt;MD-);(11.10.2015-12:50-&amp;gt;MD+)|Brian Serrano|project=oe 4,oe 5,md,Buggy,bs}}&lt;br /&gt;
&lt;br /&gt;
This is a guide to the &amp;lt;code&amp;gt;i2c_test&amp;lt;/code&amp;gt; example project included in the EMAC OE SDK.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;I²C&amp;lt;/code&amp;gt; is a two wire serial interface used to connect to a variety of sensor and I/O devices. The interface uses only two bi-directional open-drain I/Os, Serial Data Line (SDA) and Serial Clock (SCL), to communicate to devices based on an address encoded within the data transmission. SDA is a data signal which sends and receives serially transmitted data. SCL is a clock signal which is used to determine when to latch data from the SDA line.&lt;br /&gt;
&lt;br /&gt;
This procedure provides an overview of how to compile and run the &amp;lt;code&amp;gt;i2c_test&amp;lt;/code&amp;gt; C example project. This is an example test interface for reading/writing to the Linux &amp;lt;code&amp;gt;I²C&amp;lt;/code&amp;gt; device interface. It is only relevant if the &amp;lt;code&amp;gt;I²C&amp;lt;/code&amp;gt; device interface is enabled and an external &amp;lt;code&amp;gt;I²C&amp;lt;/code&amp;gt; device is connected to the bus. It assumes familiarity with the C programming language and is intended to be used by experienced programmers who are looking to learn the EMAC SDK.&lt;br /&gt;
&lt;br /&gt;
For more information about the protocol see the following page: http://www.nxp.com/documents/user_manual/UM10204.pdf&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;i2c_test&amp;lt;/code&amp;gt; project builds one executable: &amp;lt;code&amp;gt;i2c_test&amp;lt;/code&amp;gt;.&lt;br /&gt;
== Opening, Building and Uploading the Project Files ==&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
Alternatively, the &amp;lt;code&amp;gt;Makefile&amp;lt;/code&amp;gt; can be used with the &amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt; command from the commandline to build and upload the example.  For information on this method, please see [[Using EMAC OE SDK Example Projects]].&lt;br /&gt;
&lt;br /&gt;
====EMAC SDK 5.X====&lt;br /&gt;
&lt;br /&gt;
For information on opening the project from within QtCreator, please see [[Getting_Started_With_Qt_Creator#Adding_Source_Files | QtCreator: Adding Source Files]].  Then, follow [[Getting Started With Qt Creator]] for information on how to build, upload and execute the example.&lt;br /&gt;
&lt;br /&gt;
Alternatively, the &amp;lt;code&amp;gt;CMakefile.txt&amp;lt;/code&amp;gt; can be used with the &amp;lt;code&amp;gt;cmake&amp;lt;/code&amp;gt; command from the commandline to build and upload the example.  For information on this method, please see [[Getting_Started_with_the_EMAC_OE_SDK#Target_Machine_Compiling | Getting Started with the EMAC OE SDK]].&lt;br /&gt;
== Usage and Behavior ==&lt;br /&gt;
=== Hardware Requirements ===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;i2c_test&amp;lt;/code&amp;gt; C example project will run on any EMAC carrier board which has an &amp;lt;code&amp;gt;I²C&amp;lt;/code&amp;gt; interface (see also the [[EMAC_I²C_Programming | EMAC I²C Programming]] page).&lt;br /&gt;
&lt;br /&gt;
===Using i2c_test===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;i2c_test&amp;lt;/code&amp;gt; program is executed from the console. If using the Ipac-9x25 it takes an optional argument which is the string representing the device path. By default, &amp;quot;/dev/i2c-1&amp;quot; is set, but if another device path needs to be used, append that to the command. &lt;br /&gt;
&lt;br /&gt;
{{cli |./i2c_test &amp;lt;optional device_path&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
A menu will appear in the terminal:&lt;br /&gt;
&lt;br /&gt;
{{clop}}&amp;lt;nowiki&amp;gt;&lt;br /&gt;
Select a function to test:&lt;br /&gt;
    a: Set slave address&lt;br /&gt;
    b: Write byte to register&lt;br /&gt;
    c: Write 2 bytes to register&lt;br /&gt;
    d: Read byte from register&lt;br /&gt;
    e: Read 2 bytes from register&lt;br /&gt;
    q: Quit&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
{{closp}}&lt;br /&gt;
&lt;br /&gt;
Select a function (a,b,c,d,e) to test or q to quit. You will be prompted for read, write and register values as appropriate. Test results will be displayed in the terminal.&lt;br /&gt;
&lt;br /&gt;
==== Test Options ====&lt;br /&gt;
&amp;lt;!--&amp;lt;cl&amp;gt;--&amp;gt;&lt;br /&gt;
* '''Set Slave Address'''&amp;lt;br /&amp;gt;Press the ''A'' key to select the Set slave address function, then press ''Enter''.&lt;br /&gt;
{{clop | indent=1 }}&amp;lt;nowiki&amp;gt;&lt;br /&gt;
Select a function to test:&lt;br /&gt;
    a: Set slave address&lt;br /&gt;
    b: Write byte to register&lt;br /&gt;
    c: Write 2 bytes to register&lt;br /&gt;
    d: Read byte from register&lt;br /&gt;
    e: Read 2 bytes from register&lt;br /&gt;
    q: Quit&lt;br /&gt;
&amp;gt;&amp;gt; a&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Enter the slave address (in hex): 48&lt;br /&gt;
&lt;br /&gt;
Calling i2c_set_slave(3, 0x48)&lt;br /&gt;
i2c_set_slave reports success&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
{{closp}}&lt;br /&gt;
&amp;lt;p style=&amp;quot;margin-left:2%;&amp;quot;&amp;gt;&lt;br /&gt;
The slave address receives the clock and responds when addressed by the master.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p style=&amp;quot;margin-left:2%;&amp;quot;&amp;gt;This function is to set the slave address of the &amp;lt;code&amp;gt;I²C&amp;lt;/code&amp;gt; device. This only need to be done once to initialize the address and then each time that a new device is addressed.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* '''Write byte to register'''&amp;lt;br /&amp;gt;Press the ''B'' key to select the Write byte to register function, then press ''Enter''&lt;br /&gt;
{{clop | indent=1 }}&amp;lt;nowiki&amp;gt;&lt;br /&gt;
Select a function to test:&lt;br /&gt;
    a: Set slave address&lt;br /&gt;
    b: Write byte to register&lt;br /&gt;
    c: Write 2 bytes to register&lt;br /&gt;
    d: Read byte from register&lt;br /&gt;
    e: Read 2 bytes from register&lt;br /&gt;
    q: Quit&lt;br /&gt;
&amp;gt;&amp;gt; b&lt;br /&gt;
&lt;br /&gt;
Enter a byte to write (in hex): aa&lt;br /&gt;
Enter a register value to write (in hex): 01&lt;br /&gt;
&lt;br /&gt;
Calling i2c_write_cmd(3, 0x1, 0xAA)&lt;br /&gt;
i2c_write_cmd reports success&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
{{closp}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p style=&amp;quot;margin-left:2%;&amp;quot;&amp;gt;This function uses the Linux &amp;lt;code&amp;gt;write&amp;lt;/code&amp;gt; system call to write one byte to the selected register on the &amp;lt;code&amp;gt;I²C&amp;lt;/code&amp;gt; device. &amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* '''Write 2 bytes to register'''&amp;lt;br /&amp;gt;Press the ''C'' key to select the Write 2 bytes to register function, then press ''Enter''.&lt;br /&gt;
{{clop | indent=1 }}&amp;lt;nowiki&amp;gt;&lt;br /&gt;
Select a function to test:&lt;br /&gt;
    a: Set slave address&lt;br /&gt;
    b: Write byte to register&lt;br /&gt;
    c: Write 2 bytes to register&lt;br /&gt;
    d: Read byte from register&lt;br /&gt;
    e: Read 2 bytes from register&lt;br /&gt;
    q: Quit&lt;br /&gt;
&amp;gt;&amp;gt; c&lt;br /&gt;
&lt;br /&gt;
Enter a 2 byte number to write (in hex): aabb&lt;br /&gt;
Enter a register value to write (in hex): 01&lt;br /&gt;
&lt;br /&gt;
Calling i2c_write_cmd2(3, 0x1, 0xAABB)&lt;br /&gt;
i2c_write_cmd2 reports success&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
{{closp}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p style=&amp;quot;margin-left:2%;&amp;quot;&amp;gt;This function uses the same system call as the previous option, but writes 2 bytes to a register instead of just one.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* ''' Read byte from register '''&amp;lt;br /&amp;gt;Press the ''D'' key to select the Read byte from register function, then press ''Enter''.&lt;br /&gt;
{{clop | indent=1 }}&amp;lt;nowiki&amp;gt;&lt;br /&gt;
Select a function to test:&lt;br /&gt;
    a: Set slave address    &lt;br /&gt;
    b: Write byte to register    &lt;br /&gt;
    c: Write 2 bytes to register    &lt;br /&gt;
    d: Read byte from register    &lt;br /&gt;
    e: Read 2 bytes from register    &lt;br /&gt;
    q: Quit&lt;br /&gt;
&amp;gt;&amp;gt; d&lt;br /&gt;
&lt;br /&gt;
Enter a register value to read from (in hex): bb&lt;br /&gt;
&lt;br /&gt;
Calling i2c_read_reg(3, (__u8 *)&amp;amp;val, 0xBB)&lt;br /&gt;
i2c_read_reg reports success&lt;br /&gt;
Read value 0xB&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
{{closp}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p style=&amp;quot;margin-left:2%;&amp;quot;&amp;gt;This function uses the Linux &amp;lt;code&amp;gt;read&amp;lt;/code&amp;gt; system call to read a byte to the selected register on the &amp;lt;code&amp;gt;I²C&amp;lt;/code&amp;gt; device.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* '''Read 2 bytes from register'''&amp;lt;br /&amp;gt;Press the ''E'' key to select the Read 2 bytes from register function, then press ''Enter''.&lt;br /&gt;
{{clop | indent=1 }}&amp;lt;nowiki&amp;gt;&lt;br /&gt;
Select a function to test:&lt;br /&gt;
    a: Set slave address        &lt;br /&gt;
    b: Write byte to register        &lt;br /&gt;
    c: Write 2 bytes to register        &lt;br /&gt;
    d: Read byte from register        &lt;br /&gt;
    e: Read 2 bytes from register        &lt;br /&gt;
    q: Quit&lt;br /&gt;
&amp;gt;&amp;gt; e&lt;br /&gt;
&lt;br /&gt;
Enter a register value to read from (in hex): bbcc&lt;br /&gt;
&lt;br /&gt;
Calling i2c_read_reg2(3, &amp;amp;val, 0xBBCC)&lt;br /&gt;
i2c_read_reg2 reports success&lt;br /&gt;
Read value 0xB0B&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
{{closp}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p style=&amp;quot;margin-left:2%;&amp;quot;&amp;gt;This function uses the same system call as the previous option, but shifts to the right.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p style=&amp;quot;margin-left:2%;&amp;quot;&amp;gt;The &amp;lt;code&amp;gt;i2c_test&amp;lt;/code&amp;gt; example writes a byte to a selected register. The register then reads the byte, shifts the byte 8 bits to the right and then reads the address to the selected register on the &amp;lt;code&amp;gt;I²C&amp;lt;/code&amp;gt; device. &amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*'''Quit'''&amp;lt;br /&amp;gt;Press the ''Q'' key to quit out of the &amp;lt;code&amp;gt;i2c_test&amp;lt;/code&amp;gt; example, then press ''Enter''.&lt;br /&gt;
{{clop | indent=1 }}&amp;lt;nowiki&amp;gt;&lt;br /&gt;
Select a function to test:    &lt;br /&gt;
    a: Set slave address            &lt;br /&gt;
    b: Write byte to register            &lt;br /&gt;
    c: Write 2 bytes to register            &lt;br /&gt;
    d: Read byte from register            &lt;br /&gt;
    e: Read 2 bytes from register            &lt;br /&gt;
    q: Quit&lt;br /&gt;
&amp;gt;&amp;gt; q&lt;br /&gt;
Quiting...&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
{{closp}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p style=&amp;quot;margin-left:2%;&amp;quot;&amp;gt;This function exits you out of the &amp;lt;code&amp;gt;i2c_test&amp;lt;/code&amp;gt; example on the &amp;lt;code&amp;gt;I²C&amp;lt;/code&amp;gt; device.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;!--&amp;lt;/cl&amp;gt;--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Real-World Example ==&lt;br /&gt;
=== Hardware Requirements ===&lt;br /&gt;
The &amp;lt;code&amp;gt;i2c_test&amp;lt;/code&amp;gt; C Real-World example project will be running on an EMAC SOM-210ES carrier board. This example will be communicating with the RTC clock on the SOM-3517M.&lt;br /&gt;
&lt;br /&gt;
For more information about the RTC Clock see the following page for the data sheet: http://www.nxp.com/documents/data_sheet/PCA8565.pdf&lt;br /&gt;
&lt;br /&gt;
=== Using Real-World Example i2c_test ===&lt;br /&gt;
&lt;br /&gt;
Just like before, the &amp;lt;code&amp;gt;i2c_test&amp;lt;/code&amp;gt; program is executed from the console. It takes no parameters.&lt;br /&gt;
&lt;br /&gt;
{{cli |./i2c_test}}&lt;br /&gt;
&lt;br /&gt;
A menu will appear in the terminal:&lt;br /&gt;
{{clop}}&amp;lt;nowiki&amp;gt;&lt;br /&gt;
Select a function to test:&lt;br /&gt;
    a: Set slave address&lt;br /&gt;
    b: Write byte to register&lt;br /&gt;
    c: Write 2 bytes to register&lt;br /&gt;
    d: Read byte from register&lt;br /&gt;
    e: Read 2 bytes from register&lt;br /&gt;
    q: Quit&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
{{closp}}&lt;br /&gt;
&lt;br /&gt;
==== Test Options ====&lt;br /&gt;
&lt;br /&gt;
* '''Set Slave Address'''&amp;lt;br /&amp;gt;Press the ''A'' key to select the Set slave address function, then press ''Enter''.&lt;br /&gt;
&lt;br /&gt;
The RTC Clock slave address in binary is 1010001 (58 in Hexadecimal).&lt;br /&gt;
&lt;br /&gt;
{{note | The slave address must be shifted to the right one bit. }}&lt;br /&gt;
&lt;br /&gt;
{{clop}}&amp;lt;nowiki&amp;gt;&lt;br /&gt;
Select a function to test:&lt;br /&gt;
    a: Set slave address&lt;br /&gt;
    b: Write byte to register&lt;br /&gt;
    c: Write 2 bytes to register&lt;br /&gt;
    d: Read byte from register&lt;br /&gt;
    e: Read 2 bytes from register&lt;br /&gt;
    q: Quit&lt;br /&gt;
&amp;gt;&amp;gt; a&lt;br /&gt;
&lt;br /&gt;
Enter the slave address (in hex): 28&lt;br /&gt;
&lt;br /&gt;
Calling i2c_set_slave(3, 0x48)&lt;br /&gt;
i2c_set_slave reports success&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
{{closp}}&lt;br /&gt;
&lt;br /&gt;
== Summary ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;i2c_test&amp;lt;/code&amp;gt; C example project writes and reads bytes to a selected register on the &amp;lt;code&amp;gt;I²C&amp;lt;/code&amp;gt; device.&lt;/div&gt;</summary>
		<author><name>Nperkins</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.emacinc.com/index.php?title=Example_can&amp;diff=15072</id>
		<title>Example can</title>
		<link rel="alternate" type="text/html" href="https://wiki.emacinc.com/index.php?title=Example_can&amp;diff=15072"/>
		<updated>2022-10-14T16:55:33Z</updated>

		<summary type="html">&lt;p&gt;Nperkins: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{#seo:&lt;br /&gt;
|title=Example can&lt;br /&gt;
|titlemode=append&lt;br /&gt;
|keywords=Example can,Using can,EMAC C example project&lt;br /&gt;
|description=This is a guide to the &amp;lt;code&amp;gt;casn&amp;lt;/code&amp;gt; C example project included in the EMAC OE SDK.&lt;br /&gt;
}}&lt;br /&gt;
This is a guide to the &amp;lt;code&amp;gt;can&amp;lt;/code&amp;gt; C example project included in the EMAC OE SDK.&lt;br /&gt;
&lt;br /&gt;
A Controller Area Network (CAN bus) is a robust bus standard for in-vehicle networks. Originally designed for use in the automotive industry, CAN allows micro-controllers and devices to communicate through a message-based protocol with device priority and is used in many different applications to this day.&lt;br /&gt;
&lt;br /&gt;
This project serves as a demonstration of using the CAN bus.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;can&amp;lt;/code&amp;gt; project builds one executable: &amp;lt;code&amp;gt;can&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Opening, Building and Uploading the Project Files ==&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
Alternatively, the &amp;lt;code&amp;gt;Makefile&amp;lt;/code&amp;gt; can be used with the &amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt; command from the commandline to build and upload the example.  For information on this method, please see [[Using EMAC OE SDK Example Projects]].&lt;br /&gt;
&lt;br /&gt;
====EMAC SDK 5.X====&lt;br /&gt;
&lt;br /&gt;
For information on opening the project from within QtCreator, please see [[Getting_Started_With_Qt_Creator#Adding_Source_Files | QtCreator: Adding Source Files]].  Then, follow [[Getting Started With Qt Creator]] for information on how to build, upload and execute the example.&lt;br /&gt;
&lt;br /&gt;
Alternatively, the &amp;lt;code&amp;gt;CMakefile.txt&amp;lt;/code&amp;gt; can be used with the &amp;lt;code&amp;gt;cmake&amp;lt;/code&amp;gt; command from the commandline to build and upload the example.  For information on this method, please see [[Getting_Started_with_the_EMAC_OE_SDK#Target_Machine_Compiling | Getting Started with the EMAC OE SDK]].&lt;br /&gt;
&lt;br /&gt;
==Usage and Behavior==&lt;br /&gt;
&lt;br /&gt;
===Hardware Requirements===&lt;br /&gt;
&lt;br /&gt;
It should run just fine on any device with a CAN interface. You will need:&lt;br /&gt;
* Two devices with a CAN interface&lt;br /&gt;
&lt;br /&gt;
===Using &amp;lt;code&amp;gt;can&amp;lt;/code&amp;gt;===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;can&amp;lt;/code&amp;gt; program is executed from the console. Requires either the argument &amp;quot;send&amp;quot; or &amp;quot;receive&amp;quot;&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;code&amp;gt;./can [send/recieve]&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The program will wait for data payload to be received (argument: &amp;quot;receive&amp;quot;) through CAN or send data payload (argument: &amp;quot;send&amp;quot;), 8 random hex bytes, through CAN. The payload will then be printed on the receive end.   &lt;br /&gt;
&lt;br /&gt;
===Usage Example===&lt;br /&gt;
Prepare Device 1 to receive:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
root@ipac9x25:~# ./can receive&lt;br /&gt;
.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Send Data from Device 2:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
root@somimx6ul:~# ./can send&lt;br /&gt;
root@somimx6ul:~#&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Device 1 received:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
root@ipac9x25:~# ./can receive&lt;br /&gt;
&amp;lt;0x001&amp;gt; [8] 87 5a 6a 37 7a 94 a4 01&lt;br /&gt;
root@ipac9x25:~#&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Usage Example for Ipac-9x25===&lt;br /&gt;
You must first go into code and change the ifname to the name of your can port. The default example will use &amp;quot;can0&amp;quot;. &lt;br /&gt;
Prepare Device 1 to receive:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
root@ipac9x25:~# ./can receive&lt;br /&gt;
.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Send Data from Device 2:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
root@somimx6ul:~# ./can send &amp;lt;data&amp;gt;&lt;br /&gt;
root@somimx6ul:~#&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Device 1 received:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;console&amp;quot;&amp;gt;&lt;br /&gt;
root@ipac9x25:~# ./can receive&lt;br /&gt;
&amp;lt;0x001&amp;gt; [8] 87 5a 6a 37 7a 94 a4 01&lt;br /&gt;
root@ipac9x25:~#&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Summary==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;can&amp;lt;/code&amp;gt; C example project demonstrates the use of the CAN bus.&lt;/div&gt;</summary>
		<author><name>Nperkins</name></author>
		
	</entry>
</feed>