How to configure DM365 EVM for infrared remote support

From RidgeRun Developer Connection

Jump to:navigation, search

This page shows how to configure linux kernel 2.6.32 for the DM365 in order to enable an infrared remote control using the LIRC kernel subsystem. The example hardware is the TI DM365 EVM.

Contents

DM365 EVM IR Hardware

The following is excerpts are from Spectrum Digital DM365 EVM Technical Reference (Revision F).

The DM365 EVM incorporates infrared remote, interface using a MSP430 microcontroller. The I2C interface is used on the DM365 processor to communicate to the MSP430. The MSP430 acts as a slave device on the I2C bus. U1 is an infrared receiver mounted on the edge of the board.

The schematic (Revision F), page 44, shows the U1 TSOP34840 IR sensor connected to MSP430 port P1.2 and the MSP430 acting as a slave device at address 0x25 on the DM365 I2C bus. MSP430 P1.0 (active low) is used to interrupt the DM365 using GPIO 0 via a connections to the CPLD B2.IO_25 ( MSP430 P1.0) and CPLD B2.IO_37 (DM365 GPIO0).

The DM365 EVM Target Content (Revision F) includes evmdm365_v1/tests/msp430-ir/msp430-ir_test.c

The MSP430 is implemented to store the number of IR keys received in register 3, with register 1 holding the LSB of the key and register 2 holding the MSB.

The full I2C register set supported by the MSP430 (from MSP4301320/c/firmware.c):

/*
 *  Register map
 *  [0] = Version
 *  [1] = IR Data (low byte)
 *  [2] = IR Data (high byte)
 *  [3] = IR Buffer Count
 *  [4] = Register constant 0x43
 */

RidgeRun SDK configuration

Be sure to enable the following:

Symbol: FS_APPS_I2C_TOOLS [=y]
  Prompt: i2c-tools-3.0.3
    Defined at fs/apps/i2c-tools-3.0.3/Config:2
    Location:
      -> File System Configuration
        -> Select target's file system software

</pre>

and

 Symbol: GPIO_SYSFS [=y]
   Prompt: /sys/class/gpio/... (sysfs interface)
     Defined at drivers/gpio/Kconfig:51
     Location:
       -> Kernel configuration
         -> Device Drivers
           -> GPIO Support (GPIOLIB [=y])

and

 Symbol: FS_APPS_EVENT_TEST_TOOL [=y]
   Prompt: Event test tool
     Defined at fs/apps/event-test-tool/Config:1
     Location:
       -> File System Configuration
         -> Select target's file system software          

Manual MSP430 IR interaction

You can use some of the RidgeRun developer tools to verify the MSP430 is working as expected.

Interrupt GPIO 0

If the dm365evm_keys Linux driver is loaded, you will not be able to monitor GPIO 0 from user space. You can tell if a driver owns GPIO 0 as an interrupt using

fgrep GPIO /proc/interrupts

If you see

44:         66  GPIO-AINTC  dm365evm_keys

then GPIO 0 is not available via /sys/class/gpio.

After reset, the MSP430 should drive GPIO 0 high. Verify via:

<
GPIO=0

cd /sys/class/gpio
echo $GPIO > export
cd /sys/class/gpio/gpio$GPIO
echo "in" > direction
while sleep 1; do cat value ; done

Using the remote control, aim at EVM U1 sensor and press a button. You should see the GPIO5 value displayed change from a 1 to a zero.

I2C

Verify MSP430 shows up at I2C address 0x25. Issue:

i2cdetect -y 1

and you should see something like

     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- 08 -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- UU -- -- -- -- -- -- -- 
20: -- -- -- -- -- UU -- -- -- -- -- -- UU -- UU -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: UU -- -- -- -- -- -- -- -- -- -- -- UU UU -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- UU -- -- -- --                         

In this case, there is a kernel driver already controlling the MSP430 (that is what UU means). You can find this in the kernel (kernel/linux-2.6.32.17-psp03.01.01.39/arch/arm/mach-davinci/board-dm365-evm.c)

