LUFA newbie advice needed - getting started

88 views
Skip to first unread message

Scott Fausel

unread,
Apr 26, 2014, 12:11:32 PM4/26/14
to lufa-s...@googlegroups.com
I am a hobbyist with prior experience in embedded PIC programming, and just getting into the AVR world.  I've read a fair bit about USB, but admittedly my understanding of the complexities of the protocol is weak.  The LUFA project looks amazing, and I am trying to improve my understanding of its functionality.

To that end, I acquired an Adafru.it Atmega32u4 breakout board.  I am running AVR Studio 6.1 on a Win7 64-bit Home premium laptop.  I've installed the latest GCC stuff, WinAVR, AVRDude, and of course the LUFA library. 

I am able to create a new AVR Studio example project using the LUFA "Virtual Serial CDC Device Demo (Class Driver APIs) - AVR8 Architecture" selection from the ASF/Extensions.  This compiles successfully unchanged, as well as if I change the device to "ATMega32u4" in project properties.  However, if I try to set LUFA board support to "Ada_u4," (in the IDE - right hand pane) I get this compiler error:

Error 1 Board/Joystick.h: No such file or directory C:\Users\SLF\Documents\Atmel Studio\6.1\CLASS_CDC1_Test2\CLASS_CDC1_Test2\src\LUFA\LUFA\Drivers\Board\Joystick.h 125 31 CLASS_CDC1_Test2

So I haven't even made it to blinking an LED and I've messed up :-p

Assuming I can be helped past this issue <G>, I am in need of some direction regarding getting going.  Specifically:

1. Please help me wrap my head around organizing a project using this breakout board or a future user-defined board.  Specifically, I'm not sure where to start regarding which header files to modify, how to map ports (e.g. how do I "tell" LUFA the function of each microcontroller port or pin or where do I find the button/led/adc/other maps if the board is pre-defined)? 

2. I presume I would place my user functions in VirtualSerial.c and prototypes in VirtualSerial.h, then call them from main() or an appropriate interrupt handler?

Thanks for any help you can provide this newbie!

Scott

Dean Camera

unread,
May 8, 2014, 7:16:48 AM5/8/14
to lufa-s...@googlegroups.com
Hi Scott,

(Sorry - working through my inbox, lots and lots of unanswered email due to a very full schedule of late)

Welcome to LUFA! Don't worry, you haven't really messed up. I need to come up with a nicer solution for the board system, as it confuses the heck out of a more users than I'd like to admit. The current system is that most of the demos rely on one or more common board hardware elements to function, such as a joystick, LEDs, etc. To preserve my sanity and keep the demo code clean I've wrapped up these common drivers into board specific packages, which are swapped out when you recompile via the BOARD macro passed to the compiler from the command line. In Atmel Studio, this macro is automatically adjusted when you change the board selection in the ASF Wizard GUI.

However, if you swap to a board that does not have one of these hardware parts that the demo uses you will get a compilation failure. For me that makes sense (what is the reasonable expectation of being asked to compile a driver that does not exist?) but everyone seems to end up confused. You can either make your own custom board drivers as specified in the documentation here:

http://fourwalledcubicle.com/files/LUFA/Doc/140302/html/_page__writing_board_drivers.html

Or, if you just want to see the demo enumerate, you can select the "none" board driver which will silently swap out all the board drivers with dummy, do-nothing implementations. The LUFA documentation is also available inside Atmel Studio from the Help menu.

For your custom functions - either adjust the main() function code to add your functionality, or add your own files to the project. Each new example project is a copy from the internal repository, so don't worry about messing things up as you can always re-create a fresh copy.


Cheers!
- Dean
--
You received this message because you are subscribed to the Google Groups "LUFA Library Support List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to lufa-support...@googlegroups.com.
To post to this group, send email to lufa-s...@googlegroups.com.
Visit this group at http://groups.google.com/group/lufa-support.
For more options, visit https://groups.google.com/d/optout.

Scott Fausel

unread,
May 11, 2014, 12:58:16 PM5/11/14
to lufa-s...@googlegroups.com
Hi Dean,

No need to apologize - I am much appreciative of you taking the time to personally reply to posts!  I have in the meantime been studying up on AVR programming (in GCC C at least), and have a better understanding of macros and program structure (read your treatise on managing large projects <G> as part of that).  I think some of my confusion has resulted from the variety of ways to do the same thing depending upon the tools chosen like "automagically" in AVR studio, via command line options, using make files, etc.  Writing some simple programs for a 328p in Notepad++ and using GCC and AVRdude have increased my understanding of some of the stuff going on under the hood ;-)

I will see if I can enumerate the demo with a "no board" option, then try to develop a simple custom board driver via the instructions from your link.

Thanks again!

Scott
Reply all
Reply to author
Forward
0 new messages