Microchip® Advanced Software Framework

common/services/usb/class/composite/device/example2/conf_usb.h File Reference

USB configuration file.

Copyright (c) 2009-2018 Microchip Technology Inc. and its subsidiaries.

#include "compiler.h"
#include "udi_cdc.h"
#include "udi_msc.h"
#include "udi_hid_mouse.h"
#include "udi_hid_kbd.h"
#include "uart.h"
#include "main.h"
#include "ui.h"

Macros

#define USB_DEVICE_VENDOR_ID   USB_VID_ATMEL
 USB Device Configuration. More...
 
#define USB_DEVICE_PRODUCT_ID   USB_PID_ATMEL_ASF_MSC_HIDS_CDC
 
#define USB_DEVICE_MAJOR_VERSION   1
 
#define USB_DEVICE_MINOR_VERSION   0
 
#define USB_DEVICE_POWER   100
 
#define USB_DEVICE_ATTR   (USB_CONFIG_ATTR_REMOTE_WAKEUP|USB_CONFIG_ATTR_SELF_POWERED)
 
#define USB_DEVICE_MANUFACTURE_NAME   "ATMEL ASF"
 USB Device string definitions (Optional) More...
 
#define USB_DEVICE_PRODUCT_NAME   "HID Mouse, keyboard, CDC and MSC"
 
#define USB_DEVICE_SERIAL_NAME   "123123123123"
 
#define UDC_VBUS_EVENT(b_vbus_high)
 Device speeds support. More...
 
#define UDC_SOF_EVENT()   main_sof_action()
 
#define UDC_SUSPEND_EVENT()   main_suspend_action()
 
#define UDC_RESUME_EVENT()   main_resume_action()
 
#define UDC_REMOTEWAKEUP_ENABLE()   main_remotewakeup_enable()
 Mandatory when USB_DEVICE_ATTR authorizes remote wakeup feature. More...
 
#define UDC_REMOTEWAKEUP_DISABLE()   main_remotewakeup_disable()
 
#define UDC_GET_EXTRA_STRING()   main_extra_string()
 When a extra string descriptor must be supported other than manufacturer, product and serial string. More...
 
#define USB_DEVICE_EP_CTRL_SIZE   64
 USB Device low level configuration When only one interface is used, these configurations are defined by the class module. More...
 
#define USB_DEVICE_NB_INTERFACE   5
 Two interfaces for this device (CDC + MSC + HID mouse + HID keyboard) More...
 
#define USB_DEVICE_MAX_EP   7
 7 endpoints used by HID mouse, HID keyboard, CDC and MSC interfaces but an IN and OUT endpoints can be defined with the same number on XMEGA, thus 5 More...
 
#define UDI_CDC_PORT_NB   1
 USB Interface Configuration. More...
 
#define UDI_CDC_ENABLE_EXT(port)   main_cdc_enable(port)
 Interface callback definition. More...
 
#define UDI_CDC_DISABLE_EXT(port)   main_cdc_disable(port)
 
#define UDI_CDC_RX_NOTIFY(port)   uart_rx_notify(port)
 
#define UDI_CDC_TX_EMPTY_NOTIFY(port)
 
#define UDI_CDC_SET_CODING_EXT(port, cfg)   uart_config(port,cfg)
 
#define UDI_CDC_SET_DTR_EXT(port, set)   main_cdc_set_dtr(port,set)
 
#define UDI_CDC_SET_RTS_EXT(port, set)
 
#define UDI_CDC_DEFAULT_RATE   115200
 Define it when the transfer CDC Device to Host is a low rate (<512000 bauds) to reduce CDC buffers size. More...
 
#define UDI_CDC_DEFAULT_STOPBITS   CDC_STOP_BITS_1
 
#define UDI_CDC_DEFAULT_PARITY   CDC_PAR_NONE
 
#define UDI_CDC_DEFAULT_DATABITS   8
 
#define UDI_CDC_IAD_STRING_ID   4
 Enable id string of interface to add an extra USB string. More...
 
#define UDI_CDC_COMM_EP_0   (7 | USB_EP_DIR_IN)
 USB CDC low level configuration In standalone these configurations are defined by the CDC module. More...
 
#define UDI_CDC_DATA_EP_IN_0   (6 | USB_EP_DIR_IN)
 
#define UDI_CDC_DATA_EP_OUT_0   (5 | USB_EP_DIR_OUT)
 
