Prerequisite
This article provides helpful information that will be used in article series of Atmega32u4 USB applications. Please refer the below topics when required in the articles.
Basics of LUFA
What is LUFA?
LUFA stands for Lightweight USB Framework for AVRs. It is an open source framework for building USB applications using Atmel USB AVR microcontrollers. It uses the AVR-GCC compilers for the compiling the source code firmware. It supports the following Atmel microcontrollers that contain USB:
• 8-bit AVR
• 32-bit AVR
• XMEGA AVR
The LUFA can be used to design USB based devices using Atmel controllers. It is a great tool to add USB protocol in project development.
More detail resources about LUFA can be found at http://www.fourwalledcubicle.com/LUFA.php
The LUFA can be downloaded from Github.
https://github.com/abcminiuser/lufa
PID/VID, Manufacture Name and Product Name
The Descriptors.c contains the definitions for the Device Descriptor, Configuration Descriptor, Interface Descriptor, Endpoint Descriptor and String Descriptor. The PID/VID, Manufacture String and Product String are declared in this file.
The PID and VID are declared inside the device descriptor. They can be found in Device Descriptor definition with declarations as below:
.VendorID = 0x03EB
.ProductID = 0x2041
The Manufacture and Product name declarations can be found in the String Descriptors. The declarations will be like:
ManufacturerString = USB_STRING_DESCRIPTOR(L”Dean Camera”);
ProductString = USB_STRING_DESCRIPTOR(L”LUFA Mouse Demo”);
USAGE Report
The Usage Report for the HID class communications are defined inside the HIDClassCommon.h.
The file is located at: LUFADriversUSBClassCommon
The file contains the following:
• Declarations for Keyboard Key codes,
• Usage Report for Keyboard
• Usage Report for Mouse
• Usage Report for Joystick
• Data Report structure declaration for Mouse
• Data Report structure declaration for Keyboard
Compiling the firmware or source code
For compiling the source code, we will use WinAVR Programmers Notepad. The software can be downloaded from here https://sourceforge.net/projects/winavr/
Open the .c source file using Programmers Notepad and click on Tools -> Make All.
If the file is successfully complied with no error, the hex file will be created in the same folder.
Burning the Hex file
After generating the Hex file from the compilation, we need to transfer Hex code to Atmega32u4. For uploading the code we will use AVR Dude. If you are already using Arduino IDE in your desktop, then AVR Dude is already installed. It can also be downloaded from http://www.nongnu.org/avrdude/
Before using AVR Dude we need to check the COM port number at which Arduino Pro Micro is recognized as a bootloader. For checking the COM Port number, open the Device Manager, expand the Ports tab and then plug-in the Arduino using micro USB cable. After plugging the cable, reset the Arduino using Reset pin. The Arduino bootloader will be shown under Ports tab with a COM Port number. After some seconds, the Arduino Bootloader will be vanished from the Ports Tab. So the process of noting down the COM port number needs to be done after resetting the Arduino and before vanishing. The Arduino bootloader vanishes from the Ports Tab because Application firmware gets executed after bootloader section in microcontroller.
Project Source Code
Project Source Code
###
//Program to
###
Filed Under: Electronic Projects
Questions related to this article?
👉Ask and discuss on EDAboard.com and Electro-Tech-Online.com forums.
Tell Us What You Think!!
You must be logged in to post a comment.