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