Sonochan II 0.1

- Main Page
- Related Pages
- Modules
- Data Structures
- Files

All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
AVR32 USB software framework for HID

# License

Use of this program is subject to Atmel's End User License Agreement.

Please read the Copyright notice at the bottom of this page.

# Description

This embedded application source code illustrates how to implement a USB HID-mouse application on the AVR32 microcontroller.

As the AVR32 implements a device/host USB controller, the embedded application can operate in one of the following USB operating modes:

- USB device;
- USB reduced-host controller;
- USB dual-role device (depending on the ID pin).

To optimize embedded code/RAM size and reduce the number of source modules, the application can be configured to use one and only one of these operating modes.

# About the Sample Application

By default the sample code is delivered with a simple preconfigured dual-role USB application. It means that the code generated allows to operate as a device or a host depending on the USB ID pin:

- Attached to a mini-B plug (ID pin unconnected) the application will be used in the device operating mode. Thus, the application can be connected to a system host (e.g. a PC) to operate as a USB mouse device:

EVK1100 USB Device Mode
EVK1101 USB Device Mode

The mouse can be controlled thanks to the joystick and the buttons (shown in a red box in the above pictures).

- Attached to a mini-A plug (ID pin tied to ground) the application will operate in reduced-host mode. This mode allows to connect a USB mouse device:

EVK1100 USB Host Mode
EVK1101 USB Host Mode

In this mode, a mouse ascii pointer is output on the USART1 connector. Open a serial terminal (e.g. HyperTerminal under Windows systems or minicom under Linux systems; USART settings: 57600 bauds, 8-bit data, no parity bit, 1 stop bit, no flow control). Make sure that the serial terminal takes in charge the ANSI codes.

Debug output in terminal

# Using the USB Device Mode

Connect the application to a USB host (e.g. a PC) with a mini-B (embedded side) to A (PC host side) cable. The application will behave as a mouse peripheral. The mouse can be controlled thanks to the joystick and the buttons of the EVK110x.

# Using the USB Host Mode

Connect the application to a USB mouse device. The application will behave as a USB mouse reduced host. Leds will blink according to the mouse eactivity and a mouse ascii pointer is output on the USART1 connector.

# Architecture

As illustrated in the figure bellow, the application entry point is located is the hid_example.c file. The application can be ran using the FreeRTOS operating system, or in standalone mode. In the standalone mode, the main function runs the usb_task and device_mouse_hid_task tasks in an infinite loop.

The application is based on three different tasks:

- The usb_task (usb_task.c associated source file), is the task performing the USB low level enumeration process in device mode. Once this task has detected that the usb connection is fully operationnal, it updates different status flags that can be check within the high level application tasks.
- The device_mouse_hid_task task performs the high level device application operation. Once the device is fully enumerated (DEVICE SET_CONFIGURATION request received), the task transmit data (reports) on its IN endpoint.
- The host_mouse_hid_task task performs the high level host application operation. Once a device is connected and fully enumerated, the task receive data (reports) on its IN endpoint.

Architecture Overview

# Main Files

- device_mouse_hid_task.c : high level device mouse application operation
- device_mouse_hid_task.h : high level device mouse application operation header
- host_mouse_hid_task.c : high level host mouse application operation
- host_mouse_hid_task.h : high level host mouse application operation header
- hid_example.c : HID code example

# Copyright notice

Copyright (c) 2009 Atmel Corporation. All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
3. The name of Atmel may not be used to endorse or promote products derived from this software without specific prior written permission.
4. This software may only be redistributed and used in connection with an Atmel AVR product.

THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE