1 /* Copyright (c) 2010-2011 mbed.org, MIT License
3 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
4 * and associated documentation files (the "Software"), to deal in the Software without
5 * restriction, including without limitation the rights to use, copy, modify, merge, publish,
6 * distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
7 * Software is furnished to do so, subject to the following conditions:
9 * The above copyright notice and this permission notice shall be included in all copies or
10 * substantial portions of the Software.
12 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
13 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
14 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
15 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
16 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 /* These headers are included for child class. */
23 #include "USBEndpoints.h"
24 #include "USBDescriptor.h"
25 #include "USBDevice_Types.h"
27 #include "USBDevice.h"
31 class USBCDC
: public USBDevice
{
37 * @param vendor_id Your vendor_id
38 * @param product_id Your product_id
39 * @param product_release Your preoduct_release
41 USBCDC(uint16_t vendor_id
, uint16_t product_id
, uint16_t product_release
);
46 * Get device descriptor. Warning: this method has to store the length of the report descriptor in reportLength.
48 * @returns pointer to the device descriptor
50 virtual uint8_t * deviceDesc();
53 * Get string product descriptor
55 * @returns pointer to the string product descriptor
57 virtual uint8_t * stringIproductDesc();
60 * Get string interface descriptor
62 * @returns pointer to the string interface descriptor
64 virtual uint8_t * stringIinterfaceDesc();
67 * Get configuration descriptor
69 * @returns pointer to the configuration descriptor
71 virtual uint8_t * configurationDesc();
76 * @param endpoint endpoint which will be sent the buffer
77 * @param buffer buffer to be sent
78 * @param size length of the buffer
79 * @returns true if successful
81 bool send(uint8_t * buffer
, uint16_t size
);
84 * Read a buffer from a certain endpoint. Warning: blocking
86 * @param endpoint endpoint to read
87 * @param buffer buffer where will be stored bytes
88 * @param size the number of bytes read will be stored in *size
89 * @param maxSize the maximum length that can be read
90 * @returns true if successful
92 bool readEP(uint8_t * buffer
, uint16_t * size
);
95 * Read a buffer from a certain endpoint. Warning: non blocking
97 * @param endpoint endpoint to read
98 * @param buffer buffer where will be stored bytes
99 * @param size the number of bytes read will be stored in *size
100 * @param maxSize the maximum length that can be read
101 * @returns true if successful
103 bool readEP_NB(uint8_t * buffer
, uint16_t * size
);
105 virtual bool USBCallback_request();
106 virtual bool USBCallback_setConfiguration(uint8_t configuration
);