32U4 USB device class development questions

Go To Last Post
16 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I'm new to this forum so I'd like to know if this is appropriate subforum for 32U4 USB device class development questions in general. I have arduino boards wth 32U4 but my development is not specific to arduino. I would like to get better at writing USB device class code by understanding the 32U4 USB device facilities.

 

I've been reading 32U4's full documentation. I've also been modifying the USB core code in arduino IDE. To make things easier for myself, I am using an earlier version of arduino IDE that has no pluggable USB device code that complicated things quite a bit. I also stripped away the arduino bootloader and USB CDC so I'm only using USB HID keyboard in one project and USB printer class that I developed in another project. Just to be clear, the arduino USB device core code I'm modifying has "Copyright (c) 2010, Peter Barrett". I wonder if this forum has collective knowledge of this core library. If this isn't something folks here use for USB device code development, then what do you use?

 

Thank you!

Embedded system developer

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

Most people who want to use a chip like 32U4 "standalone" for USB use would always choose LUFA:

 

http://www.fourwalledcubicle.com/LUFA.php

 

As you can see Dean Camera, the (talented!) author of this code has driver support for almost every  imaginable USB class there is.

 

What's more as you will see from:

 

https://github.com/abcminiuser/lufa/blob/master/LUFA/License.txt

 

The code is provided under a "modified MIT licence" which is one of the most open/lenient licences in existence so there will be no issue about where/how you can use this code in your own projects and products.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

liudr wrote:
I'm only using USB HID keyboard in one project ...
That's in ASF3 (Atmel Studio)

ASF-USB | ASF Source Code Documentation

 

"Dare to be naïve." - Buckminster Fuller

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

gchapman wrote:

That's in ASF3

Some words about Atmel USB versus LUFA:

 

http://www.fourwalledcubicle.com/files/LUFA/Doc/120219/html/_page__l_u_f_avs_atmel_stack.html

 

;-)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks clawson. I've had a brief interaction with the LUFA library when I was modifying arduino bootloader for 32U4. That makes sense what you mentioned above. I should spend some time to explore LUFA. Hopefully there's some projects in arduino to read about.

Embedded system developer

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks for the name and links! Now I know where it came from. So maybe the pluggable USB is a more recent version of this library. I'm only trying to do very basic things, not currently a composite device that dynamically changes it's USB function. I'll start reading the docs. I didn't know what the library was so I started by reading it's source code and existing class drivers. What a headache I had!

Embedded system developer

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I just read through why LUFA is better than Atmel, according to LUFA. I'm not entirely convinced. Atmel's code, now that I realize I've been staring at it for a while, is more specific to atmel processors, such as 32u4. I can imagine that LUFA is more general, and the code may have lots of #define and templates to cover the general use case. I've been learning the USB Host Shield library V2 for MAX3421E (as host) for a while and it is so hard that I can't understand it enough to write my own code with it. I went for same library V1, which is a lot less generic and template/def laden. And I was able to understand what it was doing with MAX3421E.

 

But there seems to be advantage with LUFA since it claims to have USB host class. So does LUFA support USB host class for 32U4? What about Atmel's library? I apologize for not knowing these answers. If I could get rid of MAX3421E in my design, I'd be happy to learn harder code.

Embedded system developer

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

liudr wrote:
So does LUFA support USB host class for 32U4? What about Atmel's library?
No and no because mega32U4 is a USB device; AVR USB host is AT90USB1287 - 8-bit AVR Microcontrollers

LUFA Library: Atmel 8-Bit AVR (AVR8) Support | Supported Microcontroller Models

ASF-USB | ASF Source Code Documentation

 

"Dare to be naïve." - Buckminster Fuller

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

gchapman,

 

Thanks for clarifying. I don't wish to have false hope on something I secretly know might not be possible. I will read about AT90USB1287. There is a chance that I want to redo my work with another chip so any information leading me to a more proper chip is appreciated.

 

BTW, the 32U4 is already the top trim MCU within ATMEGA with USB device capability, correct? I've used the 168/328/328pb series and 644/1284 series in my designs, besides the 32u4. I've not used the lower-end xu2 yet.

Embedded system developer

Last Edited: Thu. Dec 12, 2019 - 10:29 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You've misunderstood. The 32U4 is exactly the kind of AVR-USB chip that LUFA was specifically written for.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

liudr wrote:
BTW, the 32U4 is already the top trim MCU within ATMEGA with USB device capability, correct?
'trim'?  pin count?

one comparison table :

Teensy Technical Specifications

AT90USB1286 has an EBI (16b addresses)

USB XMEGA - more program space, more data space, more I/O (DAC, etc), faster CPU, less power, edit : DMA

 

"Dare to be naïve." - Buckminster Fuller

Last Edited: Fri. Dec 13, 2019 - 02:11 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

gchapman wrote:

liudr wrote:
BTW, the 32U4 is already the top trim MCU within ATMEGA with USB device capability, correct?
'trim'?  pin count?

one comparison table :

Teensy Technical Specifications

AT90USB1286 has an EBI (16b addresses)

USB XMEGA - more program space, more data space, more I/O (DAC, etc), faster CPU, less power, edit : DMA

 

 

Thanks gchapman and sorry for using a noob terminology. I think I might have to use AT90 or even better a USB XMEGA. I'm taking USB data intended for a printer and forwarding it to an ESP32 for processing (pass through at the moment) and forwarding processed USB data to a USB host IC MAX3421E that sends data to an actual printer. If I can't quickly forward data to ESP32, then it'll be a slow print :) With my current 32u4 setup, the MCU has to keep checking URE1 bit (or something) for every byte it forwards via UART. If I use an MCU with hardware buffer on UART or SPI, then I can write better code.

Embedded system developer

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

If you need host then among all the 8bit AVRs only AT90USB1286/1287 have OTG (on the go) which is a limited form of host. All other chips are device only.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks clawson! Just glanced at at90USB. Its register map (USB part) is identical to 32U4 except for the otg part of 647/1287. EP DPRAM seems to be organized identically to 32U4. I wonder if 32U4 is a branch(?) of the AT90USB with less memory for smaller devices.

Embedded system developer

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

AT90USB is just a generic term meaning "8bit ATmega with USB". There are about 20 different model of them only 1286/1287 have OTG. The rest are all very similar (in terms of USB) all that really differentiates any of the others are the number of pins, amount if flash/RAM and the collection of surrounding peripherals. 32U4 is simply one of them.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I see. I didn't know that ATMEGA32U4 is a part of AT90USB. I might explore the ones with more SRAM for buffering. Thanks.

Embedded system developer