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.
Fork of USBDevice_STM32F103 by
WebUSBDFU.h
00001 /* 00002 * Copyright 2016 Devan Lai 00003 * 00004 * Licensed under the Apache License, Version 2.0 (the "License"); 00005 * you may not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http://www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an "AS IS" BASIS, 00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 */ 00016 00017 #ifndef WEB_USB_DFU_H 00018 #define WEB_USB_DFU_H 00019 00020 #include "WebUSBDevice.h" 00021 00022 class WebUSBDFU : public WebUSBDevice { 00023 public: 00024 /** 00025 * Constructor 00026 * 00027 * @param vendor_id Your vendor_id 00028 * @param product_id Your product_id 00029 * @param product_release Your product_release 00030 * @param connect Connect the device 00031 */ 00032 WebUSBDFU(uint16_t vendor_id = 0x1234, uint16_t product_id = 0x0006, uint16_t product_release = 0x0001, bool connect = true); 00033 00034 /** 00035 * Attach a callback called when a DFU detach request is received 00036 * 00037 * @param tptr pointer to the object to call the member function on 00038 * @param mptr pointer to the member function to be called 00039 */ 00040 template<typename T> 00041 void attach(T* tptr, void (T::*mptr)(void)) { 00042 if((mptr != NULL) && (tptr != NULL)) { 00043 detach.attach(tptr, mptr); 00044 } 00045 } 00046 00047 /** 00048 * Attach a callback called when a DFU detach request is received 00049 * 00050 * @param func function pointer 00051 */ 00052 void attach(Callback<void()> func); 00053 00054 protected: 00055 /* 00056 * Get string product descriptor 00057 * 00058 * @returns pointer to the string product descriptor 00059 */ 00060 virtual uint8_t * stringIproductDesc(); 00061 00062 /* 00063 * Get string interface descriptor 00064 * 00065 * @returns pointer to the string interface descriptor 00066 */ 00067 virtual uint8_t * stringIinterfaceDesc(); 00068 00069 /* 00070 * Get configuration descriptor 00071 * 00072 * @returns pointer to the configuration descriptor 00073 */ 00074 virtual uint8_t * configurationDesc(); 00075 00076 /* 00077 * Called by USBDevice on Endpoint0 request. Warning: Called in ISR context 00078 * This is used to handle extensions to standard requests 00079 * and class specific requests 00080 * 00081 * @returns true if class handles this request 00082 */ 00083 virtual bool USBCallback_request(); 00084 00085 /* 00086 * Called by USBDevice layer. Set configuration of the device. 00087 * For instance, you can add all endpoints that you need on this function. 00088 * 00089 * @param configuration Number of the configuration 00090 * @returns true if class handles this request 00091 */ 00092 virtual bool USBCallback_setConfiguration(uint8_t configuration); 00093 00094 /* 00095 * Get the WebUSB allowed origin descriptor 00096 * 00097 * @returns pointer to the WebUSB allowed origin descriptor 00098 */ 00099 virtual uint8_t * allowedOriginsDesc(); 00100 00101 /* 00102 * Get WebUSB landing page URL descriptor 00103 * 00104 * @returns pointer to the landing page URL descriptor 00105 */ 00106 virtual uint8_t * urlIlandingPage(); 00107 00108 /* 00109 * Get WebUSB allowed origin URL descriptor 00110 * 00111 * @returns pointer to the allowed origin URL descriptor 00112 */ 00113 virtual uint8_t * urlIallowedOrigin(); 00114 00115 private: 00116 Callback<void()> detach; 00117 00118 static void no_op() {}; 00119 }; 00120 00121 #endif
Generated on Thu Jul 14 2022 08:46:29 by
1.7.2
