USB HID

Please do not post requests
petr
Posts: 32
Joined: Wed Jul 15, 2015 10:33 am

Re: USB HID

Post by petr » Sat Oct 01, 2016 1:52 pm

RogerClark wrote:There is a branch of the repo where I integrated the various USB changes
https://github.com/rogerclarkmelbourne/ ... addMidiHID
I was hoping to merge this back into the master of the repo, but the problem is that if a user selects any USB device except Serial, they will not be able to upload withe the bootloader as there no way to reset the processor except via Serial ( at the moment)
I would think that the additional USB descriptors (or how it's called) are not active unless the user program calls HID.begin() or something similar. Then it's responsibility of the user space programmer to call the HID.begin() only if they don't want to upload a new firmware. Something along the following lines:

Code: Select all

setup()
{
    pinMode(XX, INPUT_PULLUP);
    if (digitalRead(XX)) HID.begin();
}
This way they could ground the XX pin temporarily to disable the HID initialization when they needed to flash new firmware via USB serial. Calling the HID.begin() unconditionally in the firmware is not smart at all.

BTW, I personally use USB HID for communication (on AVR, both using V-USB and LUFA) so it would be great if this implementation wasn't limited to keyboard/joystick/mouse but allowed also a generic HID descriptor and offered simple send/receive routines.

EDN_A
Posts: 1
Joined: Fri Nov 11, 2016 5:45 pm

Re: USB HID

Post by EDN_A » Fri Nov 11, 2016 6:00 pm

RogerClark wrote:There is a branch of the repo where I integrated the various USB changes



https://github.com/rogerclarkmelbourne/ ... addMidiHID

I was hoping to merge this back into the master of the repo, but the problem is that if a user selects any USB device except Serial, they will not be able to upload withe the bootloader as there no way to reset the processor except via Serial ( at the moment)

Ideally we need a composite device that always has Serial, as well as whichever other devi es the user wants, but I am not an expert in USB and dont have time to write this myself
I found an error in the library from this repo, don´t know if it was already fixed.

If you select the "Generic STM32F103C series" in the tools, and then any other option besides Serial in USB Type, it doesn´t compile. The error: HID.begin() <- HID was not declared in this scope.

If you do that selecting Maple Mini in the board menu instead, it works like a charm.

To fix the problem:

You have to edit the boards_setup.cpp file under the Arduino folder path where you installed the library files for the generic_stm32f103c boards, ie: "Arduino\hardware\Arduino_STM32-addMidiHID\STM32F1\variants\generic_stm32f103c\wirish\board_setup.cpp"

Just add the following code in line 44:
#include <usb_hid_device.h>
#include <usb_midi.h>

Now it works really nice, thank you for the support.

If you find the error in any other board, I think this solution may apply as well.

libarra
Posts: 56
Joined: Tue Sep 15, 2015 2:51 pm

Re: USB HID

Post by libarra » Mon May 15, 2017 1:52 am

Hello guys, sorry for the quite long time without communication from my part...

I have just updated my repo. Now if you choose any of the HID options it will also include usb serial, so you can use both the Serial and HID interfaces in the same sketch.

Now the maple mini (I don't have other boards to test) is listed as a composite device with the serial and HID interfaces, although if you use the "Serial" usb type, it will be listed just as always. if you have any trouble in windows with the device not being recognized, it may help unistalling it and check for hardware changes in the device manager.

Joe Crabhammer
Posts: 2
Joined: Tue May 16, 2017 4:44 am

Re: USB HID

Post by Joe Crabhammer » Thu May 18, 2017 3:54 am

libarra wrote:Hello guys, sorry for the quite long time without communication from my part...

I have just updated my repo. Now if you choose any of the HID options it will also include usb serial, so you can use both the Serial and HID interfaces in the same sketch.

Now the maple mini (I don't have other boards to test) is listed as a composite device with the serial and HID interfaces, although if you use the "Serial" usb type, it will be listed just as always. if you have any trouble in windows with the device not being recognized, it may help unistalling it and check for hardware changes in the device manager.
Hi. First time poster here. You solved the blocker preventing these all important HID updates from getting put into master, and nobody's noticed :cry:

petr
Posts: 32
Joined: Wed Jul 15, 2015 10:33 am

Re: USB HID

Post by petr » Thu May 18, 2017 5:16 am

I have noticed it. It's apparently better than my idea with switching between interfaces. Now if @RogerClark has time to include it in the main repo?

mamrezo
Posts: 5
Joined: Sun Feb 26, 2017 12:49 pm

Re: USB HID

Post by mamrezo » Thu May 18, 2017 12:41 pm

petr wrote:I have noticed it. It's apparently better than my idea with switching between interfaces. Now if @RogerClark has time to include it in the main repo?
I agree with you

libarra
Posts: 56
Joined: Tue Sep 15, 2015 2:51 pm

Re: USB HID

Post by libarra » Thu May 18, 2017 2:59 pm

Joe Crabhammer wrote: Hi. First time poster here. You solved the blocker preventing these all important HID updates from getting put into master, and nobody's noticed :cry:
Hi, and welcome.
petr wrote:I have noticed it.
mamrezo wrote:I agree with you
Well, now we can't say nobody has noticed it :lol:
petr wrote:It's apparently better than my idea with switching between interfaces.
I think it is better the usb composite option than switching aminly due to the time required to change the libmaple usb code to enable the interface switching.

For now, in my repo, only the maple mini and the generic stm32f103c have the usb type menu, the other boards will only have the usual usb serial working, if you want me to add the menu to other boards please tell me which ones.

petr
Posts: 32
Joined: Wed Jul 15, 2015 10:33 am

Re: USB HID

Post by petr » Fri May 19, 2017 9:46 pm

libarra wrote:Hello guys, sorry for the quite long time without communication from my part...
I have just updated my repo.
Where's your repo? I tried to search in your posts but couldn't find it.

Could you please submit a PR to Roger's https://github.com/rogerclarkmelbourne/ ... addMidiHID ?

Thanks!

libarra
Posts: 56
Joined: Tue Sep 15, 2015 2:51 pm

Re: USB HID

Post by libarra » Fri May 19, 2017 10:19 pm

petr wrote:Where's your repo? I tried to search in your posts but couldn't find it.
This is my repo: https://github.com/libarra111/Arduino_STM32
petr wrote:Could you please submit a PR to Roger's https://github.com/rogerclarkmelbourne/ ... addMidiHID ?
Sure, if Roger is ok with that. But Roger's addMidiHID branch is not even with his master branch, mine is, will there be any trouble?

petr
Posts: 32
Joined: Wed Jul 15, 2015 10:33 am

Re: USB HID

Post by petr » Fri May 19, 2017 10:24 pm

Only Roger knows if PR against his master is preferred.

Post Reply