Microchip® Advanced Software Framework

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
ASF USB Composite Device Example HIDs, CDC and MSC

Human interface on SAME70-Xplained:

Introduction

This example shows how to implement a USB Composite Device with HID mouse, keyboard, CDC and Mass Storage interfaces on Atmel MCU with USB module.

Description of the Communication Device Class (CDC)

The Communication Device Class (CDC) is a general-purpose way to enable all types of communications on the Universal Serial Bus (USB). This class makes it possible to connect communication devices such as digital telephones or analog modems, as well as networking devices like ADSL or Cable modems. While a CDC device enables the implementation of quite complex devices, it can also be used as a very simple method for communication on the USB. For example, a CDC device can appear as a virtual COM port, which greatly simplifies application development on the host side.

Startup

The example uses all memories available on the board and connects these to USB Device Mass Storage stack. Also, the example is a bridge between a USART from the main MCU and the USB CDC interface. And, the example uses the buttons or sensors available on the board to simulate a standard mouse, keyboard. After loading firmware, connect the board (EVKxx,Xplain,...) to the USB Host. When connected to a USB host system this application allows to display all available memories as a removable disks and provides a mouse in the Unix/Mac/Windows operating systems.

For USB to UART bridge:

  • Connect the USART peripheral to the USART interface of the board.
  • 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 virtual COM (see Windows Device Manager).
  • Open a HyperTerminal on both COM ports (RS232 and Virtual COM)
  • Select the same configuration for both COM ports up to 115200 baud.
  • Type a character in one HyperTerminal and it will echo in the other.
Note
This example uses the native MSC and HID drivers on Unix/Mac/Windows OS, except for Win98. About CDC, on the first connection of the board on the PC, the operating system will detect a new peripheral:
  • This will open a new hardware installation window.
  • Choose "No, not this time" to connect to Windows Update for this installation
  • click "Next"
  • When requested by Windows for a driver INF file, select the atmel_devices_cdc.inf file in the directory indicated in the Atmel Studio "Solution Explorer" window.
  • click "Next"
  • Led 0 blinks when USB host has checked and enabled All interfaces
  • Push button 1 (SW0) is linked to mouse button left
  • Only push button 1 (SW0) down opens a notepad application on Windows O.S. and sends key sequence "Atmel ARM"
  • Only a low level on push button 1 (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 stack and HID, CDC and MSC modules:
    services/usb/
    services/usb/udc/
    services/usb/class/msc/
    services/usb/class/cdc/
    services/usb/class/hid/
    services/usb/class/hid/mouse/
    services/usb/class/hid/keyboard/
  • Specific implementation:
    • main.c,
      initializes clock
      initializes interrupt
      manages UI
    • udi_composite_desc.c,udi_composite_conf.h,
      USB Composite Device definition
    • uart_xmega.c,
      implementation of RS232 bridge for XMEGA parts
    • uart_uc3.c,
      implementation of RS232 bridge for UC3 parts
    • uart_sam.c,
      implementation of RS232 bridge for SAM parts
    • specific implementation for each target "./examples/product_board/":
      • conf_foo.h configuration of each module
      • ui.c implement of user's interface (buttons, leds)

1 The memory data transfers are done outside USB interrupt routine. This is done in the MSC process ("udi_msc_process_trans()") called by main loop.