AT13722: USB Dual Role Implementation on SAM V7x E7x S7x. Introduction. References. SMART ARM-based Microcontrollers APPLICATION NOTE

Similar documents
USER GUIDE EDBG. Description

CryptoAuth Xplained Pro

APPLICATION NOTE. AT07175: SAM-BA Bootloader for SAM D21. Atmel SAM D21. Introduction. Features

SMARTCARD XPRO. Preface. SMART ARM-based Microcontrollers USER GUIDE

AT88CK490 Evaluation Kit

APPLICATION NOTE. Secure Personalization with Transport Key Authentication. ATSHA204A, ATECC108A, and ATECC508A. Introduction.

AVR151: Setup and Use of the SPI. Introduction. Features. Atmel AVR 8-bit Microcontroller APPLICATION NOTE

Atmel AVR4921: ASF - USB Device Stack Differences between ASF V1 and V2. 8-bit Atmel Microcontrollers. Application Note. Features.

USER GUIDE. ZigBit USB Stick User Guide. Introduction

How To Use An Atmel Atmel Avr32848 Demo For Android (32Bit) With A Microcontroller (32B) And An Android Accessory (32D) On A Microcontroller (32Gb) On An Android Phone Or

APPLICATION NOTE. AT16268: JD Smart Cloud Based Smart Plug Getting. Started Guide ATSAMW25. Introduction. Features

AVR1922: Xplain Board Controller Firmware. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

APPLICATION NOTE. Authentication Counting. Atmel CryptoAuthentication. Features. Introduction

Atmel AVR4920: ASF - USB Device Stack - Compliance and Performance Figures. Atmel Microcontrollers. Application Note. Features.

Atmel AVR4903: ASF - USB Device HID Mouse Application. Atmel Microcontrollers. Application Note. Features. 1 Introduction

AVR1309: Using the XMEGA SPI. 8-bit Microcontrollers. Application Note. Features. 1 Introduction SCK MOSI MISO SS

AVR1900: Getting started with ATxmega128A1 on STK bit Microcontrollers. Application Note. 1 Introduction

QT1 Xplained Pro. Preface. Atmel QTouch USER GUIDE

APPLICATION NOTE. Atmel AT04389: Connecting SAMD20E to the AT86RF233 Transceiver. Atmel SAMD20. Description. Features

8-bit. Application Note. Microcontrollers. AVR282: USB Firmware Upgrade for AT90USB

AVR115: Data Logging with Atmel File System on ATmega32U4. Microcontrollers. Application Note. 1 Introduction. Atmel

APPLICATION NOTE. AT12405: Low Power Sensor Design with PTC. Atmel MCU Integrated Touch. Introduction

32-bit AVR UC3 Microcontrollers. 32-bit AtmelAVR Application Note. AVR32769: How to Compile the standalone AVR32 Software Framework in AVR32 Studio V2

APPLICATION NOTE. Atmel AT02985: User s Guide for USB-CAN Demo on SAM4E-EK. Atmel AVR 32-bit Microcontroller. Features. Description.

AVR106: C Functions for Reading and Writing to Flash Memory. Introduction. Features. AVR 8-bit Microcontrollers APPLICATION NOTE

AVR1510: Xplain training - XMEGA USART. 8-bit Microcontrollers. Application Note. Prerequisites. 1 Introduction

APPLICATION NOTE. Atmel AVR134: Real Time Clock (RTC) Using the Asynchronous Timer. Atmel AVR 8-bit Microcontroller. Introduction.

AVR317: Using the Master SPI Mode of the USART module. 8-bit Microcontrollers. Application Note. Features. Introduction

AVR32701: AVR32AP7 USB Performance. 32-bit Microcontrollers. Application Note. Features. 1 Introduction

AT91SAM ARM-based Flash MCU. Application Note

Atmel AVR1017: XMEGA - USB Hardware Design Recommendations. 8-bit Atmel Microcontrollers. Application Note. Features.

Using CryptoMemory in Full I 2 C Compliant Mode. Using CryptoMemory in Full I 2 C Compliant Mode AT88SC0104CA AT88SC0204CA AT88SC0404CA AT88SC0808CA

AVR287: USB Host HID and Mass Storage Demonstration. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

Application Note. 8-bit Microcontrollers. AVR270: USB Mouse Demonstration

AT11805: Capacitive Touch Long Slider Design with PTC. Introduction. Features. Touch Solutions APPLICATION NOTE

