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.

Connecting a Samsung galaxy tab3 to USB in a TM4c123gh6pge based system with a 4 port hub controller

Although this is not a hardware specific question, the title describes in general what I'm attempting to do.

So the USB hardware appears tobe working fine. I've gotten devices to enumerate through the hub when they are connected, I'm using the Tivaware 2.0 USB library stack to do all the USB servicing. But the Samsung Tablet is an odd beast. It appears as a Image class device as 1 of 2 existing (on the tablet) PIDs. So I wrote a simple Class driver to get it to enumerate. The problem is that when the device emulation on the tablet is switched, while its plugged in, the stack enumerates the new device without disconnecting the first one. Then if the tablet is unplugged the first device instance still remains. At some point in the near future we will be developing an app which will hopefully cause the tablet to have another, proprietary, possible device (PID) so we can send and receive data from our system.  When looking at the Android docs on the web it appears that they want the host to act like a device when communicating to it using their open accessory interface.  I'm a bit lost and would appreciate any ideas and help.

Thanks

Lou

  • Hello Louis

    Something to start with. I would suggest connecting with Tsuneo Chinzei on the forum.

    e2e.ti.com/.../1044097

    Regards
    Amit
  • Sound like you are talking about PTP (Picture Transfer Protocol) / MTP (Media Transfer Protocol) swap on Android phone/tablet. To do this swap on the fly, Android device disconnects once (soft-detach), it swaps the configuration, and it attaches again. Depending on the implementation of each Android device model, this disconnection period may be very short (around 100 us).

    On the other hand, the host process around detection of device connection change over hub is relatively slow.
    - Hub notifies about status change of its ports over its interrupt IN endpoint
    - Reading this change, host put Get_Port_Status request to the hub on the target port

    And then, the Android device would already finish PTP/MTP swap, when the host reads out the target port status. This timing difference would be the cause of your trouble.

    In TivaWare, this part of the source code detects connection change of hub port.

    \TivaWare_C_Series-2.1.0.12573\usblib\host\usbhhub.c
    
    void
    USBHHubMain(void)
    {
        ...
        ...
                //
                // Was a device connected to or disconnected from the port?
                //
                if(ui16Changed & HUB_PORT_CHANGE_DEVICE_PRESENT)
                {
                    DEBUG_OUTPUT("Connection change on port %d\n", ui8Port);
    
                    //
                    // Clear the condition.
                    //
                    HubClearPortFeature(&g_sRootHub, ui8Port,
                                        HUB_FEATURE_C_PORT_CONNECTION);
    
                    //
                    // Was a device connected or disconnected?
                    //
                    if(ui16Status & HUB_PORT_STATUS_DEVICE_PRESENT)
                    {
                        DEBUG_OUTPUT("Connected\n");
    
                        //
                        // A device was connected.
                        //
                        HubDriverDeviceConnect(ui8Port);
                    }
                    else
                    {
                        DEBUG_OUTPUT("Disconnected\n");
    
                        //
                        // A device was disconnected.
                        //
                        HubDriverDeviceDisconnect(ui8Port);
                    }
                }
    

    Fortunately, plenty of "DEBUG_OUTPUTs" are placed in the source code. Enable this feature to know what occurs here.
    - Copy usbhhub.c to your project folder, and register this file to your project
    - Add "INCLUDE_DEBUG_OUTPUT" macro to the preprocessor definition of your compiler option.

    The debug strings should be put over the virtual COM port of ICDI / FTDI (on-board) debug adapter.
    Read them using PC terminal software.

    Tsuneo

  • Thanks Tsuneo for the insite into my problem. Unfortunately I'm not using an eval board which has a connection to the ICDI chip.  I'm working with a embedded design.  I tried your sugestion and enabled the debug in the hub class file.  Had to include UARTstdio.c to satisfy the compiler.  when the program hung on the DEBUGPrintf I new somethin was up so I took a closer look at UARTstdio.c and saw that it used UART0.  My board uses UART0 to talk to another processor on board. I guess I could modify UARTstdio.c to com with the port that I already use for debug which is UART7. I'll have to modify it to call my send routine so it doesn't clobber my own debug output..  Anyway, I was also thinking about what you said about the tablet switching faster than the usb stack can process it with the hub inbetween.  Sounds like I may have to modify the hub code to release all the resources previously allocated for a particular hub port if a new device class is being enumerated on that port. I would rather not have to modify the library code. But from what you were saying, that may be my only option.

    Your thoughts?

    Lou