blob: 97599a6337f565b7955782b41ab6384f08c830f5 [file] [log] [blame]
/**
* \file
*
* \brief USB configuration file
*
* Copyright (C) 2009 Atmel Corporation. All rights reserved.
*
* \page License
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. The name of Atmel may not be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* 4. This software may only be redistributed and used in connection with an
* Atmel AVR product.
*
* THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
* EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
* DAMAGE.
*/
#ifndef _CONF_USB_H_
#define _CONF_USB_H_
#include "compiler.h"
/**
* USB Device Configuration
* @{
*/
//! Device definition (mandatory)
#define USB_DEVICE_VENDOR_ID USB_VID_ATMEL
#define USB_DEVICE_PRODUCT_ID USB_PID_ATMEL_AVR_MSC_HIDS_CDC
#define USB_DEVICE_MAJOR_VERSION 1
#define USB_DEVICE_MINOR_VERSION 0
#define USB_DEVICE_POWER 100 // Consumption on Vbus line (mA)
#define USB_DEVICE_ATTR \
(USB_CONFIG_ATTR_REMOTE_WAKEUP|USB_CONFIG_ATTR_SELF_POWERED)
// (USB_CONFIG_ATTR_REMOTE_WAKEUP|USB_CONFIG_ATTR_BUS_POWERED)
// (USB_CONFIG_ATTR_SELF_POWERED)
// (USB_CONFIG_ATTR_BUS_POWERED)
//! USB Device string definitions (Optional)
#define USB_DEVICE_MANUFACTURE_NAME "ATMEL AVR"
#define USB_DEVICE_PRODUCT_NAME "HID Mouse, keyboard, CDC and MSC"
#define USB_DEVICE_SERIAL_NAME "123123123123" // Disk SN for MSC
/**
* Device speeds support
* @{
*/
//! To define a Low speed device
//#define USB_DEVICE_LOW_SPEED
//! To authorize the High speed
#if (UC3A3||UC3A4)
#define USB_DEVICE_HS_SUPPORT
#endif
//@}
/**
* USB Device Callbacks definitions (Optional)
* @{
*/
#define UDC_VBUS_EVENT(b_vbus_high) main_vbus_action(b_vbus_high)
#define UDC_SOF_EVENT() main_sof_action()
#define UDC_SUSPEND_EVENT() main_suspend_action()
#define UDC_RESUME_EVENT() main_resume_action()
//! Mandatory when USB_DEVICE_ATTR authorizes remote wakeup feature
#define UDC_REMOTEWAKEUP_ENABLE() main_remotewakeup_enable()
#define UDC_REMOTEWAKEUP_DISABLE() main_remotewakeup_disable()
//! When a extra string descriptor must be supported
//! other than manufacturer, product and serial string
#define UDC_GET_EXTRA_STRING() main_extra_string()
//@}
/**
* 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 here
* @{
*/
//! Control endpoint size
#define USB_DEVICE_EP_CTRL_SIZE 64
//! Two interfaces for this device (CDC + MSC + HID mouse + HID keyboard)
#define USB_DEVICE_NB_INTERFACE 5
//! 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
// (1 | USB_EP_DIR_IN) // CDC Notify endpoint
// (2 | USB_EP_DIR_IN) // CDC TX
// (2 | USB_EP_DIR_OUT) // CDC RX
// (3 | USB_EP_DIR_IN) // MSC IN
// (3 | USB_EP_DIR_OUT) // MSC OUT
// (4 | USB_EP_DIR_IN) // HID mouse report
// (5 | USB_EP_DIR_IN) // HID keyboard report
#define USB_DEVICE_MAX_EP 5
//@}
//@}
/**
* USB Interface Configuration
* @{
*/
/**
* Configuration of CDC interface
* @{
*/
//! Interface callback definition
#define UDI_CDC_ENABLE_EXT() main_cdc_enable()
#define UDI_CDC_DISABLE_EXT() main_cdc_disable()
#define UDI_CDC_SET_CODING_EXT(cfg) main_cdc_config_uart(cfg)
#define UDI_CDC_SET_DTR_EXT(set) main_cdc_set_dtr(set)
#define UDI_CDC_SET_RTS_EXT(set)
//! Default configuration of communication port
#define UDI_CDC_DEFAULT_RATE 115200
#define UDI_CDC_DEFAULT_STOPBITS CDC_STOP_BITS_1
#define UDI_CDC_DEFAULT_PARITY CDC_PAR_NONE
#define UDI_CDC_DEFAULT_DATABITS 8
//! Enable id string of interface to add an extra USB string
#define UDI_CDC_IAD_STRING_ID 4
/**
* USB CDC low level configuration
* In standalone these configurations are defined by the CDC module.
* For composite device, these configuration must be defined here
* @{
*/
//! Endpoint numbers definition
#define UDI_CDC_COMM_EP (1 | USB_EP_DIR_IN) // Notify endpoint
#define UDI_CDC_DATA_EP_IN (2 | USB_EP_DIR_IN) // TX
#define UDI_CDC_DATA_EP_OUT (2 | USB_EP_DIR_OUT) // RX
//! Interface numbers
#define UDI_CDC_COMM_IFACE_NUMBER 0
#define UDI_CDC_DATA_IFACE_NUMBER 1
//@}
//@}
/**
* Configuration of MSC interface
* @{
*/
//! Vendor name and Product version of MSC interface
#define UDI_MSC_GLOBAL_VENDOR_ID \
'A', 'T', 'M', 'E', 'L', ' ', ' ', ' '
#define UDI_MSC_GLOBAL_PRODUCT_VERSION \
'1', '.', '0', '0'
//! Interface callback definition
#define UDI_MSC_ENABLE_EXT() main_msc_enable()
#define UDI_MSC_DISABLE_EXT() main_msc_disable()
//! Enable id string of interface to add an extra USB string
#define UDI_MSC_STRING_ID 5
/**
* USB MSC low level configuration
* In standalone these configurations are defined by the MSC module.
* For composite device, these configuration must be defined here
* @{
*/
//! Endpoint numbers definition
#define UDI_MSC_EP_IN (3 | USB_EP_DIR_IN)
#define UDI_MSC_EP_OUT (3 | USB_EP_DIR_OUT)
//! Interface number
#define UDI_MSC_IFACE_NUMBER 2
//@}
//@}
/**
* Configuration of HID Mouse interface
* @{
*/
//! Interface callback definition
#define UDI_HID_MOUSE_ENABLE_EXT() main_mouse_enable()
#define UDI_HID_MOUSE_DISABLE_EXT() main_mouse_disable()
//! Enable id string of interface to add an extra USB string
#define UDI_HID_MOUSE_STRING_ID 6
/**
* 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 here
* @{
*/
//! Endpoint numbers definition
#define UDI_HID_MOUSE_EP_IN (4 | USB_EP_DIR_IN)
//! Interface number
#define UDI_HID_MOUSE_IFACE_NUMBER 3
//@}
//@}
/**
* Configuration of HID Keyboard interface
* @{
*/
//! Interface callback definition
#define UDI_HID_KBD_ENABLE_EXT() main_kbd_enable()
#define UDI_HID_KBD_DISABLE_EXT() main_kbd_disable()
#define UDI_HID_KBD_CHANGE_LED(value) ui_kbd_led(value)
//! Enable id string of interface to add an extra USB string
#define UDI_HID_KBD_STRING_ID 7
/**
* 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 here
* @{
*/
//! Endpoint numbers definition
#define UDI_HID_KBD_EP_IN (5 | USB_EP_DIR_IN)
//! Interface number
#define UDI_HID_KBD_IFACE_NUMBER 4
//@}
//@}
//@}
/**
* Description of Composite Device
* @{
*/
//! USB Interfaces descriptor structure
#define UDI_COMPOSITE_DESC_T \
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
//! USB Interfaces descriptor value for Full Speed
#define UDI_COMPOSITE_DESC_FS \
.udi_cdc_iad = UDI_CDC_IAD_DESC, \
.udi_cdc_comm = UDI_CDC_COMM_DESC, \
.udi_cdc_data = UDI_CDC_DATA_DESC, \
.udi_msc = UDI_MSC_DESC_FS, \
.udi_hid_mouse = UDI_HID_MOUSE_DESC,\
.udi_hid_kbd = UDI_HID_KBD_DESC
//! USB Interfaces descriptor value for High Speed
#define UDI_COMPOSITE_DESC_HS \
.udi_cdc_iad = UDI_CDC_IAD_DESC, \
.udi_cdc_comm = UDI_CDC_COMM_DESC, \
.udi_cdc_data = UDI_CDC_DATA_DESC, \
.udi_msc = UDI_MSC_DESC_HS, \
.udi_hid_mouse = UDI_HID_MOUSE_DESC,\
.udi_hid_kbd = UDI_HID_KBD_DESC
//! USB Interface APIs
#define UDI_COMPOSITE_API \
&udi_api_cdc_comm, \
&udi_api_cdc_data, \
&udi_api_msc, \
&udi_api_hid_mouse, \
&udi_api_hid_kbd
//@}
/**
* USB Device Driver Configuration
* @{
*/
//@}
//! The includes of classes and other headers must be done at the end of this file to avoid compile error
#include "udi_cdc.h"
#include "udi_msc.h"
#include "udi_hid_mouse.h"
#include "udi_hid_kbd.h"
#include "main.h"
#include "ui.h"
#endif // _CONF_USB_H_