#define UDI_CDC_COMM_IFACE_NUMBER_0   0
 Interface numbers. More...
 
#define UDI_CDC_DATA_IFACE_NUMBER_0   1
 
#define UDI_MSC_GLOBAL_VENDOR_ID   'A', 'T', 'M', 'E', 'L', ' ', ' ', ' '
 Configuration of MSC interface. More...
 
#define UDI_MSC_GLOBAL_PRODUCT_VERSION   '1', '.', '0', '0'
 
#define UDI_MSC_ENABLE_EXT()   main_msc_enable()
 Interface callback definition. More...
 
#define UDI_MSC_DISABLE_EXT()   main_msc_disable()
 
#define UDI_MSC_STRING_ID   5
 Enable id string of interface to add an extra USB string. More...
 
#define UDI_MSC_EP_IN   (1 | USB_EP_DIR_IN)
 USB MSC low level configuration In standalone these configurations are defined by the MSC module. More...
 
#define UDI_MSC_EP_OUT   (2 | USB_EP_DIR_OUT)
 
#define UDI_MSC_IFACE_NUMBER   2
 Interface number. More...
 
#define UDI_HID_MOUSE_ENABLE_EXT()   main_mouse_enable()
 Configuration of HID Mouse interface. More...
 
#define UDI_HID_MOUSE_DISABLE_EXT()   main_mouse_disable()
 
#define UDI_HID_MOUSE_STRING_ID   6
 Enable id string of interface to add an extra USB string. More...
 
#define UDI_HID_MOUSE_EP_IN   (3 | USB_EP_DIR_IN)
 USB HID Mouse low level configuration In standalone these configurations are defined by the HID Mouse module. More...
 
#define UDI_HID_MOUSE_IFACE_NUMBER   3
 Interface number. More...
 
#define UDI_HID_KBD_ENABLE_EXT()   main_keyboard_enable()
 Configuration of HID Keyboard interface. More...
 
#define UDI_HID_KBD_DISABLE_EXT()   main_keyboard_disable()
 
#define UDI_HID_KBD_CHANGE_LED(value)   ui_kbd_led(value)
 
#define UDI_HID_KBD_STRING_ID   7
 Enable id string of interface to add an extra USB string. More...
 
#define UDI_HID_KBD_EP_IN   (4 | USB_EP_DIR_IN)
 USB HID Keyboard low level configuration In standalone these configurations are defined by the HID Keyboard module. More...
 
#define UDI_HID_KBD_IFACE_NUMBER   4
 Interface number. More...
 
#define UDI_COMPOSITE_DESC_T
 Description of Composite Device. More...
 
#define UDI_COMPOSITE_DESC_FS
 USB Interfaces descriptor value for Full Speed. More...
 
#define UDI_COMPOSITE_DESC_HS
 USB Interfaces descriptor value for High Speed. More...
 
#define UDI_COMPOSITE_API
 USB Interface APIs. More...
 

#define UDC_GET_EXTRA_STRING ( )    main_extra_string()

When a extra string descriptor must be supported other than manufacturer, product and serial string.

#define UDC_REMOTEWAKEUP_DISABLE ( )    main_remotewakeup_disable()
#define UDC_REMOTEWAKEUP_ENABLE ( )    main_remotewakeup_enable()

Mandatory when USB_DEVICE_ATTR authorizes remote wakeup feature.

#define UDC_RESUME_EVENT ( )    main_resume_action()
#define UDC_SOF_EVENT ( )    main_sof_action()
#define UDC_SUSPEND_EVENT ( )    main_suspend_action()
#define UDC_VBUS_EVENT (   b_vbus_high)

Device speeds support.

To define a Low speed device To authorize the High speed USB Device Callbacks definitions (Optional)

#define UDI_CDC_COMM_EP_0   (7 | USB_EP_DIR_IN)

USB CDC low level configuration In standalone these configurations are defined by the CDC module.

For composite device, these configuration must be defined hereEndpoint numbers definition

#define UDI_CDC_COMM_IFACE_NUMBER_0   0

Interface numbers.

#define UDI_CDC_DATA_EP_IN_0   (6 | USB_EP_DIR_IN)
#define UDI_CDC_DATA_EP_OUT_0   (5 | USB_EP_DIR_OUT)
#define UDI_CDC_DATA_IFACE_NUMBER_0   1
#define UDI_CDC_DEFAULT_DATABITS   8
#define UDI_CDC_DEFAULT_PARITY   CDC_PAR_NONE
#define UDI_CDC_DEFAULT_RATE   115200

