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 /** \file 00031 * 00032 * \section Purpose 00033 * 00034 * Definitions and methods for USB HID + MSD device implement. 00035 * 00036 * \section Usage 00037 * 00038 * -# Initialize USB function specified driver ( for MSD currently ) 00039 * - MSDDFunctionDriver_Initialize() 00040 * 00041 * -# Initialize USB HIDMSD driver and USB driver 00042 * - HIDMSDDDriver_Initialize() 00043 * 00044 * -# Handle and dispatch USB requests 00045 * - HIDMSDDDriver_RequestHandler() 00046 * 00047 * -# Try starting a remote wake-up sequence 00048 * - HIDMSDDDriver_RemoteWakeUp() 00049 */ 00050 00051 #ifndef HIDMSDDDRIVER_H 00052 #define HIDMSDDDRIVER_H 00053 00054 /** \addtogroup usbd_composite_hidmsd 00055 *@{ 00056 */ 00057 00058 /*--------------------------------------------------------------------------- 00059 * Headers 00060 *---------------------------------------------------------------------------*/ 00061 00062 #include <USBRequests.h> 00063 #include <HIDDescriptors.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_hid_msd_desc USB HID(Kbd) + MSD Descriptors define 00074 * @{ 00075 */ 00076 /** Number of interfaces of the device */ 00077 #define HIDMSDDriverDescriptors_NUMINTERFACE 2 00078 /** Number of the HID (Keyboard) interface. */ 00079 #define HIDMSDDriverDescriptors_HID_INTERFACE 0 00080 /** Number of the MSD interface. */ 00081 #define HIDMSDDriverDescriptors_MSD_INTERFACE 1 00082 /** @}*/ 00083 00084 /*--------------------------------------------------------------------------- 00085 * Types 00086 *---------------------------------------------------------------------------*/ 00087 #pragma pack(1) 00088 #if defined ( __CC_ARM ) /* Keil ¦̀Vision 4 */ 00089 #elif defined ( __ICCARM__ ) /* IAR Ewarm */ 00090 #define __attribute__(...) 00091 #define __packed__ packed 00092 #elif defined ( __GNUC__ ) /* GCC CS3 */ 00093 #define __packed__ aligned(1) 00094 #endif 00095 /** 00096 * \typedef HidMsdDriverConfigurationDescriptors 00097 * \brief Configuration descriptor list for a device implementing a 00098 * HID MSD composite driver. 00099 */ 00100 typedef struct _HidMsdDriverConfigurationDescriptors { 00101 00102 /** Standard configuration descriptor. */ 00103 USBConfigurationDescriptor configuration; 00104 00105 /* --- HID */ 00106 USBInterfaceDescriptor hidInterface; 00107 HIDDescriptor1 hid; 00108 USBEndpointDescriptor hidInterruptIn; 00109 USBEndpointDescriptor hidInterruptOut; 00110 00111 /* --- MSD */ 00112 /** Mass storage interface descriptor. */ 00113 USBInterfaceDescriptor msdInterface; 00114 /** Bulk-out endpoint descriptor. */ 00115 USBEndpointDescriptor msdBulkOut; 00116 /** Bulk-in endpoint descriptor. */ 00117 USBEndpointDescriptor msdBulkIn; 00118 00119 } __attribute__ ((__packed__)) HidMsdDriverConfigurationDescriptors; 00120 00121 #pragma pack() 00122 00123 /*--------------------------------------------------------------------------- 00124 * Exported functions 00125 *---------------------------------------------------------------------------*/ 00126 00127 /* -HIDMSD Composite device */ 00128 extern void HIDMSDDriver_Initialize( 00129 const USBDDriverDescriptors *pDescriptors, 00130 MSDLun *pLuns, uint8_t numLuns); 00131 00132 extern void HIDMSDDriver_ConfigurationChangedHandler(uint8_t cfgnum); 00133 00134 extern void HIDMSDDriver_RequestHandler(const USBGenericRequest *request); 00135 00136 extern void HIDMSDDriver_RemoteWakeUp(void); 00137 00138 /**@}*/ 00139 #endif //#ifndef HIDMSDDDRIVER_H 00140