electro-smith / libDaisy

Hardware Library for the Daisy Audio Platform
https://www.electro-smith.com/daisy
MIT License
340 stars 146 forks source link

Create example that utilizes USB #28

Closed PaulBatchelor closed 4 years ago

PaulBatchelor commented 5 years ago

Not sure what this is used for it (MIDI?), but I see it on the Daisy, so there should be sample code that tells you how to handle this (if/when it gets implemented).

stephenhensley commented 5 years ago

Yeah, there'll likely be multiple configurations for each USB.

I'll be getting to this soon (probably next week or two).

The first one on my list to make is going to be CDC, and I'll likely make a slim example that just prints the values of the knobs or something to a com port.

Audio, and MIDI would be next up.

Other potential USB uses/examples could be having the buttons or gate inputs trigger keys on a PC as an HID

PaulBatchelor commented 5 years ago

@stephenhensley USB is pretty much magic to me, so I have a few general questions (maybe this is documented somewhere already):

The connector on the daisy is miniusb port, so what's the best practice of connecting USB stuff to it? Is is just a matter of buying an adapter?

With audio stuff, I'm assuming you are referring to any class compliant audio interface, right? What's the computational overhead like on handling an audio device. Would you be able to use the on-board codecs simultaneously, or do you expect it to be an either/or kind of deal?

I would have an interest in getting some of my HID devices working, such as the G430 drawing tablet. It's all kind of magic right now. Right now, I am parsing HID messages from it in my own event loop on Linux via hidapi (a wrapper around libusb). Do you know if the serial messaging format would change at all (like, the Linux device driver is somehow filtering the message)? Again, it's all quite magic to me, so apologies if that doesn't make sense.

stephenhensley commented 5 years ago

I'm still figuring out the USB stuff as well.

Oh! In most of the examples I was talking about the daisy would be a device, not a host. So you would connect a computer to it. (Like when you reprogram it).

However, it is capable of being either host or device. (In this case an adapter would work, if you wanted to use it to for mass storage like a USB drive.)

Re. audio, I'm not too sure what the overhead is going to be, I don't expect it to be much. What concerns me would be synchronization be all the i/o on the codecs, and the USB. But when I get it working, the first audio example would be a stereo audio interface w/ 2 ins and 2 outs. Which would send audio via USB from the codec inputs, and then send audio from a host PC via USB to the codec outputs. So we'll see how much processing that actual requires, but with DMA transfers and stuff, I expect it to be pretty handsoff on the cpu.

Using control data from something like a drawing tablet would be super cool, I hadn't thought about using USB for stuff like that.

PaulBatchelor commented 5 years ago

Oh! In most of the examples I was talking about the daisy would be a device, not a host. So you would connect a computer to it. (Like when you reprogram it).

Oh... that makes a great deal more sense now lol. With that in mind, how hard would it be to set up some kind of serial connection with a computer? I would love to be able to synchronize it with some of the stuff I'm doing on the Norns.

stephenhensley commented 5 years ago

should be really simple once I add an interface to libdaisy that uses the ST HAL, and their USB Middleware.

I've done several test with just standard COM ports (using Putty and similar). Not sure how the Norns communicates, but getting them to talk shouldn't be too hard.

PaulBatchelor commented 5 years ago

Not sure how the Norns communicates, but getting them to talk shouldn't be too hard.

Since the norns is a just raspberry pi with extra steps, the daisy just needs to be able to show up as a some kind of serial device on Linux. From there, I'd parse the data stream in some event loop in C.

stephenhensley commented 4 years ago

hardware_platforms/seed/tests/SeedUSB_CDC

very simple example of doing VCOM transmits.

Rx handling, and other USB classes coming soon.