Atmel AVR4904: ASF - USB Device HID Keyboard Application. Atmel Microcontrollers. Application Note. Features. 1 Introduction



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

Atmel AVR4905: ASF - USB Device HID Generic. 8-/32-bit Atmel 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.

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

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

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

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

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

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

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

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 LF-RFID Kits Overview. Atmel LF-RFID Kit. LF-RFID Kit 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 AT02509: In House Unit with Bluetooth Low Energy Module Hardware User Guide 8-bit Atmel Microcontroller Features Description

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

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

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

AVR1510: Xplain training - XMEGA USART. 8-bit Microcontrollers. Application Note. Prerequisites. 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

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

Atmel AVR4907: ASF - USB Device CDC Application. Atmel Microcontrollers. Application Note. Features. 1 Introduction

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

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

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

AT91SAM ARM-based Flash MCU. Application Note

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

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

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

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

Introducing a platform to facilitate reliable and highly productive embedded developments

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

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

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

AT89C5131A Starter Kit... Software User Guide

USER GUIDE. ZigBit USB Stick User Guide. Introduction

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

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

USER GUIDE EDBG. Description

Atmel AVR4027: Tips and Tricks to Optimize Your C Code for 8-bit AVR Microcontrollers. 8-bit Atmel Microcontrollers. Application Note.

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

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

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

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

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

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

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

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

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

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

AT88CK490 Evaluation Kit

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

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

Atmel AVR ATxmega384C3 microcontroller OLED display with pixels resolution Analog sensors. Ambient light sensor Temperature sensor

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

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

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

CryptoAuth Xplained Pro

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

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

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

HANDLING SUSPEND MODE ON A USB MOUSE

Section 1 Introduction to the AT91SAMD20 and the Development Environment

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

AVR1324: XMEGA ADC Selection Guide. 8-bit Atmel Microcontrollers. Application Note. Features. 1 Introduction

General Porting Considerations. Memory EEPROM XRAM

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

Application Note. 1. Introduction. 2. Associated Documentation. 3. Gigabit Ethernet Implementation on SAMA5D3 Series. AT91SAM ARM-based Embedded MPU

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

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

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

Two mechanical buttons Two user LEDs Four expansion headers. Board controller with USB interface. One power LED and one status LED

AN3265 Application note

MODFLEX MINI GATEWAY ETHERNET USER S GUIDE

APPLICATION NOTE. Atmel AT01180: Barcode and QR code scanner User Guide. Atmel 32-bit Microcontroller. Features. Introduction

AN2680 Application note

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

8-bit Atmel Microcontrollers. Application Note. Atmel AVR211: Wafer Level Chip Scale Packages

APPLICATION NOTE. Atmel AVR2033: SAM-ICE Adapter Hardware User Manual. 8-bit Atmel Microcontrollers. Features. Introduction

ChangeAuditor 5.6. For Windows File Servers Event Reference Guide

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

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

Atmel AVR1618: ATxmegaB ASCII Character Mapping. 8-bit Atmel Microcontrollers. Application Note. Features. 1 Introduction

Dell Statistica Statistica Enterprise Installation Instructions

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

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

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

Atmel ATSAM3X8E microcontroller Atmel AT86RF GHz radio transceiver Atmel proprietary Lightweight Mesh software stack 10/100Mbps Ethernet

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

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

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

Designing Feature-Rich User Interfaces for Home and Industrial Controllers

AN3354 Application note

ChangeAuditor 6.0 For Windows File Servers. Event Reference Guide

PL-2303 (Chip Rev H, HX, X) USB to Serial Adapter Windows Driver Installer Manual

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

Capacitive Touch Technology Opens the Door to a New Generation of Automotive User Interfaces

AN3990 Application note

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

Transcription:

Atmel AVR4904: ASF - USB Device HID Keyboard Application Features USB 2.0 compliance - Chapter 9 compliance - USB HID compliance - Low Speed (1.5Mbit/s), Full Speed (12Mbit/s) data rates Standard USB HID keyboard implementation - Key - Modifier keys (shift, CTRL, ) - LED report Remote wakeup support USB bus powered support Real time (O.S. compliance, interrupt driven) Support 8-bit and 32-bit AVR Atmel Microcontrollers Application Note 1 Introduction The aim of this document is to provide an easy way to integrate a USB keyboard device application on a new or existing project. Rev.

2 Abbreviations ASF: CD: FS: HID: HS: LS: UDC: UDD: UDI: USB: SOF: ZLP: AVR Software Framework Composite Device: a USB device with more than one interface USB Full Speed Human Interface Device USB High Speed USB Low Speed USB device Controller USB device Descriptor USB device Interface Universal Serial Bus Start of Frame Zero Length Packet 2 Atmel AVR4904

