This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

How do I access push buttons s1 to s8 on through the i2c on the LOGIC PD OMAP L138 EVM UI Zoom Board?

Other Parts Discussed in Thread: TCA6416, AM1808, OMAP-L138

Hello,


I am trying to access the push buttons / switches s1 to s8 on the OMAP L138 Zoom Kit UI Expander board using Linux in C++ using #include <linux/i2c-dev>.

I do an open(“/dev/i2c-1”,O_RDONLY) successfully,

and when I do an ioctl(i2c_fd,I2C_SLAVE,0x20) errno returns “Device or resource busy”.

Someone mentioned that I can access these buttons using the GPIO interface but I have no idea how the buttons are mapped to GPIO numbers.

I can access GPIO buttons successfully in my application but need to switch to I2C.

When I do a i2cdetect -l the "i2c-1" shows up. I believe that the kernel is set up correctly to see the TCA6416 device.

Has anyone done this? Is there Linux example code someplace? How are the i2c buttons mapped in GPIO numbering?


Thank you!

 

 

 

  • Hi MB Hunter,

    From my understanding i2c slave address should be 0x21.

    I referred TCA6416 DS(Refer page No: 8) and 1015186B_OMAP-L138_AM1808_UI_Board_Schematic. ADDR pin of TCA6416 is pulled high.

    TCA6416 DS: http://www.ti.com/lit/ds/symlink/tca6416.pdf

    Have you tried accessing the I2C using i2cdump command? 

    Which Kernel PSP version are you using?

    Thanks.

  • Hi,

    The value of switch S1-S8 will reflect in P17-P10 respectively. 

    Please refer "Interface definition" in TCA6416.

  • Hi, 

    Any update? Could able to read GPIO status?

  • Any update?

  • I talked with him offline.  Those 8 buttons are mapped as a keyboard as the keys F1-F8.  Here's the code that is in the BSP that implements this mapping:

     

    #define DA850_N_UI_PB                             8

     

    static struct gpio_keys_button da850_evm_ui_keys[] = {

                    [0 ... DA850_N_UI_PB - 1] = {

                                    .type                                     = EV_KEY,

                                    .active_low                         = 1,

                                    .wakeup                                              = 0,

                                    .debounce_interval        = DA850_KEYS_DEBOUNCE_MS,

                                    .code                                     = -1, /* assigned at runtime */

                                    .gpio                                      = -1, /* assigned at runtime */

                                    .desc                                     = NULL, /* assigned at runtime */

                    },

    };

     

    static struct gpio_keys_platform_data da850_evm_ui_keys_pdata = {

                    .buttons = da850_evm_ui_keys,

                    .nbuttons = ARRAY_SIZE(da850_evm_ui_keys),

                    .poll_interval = DA850_GPIO_KEYS_POLL_MS,

    };

     

    static struct platform_device da850_evm_ui_keys_device = {

                    .name = "gpio-keys-polled",

                    .id = 0,

                    .dev = {

                                    .platform_data = &da850_evm_ui_keys_pdata

                    },

    };

     

    static void da850_evm_ui_keys_init(unsigned gpio)

    {

                    int i;

                    struct gpio_keys_button *button;

     

                    for (i = 0; i < DA850_N_UI_PB; i++) {

                                    button = &da850_evm_ui_keys[i];

                                    button->code = KEY_F8 - i;

                                    button->desc = (char *)

                                                                    da850_evm_ui_exp[DA850_EVM_UI_EXP_PB8 + i];

                                    button->gpio = gpio + DA850_EVM_UI_EXP_PB8 + i;

                    }

    }

    It sounded like they didn't want this to behave as a keyboard input, i.e. they prefer to make it a traditional GPIO input.  I believe the were still working on that.

  • Hi Brad Griffis,

    Thanks for the update.