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



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

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

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

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

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

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

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

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

AT89C5131A Starter Kit... Software User Guide

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

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

Atmel AVR4921: ASF - USB Device Stack Differences between ASF V1 and V2. 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

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

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

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

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

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

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

AVR2006: Design and characterization of the Radio Controller Board's 2.4GHz PCB Antenna. Application Note. Features.

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

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

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

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

3-output Laser Driver for HD-DVD/ Blu-ray/DVD/ CD-ROM ATR0885. Preliminary. Summary. Features. Applications. 1. Description

Application Note. 8-bit Microcontrollers. AVR280: USB Host CDC Demonstration. 1. Introduction

Application Note. C51 Bootloaders. C51 General Information about Bootloader and In System Programming. Overview. Abreviations

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

General Porting Considerations. Memory EEPROM XRAM

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

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

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

AVR134: Real Time Clock (RTC) using the Asynchronous Timer. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

Application Note. USB Mass Storage Device Implementation. USB Microcontrollers. References. Abbreviations. Supported Controllers

8-bit RISC Microcontroller. Application Note. AVR910: In-System Programming

AVR ONE!... Quick-start Guide. EVK Windows 32104B AVR ONE! 02/10

AT91 ARM Thumb Microcontrollers. AT91SAM CAN Bootloader. AT91SAM CAN Bootloader User Notes. 1. Description. 2. Key Features

AT88CK490 Evaluation Kit

AT91SAM ARM-based Flash MCU. Application Note

USER GUIDE EDBG. Description

USER GUIDE. ZigBit USB Stick User Guide. Introduction

AVR2004: LC-Balun for AT86RF230. Application Note. Features. 1 Introduction

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

AVR055: Using a 32kHz XTAL for run-time calibration of the internal RC. 8-bit Microcontrollers. Application Note. Features.

Application Note. USB Microcontrollers. USB PC Drivers Based on Generic HID Class. 1. Introduction

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

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

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

AVR106: C functions for reading and writing to Flash memory. 8-bit Microcontrollers. Application Note. Features. Introduction

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

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

8-bit. Application Note. Microcontrollers. AVR273: USB Mass Storage Implementation. Features. 1. Introduction

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

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

8-bit Microcontroller. Application Note. AVR415: RC5 IR Remote Control Transmitter. Features. Introduction. Figure 1.

8-bit RISC Microcontroller. Application Note. AVR155: Accessing an I 2 C LCD Display using the AVR 2-wire Serial Interface

AVR245: Code Lock with 4x4 Keypad and I2C LCD. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

8-bit Microcontroller. Application Note. AVR134: Real-Time Clock (RTC) using the Asynchronous Timer. Features. Theory of Operation.

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

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

8-bit Microcontroller. Application Note. AVR105: Power Efficient High Endurance Parameter Storage in Flash Memory

8-bit RISC Microcontroller. Application Note. AVR182: Zero Cross Detector

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

AVR1321: Using the Atmel AVR XMEGA 32-bit Real Time Counter and Battery Backup System. 8-bit Microcontrollers. Application Note.

AT86RF230 (2450 MHz band) Radio Transceiver... User Guide

3-output Laser Driver for HD-DVD/ Blu-ray/DVD/ CD-ROM ATR0885. Preliminary. Summary

8-bit Microcontroller. Application Note. AVR286: LIN Firmware Base for LIN/UART Controller. LIN Features. 1. Atmel LIN/UART Controller

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

AVR32110: Using the AVR32 Timer/Counter. 32-bit Microcontrollers. Application Note. Features. 1 Introduction

MODFLEX MINI GATEWAY ETHERNET USER S GUIDE

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

AT91 ARM Thumb Microcontrollers. Application Note. Interfacing a PC Card to an AT91RM9200-DK. Introduction. Hardware Interface

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

8-bit Microcontroller. Application Note. AVR222: 8-point Moving Average Filter

Designing Feature-Rich User Interfaces for Home and Industrial Controllers

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

AVR1003: Using the XMEGA Clock System. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

8-bit Microcontroller. Application Note. AVR400: Low Cost A/D Converter

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

USB 2.0 Full-Speed Host/Function Processor AT43USB370. Summary. Features. Overview

8-bit Microcontroller. Application Note. AVR461: Quick Start Guide for the Embedded Internet Toolkit. Introduction. System Requirements

AVR32807: Getting Started with the AVR UC3 Software Framework USB Classes. 32-bit Microcontrollers. Application Note. Features.

AVR223: Digital Filters with AVR. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

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

Atmel AT32UC3A3256 microcontroller 64MBit SDRAM Analog input (to ADC) Temperature sensor RC filter

Atmel AVR4950: ASF - USB Host Stack. 8-bit Atmel Microcontrollers. Application Note. Features. 1 Introduction

256K (32K x 8) Battery-Voltage Parallel EEPROMs AT28BV256

Atmel AVR4905: ASF - USB Device HID Generic. 8-/32-bit Atmel Microcontrollers. Application Note. Features. 1 Introduction