APPLICATION NOTE. Atmel LF-RFID Kits Overview. Atmel LF-RFID Kit. LF-RFID Kit Introduction

Application Note. 8-bit Microcontrollers. AVR272: USB CDC Demonstration UART to USB Bridge

AVR319: Using the USI module for SPI communication. 8-bit Microcontrollers. Application Note. Features. Introduction

Application Note. Atmel ATSHA204 Authentication Modes. Prerequisites. Overview. Introduction

AVR1318: Using the XMEGA built-in AES accelerator. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

Using the RS232 serial evaluation boards on a USB port

Software Prerequisites Linux Ubuntu LTS. Estimated completion time: 15min. The goal of this hands-on is to:

AVR033: Getting Started with the CodeVisionAVR C Compiler. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

AVR1301: Using the XMEGA DAC. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

General Porting Considerations. Memory EEPROM XRAM

AVR1600: Using the XMEGA Quadrature Decoder. 8-bit Microcontrollers. Application Note. Features. 1 Introduction. Sensors

APPLICATION NOTE. Atmel AT01095: Joystick Game Controller Reference Design. 8-/16-bit Atmel Microcontrollers. Features.

APPLICATION NOTE Atmel AT02509: In House Unit with Bluetooth Low Energy Module Hardware User Guide 8-bit Atmel Microcontroller Features Description

AN3354 Application note

AT09333: USB Host Interface (UHI) for Communication Class Device (CDC) Introduction. Atmel Microcontrollers APPLICATION NOTE

Designing Feature-Rich User Interfaces for Home and Industrial Controllers

How To Design An Ism Band Antenna For 915Mhz/2.4Ghz Ism Bands On A Pbbb (Bcm) Board

More Secure, Less Costly IoT Edge Node Security Provisioning

Figure 1. 8-Bit USB Debug Adapter

Dell Statistica Statistica Enterprise Installation Instructions

AN10866 LPC1700 secondary USB bootloader

AVR305: Half Duplex Compact Software UART. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

Quest vworkspace Virtual Desktop Extensions for Linux

Spotlight Management Pack for SCOM

AT15007: Differences between ATmega328/P and ATmega328PB. Introduction. Features. Atmel AVR 8-bit Microcontrollers APPLICATION NOTE

AT12181: ATWINC1500 Wi-Fi Network Controller - AP Provision Mode. Introduction. Features. Atmel SmartConnect APPLICATION NOTE

AVR315: Using the TWI Module as I2C Master. Introduction. Features. AVR 8-bit Microcontrollers APPLICATION NOTE

AN3990 Application note

APPLICATION NOTE. Atmel AVR443: Sensor-based Control of Three Phase Brushless DC Motor. Atmel AVR 8-bit Microcontrollers. Features.

USER GUIDE Programming Adapter Cable for Fujitsu Flash Microcontroller- F²MC-16LX/FR Family Fujitsu Microelectronics America, Inc.

AVR127: Understanding ADC Parameters. Introduction. Features. Atmel 8-bit and 32-bit Microcontrollers APPLICATION NOTE

AVR32138: How to optimize the ADC usage on AT32UC3A0/1, AT32UC3A3 and AT32UC3B0/1 series. 32-bit Microcontrollers. Application Note.

AVR311: Using the TWI Module as I2C Slave. Introduction. Features. AVR 8-bit Microcontrollers APPLICATION NOTE

AN3265 Application note

Dell Spotlight on Active Directory Server Health Wizard Configuration Guide

APPLICATION NOTE. Atmel AVR600: STK600 Expansion, Routing and Socket Boards. Atmel Microcontrollers. Introduction

Dell One Identity Cloud Access Manager How to Configure for SSO to SAP NetWeaver using SAML 2.0

AN3998 Application note

8051 Flash Microcontroller. Application Note. A Digital Thermometer Using the Atmel AT89LP2052 Microcontroller

Temperature & Humidity SMS Alert Controller

AVR32788: AVR 32 How to use the SSC in I2S mode. 32-bit Microcontrollers. Application Note. Features. 1 Introduction

Atmel SMART ARM Core-based Embedded Microprocessors

AVR353: Voltage Reference Calibration and Voltage ADC Usage. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

Application Note. Atmel CryptoAuthentication Product Uses. Atmel ATSHA204. Abstract. Overview

APPLICATION NOTE. AT17284: Proximetry Cloud Based Smart Plug User Guide. SMART ARM-based Microcontrollers. Introduction. Features

