CDC/ECM driver for mbed, based on USBDevice by mbed-official. Uses PicoTCP to access Ethernet USB device. License: GPLv2
Fork of USB_Ethernet by
USBCDC_ECM.h@2:540f6e142d59, 2013-08-03 (annotated)
- Committer:
- daniele
- Date:
- Sat Aug 03 13:16:14 2013 +0000
- Revision:
- 2:540f6e142d59
- Parent:
- 1:759afa79ebe8
Moved to single package
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
daniele | 0:34c829fbc7a8 | 1 | /* Copyright (c) 2010-2011 mbed.org, MIT License |
daniele | 0:34c829fbc7a8 | 2 | * |
daniele | 0:34c829fbc7a8 | 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software |
daniele | 0:34c829fbc7a8 | 4 | * and associated documentation files (the "Software"), to deal in the Software without |
daniele | 0:34c829fbc7a8 | 5 | * restriction, including without limitation the rights to use, copy, modify, merge, publish, |
daniele | 0:34c829fbc7a8 | 6 | * distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the |
daniele | 0:34c829fbc7a8 | 7 | * Software is furnished to do so, subject to the following conditions: |
daniele | 0:34c829fbc7a8 | 8 | * |
daniele | 0:34c829fbc7a8 | 9 | * The above copyright notice and this permission notice shall be included in all copies or |
daniele | 0:34c829fbc7a8 | 10 | * substantial portions of the Software. |
daniele | 0:34c829fbc7a8 | 11 | * |
daniele | 0:34c829fbc7a8 | 12 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING |
daniele | 0:34c829fbc7a8 | 13 | * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
daniele | 0:34c829fbc7a8 | 14 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, |
daniele | 0:34c829fbc7a8 | 15 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
daniele | 0:34c829fbc7a8 | 16 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
daniele | 0:34c829fbc7a8 | 17 | */ |
daniele | 0:34c829fbc7a8 | 18 | |
daniele | 0:34c829fbc7a8 | 19 | #ifndef USBCDC_ECM_H |
daniele | 0:34c829fbc7a8 | 20 | #define USBCDC_ECM_H |
daniele | 0:34c829fbc7a8 | 21 | |
daniele | 0:34c829fbc7a8 | 22 | /* These headers are included for child class. */ |
daniele | 0:34c829fbc7a8 | 23 | #include "USBEndpoints.h" |
daniele | 0:34c829fbc7a8 | 24 | #include "USBDescriptor.h" |
daniele | 0:34c829fbc7a8 | 25 | #include "USBDevice_Types.h" |
daniele | 0:34c829fbc7a8 | 26 | |
daniele | 0:34c829fbc7a8 | 27 | #include "USBDevice.h" |
daniele | 0:34c829fbc7a8 | 28 | |
daniele | 0:34c829fbc7a8 | 29 | class USBCDC_ECM: public USBDevice { |
daniele | 0:34c829fbc7a8 | 30 | public: |
daniele | 0:34c829fbc7a8 | 31 | |
daniele | 0:34c829fbc7a8 | 32 | /* |
daniele | 0:34c829fbc7a8 | 33 | * Constructor |
daniele | 0:34c829fbc7a8 | 34 | * |
daniele | 0:34c829fbc7a8 | 35 | * @param vendor_id Your vendor_id |
daniele | 0:34c829fbc7a8 | 36 | * @param product_id Your product_id |
daniele | 0:34c829fbc7a8 | 37 | * @param product_release Your preoduct_release |
daniele | 0:34c829fbc7a8 | 38 | */ |
daniele | 0:34c829fbc7a8 | 39 | USBCDC_ECM(uint16_t vendor_id, uint16_t product_id, uint16_t product_release); |
daniele | 0:34c829fbc7a8 | 40 | |
daniele | 0:34c829fbc7a8 | 41 | protected: |
daniele | 0:34c829fbc7a8 | 42 | |
daniele | 0:34c829fbc7a8 | 43 | /* |
daniele | 0:34c829fbc7a8 | 44 | * Get device descriptor. Warning: this method has to store the length of the report descriptor in reportLength. |
daniele | 0:34c829fbc7a8 | 45 | * |
daniele | 0:34c829fbc7a8 | 46 | * @returns pointer to the device descriptor |
daniele | 0:34c829fbc7a8 | 47 | */ |
daniele | 0:34c829fbc7a8 | 48 | virtual uint8_t * deviceDesc(); |
daniele | 0:34c829fbc7a8 | 49 | |
daniele | 0:34c829fbc7a8 | 50 | /* |
daniele | 0:34c829fbc7a8 | 51 | * Get string product descriptor |
daniele | 0:34c829fbc7a8 | 52 | * |
daniele | 0:34c829fbc7a8 | 53 | * @returns pointer to the string product descriptor |
daniele | 0:34c829fbc7a8 | 54 | */ |
daniele | 0:34c829fbc7a8 | 55 | virtual uint8_t * stringIproductDesc(); |
daniele | 0:34c829fbc7a8 | 56 | |
daniele | 0:34c829fbc7a8 | 57 | /* |
daniele | 0:34c829fbc7a8 | 58 | * Get string interface descriptor |
daniele | 0:34c829fbc7a8 | 59 | * |
daniele | 0:34c829fbc7a8 | 60 | * @returns pointer to the string interface descriptor |
daniele | 0:34c829fbc7a8 | 61 | */ |
daniele | 0:34c829fbc7a8 | 62 | virtual uint8_t * stringIinterfaceDesc(); |
daniele | 0:34c829fbc7a8 | 63 | |
daniele | 0:34c829fbc7a8 | 64 | /* |
daniele | 0:34c829fbc7a8 | 65 | */ |
daniele | 0:34c829fbc7a8 | 66 | virtual bool USBCallback_setInterface(uint16_t interface, uint8_t alternate); |
daniele | 0:34c829fbc7a8 | 67 | |
daniele | 0:34c829fbc7a8 | 68 | /* Thing. |
daniele | 0:34c829fbc7a8 | 69 | * @returns the mac address location. |
daniele | 0:34c829fbc7a8 | 70 | */ |
daniele | 0:34c829fbc7a8 | 71 | virtual uint8_t * stringIserialDesc(); |
daniele | 0:34c829fbc7a8 | 72 | virtual uint8_t * stringIConfigurationDesc(); |
daniele | 0:34c829fbc7a8 | 73 | |
daniele | 0:34c829fbc7a8 | 74 | /* |
daniele | 0:34c829fbc7a8 | 75 | * Get configuration descriptor |
daniele | 0:34c829fbc7a8 | 76 | * |
daniele | 0:34c829fbc7a8 | 77 | * @returns pointer to the configuration descriptor |
daniele | 0:34c829fbc7a8 | 78 | */ |
daniele | 0:34c829fbc7a8 | 79 | virtual uint8_t * configurationDesc(); |
daniele | 0:34c829fbc7a8 | 80 | |
daniele | 1:759afa79ebe8 | 81 | public: |
daniele | 0:34c829fbc7a8 | 82 | /* |
daniele | 0:34c829fbc7a8 | 83 | * Send a buffer |
daniele | 0:34c829fbc7a8 | 84 | * |
daniele | 0:34c829fbc7a8 | 85 | * @param endpoint endpoint which will be sent the buffer |
daniele | 0:34c829fbc7a8 | 86 | * @param buffer buffer to be sent |
daniele | 0:34c829fbc7a8 | 87 | * @param size length of the buffer |
daniele | 0:34c829fbc7a8 | 88 | * @returns true if successful |
daniele | 0:34c829fbc7a8 | 89 | */ |
daniele | 0:34c829fbc7a8 | 90 | bool send(uint8_t * buffer, uint32_t size); |
daniele | 1:759afa79ebe8 | 91 | |
daniele | 0:34c829fbc7a8 | 92 | /* |
daniele | 0:34c829fbc7a8 | 93 | * Read a buffer from a certain endpoint. Warning: blocking |
daniele | 0:34c829fbc7a8 | 94 | * |
daniele | 0:34c829fbc7a8 | 95 | * @param endpoint endpoint to read |
daniele | 0:34c829fbc7a8 | 96 | * @param buffer buffer where will be stored bytes |
daniele | 0:34c829fbc7a8 | 97 | * @param size the number of bytes read will be stored in *size |
daniele | 0:34c829fbc7a8 | 98 | * @param maxSize the maximum length that can be read |
daniele | 0:34c829fbc7a8 | 99 | * @returns true if successful |
daniele | 0:34c829fbc7a8 | 100 | */ |
daniele | 0:34c829fbc7a8 | 101 | bool readEP(uint8_t * buffer, uint32_t * size); |
daniele | 0:34c829fbc7a8 | 102 | |
daniele | 0:34c829fbc7a8 | 103 | /* |
daniele | 0:34c829fbc7a8 | 104 | * Read a buffer from a certain endpoint. Warning: non blocking |
daniele | 0:34c829fbc7a8 | 105 | * |
daniele | 0:34c829fbc7a8 | 106 | * @param endpoint endpoint to read |
daniele | 0:34c829fbc7a8 | 107 | * @param buffer buffer where will be stored bytes |
daniele | 0:34c829fbc7a8 | 108 | * @param size the number of bytes read will be stored in *size |
daniele | 0:34c829fbc7a8 | 109 | * @param maxSize the maximum length that can be read |
daniele | 0:34c829fbc7a8 | 110 | * @returns true if successful |
daniele | 0:34c829fbc7a8 | 111 | */ |
daniele | 0:34c829fbc7a8 | 112 | bool readEP_NB(uint8_t * buffer, uint32_t * size); |
daniele | 0:34c829fbc7a8 | 113 | |
daniele | 0:34c829fbc7a8 | 114 | protected: |
daniele | 0:34c829fbc7a8 | 115 | virtual bool USBCallback_request(); |
daniele | 0:34c829fbc7a8 | 116 | virtual bool USBCallback_setConfiguration(uint8_t configuration); |
daniele | 0:34c829fbc7a8 | 117 | volatile bool terminal_connected; |
daniele | 1:759afa79ebe8 | 118 | |
daniele | 0:34c829fbc7a8 | 119 | |
daniele | 0:34c829fbc7a8 | 120 | }; |
daniele | 0:34c829fbc7a8 | 121 | |
daniele | 0:34c829fbc7a8 | 122 | #endif |