AT89LP Flash Data Memory. Application Note. AT89LP Flash Data Memory API. 1. Introduction. 2. Theory of Operation. 2.1 Flash Memory Operation

AN3354 Application note

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

AT91 ARM Thumb Microcontrollers. Application Note. AT91 USB CDC Driver Implementation. 1. Introduction. 2. Related Documents

USB Test Environment ATUSBTEST- SS7400. Summary

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

Introducing a platform to facilitate reliable and highly productive embedded developments

AVR32737: AVR32 AP7 Linux Getting Started. 32-bit Microcontrollers. Application Note. Features. 1 Introduction

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

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

HANDLING SUSPEND MODE ON A USB MOUSE

Transcription:

AVR270: USB Mouse Demonstration Features Runs with AT90USB Microcontrollers at 8MHz USB Low Power Bus Powered Device (less then 100mA) Supported by any PC running Windows (98SE or later), Linux or Mac OS. Less than 3Kbytes of Code Required X, Y Movement, Left Button Supported 8-bit Microcontrollers Application Note 1. Introduction The PS/2 interface has disappeared from the new generations of PCs to leave the place to the USB interface. This change has to be followed by the designers of pointing devices, who should integrate the USB interface and allow an easy connection to new PCs. This document describes a simple mouse project. It allows to quickly test USB hardware using AT90USB without any driver installation. A familiarity with USB Software Library for AT90USBxxx Microcontrollers (doc 7675, included in the CD-ROM & Atmel website) and the HID specification (http://www.usb.org/developers/hidpage) is assumed.

2. Hardware Requirements The USB mouse application requires the following hardware: AVR USB evaluation board (STK525, AT90USBKey, STK526...or your own board) AVR USB microcontroller USB cable (Standard A to Mini B) PC running on Windows (98SE, ME, 2000, XP), Linux or MAC OS with USB 1.1 or 2.0 host 3. In-System programming and Device Firmware Upgrade To program the device you can use the following methods: The JTAG interface using the JTAGICE MKII The SPI interface using the AVRISP MKII The USB interface thanks to the factory DFU bootloader and Flip software The parallel programming using the STK500 or STK600 Please refer to the hardware user guide of the board you are using (if you are using Atmel starter kit) to see how to program the device using these different methods. Please refer to Flip (1) help content to see how to install the USB driver and program the device through the USB interface. Note: 1. Flip is software provided by atmel to allow the user to program the AVR USB devices through the USB interface (No external hardware required) thanks to the factory DFU bootloader. 2 AVR270

AVR270 4. Quick Start Once your device is programmed with usb_mouse.a90 file, you can start the mouse demonstration. Check that your device is enumerated as a mouse (see figure 11), then you can use the kit as a mouse. Figure 4-1. Mouse Enumeration 3

The figure below shows the STK525 used by the demo (you may use another kit: AT90USBKey, STK526, depending on the AVR USB product you are working with): Figure 4-2. Demonstration Board HWB button Joystick Reset button To move the mouse pointer in several directions (up, down, left, right), you have to move the joystick. The HWB button will be used as a left button. 4 AVR270

AVR270 5. Application Overview The USB mouse application is a simple data exchange between the PC and the mouse. The PC asks the mouse if there is new data available each P time (polling interval time), the mouse will send the data if it is available, otherwise it will send a NAK (No Acknowledge) to tell the PC that there is no data available. Data sent to the PC are called report. This report has the structure below: Figure 5-1. USB Report Structure Byte 3 Byte 2 Byte 1 Byte 0 Wheel Y X Reserved : default value 0 2 1 0 Button left Button right The mouse pointer position Button middle 5

Figure 5-2. Application Overview 6 AVR270

AVR270 6. Firmware As explained in the USB Software Library for AT90USBxxx Microcontrollers document (doc 7675) all USB firmware packages are based on the same architecture. Figure 6-1. USB Mouse Firmware Architecture Start up Enumeration management main.c scheduler.c config.h conf_scheduler.h Mouse application management Mouse application usb_task.h usb_task.c mouse_task.h mouse_task.c API usb_standard_ request.c usb_standard_request.h usb_specific_ request.c usb_specific_request.h usb_descriptors.c usb_descriptors.h conf_usb.h Drivers usb_drv.c usb_drv.h stk_525.c stk_525.h Hardware USB hardware interface Should not be modified by user Can be modified by user Added by user 7

This section is dedicated to the mouse module only. The customization of the files described hereafter allow the user to build his own mouse application. 6.1 mouse_task.c This file contains the functions to initialize the mouse, collect the report data and put it in the endpoint FIFO to be ready to be sent to the PC. Figure 6-2. Mouse Application 6.1.1 mouse_task_init This function performs the initialization of the mouse parameters and hardware resources (joystick, button...). 6.1.2 Is_usb_mouse_event If a mouse event occurs, this function updates the USB mouse report and returns true. Otherwise it returns false. 6.1.3 mouse_task 6.2 stk_52x.c. This function checks if Is_usb_mouse_event is true and loads the report in the USB endpoint FIFO to be transmited to the host. This file contains all the routines to manage the STK 52x board resources (Joystick, potentiometer, Temperature sensor, LEDs...). The user should not modify this file when using the STK52x board. Otherwise he has to build his own hadware management file. 8 AVR270

AVR270 6.3 How to manage the Remote Wake Up feature The Remote Wake Up is an optional feature specified by the USB to allow the device to wake the host up from a stand by mode (refer to the USB specification for further details). This request is the only request which can be initiated by the device, but it has to be allowed by the host. The host sends a Set Feature request to enable the Remote Wake Up feature just before sending the suspend request. If the host did not send the Set Feature (RemoteWakeUpEnable), the device is not allowed to perform this feature. A USB device reports its ability to support remote wakeup in its configuration descriptor (refer below to see how it is done with Atmel library). If a device supports remote wakeup, it must also be allowed the capability to be enabled and disabled using the standard USB requests. The configuration descriptor is defined in the usb_descriptors.h file as below: // HID Mouse CONFIGURATION #define NB_INTERFACE 1 #define CONF_NB 1 #define CONF_INDEX 0 #define CONF_ATTRIBUTES USB_CONFIG_BUSPOWERED #define MAX_POWER 50 // 100 ma To setup the Remote Wake Up feature, you have to modify the CONF_ATTRIBUTES as below: #define CONF_ATTRIBUTES (USB_CONFIG_BUSPOWERED USB_CONFIG_REMOTEWAKEUP) If the device supports the Remote Wake Up feature, the user has to manage the Set_Feature(DEVICE_REMOTE_WAKEUP) request using the void usb_set_feature(void). Once the Set_Feature(DEVICE_REMOTE_WAKEUP) is well managed, you can use any button (must be used in external interrupt/pin change mode) for example to wake up the host. To do this, you have to take care of the following details: First, the USB controller must have detected the suspend state of the line: the remote wake-up can only be sent when a SUSPI flag is set. The firmware has then the ability to set RMWKUP to send the upstream resume stream. This will automatically be done by the controller after 5ms of inactivity on the USB line. When the controller starts to send the upstream resume, the UPRSMI interrupt is triggered (if enabled). SUSPI is cleared by hardware. RMWKUP is cleared by hardware at the end of the upstream resume. If the controller detects a good End Of Resume signal from the host, an EORSMI interrupt is triggered (if enabled). 9

6.4 How to modify my device from non-bootable to bootable device Please note that HID device may be bootable or non-bootable. By default, the HID demo provided by Atmel are non-bootable devices. If your application needs to be bootable, you have to modify the sub-class parameter (usb_descriptors.h): // USB Interface descriptor Keyboard #define INTERFACE_NB_MOUSE 0 #define ALTERNATE_MOUSE 0 #define NB_ENDPOINT_MOUSE 1 #define INTERFACE_CLASS_MOUSE 0x03 // HID Class #define INTERFACE_SUB_CLASS_MOUSE 0x00 // Non-bootable #define INTERFACE_PROTOCOL_MOUSE 0x01 //Keyboard #define INTERFACE_INDEX_MOUSE 0 Set the INTERFACE_SUB_CLASS_MOUSE to 1 to convert the mouse to a bootable device. 7. PC Software 8. Limitations The USB mouse application does not require any PC software. The middle and the right buttons are not supported by this demonstration. 9. Related Documents AVR USB Datasheet (doc 7593) USB Software Library for AT90USBxxx Microcontrollers (doc 7675) USB HID class specification (www.usb.org) 10 AVR270

Headquarters International Atmel Corporation 2325 Orchard Parkway San Jose, CA 95131 USA Tel: 1(408) 441-0311 Fax: 1(408) 487-2600 Atmel Asia Room 1219 Chinachem Golden Plaza 77 Mody Road Tsimshatsui East Kowloon Hong Kong Tel: (852) 2721-9778 Fax: (852) 2722-1369 Atmel Europe Le Krebs 8, Rue Jean-Pierre Timbaud BP 309 78054 Saint-Quentin-en- Yvelines Cedex France Tel: (33) 1-30-60-70-00 Fax: (33) 1-30-60-71-11 Atmel Japan 9F, Tonetsu Shinkawa Bldg. 1-24-8 Shinkawa Chuo-ku, Tokyo 104-0033 Japan Tel: (81) 3-3523-3551 Fax: (81) 3-3523-7581 Product Contact Web Site www.atmel.com Technical Support avr@atmel.com Sales Contact www.atmel.com/contacts Literature Requests www.atmel.com/literature 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 ATMEL S TERMS AND CONDI- TIONS OF SALE LOCATED ON ATMEL S WEB SITE, 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 INCIDEN- TAL DAMAGES (INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF 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 product 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 s products are not intended, authorized, or warranted for use as components in applications intended to support or sustain life. 2008 Atmel Corporation. All rights reserved. Atmel, logo and combinations thereof, and others are registered trademarks or trademarks of Atmel Corporation or its subsidiaries. Other terms and product names may be trademarks of others.