Introducing a platform to facilitate reliable and highly productive embedded developments

User Manual. AS-Interface Programmer

AVR131: Using the AVR s High-speed PWM. Introduction. Features. AVR 8-bit Microcontrollers APPLICATION NOTE

Dell InTrust Preparing for Auditing Cisco PIX Firewall

Product Brief. 2.0 microtoled. Intelligent GOLDELOX Display Module. µtoled-20-g2. Rev 1.0

AN2824 Application note

AN4128 Application note

Dell One Identity Cloud Access Manager How to Configure vworkspace Integration

New Features and Enhancements

CodeWarrior Development Studio for Freescale S12(X) Microcontrollers Quick Start

AVR030: Getting Started with IAR Embedded Workbench for Atmel AVR. 8-bit Microcontrollers. Application Note. Features.

Application Note. 8-bit Microcontrollers. AVR293: USB Composite Device

AN3252 Application note

Dell Statistica. Statistica Document Management System (SDMS) Requirements

AVR125: ADC of tinyavr in Single Ended Mode. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

Dell Migration Manager for Enterprise Social What Can and Cannot Be Migrated

USB OTG and Embedded Host Microchip Technology Incorporated. All Rights Reserved. Slide 1

Dell InTrust Preparing for Auditing Microsoft SQL Server

Atmel Power Line Communications. Solutions for the Smart Grid

HG2 Series Product Brief

Transcription:

SMART ARM-based Microcontrollers AT13722: USB Dual Role Implementation on SAM V7x E7x S7x APPLICATION NOTE Introduction The USB OTG (On-The-Go) is an interface to communicate with portable USB devices. In the Atmel SMART SAM V7x / E7x / S7x series, the USB host and device share the same transceiver. The shared USB transceiver can be controlled either by the USB Host Port Controller or by the USB Device Controller. This configuration allows to emulate a "USB OTG like" connector. The purpose of this document is to help the developers to implement this kind of USB. References 1. Universal Serial Bus Specification, Rev 2.0, April 27, 2000. 2. On-The-Go and Embedded Host Supplement to the USB Revision 2.0 version 1.1a.

Table of Contents Introduction...1 References... 1 1. USB in SAM V7x / E7x / S7x Products...3 1.1. Features of USBHS...3 1.2. USB Dual Role Implementation on SAM V71 Xplained Ultra...3 2. Difference from USB OTG... 11 3. Revision History...12 2

1. USB in SAM V7x / E7x / S7x Products The USB High-Speed Interface (USBHS) complies with the Universal Serial Bus (USB) 2.0 specification in all speeds. This interface is composed with a USB Device and a USB Mini Host. 1.1. Features of USBHS Compatible with the USB 2.0 Specification Supports High-Speed (480Mbps), Full-Speed (12Mbps), and Low-Speed (1.5Mbps) Communication 10 Pipes/Endpoints 4096 bytes of Embedded Dual-Port RAM (DPRAM) for Pipes/Endpoints Up to three Memory Banks per Pipe/Endpoint (not applicable for Control Pipe/Endpoint) Flexible Pipe/Endpoint Configuration and Management with Dedicated DMA Channels On-Chip UTMI Transceiver including Pull-ups/Pull-downs 1.2. USB Dual Role Implementation on SAM V71 Xplained Ultra 1.2.1. Auto Detection of ID Pin and Switching of VBUS A USB cable with standard-a plug on one end and Micro-B on the other end of the cable can be connected from a Host USB port (e.g. PC) to the TARGET USB connector on the SAMV71 Xplained Ultra. In this case, VBUS pin is powered by the external host and the SAMV71 device should act as a USB device. 3

Figure 1-1 Connection in Device Mode When a USB cable with standard-a receptacle on one end and Micro-A plug on the other end of the cable is plugged to the TARGET USB connector, the ID pin will be pulled LOW. The application should detect this change and re-initialize the USB module as host. To acheive this, an interrupt needs to be configured for PC16. Inside the corresponding interrupt service routine, the application can initialize host. When PC16 goes LOW, output of an onboard voltage regulator is enabled to power the VBUS line. 4

Figure 1-2 Connection in Host Mode 1.2.2. Hardware Connections The following illustration shows Micro-AB receptacles available on the SAM V71 Xplained Ultra. 5