Atmel AVR4904 3 Overview This document includes four sections for all types of requirements when building a USB device HID keyboard application: Quick start Describes how to start a ready to use HID keyboard device example Example description Describes a HID keyboard device example Building a USB device keyboard Describes how to add a USB device keyboard interface in a project Keyboard in a USB Composite Device Describes how to integrate a keyboard interface in a composite device project For all these sections, it is recommended to know the main modules organization of a HID keyboard application: User Application USB device Interface HID keyboard (UDI-HID keyboard) USB device Interface HID (UDI-HID) USB device Controller (UDC) USB device Driver (UDD) For more advanced information concerning the USB stack implementation, please refer to the application note Atmel AVR4900: ASF - USB Device stack. Figure 3-1. USB device HID keyboard architecture. Application UDC UDI HID keyboard UDD UDI HID USB device stack from the ASF NOTE The USB device stack is available in the Atmel AVR Software Framework (ASF) in the common/services/usb directory. 3

4 Quick start The USB device keyboard examples are available in Atmel AVR Studio 5 and ASF. It provides a keyboard peripheral application. 1. Board powering and USB connection. Connect a USB cable between board and the USB Host, this cable powers the board. 2. AVR Studio 5 allows the creation of a New Example Project. In the examples list, select a USB device HID Keyboard Example corresponding to the Atmel board used. Use the filter list to find quickly the example. 1 4 5 2 3 6 3. Compile, load and execute. The project does not require any modification and only needs to be compiled, loaded and run. Connect the Atmel debugger supported by the board and press F5. Thus, a USB keyboard is available on USB Host. 4. Use it. When a button is pressed, the example sends a key sequence which opens a note pad application under Windows O.S. and a key sequence Atmel AVR USB Keyboard. Also the user interface of the board can provide the following information: A LED is ON when USB device is in IDLE mode and is OFF in SUSPEND mode. A LED blinks showing that keyboard interface is enabled by the USB Host. A LED is ON when the numeric keys is locked. A LED is ON when the capital key is locked. 4 Atmel AVR4904

Figure 4-1. Example with Atmel XMEGA A3BU Xplained board. Atmel AVR4904 LED0 is ON showing USB in IDLE mode USB Red LED displays numeric lock status Green LED displays caps lock status SW0 send key sequence and wakeup USB Host LED1 blinks showing keyboard is enabled The user interface description (specific to the board) is defined at the end of the ui.c source file. This file is available inside the project folder under common/services/usb/class/hid/device/kbd/example/part_board/. 5

5 Example description The Atmel AVR Software Framework (ASF) provides a USB device keyboard example for various Atmel AVR products. All these examples share common files. Files description and execution behavior are described later in this section. 5.1 Example content Table 5-1 introduces a summary of the main files included in the USB device HID keyboard example. These files are associated to the modules described in Figure 3-1. USB device HID keyboard architecture. Table 5-1. USB device HID keyboard example files. Modules Files ASF paths Description Application UDI HID keyboard UDI HID UDC UDD main.c ui.c conf_usb.h Examples folder Main loop Set up hardware switches to keyboard operations USB device configuration udi_hid_kbd.c/h common/services/usb/class/hid/device/kbd/ Standard HID keyboard Class implementation udi_hid_kbd_desc.c udi_hid_kbd_conf.h common/services/usb/class/hid/device/kbd/ USB descriptors for an USB device with HID keyboard interface (not applicable for USB composite device) udi_hid.c/h common/services/usb/class/hid/device/ Common HID class implementation usb_protocol_hid.h common/services/usb/class/hid/ HID protocol constants udc.c/h udc_desc.h udi.h common/services/usb/udc/ USB device core udd.h usb_protocol.h usb_atmel.h common/services/usb/ USB protocol constants usbb_device.c/h usbc_device.c/h usb_device.c/h avr32/drivers/usbb/ avr32/drivers/usbc/ xmega/drivers/usb/ USB drivers 5.2 Example behavior 6 Atmel AVR4904 The main.c and ui.c files implement the user interface of the HID keyboard application. It is comprised of four steps: 1. Start USB device. udc_start(); udc_attach(); // Must be called when the USB cable is plugged // Cable plugged is detected via VBus events 2. Wait the enable of HID keyboard interface via callback. UDI_HID_KBD_ENABLE_EXT() // Authorize the HID keyboard events 3. Scan the switches and send a key sequence in SOF interrupt. if(is_button_pressed()) { // start key sequence

