How to combine USART (as virtual COM port) and USB of XMEGA into one USB device?

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

I would like to have Arduino bootloader code in my XMEGA that uses USART as a virtual COM port which Arduino recognizes while the rest of the code is used for file management of internal Flash storage chip and SD card which can be only with USB protocol. Now, how can I have both USART and USB be connected to one USB socket so that when it's inserted in the PC, it serves as a USB Mass Storage device and Virtual COM Port at the same time? I don't want to have two USB sockets sticking out of my device. It's not really nice to see.

 

If you're going to give me any example code right now, keep in mind that I'll be writing the bootloader in assembler so I would like it to be assemblerizable in case it's in C. The reason is that the Boot Section should have something like a kernel and I want maximum efficiency which can only be achieved with assembler.

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

During enumeration a USB device can enumerate as more than one class device. It just depends on what you give in the enumeration table. 

 

Obviously there is no "USART" involved in this. You are talking about combined MSC and CDC-ACM devices. 

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

Foxy - some advice regarding your quest for 'maximum efficiency'. The first rule of optimisation is: get the code working. For me, i would write it in C. Once you've got it working, you have a baseline value for the size of code and the execution time. You also need to understand the fundamental limits of USB. Point being you can fine tune your code all you like, but it won't make USB work any faster.
The second rule is: measure.

The gcc compiler generates assembler. So you can look at the code and see if you can do any better. Since you already have a baseline, you can compare your efforts and determine if you've made an improvement. You'll probably figure out that 80% of the time, the compiler does a pretty good job, 19% of the time any improvement makes little difference to the overall performace and 1% where you can affect a noticeable improvement. Of course, these are not hard and fast numbers, so feel free to tell us what you found.

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

I've had trouble with PROGMEM, command binders, strings in structs in PROGMEM, function pointers, etc. I would like to avoid that by using assembler. But I might try C or C++ if assembler gets too boring or slow to program.

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

I forgot to say also that I need to know what I need to send to the PC via USB that the XMEGA can communicate with the Arduino bootloader with a virtual COM port while at the same time, it should serve as a USB Mass Storage device. How can it be recognized?

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

Have you Googled 'xmega usb'? Have you read the LUFA doc? How about ASF?

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

As Kartman says have you even looked at LUFA or ASF that you'll be using to provide your USB support? LUFA at least has examples of dual class. 

 

Have you read the general documentation about USB at usb.org?

 

Have you read anything by Jan Axelson (janaxelson.com)?

 

I think you need to have done all three before you can plan /prototype your USB solution.