00001 /* ---------------------------------------------------------------------------- */ 00002 /* Atmel Microcontroller Software Support */ 00003 /* SAM Software Package License */ 00004 /* ---------------------------------------------------------------------------- */ 00005 /* Copyright (c) 2015, Atmel Corporation */ 00006 /* */ 00007 /* All rights reserved. */ 00008 /* */ 00009 /* Redistribution and use in source and binary forms, with or without */ 00010 /* modification, are permitted provided that the following condition is met: */ 00011 /* */ 00012 /* - Redistributions of source code must retain the above copyright notice, */ 00013 /* this list of conditions and the disclaimer below. */ 00014 /* */ 00015 /* Atmel's name may not be used to endorse or promote products derived from */ 00016 /* this software without specific prior written permission. */ 00017 /* */ 00018 /* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR */ 00019 /* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF */ 00020 /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE */ 00021 /* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, */ 00022 /* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */ 00023 /* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, */ 00024 /* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF */ 00025 /* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING */ 00026 /* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, */ 00027 /* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ 00028 /* ---------------------------------------------------------------------------- */ 00029 00030 /** 00031 *\file 00032 * 00033 *\section Purpose 00034 * 00035 *Definition of methods for using a HID transfer %device driver. 00036 * 00037 *\section Usage 00038 * 00039 *-# Re-implement the USBDCallbacks_RequestReceived callback to forward 00040 * requests to HIDDTransferDriver_RequestHandler. This is done 00041 * automatically unless the NOAUTOCALLBACK symbol is defined during 00042 * compilation. 00043 *-# Initialize the driver using HIDDTransferDriver_Initialize. The 00044 * USB driver is automatically initialized by this method. 00045 *-# Call the HIDDTransferDriver_Write method when sending data to host. 00046 *-# Call the HIDDTransferRead, HIDDTransferReadReport when checking and getting 00047 * received data from host. 00048 */ 00049 00050 #ifndef HIDDKEYBOARDDRIVER_H 00051 #define HIDDKEYBOARDDRIVER_H 00052 00053 /** \addtogroup usbd_hid_tran 00054 *@{ 00055 */ 00056 00057 /*------------------------------------------------------------------------------ 00058 * Headers 00059 *------------------------------------------------------------------------------*/ 00060 00061 #include <USBDescriptors.h> 00062 #include <HIDDescriptors.h> 00063 00064 #include <USBRequests.h> 00065 00066 #include "USBD.h" 00067 #include <USBDDriver.h> 00068 00069 /*------------------------------------------------------------------------------ 00070 * Definitions 00071 *------------------------------------------------------------------------------*/ 00072 00073 /** Size of the input and output report, in bytes */ 00074 #define HIDDTransferDriver_REPORTSIZE 32 00075 00076 /** Size of the report descriptor, in bytes */ 00077 #define HIDDTransferDriver_REPORTDESCRIPTORSIZE 32 00078 00079 /*------------------------------------------------------------------------------ 00080 * Types 00081 *------------------------------------------------------------------------------*/ 00082 #pragma pack(1) 00083 #if defined ( __CC_ARM ) /* Keil ¦̀Vision 4 */ 00084 #elif defined ( __ICCARM__ ) /* IAR Ewarm */ 00085 #define __attribute__(...) 00086 #define __packed__ packed 00087 #elif defined ( __GNUC__ ) /* GCC CS3 */ 00088 #define __packed__ aligned(1) 00089 #endif 00090 00091 /** 00092 * \typedef HIDDTransferDriverConfigurationDescriptors 00093 * \brief List of descriptors that make up the configuration descriptors of a 00094 * device using the HID Transfer driver. 00095 */ 00096 typedef struct _HIDDTransferDriverConfigurationDescriptors { 00097 00098 /** Configuration descriptor. */ 00099 USBConfigurationDescriptor configuration; 00100 /** Interface descriptor. */ 00101 USBInterfaceDescriptor interface; 00102 /** HID descriptor. */ 00103 HIDDescriptor1 hid; 00104 /** Interrupt IN endpoint descriptor. */ 00105 USBEndpointDescriptor interruptIn; 00106 /** Interrupt OUT endpoint descriptor. */ 00107 USBEndpointDescriptor interruptOut; 00108 00109 } __attribute__ ((__packed__)) HIDDTransferDriverConfigurationDescriptors; 00110 00111 #pragma pack() 00112 00113 /*------------------------------------------------------------------------------ 00114 * Exported functions 00115 *------------------------------------------------------------------------------*/ 00116 00117 extern void HIDDTransferDriver_Initialize( 00118 const USBDDriverDescriptors * pDescriptors); 00119 00120 extern void HIDDTransferDriver_ConfigurationChangedHandler(uint8_t cfgnum); 00121 00122 extern void HIDDTransferDriver_RequestHandler( 00123 const USBGenericRequest *request); 00124 00125 extern uint16_t HIDDTransferDriver_Read(void *pData, 00126 uint32_t dLength); 00127 00128 extern uint16_t HIDDTransferDriver_ReadReport(void *pData, 00129 uint32_t dLength); 00130 00131 extern uint8_t HIDDTransferDriver_Write(const void *pData, 00132 uint32_t size, 00133 TransferCallback callback, 00134 void *pArg); 00135 00136 00137 extern void HIDDTransferDriver_RemoteWakeUp(void); 00138 00139 /**@}*/ 00140 00141 #endif /*#ifndef HIDDKEYBOARDDRIVER_H*/ 00142