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.

MSP430G2744: qwerty keypad controller in linux os

Part Number: MSP430G2744

Hi,

-We are using msp430g2744 as qwerty keypad controller in our android based laptop.

I got the firmware code for the same from below link.

https://www.ti.com/tool/TIDM-KEYBOARD

I have built it and flashed in our board's msp430g2744.

Now, when I run the i2cdetect command over the i2c channel we connected the

msp430g2744, we are able to detect the slave with address 0x22.

trinket:/sys/devices/platform/soc/4c80000.i2c # i2cdetect 3                                                                                                                                                
Probe chips 0x03-0x77 on bus 3? (Y/n):y
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- 22 -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --  

This address only is configured in the code we got from below link.

www.ti.com/.../TIDM-KEYBOARD

-Android as we know is linux based and linux has support for i2c-over-hid driver.

Below is the location of the driver in linux source code.

drivers/hid/i2c-hid/

To be able to use this driver, we just need to enable the device tree data with

only two info

-interrupt number

-i2c adress from which to read the hid descriptor

I have enabled the devicetree  as

&qupv3_se5_i2c {
       status = "okay";
       i2c-hid-dev@22 {
               compatible = "msp-i2c-hid";
               reg = <0x22>;
               hid-descr-addr = <0x0001>;
               interrupt-parent = <&tlmm>;
               interrupts = <1 0>;
                status = "disabled";
       };
};

Now, when device boots up and probe for msp430g2744 i2c-ver-hid

driver is called it fails with below error

[    9.806578] i2c_hid 3-0022: Fetching the HID descriptor
[    9.811991] i2c_hid 3-0022: __i2c_hid_command: cmd=01 00
[    9.818574] i2c_hid 3-0022: unexpected HID descriptor bcdVersion (0x0000)

Can you please help to correct the hid-descr-addr?

Thanks and regards

Dishnedra

  • Hi Dishnedra,

    I am not fulling understand your issue. 

    Do you need to configure another slave address for the msp430g2744? Or configure the 0x22 as the slave address on the master side?

    Best regards,

    Cash Hao

  • Hi Cash Hao,

    -I am ok with 0x22 address.

    Has msp430g2744 as QWERTY keypad controller has ever been tested on any linux platform?

    please let me know.

    -Also, if it is tested, then in that platform the i2c hid linux driver should have been be able to read the hid descriptor. if so, what address is used by the driver in that code.

    Can you please connect to me on +919035169215, for quicker resolution?

    Thanks and Regards,

    Dishendra Deshmukh

  • Hi Cash,

    Any update.

    I wanted to provide one more input.

    As you know after flashing the QWERTY keypad firmware available below:

    https://www.ti.com/tool/TIDM-KEYBOARD

    I can detect the chip at address 0x22.

    Now whenever I am trying to read any register I am getting value as zero.

    As I was browsing over the above firmware I see function

    USCI_B0_RXX_ISR in the file

    KBD430_SW/./hidi2c/i2c/usci/i2c_engine_usci2xx.c
    In this function I see one condition,

     if (usciB0xferIndex == usciB0BytesToXfer)

    I am not able to understand this condition.

    I think this condition is failing for us.

    Can you please look in this direction and provide us the rootcause and fix.

    Thanks and Regards,

    Dishendra

  • Hi Dishendra,

    My understanding of this code "if (usciB0xferIndex == usciB0BytesToXfer)" is to change some status after one TX cycle is done. It should not affect the TX data. 

    Also, I saw in the code in the same interrupt routine. "#ifdef USCI30WORKAROUND" and by default it is not built. You can try to add the this USCI30 workaround and find out whether it has an impact on this issue.

    Best regards,

    Cash Hao

  • Hi Cash,

    Can you please elaborate on this.

    My understanding of this code "if (usciB0xferIndex == usciB0BytesToXfer)" is to change some status after one TX cycle is don

    I tried this, 

    "#ifdef USCI30WORKAROUND

    But still it is not helping.

    Do you know about any setup be it windows only, where firmware works?

    Please let us know about this.

    Thanks,

    Dishendra

  • Hi Dishendra,

    I mean is to add "#define USCI30WORKAROUND" in the code to active that workaround.

    Best regards,

    Cash Hao

  • Hi Cash,

    -By mistake I clicked on tab

    "This resolved my issue"

    but issue is not resolved.

    -As per your suggestion I have added

    #define USCI30WORKAROUND"

    In the code but it is not helping to resolve the issue.

    I get compilation error saying

    HIDI2CUSCI30DELAY

    is not defined.

    Br,

    Dishendra

  • Hi,

    You also need to define HIDI2CUSCI30DELAY as well. Based on the comment, the "delay is 1 quarter of bit clock". In this code, DCO runs at 8MHz. So check your I2C master configuration to get the bit clock and then you can have your.HIDI2CUSCI30DELAY. 

    Best regards,

    Cash Hao

  • Hi Cash,

    The status of case says resolved.

    Can you please help to change to open only.

    Also, I tried the last suggestion by you.

    #define USCI30WORKAROUND

    #define HIDI2CUSCI30DELAY 25000

    since host i2c is running at 100Khz

    but still the issue is same.

    Host is still reading 0 bytes only.

    Please help.

    thanks and Regards

    Dishenra

  • Hi Dishenra,

    This thread status should be open now. 

    I do not know what else to check on this code. I just have a thought that is it possible to run a I2C example code and change the address to 0x22 and check if it can work properly. You can find the example code in this link. 

    https://dev.ti.com/tirex/explore/node?node=AI98NRZzwlSml4EJTBwAvw__IOGqZri__LATEST

    Best regards,

    Cash Hao

**Attention** This is a public forum