Forked to make modifications to bring the USBHID into USB compliance and add additional features.

Dependents:   HW4_AudioControl

Fork of USBDevice by mbed official

As of Revision 18 everything in the USBHID specification is now implemented, except Multi-reports.

Revision comments for changelist 18

USBHID.cpp

  • Added SET_PROTOCOL support
  • Added GET_PROTOCOL support
  • protocolSate is set to 1 by default to match USB HID specification. This variable should be checked to determine which format theinput report should have. 1 - Use the user specified report format. 0 - Use the BOOT protocol report format.

Revision comments for changelist 16

  • HID_REPORT transformed from structure to class. This was done for several reasons.
  1. When multiple reports are used the 64 byte size for every report becomes a problem.
  2. The length value should always remain the same for a report, Make the constructor set the vale at the same time it allocates memory for the DATA area.
  • By default the data will be an array of MAX_HID_REPORT_SIZE like the structure,
  • When given a length argument, the hid_report.length will be set, and hid_report.data will be an array of the size given.
  • Length zero causes data to be NULL
  • Mostly backwards compatible. The definition of a destructor caused a compiler error in USBMouse::update and USBMousekeyboard::update. This error was caused by instatiation of HID_REPORT in the middle of an IF logic statement. These files have been modified. The error complained that the logic skipped object initialization. The HID_REPORT has been moved to the class definition. Since both ABSOLUTE and RELATIVE modes used the HID_REPORT, this seems to make more sense. Previously the hid_report would be instatiated in <class>::mousesend and <class>::update.

Revision comments for changelist 14

USBdevice.cpp

  • Modified USB device state to change from Configure when disconnect is called.
  • Modified the call back function for when the suspend state changes. This should be used to turn off peripherals to conserve power.

Revision comments for changelist 13

USBdevice.cpp

  • ) Changed DEBUG messages to be more descriptive for string descriptor
  • ) Bug fix: Control Transfers did not actually transfer the data from Buffer to transfer->ptr

USBHIDTypes.h

  • ) Added ALL CLASS request to KEYWORD list
  • ) Added KEYWORDS for report type

USBHID.h

  • ) Added a new constructor to specify size of feature report
  • ) Added HID_REPORT inputReport and featureReport
  • ) Added data structures to support IDLE rate
  • ) Added data structures to support callback functions

USBHID.cpp

  • ) Changed constructor to initialize new feature data structures
  • ) Implemented Set_IDLE/GET_IDLE and the periodic resend of non-changed data
  • ) Implemented HID specification required control transfer GET_REPORT
  • ) Fixed issue where Intreput transfers and control transfers did not access the same data structures.
  • ) Implemented Feature reports
  • ) Implemented Callback Hooks for get_report/set_report actions.
  • ) Added callback hooks for interupt actions in the new functions.
  • ) interupt transfer can now write to outputReport
  • ) Modified SET_REPORT code to function for multiple types.
  • ) Refactored some code in preperation to add multi report support
Test NumberTest DescriptionTest ResultNotes
1Use USBmouse to verify backward compatibility of constructor and methodsPass
2Test SET_REPORT can set a feature reportPass
3Test GET_REPORT can retrieve a feature reportPass
4Test SET_IDLE sets up a reoccuring triggerPassIOCTL_SET_POLL_FREQUENCY_MSEC does not function for the windows HID driver. A Special test program is used to rearm the IDLE rate after windows sets it to zero
5Test SET_IDLE disables a triggerPassWindows automatically sends this command to a HID device when it is inserted.
6Enabled DEBUG in USBDevice.cpp and generated str descriptor requests.Pass
7Test SET_REPORT can set an output reportPass
8Test GET_REPORT can retrieve an output reportPass
9ReadFile, accesses the input_reportPass
10WriteFile accesses the output_report, via interupt transfer when ep1_out is used.Pass
11WriteFile accesses the output_report, via control transfer when ep1_out is NOT used.Not Tested
12Callback hooks trigger independently for each type of set_report/get_reportPass
13New constructor sets feature_report sizePass
14Control transfer SET_REPORT and writeFile access the same data structureBUGThe same data structure is accessed, but the data transfer size is different. The writeFile strips the leading byte which is the report ID, The Control transfer keeps the byte.
15Control transfer GET_REPORT and readFile access the same data structureBUGThe same dtat structure is accessed, but the data transfer size is different. The readFile strips the leading byte which is the report ID, The Control transfer keeps the byte.
16Test GET_IDLE retrieves the IDLE rateUnknownWindows HID driver does not implement IOCTL_HID_GET_POLL_FREQUENCY_MSEC
Committer:
jakowisp
Date:
Thu Aug 08 08:02:46 2013 +0000
Revision:
18:cb3afa532fcd
Parent:
17:cf5d77f1026a
Default ProtocolState was incorrectly being set to 0:Boot when the HID specification states that the default should be 1:Report

