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 /**\file 00031 * 00032 * \section Purpose 00033 * 00034 * Definitions used for declaring the requests of a HID device. 00035 * 00036 * -# Receive a GET_REPORT or SET_REPORT request from the host. 00037 * -# Retrieve the report type using HIDReportRequest_GetReportType. 00038 * -# Retrieve the report ID using HIDReportRequest_GetReportId. 00039 * -# Retrieve the idle rate indicated by a GET_IDLE or SET_IDLE request 00040 * with HIDIdleRequest_GetIdleRate. 00041 */ 00042 00043 #ifndef _HIDREQUESTS_H_ 00044 #define _HIDREQUESTS_H_ 00045 /** \addtogroup usb_hid 00046 *@{ 00047 */ 00048 00049 /*---------------------------------------------------------------------------- 00050 * Includes 00051 *----------------------------------------------------------------------------*/ 00052 00053 #include <stdint.h> 00054 #include <USBRequests.h> 00055 00056 /*---------------------------------------------------------------------------- 00057 * Definitions 00058 *----------------------------------------------------------------------------*/ 00059 00060 /** \addtogroup usb_hid_request_codes HID Request Codes 00061 * @{ 00062 * 00063 * \section Codes 00064 * - HIDGenericRequest_GETREPORT 00065 * - HIDGenericRequest_GETIDLE 00066 * - HIDGenericRequest_GETPROTOCOL 00067 * - HIDGenericRequest_SETREPORT 00068 * - HIDGenericRequest_SETIDLE 00069 * - HIDGenericRequest_SETPROTOCOL 00070 */ 00071 00072 /** GetReport request code. */ 00073 #define HIDGenericRequest_GETREPORT 0x01 00074 /** GetIdle request code. */ 00075 #define HIDGenericRequest_GETIDLE 0x02 00076 /** GetProtocol request code. */ 00077 #define HIDGenericRequest_GETPROTOCOL 0x03 00078 /** SetReport request code. */ 00079 #define HIDGenericRequest_SETREPORT 0x09 00080 /** SetIdle request code. */ 00081 #define HIDGenericRequest_SETIDLE 0x0A 00082 /** SetProtocol request code. */ 00083 #define HIDGenericRequest_SETPROTOCOL 0x0B 00084 /** @}*/ 00085 00086 /** \addtogroup usb_hid_report_types HID Report Types 00087 * @{ 00088 * This page lists the types for USB HID Reports. 00089 * 00090 * \section Types 00091 * - HIDReportRequest_INPUT 00092 * - HIDReportRequest_OUTPUT 00093 * - HIDReportRequest_FEATURE 00094 */ 00095 00096 /** Input report. */ 00097 #define HIDReportRequest_INPUT 1 00098 /** Output report. */ 00099 #define HIDReportRequest_OUTPUT 2 00100 /** Feature report. */ 00101 #define HIDReportRequest_FEATURE 3 00102 /** @}*/ 00103 00104 /** \addtogroup usb_hid_protocol_types HID Protocol Types 00105 * @{ 00106 */ 00107 /** Boot Protocol */ 00108 #define HIDProtocol_BOOT 0 00109 /** Report Protocol */ 00110 #define HIDProtocol_REPORT 1 00111 00112 /** Infinite idle rate.*/ 00113 #define HIDIdleRequest_INFINITE 0 00114 00115 /*---------------------------------------------------------------------------- 00116 * Types 00117 *----------------------------------------------------------------------------*/ 00118 00119 #pragma pack(1) 00120 #if defined ( __CC_ARM ) /* Keil ¦̀Vision 4 */ 00121 #elif defined ( __ICCARM__ ) /* IAR Ewarm 5.41+ */ 00122 #define __attribute__(...) 00123 #elif defined ( __GNUC__ ) /* GCC CS3 2009q3-68 */ 00124 #endif 00125 00126 00127 00128 #pragma pack() 00129 00130 /*---------------------------------------------------------------------------- 00131 * Functions 00132 *----------------------------------------------------------------------------*/ 00133 00134 extern uint8_t HIDReportRequest_GetReportType( 00135 const USBGenericRequest *request); 00136 00137 extern uint8_t HIDReportRequest_GetReportId( 00138 const USBGenericRequest *request); 00139 00140 00141 static inline uint16_t HIDProtocolRequest_GetProtocol( 00142 const USBGenericRequest *request) 00143 { 00144 return USBGenericRequest_GetValue(request); 00145 } 00146 00147 extern uint8_t HIDIdleRequest_GetReportId( 00148 const USBGenericRequest * request); 00149 00150 extern uint8_t HIDIdleRequest_GetIdleRate( 00151 const USBGenericRequest *request); 00152 00153 /**@}*/ 00154 #endif /* #define _HIDREQUESTS_H_ */