Define it when the transfer CDC Device to Host is a low rate (<512000 bauds) to reduce CDC buffers size.

Default configuration of communication port

#define UDI_CDC_DEFAULT_STOPBITS   CDC_STOP_BITS_1
#define UDI_CDC_DISABLE_EXT (   port)    main_cdc_disable(port)
#define UDI_CDC_ENABLE_EXT (   port)    main_cdc_enable(port)

Interface callback definition.

#define UDI_CDC_IAD_STRING_ID   4

Enable id string of interface to add an extra USB string.

#define UDI_CDC_PORT_NB   1

USB Interface Configuration.

Configuration of CDC interfaceDefine two USB communication ports

#define UDI_CDC_RX_NOTIFY (   port)    uart_rx_notify(port)
#define UDI_CDC_SET_CODING_EXT (   port,
  cfg 
)    uart_config(port,cfg)
#define UDI_CDC_SET_DTR_EXT (   port,
  set 
)    main_cdc_set_dtr(port,set)
#define UDI_CDC_SET_RTS_EXT (   port,
  set 
)
#define UDI_CDC_TX_EMPTY_NOTIFY (   port)
#define UDI_COMPOSITE_API
Value:
UDC_DESC_STORAGE udi_api_t udi_api_cdc_comm
Global structure which contains standard UDI API for UDC.
Definition: udi_cdc.c:83
UDC_DESC_STORAGE udi_api_t udi_api_msc
Global structure which contains standard UDI API for UDC.
Definition: udi_msc.c:66
UDC_DESC_STORAGE udi_api_t udi_api_cdc_data
Definition: udi_cdc.c:89
UDC_DESC_STORAGE udi_api_t udi_api_hid_kbd
Global structure which contains standard UDI interface for UDC.
Definition: udi_hid_kbd.c:60
UDC_DESC_STORAGE udi_api_t udi_api_hid_mouse
Global structure which contains standard UDI interface for UDC.
Definition: udi_hid_mouse.c:59

USB Interface APIs.

#define UDI_COMPOSITE_DESC_FS
Value:
.udi_cdc_iad = UDI_CDC_IAD_DESC_0, \
.udi_cdc_comm = UDI_CDC_COMM_DESC_0, \
.udi_cdc_data = UDI_CDC_DATA_DESC_0_FS, \
.udi_msc = UDI_MSC_DESC_FS, \
.udi_hid_mouse = UDI_HID_MOUSE_DESC, \
.udi_hid_kbd = UDI_HID_KBD_DESC
#define UDI_MSC_DESC_FS
Content of MSC interface descriptor for full speed only.
Definition: udi_msc.h:108
#define UDI_HID_MOUSE_DESC
Content of HID mouse interface descriptor for all speed.
Definition: udi_hid_mouse.h:89
#define UDI_CDC_COMM_DESC_0
Definition: udi_cdc.h:138
#define UDI_CDC_DATA_DESC_0_FS
Definition: udi_cdc.h:139
#define UDI_CDC_IAD_DESC_0
Definition: udi_cdc.h:137
#define UDI_HID_KBD_DESC
Content of HID keyboard interface descriptor for all speed.
Definition: udi_hid_kbd.h:89

USB Interfaces descriptor value for Full Speed.

#define UDI_COMPOSITE_DESC_HS
Value:
.udi_cdc_iad = UDI_CDC_IAD_DESC_0, \
.udi_cdc_comm = UDI_CDC_COMM_DESC_0, \
.udi_cdc_data = UDI_CDC_DATA_DESC_0_HS, \
.udi_msc = UDI_MSC_DESC_HS, \
.udi_hid_mouse = UDI_HID_MOUSE_DESC, \
.udi_hid_kbd = UDI_HID_KBD_DESC
#define UDI_HID_MOUSE_DESC
Content of HID mouse interface descriptor for all speed.
Definition: udi_hid_mouse.h:89
#define UDI_CDC_COMM_DESC_0
Definition: udi_cdc.h:138
#define UDI_CDC_IAD_DESC_0
Definition: udi_cdc.h:137
#define UDI_HID_KBD_DESC
Content of HID keyboard interface descriptor for all speed.
Definition: udi_hid_kbd.h:89
#define UDI_CDC_DATA_DESC_0_HS
Definition: udi_cdc.h:140
#define UDI_MSC_DESC_HS
Content of MSC interface descriptor for high speed only.
Definition: udi_msc.h:115