Atmel AVR4904 Sequence_running = true; // Sequence process running each 200ms if (200 > cpt_sof) { return; cpt_sof = 0; if (sequence_running) { // Extract the next key of the array sequence // Send this key with a following function udi_hid_kbd_modifier_down(modifier_key_value); // e.g. shift udi_hid_kbd_modifier_up(modifier_key_value); // e.g. shift udi_hid_kbd_down(key_value); udi_hid_kbd_up(key_value); Tip: To simplify the implementation, the SOF event is used to scan switches each 1ms. 4. Display the new caps and numeric lock status via callback. UDI_HID_KBD_CHANGE_LED(HID_LED_NUM_LOCK HID_LED_CAPS_LOCK) 7

Figure 5-1. Example behavior sequence. Application UDC / UDI / UDD Step 1 - Started USB device Startup udc start() VBus high udc attach() Step 2 - Wait the keyboard interface enable Enumeration Enable switches scan UDI_HID_KBD_ENABLE_EXT() Step 3 - Scan the switches Scan switches No key event Scan switches Send Key events UDC_SOF_EVENT() UDC_SOF_EVENT() udi_hid_kbd_down() SOF SOF Step 4 - Display the locks status Turn on or off the caps lock and numeric lock LEDs UDI_HID_KBD_CHANGE_LED() Setup request Manage power consumption in suspend mode UDC_SUSPEND_EVENT() Turn off external components UDC_RESUME_EVENT() Turn on external components Suspend Resume SOF UDC SOF EVENT() 8 Atmel AVR4904

6 Building a USB device keyboard Atmel AVR4904 The USB device keyboard 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 keyboard in a project: 1. Import USB keyboard module. 2. Configure personal USB parameters. 3. Call USB routines to run USB device. 6.1 Import USB module To import the USB HID keyboard module, follow the instructions below: 1. Open or create your project: 2. From Project menu, choose Select Drivers from AVR Software Framework. 3. Select Services (1), choose USB HID Keyboard (Single Interface Device) (2) and click on the Add to selection button (3). 1 2 3 6.2 USB configuration All USB stack configurations are stored in the conf_usb.h file in the application module. These configurations are simple and do not require any specific USB knowledge. 9

IMPORTANT 6.3 USB implementation 6.3.1 USB device control There is one configuration section for each USB modules: UDC, UDI and UDD. The UDC configuration possibilities are described in the application note AVR4900: ASF USB device stack, Section 7.1.1 - USB device configuration. The UDD configuration possibilities are described in the application note AVR4900: ASF USB device stack, Section 7.1.3 - USB Drivers configuration. The UDI which is the keyboard interface does not require any configuration. It is important to verify the configuration defined in the conf_clock.h file, because the USB hardware requires a specific clock frequency (see comment in the conf_clock.h file). This section describes source code to add and to run a USB device keyboard application. The implementation is made of three steps: 1. Start USB device. 2. Wait the enable of HID keyboard interface by the Host. 3. Scan the keys of the keyboard and send USB keyboard events if any. Only two function calls are needed to start a USB device application, see Figure 6-1. Figure 6-1. USB device application sequence. To start a USB device application udc_start() no VBus monitoring available udc_include_vbus_monitoring() yes Wait for VBUS power UDC_VBUS_EVENT() no yes Enable D+ or D- pull-up resistors udc_attach() Bus enumeration 10 Atmel AVR4904

Atmel AVR4904 NOTE In case of a new project, the USB stack requires to enable interrupts and to initialize the clock and sleepmgr services. Example: <conf_usb.h> #define UDC_VBUS_EVENT(b_vbus_high) \ vbus_event(b_vbus_high) <main C file>: main() { // 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(); vbus_event(b_vbus_high) { if (b_vbus_high) { // Connect USB device udc_attach(); else{ // Disconnect USB device udc_detach(); 6.3.2 USB interface control After the device enumeration (detecting and identifying USB devices), the USB Host starts the device configuration. When the USB keyboard interface from device is accepted, the USB host enables this interface and the UDI_HID_KBD_ENABLE_EXT() callback function is called. When the USB device is unplugged or is reset by the USB Host, the USB interface is disabled and the UDI_HID_KBD_DISABLE_EXT() callback function is called. Thus, it is recommended to enable/disable sensors used by keyboard in these functions. Example: <conf_usb.h> #define UDI_HID_KBD_ENABLE_EXT() \ kbd_enable() #define UDI_HID_KBD_DISABLE_EXT() \ kbd_disable() <main C file>: kbd_enable() { // Enable process which scans the keys return true; kbd_disable() { // Disable process which scans the keys 11

