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 CDCMSD device implement. 00036 * 00037 * \section Usage 00038 * 00039 * -# Initialize USB function specified driver ( for MSD currently ) 00040 * - MSDDFunctionDriver_Initialize 00041 * 00042 * -# Initialize USB CDCMSD driver and USB driver 00043 * - CDCMSDDDriver_Initialize 00044 * 00045 * -# Handle and dispatch USB requests 00046 * - CDCMSDDDriver_RequestHandler 00047 * 00048 * -# Try starting a remote wake-up sequence 00049 * - CDCMSDDDriver_RemoteWakeUp 00050 */ 00051 00052 #ifndef CDCMSDDDRIVER_H 00053 #define CDCMSDDDRIVER_H 00054 /** \addtogroup usbd_composite_cdcmsd 00055 *@{ 00056 */ 00057 00058 /*--------------------------------------------------------------------------- 00059 * Headers 00060 *---------------------------------------------------------------------------*/ 00061 00062 #include <USBRequests.h> 00063 #include <CDCDescriptors.h> 00064 #include <MSDescriptors.h> 00065 #include <MSDLun.h> 00066 #include "USBD.h" 00067 #include <USBDDriver.h> 00068 00069 /*--------------------------------------------------------------------------- 00070 * Constants 00071 *---------------------------------------------------------------------------*/ 00072 00073 /** \addtogroup usbd_cdc_msd_desc USB CDC(Serial) + MS Descriptors define 00074 * @{ 00075 */ 00076 /** Number of interfaces of the device */ 00077 #define CDCMSDDriverDescriptors_NUMINTERFACE 3 00078 /** Number of the CDC interface. */ 00079 #define CDCMSDDriverDescriptors_CDC_INTERFACE 0 00080 /** Number of the HID interface. */ 00081 #define CDCMSDDriverDescriptors_MSD_INTERFACE 2 00082 /** @}*/ 00083 00084 00085 /*--------------------------------------------------------------------------- 00086 * Types 00087 *---------------------------------------------------------------------------*/ 00088 #pragma pack(1) 00089 #if defined ( __CC_ARM ) /* Keil ¦̀Vision */ 00090 #elif defined ( __ICCARM__ ) /* IAR Ewarm */ 00091 #define __attribute__(...) 00092 #define __packed__ packed 00093 #elif defined ( __GNUC__ ) /* GCC CS3 */ 00094 #define __packed__ aligned(1) 00095 #endif 00096 /** 00097 * \typedef CDCMSDDriverConfigurationDescriptors 00098 * \brief Configuration descriptor list for a device implementing 00099 * a CDCMSD driver. 00100 */ 00101 typedef struct _CDCMSDDriverConfigurationDescriptors { 00102 00103 /** Standard configuration descriptor. */ 00104 USBConfigurationDescriptor configuration; 00105 00106 /* --- CDC 0 */ 00107 /** IAD 0 */ 00108 USBInterfaceAssociationDescriptor cdcIAD0; 00109 /** Communication interface descriptor */ 00110 USBInterfaceDescriptor cdcCommunication0; 00111 /** CDC header functional descriptor. */ 00112 CDCHeaderDescriptor cdcHeader0; 00113 /** CDC call management functional descriptor. */ 00114 CDCCallManagementDescriptor cdcCallManagement0; 00115 /** CDC abstract control management functional descriptor. */ 00116 CDCAbstractControlManagementDescriptor cdcAbstractControlManagement0; 00117 /** CDC union functional descriptor (with one slave interface). */ 00118 CDCUnionDescriptor cdcUnion0; 00119 /** Notification endpoint descriptor. */ 00120 USBEndpointDescriptor cdcNotification0; 00121 /** Data interface descriptor. */ 00122 USBInterfaceDescriptor cdcData0; 00123 /** Data OUT endpoint descriptor. */ 00124 USBEndpointDescriptor cdcDataOut0; 00125 /** Data IN endpoint descriptor. */ 00126 USBEndpointDescriptor cdcDataIn0; 00127 00128 /* --- MSD */ 00129 /** Mass storage interface descriptor. */ 00130 USBInterfaceDescriptor msdInterface; 00131 /** Bulk-out endpoint descriptor. */ 00132 USBEndpointDescriptor msdBulkOut; 00133 /** Bulk-in endpoint descriptor. */ 00134 USBEndpointDescriptor msdBulkIn; 00135 00136 } __attribute__ ((__packed__)) CDCMSDDriverConfigurationDescriptors; 00137 00138 #pragma pack() 00139 00140 /*--------------------------------------------------------------------------- 00141 * Exported functions 00142 *---------------------------------------------------------------------------*/ 00143 00144 /* -CDCMSD */ 00145 extern void CDCMSDDriver_Initialize( 00146 const USBDDriverDescriptors *pDescriptors, 00147 MSDLun *pLuns, unsigned char numLuns); 00148 00149 extern void CDCMSDDriver_ConfigurationChangedHandler(unsigned char cfgnum); 00150 00151 extern void CDCMSDDriver_RequestHandler(const USBGenericRequest *request); 00152 00153 /**@}*/ 00154 #endif /* #ifndef CDCMSDDDRIVER_H */ 00155