Difference between revisions of "Example i2c test"

From wiki.emacinc.com
Jump to: navigation, search
(Fixed headers and fonts)
Line 24: Line 24:
 
ie: ./i2c_test
 
ie: ./i2c_test
  
A menu will appear in the terminal.<br />
+
A menu will appear in the terminal:
[[File:I2c test terminal menu.jpg|i2c menu]]
+
<syntaxhighlight lang=console>
 +
Select a function to test:
 +
    a: Set slave address
 +
    b: Write byte to register
 +
    c: Write 2 bytes to register
 +
    d: Read byte from register
 +
    e: Read 2 bytes from register
 +
    q: Quit
 +
</syntaxhighlight>
  
 
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.
 
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.
  
The is an example session:<br />
+
This is an example session:
[[File:i2c_test_terminal_samplesession.jpg|i2c sample session]]
+
<syntaxhighlight lang=console>
 +
Select a function to test:
 +
    a: Set slave address
 +
    b: Write byte to register
 +
    c: Write 2 bytes to register
 +
    d: Read byte from register
 +
    e: Read 2 bytes from register
 +
    q: Quit
 +
>> a
 +
 
 +
Enter the slave address (in hex): 48
 +
 
 +
Calling i2c_set_slave(3, 0x48)
 +
i2c_set_slave reports success
 +
 
 +
 
 +
Select a function to test:
 +
    a: Set slave address
 +
    b: Write byte to register
 +
    c: Write 2 bytes to register
 +
    d: Read byte from register
 +
    e: Read 2 bytes from register
 +
    q: Quit
 +
>> b
 +
 
 +
Enter a byte to write (in hex): aa
 +
Enter a register value to write (in hex): 01
 +
 
 +
Calling i2c_write_cmd(3, 0x1, 0xAA)
 +
i2c_write_cmd reports success
 +
 
 +
Select a function to test:
 +
    a: Set slave address
 +
    b: Write byte to register
 +
    c: Write 2 bytes to register
 +
    d: Read byte from register
 +
    e: Read 2 bytes from register
 +
    q: Quit
 +
>> q
 +
Quiting...

Revision as of 12:08, 21 January 2014

TODO: {{#todo:InProgress(11.14.13-13:25->JG+);(11.14.13-15:45->MD-)|Brian Serrano|oe 4,oe 5,md,InProgress,bs}}

Create a real intro. This is going to need quite a bit of work still.

This is a guide to the i2c_test example project included in the EMAC OE SDK.

This procedure provides an overview of how to compile and run the i2c_test C example project. 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.

Opening, Building and Uploading the Project Files

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.

Alternatively, the Makefile can be used with the make command from the commandline to build and upload the example. For more information on this method, please see Using EMAC OE SDK Example Projects.

Usage and Behavior

This is far too sparse. They could discover this on their own. There needs to be information on how and why to use each option of these menus.

This is an example test interface for reading/writing to the Linux I2C device interface. It is only relevant if the I2C device interface is enabled and an external I2C device is connected to the bus. See comments in i2c_test.c for details.

Usage for i2c_test

i2c_test - Run it with the following command.

ie: ./i2c_test

A menu will appear in the terminal:

Select a function to test:
    a: Set slave address
    b: Write byte to register
    c: Write 2 bytes to register
    d: Read byte from register
    e: Read 2 bytes from register
    q: Quit

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.

This is an example session: <syntaxhighlight lang=console> Select a function to test:

   a: Set slave address
   b: Write byte to register
   c: Write 2 bytes to register
   d: Read byte from register
   e: Read 2 bytes from register
   q: Quit

>> a

Enter the slave address (in hex): 48

Calling i2c_set_slave(3, 0x48) i2c_set_slave reports success


Select a function to test:

   a: Set slave address
   b: Write byte to register
   c: Write 2 bytes to register
   d: Read byte from register
   e: Read 2 bytes from register
   q: Quit

>> b

Enter a byte to write (in hex): aa Enter a register value to write (in hex): 01

Calling i2c_write_cmd(3, 0x1, 0xAA) i2c_write_cmd reports success

Select a function to test:

   a: Set slave address
   b: Write byte to register
   c: Write 2 bytes to register
   d: Read byte from register
   e: Read 2 bytes from register
   q: Quit

>> q Quiting...