• AVR Freaks

Hot!USB host for multiple devices

Author
cmj
New Member
  • Total Posts : 5
  • Reward points : 0
  • Joined: 2019/05/07 03:01:44
  • Location: 0
  • Status: offline
2019/08/21 09:27:21 (permalink)
0

USB host for multiple devices

Hi all
 
I assume it's possible to have a USB host be able to talk to more than one device? If so, could someone give me some pointers at what I need to do to make it work? :)
 
Just to clarify - it's only of them at any given time.
 
So if a mouse is plugged in it will do one thing (say monitor its movement), if a keyboard is connected it will do another (watch for the arrow keys being pressed), if a joystick is connected it will do something else (watch for the joystick being moved).
#1

5 Replies Related Threads

    Jim Nickerson
    User 452
    • Total Posts : 6184
    • Reward points : 0
    • Joined: 2003/11/07 12:35:10
    • Location: San Diego, CA
    • Status: offline
    Re: USB host for multiple devices 2019/08/21 09:55:11 (permalink)
    0
    Maybe you could start with the MLA and get one device working first
    #2
    maxruben
    Super Member
    • Total Posts : 3352
    • Reward points : 0
    • Joined: 2011/02/22 03:35:11
    • Location: Sweden
    • Status: offline
    Re: USB host for multiple devices 2019/08/21 13:06:28 (permalink)
    0
    When it comes to USB, check out Jan Axelson's pages at http://janaxelson.com/usb.htm
     
    /Ruben
    #3
    Aussie Susan
    Super Member
    • Total Posts : 3612
    • Reward points : 0
    • Joined: 2008/08/18 22:20:40
    • Location: Melbourne, Australia
    • Status: offline
    Re: USB host for multiple devices 2019/08/21 19:23:37 (permalink)
    0
    Are you talking about multiple devices sequentially or simultaneously?
    If I remember correctly, the MLA code does not support a hub. However I have a very old reference to http://www.suwa-koubou.jp/micom/USBHub/usb_hub_en.html that says that it does - not used this myself so treat with all due caution.
    Susan
    #4
    cmj
    New Member
    • Total Posts : 5
    • Reward points : 0
    • Joined: 2019/05/07 03:01:44
    • Location: 0
    • Status: offline
    Re: USB host for multiple devices 2019/08/22 00:29:25 (permalink)
    0
    Thanks for the links.
     
    I want to use them sequentially. ie. I want to be able to use either a keyboard or a mouse without needing to re-program the PIC. I was under the impression that it doesn't support a hub too, and I don't want to complicate matters by trying that as well.
     
    I've got a bit further anyway.
     
    I have combined the keyboard and mouse demos into one project and it's fine once I have connected a mouse (so the keyboard works if I first connect and disconnect the mouse, but not if I connect it first). I added the keyboard bits to the mouse demo, so I guessing something is being setup when the mouse is connected,, so I will investigate that next.
     
     
     
    #5
    cmj
    New Member
    • Total Posts : 5
    • Reward points : 0
    • Joined: 2019/05/07 03:01:44
    • Location: 0
    • Status: offline
    Re: USB host for multiple devices 2019/08/22 01:09:03 (permalink)
    0
    Think I have sorted it. The keyboard demo called SYSTEM_Initialize(SYSTEM_STATE_USB_HOST_KEYBOARD) at the top of main. The mouse one doesn't, but calls (SYSTEM_STATE_USB_HOST_MOUSE) in the APP_HostHIDMouseTasks when it's in the WAITING_FOR_DEVICE state.
     
    One of the things that SYSTEM_STATE_USB_HOST_KEYBOARD / SYSTEM_STATE_USB_HOST_MOUSE does is to setup the timer, so if the mouse hadn't been 'seen' it would never set the timer up, so the keyboard didn't do anything.
     
    In case anyone else needs some hints - the changes I did when merging the two projects were:
    Merge the two USB_TPLs (usb_config.c) and update NUM_TPL_ENTRIES (usb_config.h)
     
    call SYSTEM_Initialize(SYSTEM_STATE_USB_HOST_KEYBOARD in APP_HostHIDKeyboardTasks (see above).
     
    In the USB_ApplicationEventHandler (main.c)
     
            case EVENT_OVERRIDE_CLIENT_DRIVER_SELECTION:
                if (size > 7)
                {
                    uint8_t class    = ((uint8_t*)data)[4];
                    uint8_t subclass = ((uint8_t*)data)[5];
                    uint8_t protocol = ((uint8_t*)data)[6];
                    
                    if ( class == 3 && subclass == 1 )
                    {
                        connected = protocol;
                    }
                }
                break;

            case EVENT_HID_RPT_DESC_PARSED:
                switch (connected)
                {
                    case 0x01: return APP_HostHIDKeyboardReportParser();
                    case 0x02: return APP_HostHIDMouseReportParser();
                }
                break;


    #6
    Jump to:
    © 2019 APG vNext Commercial Version 4.5