static struct i2c_board_info i2c_info[] = {
	{
		I2C_BOARD_INFO("dm365evm_keys", 0x25),
	},

with the matching driver found at kernel/linux-2.6.32.17-psp03.01.01.39/input/misc/dm365evm_keys.c, which has the nice comment:

/*
 * The MSP430 firmware on the DM365 EVM monitors an IR receptor used for
 * the remote control.  When any key is pressed, or its autorepeat kicks
 * in, an event is sent.  This driver read those events from the small
 * event queue and reports them.
...
 */

IR keys via Linux event subsystem

You can verify the dm365evm_keys is controlling the I2C chip at address 0x25 via

cat /sys/devices/platform/i2c

_davinci.1/i2c-1/1-0025/modalias

You can identify which input device and event device via

ls -d /sys/devices/platform/i2c_davinci.1/i2c-1/1-0025/input/input*/event*

You can monitor the remote key presses using the event-test-tool (fs/apps/event-test-tool):

evtest /dev/input/event0

With example output like:

Input driver version is 1.0.0
Input device ID: bus 0x18 vendor 0x0 product 0x365 version 0xa2
Input device name: "DM365 EVM Controls"
Supported events:
  Event type 0 (Sync)
  Event type 1 (Key)
    Event code 28 (Enter)
    Event code 103 (Up)
    Event code 105 (Left)
    Event code 106 (Right)
    Event code 108 (Down)
    Event code 113 (Mute)
    Event code 114 (VolumeDown)
    Event code 115 (VolumeUp)
    Event code 116 (Power)
    Event code 119 (Pause)
    Event code 128 (Stop)
    Event code 142 (Sleep)
    Event code 167 (Record)
    Event code 168 (Rewind)
    Event code 207 (Play)
    Event code 208 (Fast Forward)
    Event code 352 (Ok)
    Event code 353 (Select)
    Event code 370 (Subtitle)
    Event code 373 (Mode)
    Event code 402 (ChannelUp)
    Event code 403 (ChannelDown)
    Event code 512 (?)
    Event code 513 (?)
    Event code 514 (?)
    Event code 515 (?)
    Event code 516 (?)
    Event code 517 (?)
    Event code 518 (?)
    Event code 519 (?)
    Event code 520 (?)
    Event code 521 (?)
Testing ... (interrupt to exit)
Event: time 946687228.993504, type 1 (Key), code 520 (?), value 1
Event: time 946687228.993646, -------------- Report Sync ------------
Event: time 946687228.993731, type 1 (Key), code 520 (?), value 0
Event: time 946687228.993798, -------------- Report Sync ------------
Event: time 946687229.220974, type 1 (Key), code 520 (?), value 1
Event: time 946687229.221118, -------------- Report Sync ------------
Event: time 946687229.221246, type 1 (Key), code 520 (?), value 0
Event: time 946687229.221328, -------------- Report Sync ------------
Event: time 946687230.059211, type 1 (Key), code 520 (?), value 1
Event: time 946687230.059355, -------------- Report Sync ------------
Event: time 946687230.059442, type 1 (Key), code 520 (?), value 0
Event: time 946687230.059509, -------------- Report Sync ------------
Event: time 946687231.046284, type 1 (Key), code 512 (?), value 1
Event: time 946687231.046432, -------------- Report Sync ------------
Event: time 946687231.046516, type 1 (Key), code 512 (?), value 0
Event: time 946687231.046584, -------------- Report Sync ------------
Event: time 946687232.931260, type 1 (Key), code 512 (?), value 1
Event: time 946687232.931406, -------------- Report Sync ------------
Event: time 946687232.931493, type 1 (Key), code 512 (?), value 0
Event: time 946687232.931708, -------------- Report Sync ------------
Event: time 946687233.846057, type 1 (Key), code 520 (?), value 1
Event: time 946687233.846203, -------------- Report Sync ------------
Event: time 946687233.846289, type 1 (Key), code 520 (?), value 0
Event: time 946687233.846357, -------------- Report Sync -----------
Navigation
Toolbox