Christina Quast | b123d74 | 2014-12-23 13:03:36 +0100 | [diff] [blame] | 1 | /* ---------------------------------------------------------------------------- |
| 2 | * ATMEL Microcontroller Software Support |
| 3 | * ---------------------------------------------------------------------------- |
| 4 | * Copyright (c) 2010, Atmel Corporation |
| 5 | * |
| 6 | * All rights reserved. |
| 7 | * |
| 8 | * Redistribution and use in source and binary forms, with or without |
| 9 | * modification, are permitted provided that the following conditions are met: |
| 10 | * |
| 11 | * - Redistributions of source code must retain the above copyright notice, |
| 12 | * this list of conditions and the disclaimer below. |
| 13 | * |
| 14 | * Atmel's name may not be used to endorse or promote products derived from |
| 15 | * this software without specific prior written permission. |
| 16 | * |
| 17 | * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR |
| 18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
| 19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE |
| 20 | * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, |
| 21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 22 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, |
| 23 | * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF |
| 24 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
| 25 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, |
| 26 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | * ---------------------------------------------------------------------------- |
| 28 | */ |
| 29 | |
| 30 | /**\file |
| 31 | * |
| 32 | * \section Purpose |
| 33 | * |
| 34 | * Definitions used for declaring the requests of a HID device. |
| 35 | * |
| 36 | * -# Receive a GET_REPORT or SET_REPORT request from the host. |
| 37 | * -# Retrieve the report type using HIDReportRequest_GetReportType. |
| 38 | * -# Retrieve the report ID using HIDReportRequest_GetReportId. |
| 39 | * -# Retrieve the idle rate indicated by a GET_IDLE or SET_IDLE request |
| 40 | * with HIDIdleRequest_GetIdleRate. |
| 41 | */ |
| 42 | |
| 43 | #ifndef _HIDREQUESTS_H_ |
| 44 | #define _HIDREQUESTS_H_ |
| 45 | /** \addtogroup usb_hid |
| 46 | *@{ |
| 47 | */ |
| 48 | |
| 49 | /*---------------------------------------------------------------------------- |
| 50 | * Includes |
| 51 | *----------------------------------------------------------------------------*/ |
| 52 | |
| 53 | #include <stdint.h> |
| 54 | #include <USBRequests.h> |
| 55 | |
| 56 | /*---------------------------------------------------------------------------- |
| 57 | * Definitions |
| 58 | *----------------------------------------------------------------------------*/ |
| 59 | |
| 60 | /** \addtogroup usb_hid_request_codes HID Request Codes |
| 61 | * @{ |
| 62 | * |
| 63 | * \section Codes |
| 64 | * - HIDGenericRequest_GETREPORT |
| 65 | * - HIDGenericRequest_GETIDLE |
| 66 | * - HIDGenericRequest_GETPROTOCOL |
| 67 | * - HIDGenericRequest_SETREPORT |
| 68 | * - HIDGenericRequest_SETIDLE |
| 69 | * - HIDGenericRequest_SETPROTOCOL |
| 70 | */ |
| 71 | |
| 72 | /** GetReport request code. */ |
| 73 | #define HIDGenericRequest_GETREPORT 0x01 |
| 74 | /** GetIdle request code. */ |
| 75 | #define HIDGenericRequest_GETIDLE 0x02 |
| 76 | /** GetProtocol request code. */ |
| 77 | #define HIDGenericRequest_GETPROTOCOL 0x03 |
| 78 | /** SetReport request code. */ |
| 79 | #define HIDGenericRequest_SETREPORT 0x09 |
| 80 | /** SetIdle request code. */ |
| 81 | #define HIDGenericRequest_SETIDLE 0x0A |
| 82 | /** SetProtocol request code. */ |
| 83 | #define HIDGenericRequest_SETPROTOCOL 0x0B |
| 84 | /** @}*/ |
| 85 | |
| 86 | /** \addtogroup usb_hid_report_types HID Report Types |
| 87 | * @{ |
| 88 | * This page lists the types for USB HID Reports. |
| 89 | * |
| 90 | * \section Types |
| 91 | * - HIDReportRequest_INPUT |
| 92 | * - HIDReportRequest_OUTPUT |
| 93 | * - HIDReportRequest_FEATURE |
| 94 | */ |
| 95 | |
| 96 | /** Input report. */ |
| 97 | #define HIDReportRequest_INPUT 1 |
| 98 | /** Output report. */ |
| 99 | #define HIDReportRequest_OUTPUT 2 |
| 100 | /** Feature report. */ |
| 101 | #define HIDReportRequest_FEATURE 3 |
| 102 | /** @}*/ |
| 103 | |
| 104 | /** \addtogroup usb_hid_protocol_types HID Protocol Types |
| 105 | * @{ |
| 106 | */ |
| 107 | /** Boot Protocol */ |
| 108 | #define HIDProtocol_BOOT 0 |
| 109 | /** Report Protocol */ |
| 110 | #define HIDProtocol_REPORT 1 |
| 111 | |
| 112 | /** Infinite idle rate.*/ |
| 113 | #define HIDIdleRequest_INFINITE 0 |
| 114 | |
| 115 | /*---------------------------------------------------------------------------- |
| 116 | * Types |
| 117 | *----------------------------------------------------------------------------*/ |
| 118 | |
| 119 | #ifdef __ICCARM__ /* IAR */ |
| 120 | #pragma pack(1) /* IAR */ |
| 121 | #define __attribute__(...) /* IAR */ |
| 122 | #endif /* IAR */ |
| 123 | |
| 124 | |
| 125 | |
| 126 | #ifdef __ICCARM__ /* IAR */ |
| 127 | #pragma pack() /* IAR */ |
| 128 | #endif /* IAR */ |
| 129 | |
| 130 | /*---------------------------------------------------------------------------- |
| 131 | * Functions |
| 132 | *----------------------------------------------------------------------------*/ |
| 133 | |
| 134 | extern uint8_t HIDReportRequest_GetReportType( |
| 135 | const USBGenericRequest *request); |
| 136 | |
| 137 | extern uint8_t HIDReportRequest_GetReportId( |
| 138 | const USBGenericRequest *request); |
| 139 | |
| 140 | |
| 141 | static inline uint16_t HIDProtocolRequest_GetProtocol( |
| 142 | const USBGenericRequest *request) |
| 143 | { |
| 144 | return USBGenericRequest_GetValue(request); |
| 145 | } |
| 146 | |
| 147 | extern uint8_t HIDIdleRequest_GetReportId( |
| 148 | const USBGenericRequest * request); |
| 149 | |
| 150 | extern uint8_t HIDIdleRequest_GetIdleRate( |
| 151 | const USBGenericRequest *request); |
| 152 | |
| 153 | /**@}*/ |
| 154 | #endif /* #define _HIDREQUESTS_H_ */ |