Figure 1-3 Micro-AB Connectors on SAM V71 Xplained Ultra On the SAM V71 Xplained Ultra (hardware revision 8), the USB ID pin of the Micro-USB receptacle is connected to PC16 of the ATSAMV71Q21 device. This pin is also routed to the enable pin for the voltage regulator which powers VBUS in host mode. PC16 can be configured to generate an interrupt, which can be used for switching roles (Host/Device). 6

Figure 1-4 USB ID Pin Connection and VBUS Enable 1.2.3. Software Implementation The application is developed with the help of example applications available in the Software Package for SAM V7x / E7x / S7x. Modified source files are available in the zip file associated with this application note. Steps to develop the application are provided in the upcoming sections. Both the host and device stack are included in the project. The USB module will be initialized as CDC device or a MSC host based on the cable connected to the Micro-USB connector on the SAM V71 Xplained Ultra. When a USB flash drive connected to a USB OTG cable is plugged into the Micro-AB receptacle, the USB ID pin will be pulled LOW, which in turn will generate an interrupt. Inside the corresponding interrupt handler a specific flag will be cleared to indicate that the USB module needs to be configured as MSC host. This flag is checked inside the infinite loop in the main function, the USB module will be configured as MSC host and a text file will be created on the disk connected. When the OTG cable is removed, the USB module will be re-configured as CDC device. When the bit UIMOD in USBHS_CTRL register is set, the USBHS will be in device mode. When this bit is cleared, the USBHS will be in Host mode. 1.2.4. Developing a Dual Role Application with SAMV71-XULT Atmel Studio Software Package Software package for SAM V7 devices is available at http://www.atmel.com/tools/samv71-samv70- same70-sams70-software-package.aspx. The Dual Role application is tested using software package version 1.4 and it may need slight changes when working with any updated version of the software package. Download and extract the software package to the PC. The paths used in the following description refers to the files inside the folder created using the software package installer. Start developing an application using an available example project in the software package. There are examples for Host Mass Storage and Device CDC. These steps assume that we start with the Host Mass Storage example available at the location \Atmel \samv71_xplained_ultra\examples_usb\host_examples\usb_host_msc in the software package. 7

Download and extract the software package to the PC. The paths used in the following description refers to the files inside the folder created using the software package installer. Start developing an application using an available example project in the software package. There are examples for Host Mass Storage and Device CDC. These steps assume that we start with the Host Mass Storage example present at the location \Atmel\samv71_Xplained_Ultra\examples_usb\host_examples\usb_host_msc in the software package. 1. Create folders in the samv71_xplained_ultra\examples_usb folder to develop the dual role application. For example, create a folder named dual_role_examples. Within this folder create another subfolder and copy all folders/files from samv71_xplained_ultra\examples_usb \host_examples\usb_host_msc. The folder structure is important since the project uses relative paths for all driver files. After copying the files, open the project available in build\studio and change the optimization level to -O1. Build the project and make sure that copying the files didn t break the relative paths. 2. To add files for CDC support, refer to the CDC example in software package and copy all the required files. The paths specified in the following path are created by the software package installer. 1. samv71_xplained_ultra\libraries\libusb\device\cdc-serial \CDCDSerial.c 2. samv71_xplained_ultra\libraries\libusb\device\cdc-serial \CDCDSerial_Callbacks.c 3. samv71_xplained_ultra\libraries\libusb\device\cdc-serial \CDCDSerialDriver.c 4. samv71_xplained_ultra\libraries\libusb\device\cdc-serial \CDCDSerialDriver_Callbacks.c 5. samv71_xplained_ultra\libraries\libusb\device\cdc-serial \CDCDSerialPort.c 6. samv71_xplained_ultra\libraries\libusb\device\core\usbd.c 7. samv71_xplained_ultra\libraries\libusb\device\core\usbdcallbacks.c 8. samv71_xplained_ultra\libraries\libusb\device\core\usbddriver.c 9. samv71_xplained_ultra\libraries\libusb\device\core \USBDDriverCallbacks.c 10. samv71_xplained_ultra\libraries\libusb\common\cdc\cdclinecoding.c 11. samv71_xplained_ultra\libraries\libusb\common\cdc \CDCSetControlLineStateRequest.c 12. samv71_xplained_ultra\libraries\libusb\common\core\usbd_hal.c 13. samv71_xplained_ultra\libraries\libusb\common\core\usbdescriptors.c 14. samv71_xplained_ultra\libraries\libusb\common\core\usbrequests.c 15. samv71_xplained_ultra\libraries\libchip_samv7\source\usart.c 16. samv71_xplained_ultra\libraries\libchip_samv7\source\usart_dma.c 3. Rename USBHS_Handler in USBD_HAL.c to USBHS_Device_Handler since it is required to use a single entry point for both Host and Device interrupt handlers. 4. After these files are added, copy the files USBH.c, USBH_HAL.c, and usbhs.h from the zip file available with this application note and replace the corresponding files available in the software package. 5. Copy the file named USBDDriverDescriptors.c from the CDC example and add it to the project. 8

