# ATmega32U4 Mouse demonstration

## License

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

Please read file lic_page for copyright notice.

## Description

This embedded application source code illustrates how to implement a HID mouse application over the ATmega32U4 controller.
The STK600 configuration provide the following user interface (read STK600 configuration ):

- Switch 6 associated to left bouton from a mouse
- Switch 5 associated to middle bouton from a mouse
- Switch 4 associated to right bouton from a mouse
- Switch 3 associated to left move from a mouse
- Switch 2 associated to right move from a mouse
- Switch 1 associated to up move from a mouse
- Switch 0 associated to down move from a mouse
- Led 7 signal demo running and no in usb suspend mode
- Led 6 signal a mouse event sending to USB host

## About the sample application

The sample code is delivered for STK600.

## About the source code

This source code is usable with the following compilers:

- IAR Embedded Workbench (5.11A and higher)
- AVRGCC (WinAVR 20080411 and higher).

Support for other compilers may required modifications or attention for:

- compiler.h file
- special registers declaration file
- interrupt subroutines declarations

## Architecture

As illustrated in the figure bellow, the application entry point is located is the main.c file. The main function first performs the initialization of a scheduler module and then runs it in an infinite loop. The scheduler is a simple infinite loop calling all its tasks defined in the conf_scheduler.h file. No real time schedule is performed, when a task ends, the scheduler calls the next task defined in the configuration file (conf_scheduler.h).

The sample dual role application is based on two different tasks:

- The usb_task (usb_task.c associated source file), is the task performing the USB low level enumeration process in device mode.
- The mouse task performs mouse events decoding and report construction to the USB host.