Microchip® Advanced Software Framework

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
ASF USB host and device HID mouse

Human interface on SAM L21 Xplained Pro:

Introduction

This example shows how to implement a USB dual mode (device and host) HID Mouse on Atmel MCU with USB module.

Startup

In device mode, the example uses the buttons or sensors available on the board to simulate a standard mouse. After loading firmware, connect the board to the USB Host. When connected to a USB host system this application provides a mouse application in the Unix/Mac/Windows operating systems. This example uses the native HID driver for these operating systems.

In host mode, after loading firmware, connect the board to a USB device mouse.

  • host mode:
    • Led 0 is on when it's host and there is no device connected
    • Led 0 blinks when a HID mouse is enumerated and USB in idle mode
      • The blink is slow (1s) with low speed device
      • The blink is normal (0.5s) with full speed device
      • The blink is fast (0.25s) with high speed device
    • Led 0 is on when a HID mouse button is pressed
    • Button SW0 allows to enter the device in suspend mode with remote wakeup feature authorized
    • Only SW0 button can be used to wakeup USB device in suspend mode
  • device mode:
    • Led 0 blinks when the device is enumerated and USB in idle mode
    • SW0 is used to move mouse around
    • Only a low level on SW0 will generate a wakeup to USB Host in remote wakeup mode.

About example

The example uses the following module groups:

  • Basic modules: Startup, board, clock, interrupt, power management
  • USB device and host stack and HID modules:
    services/usb/
    services/usb/udc/
    services/usb/uhc/
    services/usb/class/hid/
    services/usb/class/hid/device/mouse/
    services/usb/class/hid/host/mouse/
  • Specific implementation:
    • main.c,
      initializes clock
      initializes interrupt
      manages UI
    • specific implementation for each target "./examples/product_board/":
      • conf_foo.h configuration of each module
      • ui.c implement of user's interface (buttons, leds)