Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: 11u35_usbLocalFilesystem
Fork of USBDAP by
USBDAP.h
00001 /* Copyright (c) 2010-2011 mbed.org, MIT License 00002 * 00003 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software 00004 * and associated documentation files (the "Software"), to deal in the Software without 00005 * restriction, including without limitation the rights to use, copy, modify, merge, publish, 00006 * distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the 00007 * Software is furnished to do so, subject to the following conditions: 00008 * 00009 * The above copyright notice and this permission notice shall be included in all copies or 00010 * substantial portions of the Software. 00011 * 00012 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING 00013 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 00014 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 00015 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 00016 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 00017 */ 00018 00019 #ifndef USB_DAP_H 00020 #define USB_DAP_H 00021 00022 /* These headers are included for child class. */ 00023 #include "USBEndpoints.h" 00024 #include "USBDescriptor.h" 00025 #include "USBDevice_Types.h" 00026 00027 #include "USBHID_Types.h" 00028 #include "USBDevice.h" 00029 00030 /** USB HID device for CMSIS-DAP 00031 */ 00032 class USBDAP: public USBDevice { 00033 public: 00034 00035 /** 00036 * Constructor 00037 * 00038 * @param product product name default: "CMSIS-DAP" 00039 * @param vendor_id Your vendor_id 00040 * @param product_id Your product_id 00041 * @param product_release Your preoduct_release 00042 * @param connect Connect the device 00043 */ 00044 USBDAP(const char *product = "CMSIS-DAP", uint16_t vendor_id = 0x1234, uint16_t product_id = 0x0006, uint16_t product_release = 0x0001, bool connect = true); 00045 00046 /** 00047 * Constructor 00048 * 00049 * @param output_report_length Maximum length of a sent report (up to 64 bytes) (default: 64 bytes) 00050 * @param input_report_length Maximum length of a received report (up to 64 bytes) (default: 64 bytes) 00051 * @param vendor_id Your vendor_id 00052 * @param product_id Your product_id 00053 * @param product_release Your preoduct_release 00054 * @param connect Connect the device 00055 */ 00056 USBDAP(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); 00057 00058 00059 /** 00060 * Send a Report. warning: blocking 00061 * 00062 * @param report Report which will be sent (a report is defined by all data and the length) 00063 * @returns true if successful 00064 */ 00065 bool send(HID_REPORT *report); 00066 00067 00068 /** 00069 * Send a Report. warning: non blocking 00070 * 00071 * @param report Report which will be sent (a report is defined by all data and the length) 00072 * @returns true if successful 00073 */ 00074 bool sendNB(HID_REPORT *report); 00075 00076 /** 00077 * Read a report: blocking 00078 * 00079 * @param report pointer to the report to fill 00080 * @returns true if successful 00081 */ 00082 bool read(HID_REPORT * report); 00083 00084 /** 00085 * Read a report: non blocking 00086 * 00087 * @param report pointer to the report to fill 00088 * @returns true if successful 00089 */ 00090 bool readNB(HID_REPORT * report); 00091 00092 protected: 00093 uint16_t reportLength; 00094 00095 /* 00096 * Get the Report descriptor 00097 * 00098 * @returns pointer to the report descriptor 00099 */ 00100 virtual uint8_t * reportDesc(); 00101 00102 /* 00103 * Get the length of the report descriptor 00104 * 00105 * @returns the length of the report descriptor 00106 */ 00107 virtual uint16_t reportDescLength(); 00108 00109 /* 00110 * Get string product descriptor 00111 * 00112 * @returns pointer to the string product descriptor 00113 */ 00114 virtual uint8_t * stringIproductDesc(); 00115 00116 /* 00117 * Get string interface descriptor 00118 * 00119 * @returns pointer to the string interface descriptor 00120 */ 00121 virtual uint8_t * stringIinterfaceDesc(); 00122 00123 /* 00124 * Get configuration descriptor 00125 * 00126 * @returns pointer to the configuration descriptor 00127 */ 00128 virtual uint8_t * configurationDesc(); 00129 00130 00131 /* 00132 * HID Report received by SET_REPORT request. Warning: Called in ISR context 00133 * First byte of data will be the report ID 00134 * 00135 * @param report Data and length received 00136 */ 00137 virtual void HID_callbackSetReport(HID_REPORT *report){}; 00138 00139 00140 /* 00141 * Called by USBDevice on Endpoint0 request. Warning: Called in ISR context 00142 * This is used to handle extensions to standard requests 00143 * and class specific requests 00144 * 00145 * @returns true if class handles this request 00146 */ 00147 virtual bool USBCallback_request(); 00148 00149 00150 /* 00151 * Called by USBDevice layer. Set configuration of the device. 00152 * For instance, you can add all endpoints that you need on this function. 00153 * 00154 * @param configuration Number of the configuration 00155 * @returns true if class handles this request 00156 */ 00157 virtual bool USBCallback_setConfiguration(uint8_t configuration); 00158 00159 private: 00160 HID_REPORT outputReport; 00161 uint8_t *_stringIproductDescriptor; 00162 void buildStringIproductDescriptor(const char* s); 00163 }; 00164 00165 #endif
Generated on Sun Jul 24 2022 03:54:20 by
1.7.2
