USB HID / USB MIDI as libraries

Please do not post requests
User avatar
RogerClark
Posts: 7478
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: USB HID / USB MIDI as libraries

Post by RogerClark » Thu Dec 07, 2017 4:05 am

Wow

Looks good

I will try to test, when I get time, probably at the weekend

User avatar
RogerClark
Posts: 7478
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: USB HID / USB MIDI as libraries

Post by RogerClark » Thu Dec 07, 2017 4:06 am

Umm

You link does not work :-(

Is it this one

https://github.com/arpruss/USBHID_stm32f1

arpruss
Posts: 97
Joined: Sat Sep 30, 2017 3:34 am

Re: USB HID / USB MIDI as libraries

Post by arpruss » Thu Dec 07, 2017 5:12 am

Yeah, it's this one.

One problem I haven't figured out is how to reset the USB connection. HID.begin(USB_HID_JOYSTICK); HID.end(); HID.begin(USB_HID_KEYBOARD); doesn't work, at least not with Windows. Windows still sees the joystick device, not the keyboard, even though HID.begin() includes the PA12 reset code.

arpruss
Posts: 97
Joined: Sat Sep 30, 2017 3:34 am

Re: USB HID / USB MIDI as libraries

Post by arpruss » Thu Dec 07, 2017 4:55 pm

Looking at the bootloader code, I figured out the issue of how to reset the connection to switch HID identities: I now turn off the USB peripheral in usb_hid_disable() and usb_midi_disable(). Probably something similar should be done in the core with regard to serial.

A minor issue I noticed is that if you send data to the keyboard (and probably other devices) too soon after HID.begin(), it will disappear. A 500ms pause is good enough.

User avatar
RogerClark
Posts: 7478
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: USB HID / USB MIDI as libraries

Post by RogerClark » Thu Dec 07, 2017 7:56 pm

Serial seems to have the same problem.

Sending too soon after the USB starts, causes the data to be lost.

arpruss
Posts: 97
Joined: Sat Sep 30, 2017 3:34 am

Re: USB HID / USB MIDI as libraries

Post by arpruss » Fri Dec 08, 2017 1:55 am

I posted a pull request for powering down USB with Serial.end().

User avatar
RogerClark
Posts: 7478
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: USB HID / USB MIDI as libraries

Post by RogerClark » Fri Dec 08, 2017 3:21 am

OK

I'm a bit snowed under with PR's at the moment.

There are 2 urgent ones, because Wire is not working correctly and nor is tone()

And there seem to be other assorted PR's some of which I will decline

I'm also in the middle of bringing the ZumSpot branch up to date, as it was nearly 300 commits out of date...
So I need to confirm the merge with Head Master (plus some manual changes) are OK.


If your PR is just the addition of lib's I should be able to take a look at the weekend.

arpruss
Posts: 97
Joined: Sat Sep 30, 2017 3:34 am

Re: USB HID / USB MIDI as libraries

Post by arpruss » Fri Dec 08, 2017 4:06 am

No, my PR is just to power down USB when the serial disable function is called. This is needed to allow one to disconnect and start a different USB mode, e.g., switching from Serial to HID or from Serial to MIDI. It's about five lines of code, ported from the bootloader's USB powerdown code.

I am not merging in the libraries yet, as I would like to be able to make improvements to them over the next couple of weeks, as I have a project that will use them, so I may have more ideas for them.

I closed my PR to merge in the addMidiHID branch. If you want, I can give you a PR to bring the addMidiHID branch up to date with Master, but I am thinking that that branch is obsolete given the libraries.

User avatar
RogerClark
Posts: 7478
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: USB HID / USB MIDI as libraries

Post by RogerClark » Fri Dec 08, 2017 6:24 am

If the libraries are as good as, or better than the branch, then we may as well only use the libraries

arpruss
Posts: 97
Joined: Sat Sep 30, 2017 3:34 am

Re: USB HID / USB MIDI as libraries

Post by arpruss » Sat Dec 09, 2017 4:03 pm

At this point, the libraries are better than the branch.

One thing I haven't been able to get working -- it also wasn't working in the branch -- is two-way HID RAW. I have one-way (device to host) transmission working, but the receive interrupt function isn't being called.

Post Reply