6. Use the main.c file available with this application note as main application file. 7. Build the project and check it on the SAM V71 Xplained Ultra. Details required to test the application is provided in the main.c file available in the zip file available with this application note. Figure 1-5 Terminal Window (EDBG Virtual COM) when a USB Flash Drive is Connected Figure 1-6 Terminal Window (EDBG Virtual COM) when a Connected to Host PC Pressing the letter t sends a series of characters to the COM port of the CDC device 9

Figure 1-7 Terminal Window (COM port of CDC Device) when pressing t on EDBG Virtual COM Port 10

2. Difference from USB OTG From the hardware perspective, the same Micro-AB receptacle can be used for host and device, similar to USB OTG. A single GPIO is used to detect ID pin status and switch between host and device role. In host mode, a voltage regulator on the SAM V71 Xplained Ultra drives VBUS. The regulator, which powers VBUS is enabled when the USB ID pin is LOW. However, the solution is not the same with the real USB OTG that does not need external detection circuit. Another major difference is that the USB cable has to be manually changed to switch between Host and Device modes. Other differences between them are : VBUS output voltage range: USB 2.0: 4.75V to 5.25V (1) USB OTG: 4.4V to 5.25V VBUS output current range: USB 2.0: 100mA to 500mA (1) USB OTG: from 8mA HNP and SRP are not supported on the USB module in SAM V7x / E7x / S7x series. Note: 1. This is the value for the USB Dual Role implementations. 11

3. Revision History Doc Rev. Date Comments 42565A 11/2015 Initial document release. 12

Atmel Corporation 1600 Technology Drive, San Jose, CA 95110 USA T: (+1)(408) 441.0311 F: (+1)(408) 436.4200 www.atmel.com 2015 Atmel Corporation. / Rev.: Atmel, Atmel logo and combinations thereof, Enabling Unlimited Possibilities, and others are registered trademarks or trademarks of Atmel Corporation in U.S. and other countries. ARM, ARM Connected logo, and others are the registered trademarks or trademarks of ARM Ltd. Windows is a the registered trademark of Microsoft Corporation in U.S. and or other countries Other terms and product names may be trademarks of others. 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 TERMS AND CONDITIONS OF SALES LOCATED ON THE ATMEL WEBSITE, ATMEL ASSUMES NO LIABILITY WHATSOEVER AND DISCLAIMS ANY EXPRESS, IMPLIED OR STATUTORY WARRANTY RELATING TO ITS PRODUCTS INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, CONSEQUENTIAL, PUNITIVE, SPECIAL OR INCIDENTAL DAMAGES (INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS AND PROFITS, BUSINESS INTERRUPTION, OR LOSS OF INFORMATION) ARISING OUT OF THE USE OR INABILITY TO USE THIS DOCUMENT, EVEN IF ATMEL HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. Atmel makes no representations or warranties with respect to the accuracy or completeness of the contents of this document and reserves the right to make changes to specifications and products descriptions at any time without notice. Atmel does not make any commitment to update the information contained herein. Unless specifically provided otherwise, Atmel products are not suitable for, and shall not be used in, automotive applications. Atmel products are not intended, authorized, or warranted for use as components in applications intended to support or sustain life. SAFETY-CRITICAL, MILITARY, AND AUTOMOTIVE APPLICATIONS DISCLAIMER: Atmel products are not designed for and will not be used in connection with any applications where the failure of such products would reasonably be expected to result in significant personal injury or death ( Safety-Critical Applications ) without an Atmel officer's specific written consent. Safety-Critical Applications include, without limitation, life support devices and systems, equipment or systems for the operation of nuclear facilities and weapons systems. Atmel products are not designed nor intended for use in military or aerospace applications or environments unless specifically designated by Atmel as military-grade. Atmel products are not designed nor intended for use in automotive applications unless specifically designated by Atmel as automotive-grade.