USB device types

The official pyboard running MicroPython.
This is the reference design and main target board for MicroPython.
You can buy one at the store.
Target audience: Users with a pyboard.
Post Reply
fun
Posts: 3
Joined: Tue Jun 03, 2014 6:52 pm

USB device types

Post by fun » Tue Jun 03, 2014 6:54 pm

Hi, I'm not sure if this is possible, but can I get the pyboard to press t as another type of USB device, or am I stuck with HID/Serial?

fun
Posts: 3
Joined: Tue Jun 03, 2014 6:52 pm

Re: USB device types

Post by fun » Wed Jun 04, 2014 8:03 am

OK, looking a little deeper, it's totally possible. I'm a little rusty with C, but have been meaning to do some more. Any pointers as to where to start looking in the code?

blmorris
Posts: 345
Joined: Fri May 02, 2014 3:43 pm
Location: Massachusetts, USA

Re: USB device types

Post by blmorris » Wed Jun 04, 2014 4:27 pm

Is it possible that the 'boot.py' script on your pyboard's is configured to boot up in CDC+HID mode? The default is to boot up in CDC+MSC mode (serial emulation plus mass storage) but you can make it boot into CDC+HID mode by uncommenting the line

Code: Select all

#pyb.usb_mode('CDC+HID') # act as a serial device and a mouse
in boot.py. Of course, if you aren't in CDC+MSC mode then you can't directly see boot.py on your filesystem.

Are you running code from an SD Card? If so, try removing it to see what that does. If not, I think that you can reset the boot.py script to its default setting by holding down the 'USR' button while pressing the reset button. (I know that this resets the main.py script, not sure about boot.py)

Hope this helps.
Bryan

fun
Posts: 3
Joined: Tue Jun 03, 2014 6:52 pm

Re: USB device types

Post by fun » Wed Jun 04, 2014 10:16 pm

Those two modes work fine. What I actually want is to present as a USB Audio Class device, set up isochronous endpoints and send the data to a DAC over I2S. The peripherals library for the STM32F4 has some useful code, but getting it working with python is the tricky part. I'll have to dig into the code when I have time to see how the pyb module sets the various USB device descriptors.

blmorris
Posts: 345
Joined: Fri May 02, 2014 3:43 pm
Location: Massachusetts, USA

Re: USB device types

Post by blmorris » Thu Jun 05, 2014 2:46 am

Sorry about that; I misinterpreted your comment about being stuck with HID/Serial.

As for being able to present as a USB Audio Class Device, sign me up as interested. I'm a hardware designer rather than software developer, but I have been running Micro Python on a board I had already developed, an audio amplifier with a built-in DSP codec controlled by an STM32F405RGT6, conveniently the same chip that Damien chose for the pyboard.

Before getting too involved in writing code to get the USB Audio Class to work, note that I2S is not yet supported in Micro Python, so the built-in 12-bit DACs are the only way to get audio out of the chip. I'm looking into supporting I2S, but as I noted I'm not a software developer :? so it might be more accurate to say that I'm trying to get others interested in supporting it. I'm happy to test it if someone gets there before me. ;)

Post Reply