views:

981

answers:

5

Hello,

I have been tasked to write a device driver for an embedded device which will communicate with the micro controller via the SPI interface. Eventually, the USB interface will be used to download updated code externally and used during the verification phase.

My question is, does anyone know of a good reference design or documentation or online tutorial which covers the implementation/design of the USB protocol stack/device driver within an embedded system? I am just starting out and reading through the 650 page USB v2.0 spec is a little daunting at the moment.

Just as a FYI, the micro controller that I am using is a Freescale 9S12.

Mark

Based upon goldenmean's (-AD) comments I wanted to add the following info:

1) The embedded device uses a custom executive and makes no use of a COTS or RTOS.

2) The device will use interrupts to indicate data is ready to be retrieved from the device.

3) I have read through some of the docs regarding Linux, but since I am not at all familiar with Linux it isn't very helpful at the moment (though I am hoping it will be very quickly).

4) The design approach, for now at least, it to write a device driver for the USB device then a USB protocol layer (I/O) would reside on top of the device driver to interpret the data. I would assume this would be the best approach, though I could be wrong.

+3  A: 

While writing a device driver for any interface (USB, Parallel port, etc...) the code needed to be developed would depend upon whether there is any Operating System(OS), RTOS running on that Processor/Micro controller. e.g. if thats going to run say WinCE - It will have its own Driver development Kit , and steps to be followed in the device driver development. Same for any other OS like Linux, symbian.

If its going to be a plain firmware code(No OS) which is going to control the processor/microcontroller, then it's a different situation altogether. So based on either of the above situation u are in, one needs to read & understand:-

1.) The Hardware Specification of the processor/micro controller development board - Register files, ports, memory layout, etc.

2.) USB spec

3.) Couple of pointers i found quickly. Google shud be ur friend! http://www.lrr.in.tum.de/Par/arch/usb/usbdoc/ - Linux USB device driver

http://www.microsoft.com/technet/archive/wce/support/usbce.mspx

-AD

goldenmean
A: 

I don't know which hardware you're planning to use but assuming that's flexible, STMicro offers a line of microcontrollers with USB/SPI support and a library of C-code that can be used with their parts. -- I've used their ARM7 series micros for years with great success.

Nate
+1  A: 

I've used an earlier edition of This book. Indeed very complete.

From the editorial review:

Now in its fourth edition, this developer's guide to the Universal Serial Bus (USB) interface covers all aspects of project development, such as hardware design, device firmware, and host application software.

Marcelo MD
Marcelo, Thanks for the info and I will place this on my wish list, but I need to develop the device driver and protocol layers by the time this book comes out. I did order another one of the books by the same author.
lordhog
Hm, didn't saw it wasn't out yet, sorry. But I'm happy that it was of some use to you =) Her books are great.
Marcelo MD
A: 

I'm curious, why did you pick the 9S12? I used it at a previous job, and was not pleased.

  • It had lousy gcc support so we used Metrowerks
    • which may have been okay for C, but often generated buggy C++
    • had a lousy IDE with binary project files!
  • The 9s12 was also slow, a lot of instructions executed in 5 cycles.
  • Not very power efficient, either.
  • no barrel shifter, made operations that are common in embedded code slow
  • not that cheap.

About the only thing I dislike more is an 8051. I'm using an ARM CortexM3 at my current job, it's better than a 9S12 in every way (faster clock, more work done per clock, less power consumption, cheaper, good gcc support, 32-bit vs. 16-bit).

KeyserSoze
You can switch the project files from binary to text-based (XML), but overall Codewarrior is still pretty lousy. They are currently working on an Eclipsed based IDE, though.
cschol
A: 

Here is an excellent site maintained by Jonathan Valvano, a professor at the University of Texas. He teaches four courses over there (three undergraduate, one graduate), all are about using a 9S12 microcontroller. His site contains all the lecture notes, lab manuals, and more importantly, starter files, that he uses for all his classes.

The website looks like it's from the 90's, but just dig around a bit and you should find everything you need.

users.ece.utexas.edu/~valvano/

ZainR