Who changed what in which revision?

UserRevisionLine numberNew contents of line
samux 1:80ab0d068708 1 /* Copyright (c) 2010-2011 mbed.org, MIT License
samux 1:80ab0d068708 2 *
samux 1:80ab0d068708 3 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
samux 1:80ab0d068708 4 * and associated documentation files (the "Software"), to deal in the Software without
samux 1:80ab0d068708 5 * restriction, including without limitation the rights to use, copy, modify, merge, publish,
samux 1:80ab0d068708 6 * distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
samux 1:80ab0d068708 7 * Software is furnished to do so, subject to the following conditions:
samux 1:80ab0d068708 8 *
samux 1:80ab0d068708 9 * The above copyright notice and this permission notice shall be included in all copies or
samux 1:80ab0d068708 10 * substantial portions of the Software.
samux 1:80ab0d068708 11 *
samux 1:80ab0d068708 12 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
samux 1:80ab0d068708 13 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
samux 1:80ab0d068708 14 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
samux 1:80ab0d068708 15 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
samux 1:80ab0d068708 16 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
samux 1:80ab0d068708 17 */
samux 1:80ab0d068708 18
samux 1:80ab0d068708 19 #ifndef USB_HID_H
samux 1:80ab0d068708 20 #define USB_HID_H
samux 1:80ab0d068708 21
samux 1:80ab0d068708 22 /* These headers are included for child class. */
samux 1:80ab0d068708 23 #include "USBEndpoints.h"
samux 1:80ab0d068708 24 #include "USBDescriptor.h"
samux 1:80ab0d068708 25 #include "USBDevice_Types.h"
samux 1:80ab0d068708 26
samux 1:80ab0d068708 27 #include "USBHID_Types.h"
samux 1:80ab0d068708 28 #include "USBDevice.h"
samux 1:80ab0d068708 29
samux 1:80ab0d068708 30 /**
samux 1:80ab0d068708 31 * USBHID example
samux 1:80ab0d068708 32 * @code
jakowisp 13:9f652add7891 33 *
jakowisp 13:9f652add7891 34 * //We declare a USBHID device. Input, Output, and Feature reports have a length of 8 bytes
jakowisp 13:9f652add7891 35 * USBHID hid(8, 8, 8,0x1234,0x0006, 0x0001,true);
jakowisp 13:9f652add7891 36 * HID_REPORT tempReport;
jakowisp 13:9f652add7891 37
jakowisp 13:9f652add7891 38 * void MycallbackSetReport(HID_REPORT *report){
jakowisp 13:9f652add7891 39 * printf("Report: ");
jakowisp 13:9f652add7891 40 * for(int i = 0; i < report->length; i++) {
jakowisp 13:9f652add7891 41 * printf("%x ", report->data[i]);
jakowisp 13:9f652add7891 42 * }
jakowisp 13:9f652add7891 43 * printf("\r\n");
jakowisp 13:9f652add7891 44 * };
jakowisp 13:9f652add7891 45 *
jakowisp 13:9f652add7891 46 * bool SetTempReport(HID_REPORT *report){
jakowisp 13:9f652add7891 47 * for (int i = 0; i < report->length; i++) {
jakowisp 13:9f652add7891 48 * report->data[i] = rand() & 0xff;
jakowisp 13:9f652add7891 49 * }
jakowisp 13:9f652add7891 50 * return true;
jakowisp 13:9f652add7891 51 * };
jakowisp 13:9f652add7891 52 *
samux 1:80ab0d068708 53 * int main(void) {
jakowisp 13:9f652add7891 54 * printf("Starting==>\r\n");
jakowisp 13:9f652add7891 55 * hid.callbackSetOutputReport=&MycallbackSetReport;
jakowisp 13:9f652add7891 56 * tempReport.length=8;
jakowisp 13:9f652add7891 57
jakowisp 13:9f652add7891 58 * while (1) {
jakowisp 13:9f652add7891 59 * SetTempReport(&tempReport);
jakowisp 13:9f652add7891 60 * hid.FillInputReport(&tempReport);
jakowisp 13:9f652add7891 61 * wait(2.2);
jakowisp 13:9f652add7891 62 * }
samux 1:80ab0d068708 63 * }
jakowisp 13:9f652add7891 64 *
samux 1:80ab0d068708 65 * @endcode
samux 1:80ab0d068708 66 */
samux 1:80ab0d068708 67
samux 1:80ab0d068708 68 class USBHID: public USBDevice {
samux 1:80ab0d068708 69 public:
samux 1:80ab0d068708 70
samux 1:80ab0d068708 71 /**
jakowisp 13:9f652add7891 72 * Constructor
samux 1:80ab0d068708 73 *
samux 1:80ab0d068708 74 * @param output_report_length Maximum length of a sent report (up to 64 bytes) (default: 64 bytes)
samux 1:80ab0d068708 75 * @param input_report_length Maximum length of a received report (up to 64 bytes) (default: 64 bytes)
jakowisp 12:590d5be7b7f4 76 * @param report_report_length Maximum length of a received report (up to 64 bytes) (default: 64 bytes)
samux 1:80ab0d068708 77 * @param vendor_id Your vendor_id
samux 1:80ab0d068708 78 * @param product_id Your product_id
samux 1:80ab0d068708 79 * @param product_release Your preoduct_release
samux 1:80ab0d068708 80 * @param connect Connect the device
samux 1:80ab0d068708 81 */
jakowisp 12:590d5be7b7f4 82 USBHID(uint8_t output_report_length , uint8_t input_report_length , uint8_t feature_report_length , uint16_t vendor_id , uint16_t product_id , uint16_t product_release , bool connect );
jakowisp 13:9f652add7891 83 /**
jakowisp 13:9f652add7891 84 * Constructor
jakowisp 13:9f652add7891 85 * default constructor to maintain backwards compatibility.
jakowisp 13:9f652add7891 86 *
jakowisp 13:9f652add7891 87 * @param output_report_length Maximum length of a sent report (up to 64 bytes) (default: 64 bytes)
jakowisp 13:9f652add7891 88 * @param input_report_length Maximum length of a received report (up to 64 bytes) (default: 64 bytes)
jakowisp 13:9f652add7891 89 * @param report_report_length Maximum length of a received report (up to 64 bytes) (default: 64 bytes)
jakowisp 13:9f652add7891 90 * @param vendor_id Your vendor_id
jakowisp 13:9f652add7891 91 * @param product_id Your product_id
jakowisp 13:9f652add7891 92 * @param product_release Your preoduct_release
jakowisp 13:9f652add7891 93 * @param connect Connect the device
jakowisp 13:9f652add7891 94 */
samux 1:80ab0d068708 95 USBHID(uint8_t output_report_length = 64, uint8_t input_report_length = 64, uint16_t vendor_id = 0x1234, uint16_t product_id = 0x0006, uint16_t product_release = 0x0001, bool connect = true);
samux 1:80ab0d068708 96
samux 1:80ab0d068708 97
samux 1:80ab0d068708 98 /**
samux 1:80ab0d068708 99 * Send a Report. warning: blocking
jakowisp 13:9f652add7891 100 * legacy method retained for backward compatability
samux 1:80ab0d068708 101 *
samux 1:80ab0d068708 102 * @param report Report which will be sent (a report is defined by all data and the length)
samux 1:80ab0d068708 103 * @returns true if successful
samux 1:80ab0d068708 104 */
samux 1:80ab0d068708 105 bool send(HID_REPORT *report);
samux 1:80ab0d068708 106
samux 1:80ab0d068708 107
samux 1:80ab0d068708 108 /**
samux 1:80ab0d068708 109 * Send a Report. warning: non blocking
jakowisp 13:9f652add7891 110 * legacy method retained for backward compatability
samux 1:80ab0d068708 111 *
samux 1:80ab0d068708 112 * @param report Report which will be sent (a report is defined by all data and the length)
samux 1:80ab0d068708 113 * @returns true if successful
samux 1:80ab0d068708 114 */
samux 1:80ab0d068708 115 bool sendNB(HID_REPORT *report);
samux 1:80ab0d068708 116
samux 1:80ab0d068708 117 /**
samux 1:80ab0d068708 118 * Read a report: blocking
jakowisp 13:9f652add7891 119 * legacy method retained for backward compatability
samux 1:80ab0d068708 120 *
samux 1:80ab0d068708 121 * @param report pointer to the report to fill
samux 1:80ab0d068708 122 * @returns true if successful
samux 1:80ab0d068708 123 */
samux 1:80ab0d068708 124 bool read(HID_REPORT * report);
samux 1:80ab0d068708 125
samux 1:80ab0d068708 126 /**
samux 1:80ab0d068708 127 * Read a report: non blocking
jakowisp 13:9f652add7891 128 * legacy method retained for backward compatability
samux 1:80ab0d068708 129 *
samux 1:80ab0d068708 130 * @param report pointer to the report to fill
samux 1:80ab0d068708 131 * @returns true if successful
samux 1:80ab0d068708 132 */
samux 1:80ab0d068708 133 bool readNB(HID_REPORT * report);
jakowisp 12:590d5be7b7f4 134
jakowisp 12:590d5be7b7f4 135 /**
jakowisp 13:9f652add7891 136 * Provide the ability to Fill the inputReport. Report transfer is automatic if the data changes
jakowisp 12:590d5be7b7f4 137 *
jakowisp 12:590d5be7b7f4 138 * @param HID_REPORT
jakowisp 12:590d5be7b7f4 139 * @returns true if succsful
jakowisp 12:590d5be7b7f4 140 * The devloper should always use FillReport, The IDLE logic will send a report if the value has changed, or if the idle period expires.
jakowisp 12:590d5be7b7f4 141 */
jakowisp 12:590d5be7b7f4 142 bool FillInputReport(HID_REPORT *report);
jakowisp 13:9f652add7891 143
jakowisp 13:9f652add7891 144 /**
jakowisp 13:9f652add7891 145 * Provide the ability to Fill the featureReport.
jakowisp 13:9f652add7891 146 *
jakowisp 13:9f652add7891 147 * @param HID_REPORT
jakowisp 13:9f652add7891 148 * @returns true if succsful
jakowisp 13:9f652add7891 149 */
jakowisp 12:590d5be7b7f4 150 bool FillFeatureReport(HID_REPORT *report);
jakowisp 12:590d5be7b7f4 151
jakowisp 12:590d5be7b7f4 152
jakowisp 12:590d5be7b7f4 153 /**
jakowisp 13:9f652add7891 154 * Callback pointers to functions
jakowisp 12:590d5be7b7f4 155 *
jakowisp 12:590d5be7b7f4 156 * @param report pointer to the report to fill
jakowisp 13:9f652add7891 157 * These allow a user program to hook on get_report/set_report actions for each type.
jakowisp 12:590d5be7b7f4 158 */
jakowisp 12:590d5be7b7f4 159 void (*callbackSetInputReport)(HID_REPORT *report);
jakowisp 13:9f652add7891 160 /**
jakowisp 13:9f652add7891 161 * Callback pointers to functions
jakowisp 13:9f652add7891 162 *
jakowisp 13:9f652add7891 163 * @param report pointer to the report to fill
jakowisp 13:9f652add7891 164 * These allow a user program to hook on get_report/set_report actions for each type.
jakowisp 13:9f652add7891 165 */
jakowisp 12:590d5be7b7f4 166 bool (*callbackGetInputReport)(HID_REPORT *report);
jakowisp 13:9f652add7891 167 /**
jakowisp 13:9f652add7891 168 * Callback pointers to functions
jakowisp 13:9f652add7891 169 *
jakowisp 13:9f652add7891 170 * @param report pointer to the report to fill
jakowisp 13:9f652add7891 171 * These allow a user program to hook on get_report/set_report actions for each type.
jakowisp 13:9f652add7891 172 */
jakowisp 12:590d5be7b7f4 173 void (*callbackSetOutputReport)(HID_REPORT *report);
jakowisp 13:9f652add7891 174 /**
jakowisp 13:9f652add7891 175 * Callback pointers to functions
jakowisp 13:9f652add7891 176 *
jakowisp 13:9f652add7891 177 * @param report pointer to the report to fill
jakowisp 13:9f652add7891 178 * These allow a user program to hook on get_report/set_report actions for each type.
jakowisp 13:9f652add7891 179 */
jakowisp 12:590d5be7b7f4 180 bool (*callbackGetOutputReport)(HID_REPORT *report);
jakowisp 13:9f652add7891 181 /**
jakowisp 13:9f652add7891 182 * Callback pointers to functions
jakowisp 13:9f652add7891 183 *
jakowisp 13:9f652add7891 184 * @param report pointer to the report to fill
jakowisp 13:9f652add7891 185 * These allow a user program to hook on get_report/set_report actions for each type.
jakowisp 13:9f652add7891 186 */
jakowisp 12:590d5be7b7f4 187 void (*callbackSetFeatureReport)(HID_REPORT *report);
jakowisp 13:9f652add7891 188 /**
jakowisp 13:9f652add7891 189 * Callback pointers to functions
jakowisp 13:9f652add7891 190 *
jakowisp 13:9f652add7891 191 * @param report pointer to the report to fill
jakowisp 13:9f652add7891 192 * These allow a user program to hook on get_report/set_report actions for each type.
jakowisp 13:9f652add7891 193 */
jakowisp 12:590d5be7b7f4 194 bool (*callbackGetFeatureReport)(HID_REPORT *report);
jakowisp 12:590d5be7b7f4 195
jakowisp 13:9f652add7891 196 /**
jakowisp 13:9f652add7891 197 * This function should be private, but is exposed to allow a developer to reenable IDLE values > zero after windows sets the value to zero.
jakowisp 13:9f652add7891 198 * This is due to microsoft windows HID driver not implementing IOCTL_HID_SET_POLL_FREQUENCY_MSEC/IOCTL_HID_GET_POLL_FREQUENCY_MSEC
jakowisp 12:590d5be7b7f4 199 */
jakowisp 12:590d5be7b7f4 200 virtual void SetReportIdle(uint16_t wValue);
jakowisp 17:cf5d77f1026a 201 uint8_t protocolState;
jakowisp 12:590d5be7b7f4 202
samux 1:80ab0d068708 203
samux 1:80ab0d068708 204 protected:
samux 1:80ab0d068708 205 uint16_t reportLength;
samux 1:80ab0d068708 206
samux 1:80ab0d068708 207 /*
samux 1:80ab0d068708 208 * Get the Report descriptor
samux 1:80ab0d068708 209 *
samux 1:80ab0d068708 210 * @returns pointer to the report descriptor
samux 1:80ab0d068708 211 */
samux 1:80ab0d068708 212 virtual uint8_t * reportDesc();
samux 1:80ab0d068708 213
samux 1:80ab0d068708 214 /*
samux 1:80ab0d068708 215 * Get the length of the report descriptor
samux 1:80ab0d068708 216 *
samux 1:80ab0d068708 217 * @returns the length of the report descriptor
samux 1:80ab0d068708 218 */
samux 1:80ab0d068708 219 virtual uint16_t reportDescLength();
samux 1:80ab0d068708 220
samux 1:80ab0d068708 221 /*
samux 1:80ab0d068708 222 * Get string product descriptor
samux 1:80ab0d068708 223 *
samux 1:80ab0d068708 224 * @returns pointer to the string product descriptor
samux 1:80ab0d068708 225 */
samux 1:80ab0d068708 226 virtual uint8_t * stringIproductDesc();
samux 1:80ab0d068708 227
samux 1:80ab0d068708 228 /*
samux 1:80ab0d068708 229 * Get string interface descriptor
samux 1:80ab0d068708 230 *
samux 1:80ab0d068708 231 * @returns pointer to the string interface descriptor
samux 1:80ab0d068708 232 */
samux 1:80ab0d068708 233 virtual uint8_t * stringIinterfaceDesc();
samux 1:80ab0d068708 234
samux 1:80ab0d068708 235 /*
samux 1:80ab0d068708 236 * Get configuration descriptor
samux 1:80ab0d068708 237 *
samux 1:80ab0d068708 238 * @returns pointer to the configuration descriptor
samux 1:80ab0d068708 239 */
samux 1:80ab0d068708 240 virtual uint8_t * configurationDesc();
samux 1:80ab0d068708 241
samux 1:80ab0d068708 242
samux 1:80ab0d068708 243 /*
samux 1:80ab0d068708 244 * HID Report received by SET_REPORT request. Warning: Called in ISR context
samux 1:80ab0d068708 245 * First byte of data will be the report ID
samux 1:80ab0d068708 246 *
samux 1:80ab0d068708 247 * @param report Data and length received
samux 1:80ab0d068708 248 */
jakowisp 12:590d5be7b7f4 249 static void HID_callbackSetReport(HID_REPORT *report){};
jakowisp 12:590d5be7b7f4 250
jakowisp 12:590d5be7b7f4 251 /*
jakowisp 12:590d5be7b7f4 252 * HID Report received by GET_REPORT request. Warning: Called in ISR context
jakowisp 12:590d5be7b7f4 253 * First byte of data will be the report ID
jakowisp 12:590d5be7b7f4 254 *
jakowisp 12:590d5be7b7f4 255 * @param report Data and length received
jakowisp 12:590d5be7b7f4 256 */
jakowisp 12:590d5be7b7f4 257 static bool HID_callbackGetReport(HID_REPORT *report){return true;};
jakowisp 12:590d5be7b7f4 258
samux 1:80ab0d068708 259 /*
samux 1:80ab0d068708 260 * Called by USBDevice on Endpoint0 request. Warning: Called in ISR context
samux 1:80ab0d068708 261 * This is used to handle extensions to standard requests
samux 1:80ab0d068708 262 * and class specific requests
samux 1:80ab0d068708 263 *
samux 1:80ab0d068708 264 * @returns true if class handles this request
samux 1:80ab0d068708 265 */
samux 1:80ab0d068708 266 virtual bool USBCallback_request();
jakowisp 12:590d5be7b7f4 267 /*
jakowisp 12:590d5be7b7f4 268 * Called by USBDevice on Endpoint0 request completion
jakowisp 12:590d5be7b7f4 269 * if the 'notify' flag has been set to true. Warning: Called in ISR context
jakowisp 12:590d5be7b7f4 270 *
jakowisp 12:590d5be7b7f4 271 * In this case it is used to indicate that a HID report has
jakowisp 12:590d5be7b7f4 272 * been received from the host on endpoint 0
jakowisp 12:590d5be7b7f4 273 *
jakowisp 12:590d5be7b7f4 274 * @param buf buffer received on endpoint 0
jakowisp 12:590d5be7b7f4 275 * @param length length of this buffer
jakowisp 12:590d5be7b7f4 276 */
jakowisp 12:590d5be7b7f4 277 virtual void USBCallback_requestCompleted(uint8_t * buf, uint32_t length);
samux 1:80ab0d068708 278
samux 1:80ab0d068708 279 /*
jakowisp 12:590d5be7b7f4 280 * Called by USBDevice layer. to ensure that control transfers and interupt transfers work on the same reports.
jakowisp 12:590d5be7b7f4 281 */
jakowisp 12:590d5be7b7f4 282 virtual bool EP1_OUT_callback();
jakowisp 12:590d5be7b7f4 283
jakowisp 12:590d5be7b7f4 284 /* Called by FillInputReport when data has changed, and transmits the data. */
jakowisp 12:590d5be7b7f4 285 bool SendReport(void);
jakowisp 12:590d5be7b7f4 286
jakowisp 12:590d5be7b7f4 287 /*
jakowisp 12:590d5be7b7f4 288 * Called by USBDevice layer.to set configuration
samux 1:80ab0d068708 289 */
samux 1:80ab0d068708 290 virtual bool USBCallback_setConfiguration(uint8_t configuration);
jakowisp 12:590d5be7b7f4 291
jakowisp 12:590d5be7b7f4 292 /* tells SET_IDLE/GET_IDLE where the IDE rate value is. */
jakowisp 12:590d5be7b7f4 293
jakowisp 12:590d5be7b7f4 294 virtual uint8_t * getReportIdlePtr(uint8_t reportID){ return &reportIdleRateInt; };
jakowisp 12:590d5be7b7f4 295
jakowisp 12:590d5be7b7f4 296
samux 1:80ab0d068708 297 private:
jakowisp 12:590d5be7b7f4 298 // TODO: HID Reports should be dynamically malloced to save memory and prepare for multi-reports
jakowisp 12:590d5be7b7f4 299 HID_REPORT inputReport;
samux 1:80ab0d068708 300 HID_REPORT outputReport;
jakowisp 12:590d5be7b7f4 301 HID_REPORT featureReport;
samux 1:80ab0d068708 302 uint8_t output_length;
samux 1:80ab0d068708 303 uint8_t input_length;
jakowisp 12:590d5be7b7f4 304 uint8_t feature_length;
jakowisp 12:590d5be7b7f4 305
jakowisp 12:590d5be7b7f4 306 //TODO: REPORT clsss should be created to handle MULTI-report
jakowisp 12:590d5be7b7f4 307 //Implementation items for IDLE rate (TICKER)
jakowisp 12:590d5be7b7f4 308 float reportIdleRate;
jakowisp 12:590d5be7b7f4 309 uint8_t reportIdleRateInt;
jakowisp 12:590d5be7b7f4 310 Ticker countDownToReportTrigger;
jakowisp 12:590d5be7b7f4 311 void ResetIdleTicker(void);
jakowisp 12:590d5be7b7f4 312 void IdlePeriodReSend(void);
jakowisp 12:590d5be7b7f4 313
jakowisp 12:590d5be7b7f4 314 //Report REPORT data pointer retrieval.
jakowisp 12:590d5be7b7f4 315 HID_REPORT * GetReportTargetPointer(uint16_t wValue);
jakowisp 12:590d5be7b7f4 316 //Report Set/GET REPORT callback handlers
jakowisp 12:590d5be7b7f4 317 bool HIDCallback_GetReportHandler(HID_REPORT *targetPtr);
jakowisp 12:590d5be7b7f4 318 bool HIDCallback_SetReportHandler(HID_REPORT *targetPtr);
samux 1:80ab0d068708 319 };
samux 1:80ab0d068708 320
samux 1:80ab0d068708 321 #endif