Version: 1.1

AT91 SAM7 Basic HID Project

The goal of this demonstration project is to use the SAM7S64_EK as a USB mouse.

Install

Connect the AT91SAM7S64_EK board using a standard USB cable to a host controller running HID class driver i.e. Windows PC, Linux PC, AT91RM9200 running WIN CE or Linux.

Once enumerated, led on the board are switched on. Clicks on buttons move the host mouse pointer. Clicking on left and bottom buttons in the same time is equivalent to a click on the left button on a standard mouse. Clicking on right and left buttons in the same time is equivalent to a click on the right button on a standard mouse.

Each time a button on the AT91SAM7S64_EK is pressed, the corresponding led is switched off.

Quick description

This device enumerates as a standard HID device. Once the device is enumerated, the host periodically sends IN token to the device. Each time the device detects a user action (button pressed), it sends a report to the host which is carried by the next IN packet.

The format of the report sent to the host is defined in the mouseDescriptor[] defined in the hid_enumerate file. It contains button state and x and y offset information.

The enumeration is controlled by the IsConfigured() function in the hid_enumerate.c file. This function is called as often as possible to detect a host disconnect. In a multithread system, this could be a dedicated thread.

The main application waits for a tick sent by the RTT and checks for button activity. If a new activity is detected, a report is sent to the host. To increase mouse sensitivity, the tick rate can be increased modifying the RTT configuration.

The application uses 3 pipes associated with physical endpoints:

· EP 0 Control endpoint

· EP 1 Bulk IN endpoint

During the initialisation,

· The peripheral clock must be enabled for the USB device and the 48MHz PLL USB clock.

· Pipe objects are then initialised and the dispatch routine is associated with the control pipe

· The pull-up on USB DP line is finally activated

DBGU Trace

-I- BasicUSB 1.1 (USB_DP_PUP)

0) Set Pull-UP 1) Clear Pull UP

(Start PC application)

…

Reference Documents

Name | Reference
ARM-Based Software Package | 6016
AT91SAM7 Data sheet |
Device Class Definition for Human Interface Devices (HID) (class driver specification available at www.usb.org) |

Contents:

Software tools

Source Files

Source Files:

| Description Files
srcxxx/SAM7Board.h | SAM7 evaluation board description
| Startup Files
srcxxx/Cstartup.xxx | AT91SAM7Sxx Microcontroller reset entry point
srcxxx/Cstartup_SAM7.c | AT91SAM7Sxx Initialization called by Assembly code in Cstartup
| C Files
../src/main.c | Main entry point
../src/dbgu.c | DBGU functions
../src/hid_enumerate.c | Includes USB low level functions

Modification

Version 1.0 Creation

Version 1.1: Addicting LED1 On at power on.