USB Interfaces descriptor value for High Speed.

#define UDI_COMPOSITE_DESC_T
Value:
usb_iad_desc_t udi_cdc_iad; \
udi_cdc_comm_desc_t udi_cdc_comm; \
udi_cdc_data_desc_t udi_cdc_data; \
udi_msc_desc_t udi_msc; \
udi_hid_mouse_desc_t udi_hid_mouse; \
udi_hid_kbd_desc_t udi_hid_kbd
Standard USB association descriptor structure.
Definition: usb_protocol.h:432

Description of Composite Device.

USB Interfaces descriptor structure

#define UDI_HID_KBD_CHANGE_LED (   value)    ui_kbd_led(value)
#define UDI_HID_KBD_DISABLE_EXT ( )    main_keyboard_disable()
#define UDI_HID_KBD_ENABLE_EXT ( )    main_keyboard_enable()

Configuration of HID Keyboard interface.

Interface callback definition

#define UDI_HID_KBD_EP_IN   (4 | USB_EP_DIR_IN)

USB HID Keyboard low level configuration In standalone these configurations are defined by the HID Keyboard module.

For composite device, these configuration must be defined hereEndpoint numbers definition

#define UDI_HID_KBD_IFACE_NUMBER   4

Interface number.

#define UDI_HID_KBD_STRING_ID   7

Enable id string of interface to add an extra USB string.

#define UDI_HID_MOUSE_DISABLE_EXT ( )    main_mouse_disable()
#define UDI_HID_MOUSE_ENABLE_EXT ( )    main_mouse_enable()

Configuration of HID Mouse interface.

Interface callback definition

#define UDI_HID_MOUSE_EP_IN   (3 | USB_EP_DIR_IN)

USB HID Mouse low level configuration In standalone these configurations are defined by the HID Mouse module.

For composite device, these configuration must be defined hereEndpoint numbers definition

#define UDI_HID_MOUSE_IFACE_NUMBER   3

Interface number.

#define UDI_HID_MOUSE_STRING_ID   6

Enable id string of interface to add an extra USB string.

#define UDI_MSC_DISABLE_EXT ( )    main_msc_disable()
#define UDI_MSC_ENABLE_EXT ( )    main_msc_enable()

Interface callback definition.

#define UDI_MSC_EP_IN   (1 | USB_EP_DIR_IN)

USB MSC low level configuration In standalone these configurations are defined by the MSC module.

For composite device, these configuration must be defined hereEndpoint numbers definition

#define UDI_MSC_EP_OUT   (2 | USB_EP_DIR_OUT)
#define UDI_MSC_GLOBAL_PRODUCT_VERSION   '1', '.', '0', '0'
#define UDI_MSC_GLOBAL_VENDOR_ID   'A', 'T', 'M', 'E', 'L', ' ', ' ', ' '

Configuration of MSC interface.

Vendor name and Product version of MSC interface

#define UDI_MSC_IFACE_NUMBER   2

Interface number.

#define UDI_MSC_STRING_ID   5

Enable id string of interface to add an extra USB string.

#define USB_DEVICE_EP_CTRL_SIZE   64

USB Device low level configuration When only one interface is used, these configurations are defined by the class module.

For composite device, these configuration must be defined hereControl endpoint size

#define USB_DEVICE_MAJOR_VERSION   1
#define USB_DEVICE_MANUFACTURE_NAME   "ATMEL ASF"

USB Device string definitions (Optional)

#define USB_DEVICE_MAX_EP   7

7 endpoints used by HID mouse, HID keyboard, CDC and MSC interfaces but an IN and OUT endpoints can be defined with the same number on XMEGA, thus 5

#define USB_DEVICE_MINOR_VERSION   0
#define USB_DEVICE_NB_INTERFACE   5

Two interfaces for this device (CDC + MSC + HID mouse + HID keyboard)

#define USB_DEVICE_POWER   100
#define USB_DEVICE_PRODUCT_ID   USB_PID_ATMEL_ASF_MSC_HIDS_CDC
#define USB_DEVICE_PRODUCT_NAME   "HID Mouse, keyboard, CDC and MSC"
#define USB_DEVICE_SERIAL_NAME   "123123123123"
#define USB_DEVICE_VENDOR_ID   USB_VID_ATMEL

USB Device Configuration.

Device definition (mandatory)