Advertisement

Quick Links

Atmel AVR4901: ASF - USB Vendor Class

Features

• USB 2.0 compliance
- Chapter 9 compliance
- Full Speed (12Mbit/s), High Speed (480Mbit/s) data rates
• Control, Bulk, Isochronous and Interrupt transfer types
• Small stack size frees space for main application
• Remote wakeup support
• USB bus powered support
• Real time (O.S. compliance, interrupt driven)
• Support 8-bit and 32-bit AVR

1 Introduction

The aim of this document is to provide an easy way to integrate a USB vendor
class application on a new or existing project.
Application
®
8-/32-bit Atmel
Microcontrollers
Application Note
Rev. 8481A-AVR-01/12

Advertisement

Table of Contents
loading

Summary of Contents for Atmel AVR4901

  • Page 1: Atmel Avr4901: Asf - Usb Vendor Class Application

    Atmel AVR4901: ASF - USB Vendor Class Application Features 8-/32-bit Atmel • USB 2.0 compliance - Chapter 9 compliance Microcontrollers - Full Speed (12Mbit/s), High Speed (480Mbit/s) data rates • Control, Bulk, Isochronous and Interrupt transfer types • Small stack size frees space for main application •...
  • Page 2: Abbreviations

    USB Full Speed HID: Human Interface Device USB High Speed USB Low Speed MSC: Mass Storage Class UDC: USB device Controller UDD: USB device Descriptor UDI: USB device Interface USB: Universal Serial Bus SOF: Start of Frame Atmel AVR49011 8481A-AVR-01/12...
  • Page 3: Overview

    • USB device Controller (UDC) • USB device Driver (UDD) For more advanced information concerning the USB stack implementation, please ® refer to the Atmel AVR4900 ASF USB Device stack application note. Figure 3-1. USB vendor class solution architecture. Application UDI –...
  • Page 4: Vendor Class Specification

    Real time constraints and low Interrupt bandwidth transfer • Frequency guaranteed • • High transfer rate Large amount of data transfer Bulk • Transfer guaranteed (ACK) • • Very High transfer rate Streaming application Isochronous • Transfer not guaranteed Atmel AVR49011 8481A-AVR-01/12...
  • Page 5: Quick Start

    Atmel AVR49011 5 Quick start ® The USB device vendor examples are available in Atmel AVR Studio 5 and ASF. Hereunder is the procedure to start a USB device vendor class example quickly: ® 1. Connect the board (for example the Atmel AVR XMEGA -A3BU Xplained kit) to the PC using the USB cable.
  • Page 6 For this example, an open source solution “libusb” is used to support this device. An inf file was generated by the libusb tool. Point to the folder avr4901/driver/ to install the driver.
  • Page 7: Hardware Behavior

    Atmel AVR49011 Once the device is correctly installed, lunch the avr_vendor_class_example.exe from the folder avr4901/tool/. This program will perform a loopback in all endpoints. A status is displayed to show the correct execution of the application: 5.1 Hardware behavior During the application execution the hardware (used board) should behave as below: •...
  • Page 8 The user interface description (specific to the board) is defined at the end of ui.c source file. This file available within “Solution Explorer” under “common/services/usb/class/vendor/device/example/part_number_board/”. Figure 5-3 ui.c file location. Atmel AVR49011 8481A-AVR-01/12...
  • Page 9: Example Description

    Atmel AVR49011 6 Example description 6.1 Example content The ASF provides a USB device vendor class example for various Atmel AVR products. All these examples share common files and implement the same application. Table 6-1 introduces a summary of the main files included in the USB device vendor example.
  • Page 10 // When a IN data has been sent, then the OUT transfer is enabled again void main_vendor_int_in_received(udd_ep_status_t status, iram_size_t nb_transfered) if (UDD_EP_TRANSFER_OK != status) { return; // Tranfert aborted, then stop loopback ui_loop_back_state(false); // Wait a full buffer udi_vendor_interrupt_out_run( main_buf_loopback, sizeof(main_buf_loopback), main_vendor_int_out_received); Atmel AVR49011 8481A-AVR-01/12...
  • Page 11 Atmel AVR49011 Figure 6-1. Example behavior sequence. Application UDC / UDI / UDD udc_start() Step 1 - Started USB device Startup VBus high udc_attach() Step 2 - Wait the vendor interface enable Enumeration UDI_VENDOR_ENABLE_EXT() udi_vendor_interrupt_out_run() Enable loopback process udi_vendor_bulk_out_run() udi_vendor_iso_out_run() Step 3 –...
  • Page 12: Building A Usb Device Vendor

    The USB device vendor modules provide a USB vendor interface which can be used to build a USB vendor class application. These modules are available in Atmel AVR Studio 5 and can be imported in an AVR Studio 5 project. This section describes how to add a USB device vendor in a project: 1.
  • Page 13: Usb Configuration

    There is one configuration section for each USB modules: UDC, UDI and UDD. The UDC configuration possibilities are described in the Atmel AVR4900: ASF – USB Device Stack application note in the Section 7.1.1: USB device configuration”. The UDD configuration possibilities are described in the Atmel AVR4900: ASF –...
  • Page 14 { // Authorize interrupts irq_initialize_vectors(); cpu_irq_enable(); // Initialize the sleep manager service sleepmgr_init(); // Initialize the clock service sysclk_init(); // Enable USB Stack device udc_start(); if (!udc_include_vbus_monitoring()) { // VBUS monitoring is not available on this product Atmel AVR49011 8481A-AVR-01/12...
  • Page 15: Usb Interface Control

    Atmel AVR49011 // thereby VBUS has to be considered as present vbus_event (true); vbus_event(b_vbus_high) { if (b_vbus_high) { // Connect USB device udc_attach(); }else{ // Disconnect USB device udc_detach(); 7.3.2 USB interface control After the device enumeration (detecting and identifying USB devices), the USB Host starts the device configuration.
  • Page 16: Usb Vendor Functions

    ® platforms (Windows, Linux , Mac OS ) and offers an open source solution. Atmel provide an example using this solution available within the Atmel AVR4901 application note. For further information regarding libusb, please refer to http://www.libusb.org/ WinUSB: This solution is provided by and dedicated to Windows platforms ®...
  • Page 17: Vendor Class In A Usb Composite Device

    Atmel AVR49011 8 Vendor class in a USB composite device The information required to build a composite device is available in the Atmel AVR4902 ASF - USB Composite Device application note. A familiarity with this application note is mandatory. This section introduced only the specific information required to build a composite device with a vendor class interface.
  • Page 18: Usb Descriptor

    //! Fill composite interfaces descriptor for Full Speed #define UDI_COMPOSITE_DESC_FS .udi_vendor = UDI_VENDOR_DESC_FS, \ //! Fill composite interfaces descriptor for High Speed #define UDI_COMPOSITE_DESC_HS .udi_vendor = UDI_VENDOR_DESC_HS, \ //! Fill Interface APIs corresponding at interfaces descriptor #define UDI_COMPOSITE_API &udi_api_vendor, Atmel AVR49011 8481A-AVR-01/12...
  • Page 19: Table Of Contents

    Atmel AVR49011 9 Table of contents Atmel AVR4901: ASF - USB Vendor Class Application ....1 Features ....................1 1 Introduction ..................1 2 Abbreviations ................... 2 3 Overview ................... 3 4 Vendor class specification.............. 4 5 Quick start ..................5 5.1 Hardware behavior ....................
  • Page 20 Disclaimer: The information in this document is provided in connection with Atmel products. No license, express or implied, by estoppel or otherwise, to any intellectual property right is granted by this document or in connection with the sale of Atmel products. EXCEPT AS SET FORTH IN THE ATMEL...

Table of Contents