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.

TCA8418: TCA8418

Part Number: TCA8418

HI

How to configure these three registers in gpio mode if you want to read the gpio state

0x29 0x30 0x2B

  • You need debouncing only for mechanical switches. As far as I can see, debouncing affects only the interrupt, but not reading the pin itself.

    (There is no register 0x30; the table in section 8.6.2.15 should say 0x2A instead.)

  • Hi COCO J,

    If you desire to write data to the debouncing registers, then you would need to follow the data format listed in figure 24 with correct device slave address, register address (either 0x29, 0x30, 0x2B), and the data you want to put into the register. 

    Configuration of these registers is done via the I2C bus on pins 23 and 22. 

    FYI,

    a bit value of 0 enables the debounce feature for that row/col pin, this is the default value. 

    a bit value of 1 disables the debounce.

    Regards,

    Tyler

  • HI ti:

    set mode, how to modify the code, we now send the data, only in one case the voltage is all high, and in other cases the voltage is low

    static void tca8418_gpio_set(struct gpio_chip *gpiochip, unsigned int offset,
                     int value)
    {
        struct tca8418_keypad *keypad_data
            = container_of(gpiochip, struct tca8418_keypad, gc);

        int byte_offset = offset/8;  //2

        mutex_lock(&keypad_data->lock);
        /*if (value){
            keypad_data->gpio_out |= (value << offset);
        }else{
        keypad_data->gpio_out &= ~(value << offset);
        }*/
        keypad_data->gpio_out &= ~(1 << offset);
        keypad_data->gpio_out |= (value << offset);

        tca8418_write_byte(keypad_data,
                   REG_GPIO_DAT_OUT1+byte_offset,
                   keypad_data->gpio_out>>(byte_offset*8));

        mutex_unlock(&keypad_data->lock);
    }

  • This has nothing to do with the previous question.

    The code looks correct. What are the offset/value values you're calling this function which, and what is the desired effect, and what actually happens?

  • Hi COCO J,

    Do you have values that relate to each variable in the code?

    Regards,

    Tyler