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.

Linux/TCA9539: student

Part Number: TCA9539
Other Parts Discussed in Thread: DM3730, PCA9539, TCA8418E, TCA8418

Tool/software: Linux

hi

I am using two tca9539 device to have 20 input keys, The two devices is  connected to dm3730 with i2c. The linux kernel is 2.6.3. However, the kernel only have driver pca953x.c, so I add some code in pca953x.c:

static const struct i2c_device_id pca953x_id[] = {
	{ "pca9534", 8, },
	{ "pca9535", 16, },
	{ "pca9536", 4, },
	{ "pca9537", 4, },
	{ "pca9538", 8, },
	{ "pca9539", 16, },
	{ "pca9554", 8, },
	{ "pca9555", 16, },
	{ "pca9556", 8, },
	{ "pca9557", 8, },

	{ "max7310", 8, },
	{ "max7315", 8, },
	{ "pca6107", 8, },
	{ "tca6408", 8, },
	{ "tca6416", 16, },
	{ "tca9539", 16, }, /*add by me-20190723*/
	/* NYET:  { "tca6424", 24, }, */
	{ }
};

more over, I also add some code in board-omap3devkit8500.c:


static struct pca953x_platform_data gpio_tca9539[]={ [0] = { .gpio_base = 500, }, [1] = { .gpio_base = 550, }, }; static struct i2c_board_info __initdata devkit8500_i2c3_boardinfo[] = { { I2C_BOARD_INFO("tca9539", 0x75), .platform_data = &gpio_tca9539[0], }, { I2C_BOARD_INFO("tca9539", 0x76), .platform_data = &gpio_tca9539[1], }, }; static int __init omap3_devkit8500_i2c_init(void) { omap_register_i2c_bus(1, 2600, devkit8500_i2c1_boardinfo, ARRAY_SIZE(devkit8500_i2c1_boardinfo)); omap_register_i2c_bus(2, 400, devkit8500_i2c2_boardinfo, ARRAY_SIZE(devkit8500_i2c2_boardinfo)); /* Bus 3 is attached to the DVI port where devices like the pico DLP * projector don't work reliably with 400kHz */ //omap_register_i2c_bus(3, 100, NULL, 0); omap_register_i2c_bus(3, 100, devkit8500_i2c3_boardinfo, ARRAY_SIZE(devkit8500_i2c3_boardinfo)); return 0; }

 I do not know the two tca9539 device 20 keys gpio_base, so i give 500 and 550, 

in make menuconfig, I have include

[*] /sys/class/gpio/...(syses interface)

<*>pca953x, pca955x, tca64xx, and max7310 I/o ports

<*>map i2c adapter

the questions is 

1) am I right in configuring tca9539 driver?

2) how I can use this 20 keys  in user level ?

please tell me , thank you very much.

  • Hello user6044731 ,

    "1) am I right in configuring tca9539 driver?"

    We don't typically provide coding level support for our devices but do analog level support instead. (My expertise is not in coding so I probably will not be able to critique the code you wrote). [I have no idea what the GPIO base number is, if you explain what that is I may be able to help assuming it requires information from our device....]

    I see that you have some pre-written code from the PCA9539. Our TCA9539 is a direct pin to pin replacement to the PCA9539 so whatever driver works for the PCA9539 will work for the TCA9539.

    "2) how I can use this 20 keys  in user level ?"

    If you are trying to get user level inputs, you may want to try to use a keypad device like TCA8418/TCA8418E instead.

    Our I/O expanders do not latch the INT pin and do not have memory to store if a bit flipped, for example if the input was '1' and then a user pressed a button to make it '0' and released and then the signal went back to '1' due to a pull up resistor then you go to read the device's input, it would tell you the input was still '1'. There is not memory in this device to store if the bit flips. This is why TCA8418 may be a better suitable device for an application like this because it has a FIFO (memory).

    Does this help?

    -Bobby

  • hi boddy:

    what is meaning of "then you go to read the device's input". how to read the device register? with i2c?  I think the right way is to check the interrupt int /sys/class/gpio/ when user press button. most people deal with gpio input in the way just like I said.

  • Hey User,

    I am speaking from a device standpoint, and not a coding level stand point. You would need to read the device's internal register quick enough in order to capture a keypress event because we do not have a FIFO inside the device.

    -Bobby