6.3.3 USB keyboard control The USB HID keyboard functions described in Table 6-1 allow the application to control the keyboard. Table 6-1. UDI HID keyboard - functions. Declaration udi_hid_kbd_modifier_up(uint8_t modifier_id) udi_hid_kbd_modifier_down(uint8_t modifier_id) udi_hid_kbd_up(uint8_t key_id) udi_hid_kbd_down(uint8_t key_id) Description Send events key modifier released Send events key modifier pressed Send events key released Send events key pressed Example: process_to_scan_keys() { if (is_key_shift_is_released()) udi_hid_kbd_modifier_down(hid_modifier_left_shift); if (is_key_a_is_press()) udi_hid_kbd_up(hid_a);... The USB HID keyboard callback UDI_HID_KBD_CHANGE_LED(uint8_t value) is called when the caps or numeric lock change. When the value argument contains the flag HID_LED_NUM_LOCK, the numeric lock is enabled. When the value argument contains the flag HID_LED_CAPS_LOCK, the caps lock is enabled. Example: <conf_usb.h file>: #define UDI_HID_KBD_CHANGE_LED(value) ui_kbd_led(value) <C file>: void ui_kbd_led(uint8_t value) { if (value & HID_LED_NUM_LOCK) { // Here, turn on Num LED else{ // Here, turn off Num LED if (value & HID_LED_CAPS_LOCK) { // Here, turn on Caps LED else { // Here, turn off Caps LED 12 Atmel AVR4904

Atmel AVR4904 7 Keyboard in a USB composite device 7.1 USB configuration 7.2 USB descriptor 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 HID keyboard interface. In addition to the USB configuration described in Section 6.2, the following values must be defined in the conf_usb.h file: USB_DEVICE_EP_CTRL_SIZE Endpoint control size. This must be: 8 for low speed device 8, 16, 32, or 64 for full speed device (8 is recommended to save RAM) 64 for a high speed device UDI_HID_KBD_EP_IN IN endpoint number used by the HID keyboard interface. UDI_HID_KBD_IFACE_NUMBER Interface number of the HID keyboard interface. USB_DEVICE_MAX_EP Total number of endpoints in the application. This must include one endpoint for HID keyboard interface. The USB device Descriptor of composite device, defined in the conf_usb.h file, must include the HID keyboard interface descriptor: //! Define structure of composite interfaces descriptor #define UDI_COMPOSITE_DESC_T \ udi_hid_kbd_desc_t udi_hid_kbd; \... //! Fill composite interfaces descriptor for Full Speed #define UDI_COMPOSITE_DESC_FS \.udi_hid_kbd = UDI_HID_KBD_DESC, \... //! Fill composite interfaces descriptor for High Speed #define UDI_COMPOSITE_DESC_HS \.udi_hid_kbd = UDI_HID_KBD_DESC, \... //! Fill Interface APIs corresponding at interfaces descriptor #define UDI_COMPOSITE_API \ &udi_api_hid_kbd, \... 13

8 Table of contents Features... 1 1 Introduction... 1 2 Abbreviations... 2 3 Overview... 3 4 Quick start... 4 5 Example description... 6 5.1 Example content... 6 5.2 Example behavior... 6 6 Building a USB device keyboard... 9 6.1 Import USB module... 9 6.2 USB configuration... 9 6.3 USB implementation... 10 6.3.1 USB device control... 10 6.3.2 USB interface control... 11 6.3.3 USB keyboard control... 12 7 Keyboard in a USB composite device... 13 7.1 USB configuration... 13 7.2 USB descriptor... 13 8 Table of contents... 14 14 Atmel AVR4904

Atmel Corporation 2325 Orchard Parkway San Jose, CA 95131 USA Tel: (+1)(408) 441-0311 Fax: (+1)(408) 487-2600 www.atmel.com Atmel Asia Limited Unit 01-5 & 16, 19F BEA Tower, Milennium City 5 418 Kwun Tong Road Kwun Tong, Kowloon HONG KONG Tel: (+852) 2245-6100 Fax: (+852) 2722-1369 Atmel Munich GmbH Business Campus Parkring 4 D-85748 Garching b. Munich GERMANY Tel: (+49) 89-31970-0 Fax: (+49) 89-3194621 Atmel Japan 16F, Shin Osaki Kangyo Bldg. 1-6-4 Osaki Shinagawa-ku Tokyo 104-0032 JAPAN Tel: (+81) 3-6417-0300 Fax: (+81) 3-6417-0370 2011 Atmel Corporation. All rights reserved. Atmel, Atmel logo and combinations thereof, AVR, AVR Studio, XMEGA, and others are registered trademarks or trademarks of Atmel Corporation or its subsidiaries. Windows and others are registered trademarks or trademarks 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 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 products are not intended, authorized, or warranted for use as components in applications intended to support or sustain life.