00001 /* ---------------------------------------------------------------------------- 00002 * SAM Software Package License 00003 * ---------------------------------------------------------------------------- 00004 * Copyright (c) 2014, Atmel Corporation 00005 * 00006 * All rights reserved. 00007 * 00008 * Redistribution and use in source and binary forms, with or without 00009 * modification, are permitted provided that the following conditions are met: 00010 * 00011 * - Redistributions of source code must retain the above copyright notice, 00012 * this list of conditions and the disclaimer below. 00013 * 00014 * Atmel's name may not be used to endorse or promote products derived from 00015 * this software without specific prior written permission. 00016 * 00017 * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR 00018 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 00019 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE 00020 * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, 00021 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 00022 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 00023 * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 00024 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 00025 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 00026 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00027 * ---------------------------------------------------------------------------- 00028 */ 00029 00030 /** 00031 * \file 00032 * 00033 * \section Purpose 00034 * 00035 * Definitions and methods for USB composite device implement. 00036 * 00037 */ 00038 00039 #ifndef DUALCDCDDRIVER_H 00040 #define DUALCDCDDRIVER_H 00041 /** \addtogroup usbd_composite_cdccdc 00042 *@{ 00043 */ 00044 00045 /*--------------------------------------------------------------------------- 00046 * Headers 00047 *---------------------------------------------------------------------------*/ 00048 00049 #include <USBRequests.h> 00050 #include <CDCDescriptors.h> 00051 00052 #include "USBD.h" 00053 #include <CDCDSerialPort.h> 00054 00055 00056 /*--------------------------------------------------------------------------- 00057 * Defines 00058 *---------------------------------------------------------------------------*/ 00059 00060 /** \addtogroup usbd_composite_cdccdc_desc 00061 * The driver uses these interface numbers in configuration descriptor. 00062 * @{ 00063 */ 00064 /** Number of interfaces of the device */ 00065 #define DUALCDCDDriverDescriptors_NUMINTERFACE 4 00066 /** Number of the CDC0 interface. */ 00067 #define DUALCDCDDriverDescriptors_INTERFACENUM0 0 00068 /** Number of the CDC1 interface. */ 00069 #define DUALCDCDDriverDescriptors_INTERFACENUM1 2 00070 /** @}*/ 00071 00072 /*--------------------------------------------------------------------------- 00073 * Types 00074 *---------------------------------------------------------------------------*/ 00075 #pragma pack(1) 00076 #if defined ( __CC_ARM ) /* Keil ¦̀Vision 4 */ 00077 #elif defined ( __ICCARM__ ) /* IAR Ewarm */ 00078 #define __attribute__(...) 00079 #define __packed__ packed 00080 #elif defined ( __GNUC__ ) /* GCC CS3 */ 00081 #define __packed__ aligned(1) 00082 #endif 00083 /** 00084 * \typedef DualCdcDriverConfigurationDescriptors 00085 * \brief Configuration descriptor list for a device implementing a 00086 * dual CDC serial composite driver. 00087 */ 00088 typedef struct _DualCdcDriverConfigurationDescriptors { 00089 00090 /** Standard configuration descriptor. */ 00091 USBConfigurationDescriptor configuration; 00092 00093 /* --- CDC 0 */ 00094 /** IAD 0 */ 00095 USBInterfaceAssociationDescriptor cdcIAD0; 00096 /** Communication interface descriptor */ 00097 USBInterfaceDescriptor cdcCommunication0; 00098 /** CDC header functional descriptor. */ 00099 CDCHeaderDescriptor cdcHeader0; 00100 /** CDC call management functional descriptor. */ 00101 CDCCallManagementDescriptor cdcCallManagement0; 00102 /** CDC abstract control management functional descriptor. */ 00103 CDCAbstractControlManagementDescriptor cdcAbstractControlManagement0; 00104 /** CDC union functional descriptor (with one slave interface). */ 00105 CDCUnionDescriptor cdcUnion0; 00106 /** Notification endpoint descriptor. */ 00107 USBEndpointDescriptor cdcNotification0; 00108 /** Data interface descriptor. */ 00109 USBInterfaceDescriptor cdcData0; 00110 /** Data OUT endpoint descriptor. */ 00111 USBEndpointDescriptor cdcDataOut0; 00112 /** Data IN endpoint descriptor. */ 00113 USBEndpointDescriptor cdcDataIn0; 00114 00115 /* --- CDC 1 */ 00116 /** IAD 1 */ 00117 USBInterfaceAssociationDescriptor cdcIAD1; 00118 /** Communication interface descriptor */ 00119 USBInterfaceDescriptor cdcCommunication1; 00120 /** CDC header functional descriptor. */ 00121 CDCHeaderDescriptor cdcHeader1; 00122 /** CDC call management functional descriptor. */ 00123 CDCCallManagementDescriptor cdcCallManagement1; 00124 /** CDC abstract control management functional descriptor. */ 00125 CDCAbstractControlManagementDescriptor cdcAbstractControlManagement1; 00126 /** CDC union functional descriptor (with one slave interface). */ 00127 CDCUnionDescriptor cdcUnion1; 00128 /** Notification endpoint descriptor. */ 00129 USBEndpointDescriptor cdcNotification1; 00130 /** Data interface descriptor. */ 00131 USBInterfaceDescriptor cdcData1; 00132 /** Data OUT endpoint descriptor. */ 00133 USBEndpointDescriptor cdcDataOut1; 00134 /** Data IN endpoint descriptor. */ 00135 USBEndpointDescriptor cdcDataIn1; 00136 00137 } __attribute__ ((__packed__)) DualCdcDriverConfigurationDescriptors; 00138 00139 #pragma pack() 00140 00141 /*--------------------------------------------------------------------------- 00142 * Exported functions 00143 *---------------------------------------------------------------------------*/ 00144 00145 /* -DUALCDC */ 00146 extern void DUALCDCDDriver_Initialize( 00147 const USBDDriverDescriptors* pDescriptors); 00148 00149 extern void DUALCDCDDriver_ConfigurationChangeHandler(uint8_t cfgnum); 00150 00151 extern void DUALCDCDDriver_RequestHandler(const USBGenericRequest *request); 00152 00153 extern CDCDSerialPort* DUALCDCDDriver_GetSerialPort(uint32_t port); 00154 00155 /**@}*/ 00156 #endif /* #ifndef DUALCDCDDRIVER_H */ 00157