chipweinberger / xesp-usbh

A libusb inspired usb host implemention for the esp32 s2.
2 stars 1 forks source link

Questions about code [discussion] #1

Open csBlueChip opened 3 years ago

csBlueChip commented 3 years ago

Hi Chip,

You don't seem to have "discussions" enabled so excuse me posting a 'discussion' to the 'issues' tab.

First off: What delightfully easy to read code. Nice job :) ...Your code looks like what I have spent the last couple of weeks trying to find! ...Notably MIDI USB Host for a 'cheap' μC.

  1. I see your code has the MIDI Out Endpoint lines commented-out? Is this simply because you have no use for them in your test case, or is this an ESP32-S2 hardware limitation? (EG. the RP2040/Pico which (apparently) only has ONE Bulk Endpoint!)
    IE. If I 'uncomment' the lines is it reasonable to expect both MIDI In and Out Bulk Endpoints to work?

  2. Am I correct to think that the xesp_*.[c|h] files are from the ESP IDF? ...Or are these also your work?

  3. Many MIDI devices (including my CH-345 USB<->MIDI cable) have Descriptors which lie about the size of their Endpoint (8 > 4) ...Do you know where I would need to apply this (Linux kernel) patch [line 1317] in the ESP USB library?

Thanks, BlueChip

chipweinberger commented 3 years ago

thanks for the compliment!

few things:

in other words, wait for the official support :)

This code was written so I didn't have to wait around! and we didn't know how long it would be until the official code came out.

chipweinberger commented 3 years ago

as for #3 that's the first i'm hearing about that. I'll need to look into that!

also, what are you working on out of curiosity?

csBlueChip commented 3 years ago

/ALL/ of that is yours?! :o ...I think I need to upgrade my level of impressed ;)

I have written (but, obvs, not tested) the code to be a:

You can find my 1st draft here, there's a block diagram of the I/O side of things in the readme The synth files contain the functions you need to write to implement your own synth module ...I'll probably knock up an FM synth as a demo, but that is not a priority.

cb.c is the user callbacks - when incoming MIDI events are received core.c is the driver that dispatches callbacks, etc. It's pretty well commented, so if you want a quick idea of the goal - the API functions are listed at the bottom of midih.h and midiu.h

I've also got a MID/RIFF player working nicely for format-0 and format-1 (non-SMPTE) ...I got distracted and am currently designing a Linux Console UI (!ncurses) for it <shrug> ...I'll probably push that to a new repo sometime over the next week or two - I keep finding obscure edge-cases :/

Hmmm. Espressif have been promising USBH support for the S2 for over a year now ...I'm cautious to hold my breath any longer on this - especially if I've just found some tried-and-tested code, with an easy to read test harness, that does the exact thing I need.

csBlueChip commented 3 years ago

as for #3 that's the first i'm hearing about that. I'll need to look into that!

I've not tried this cable with Windows in years, but when I first got it, I was getting the weirdest problems, SOME events were making it through, but not others ...I jumped through a lot of forums (or was it BBS'es) to find the root cause of the problem - and (anecdotally) it certainly fixed my issues <shrug>

chipweinberger commented 3 years ago

Espressif released their USB host code about a month ago.

It's not yet in an official release though so it could be subject to change. But it should be better tested then mine.

If you do use my code, make sure to use a esp-idf commit from around april/may 2021 since it does not work or even compile anymore on newer commits.

It's on my todo list to update this code, but I won't get to that for awhile.