cleanup before merging
[clinton/Smoothieware.git] / gcc4mbed / samples / MSTest / USBDevice / USBSERIAL / USBCDC.h
1 /* Copyright (c) 2010-2011 mbed.org, MIT License
2 *
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:
8 *
9 * The above copyright notice and this permission notice shall be included in all copies or
10 * substantial portions of the Software.
11 *
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.
17 */
18
19 #ifndef USBCDC_H
20 #define USBCDC_H
21
22 /* These headers are included for child class. */
23 #include "USBEndpoints.h"
24 #include "USBDescriptor.h"
25 #include "USBDevice_Types.h"
26
27 #include "USBDevice.h"
28
29
30
31 class USBCDC: public USBDevice {
32 public:
33
34 /*
35 * Constructor
36 *
37 * @param vendor_id Your vendor_id
38 * @param product_id Your product_id
39 * @param product_release Your preoduct_release
40 */
41 USBCDC(uint16_t vendor_id, uint16_t product_id, uint16_t product_release);
42
43 protected:
44
45 /*
46 * Get device descriptor. Warning: this method has to store the length of the report descriptor in reportLength.
47 *
48 * @returns pointer to the device descriptor
49 */
50 virtual uint8_t * deviceDesc();
51
52 /*
53 * Get string product descriptor
54 *
55 * @returns pointer to the string product descriptor
56 */
57 virtual uint8_t * stringIproductDesc();
58
59 /*
60 * Get string interface descriptor
61 *
62 * @returns pointer to the string interface descriptor
63 */
64 virtual uint8_t * stringIinterfaceDesc();
65
66 /*
67 * Get configuration descriptor
68 *
69 * @returns pointer to the configuration descriptor
70 */
71 virtual uint8_t * configurationDesc();
72
73 /*
74 * Send a buffer
75 *
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
80 */
81 bool send(uint8_t * buffer, uint16_t size);
82
83 /*
84 * Read a buffer from a certain endpoint. Warning: blocking
85 *
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
91 */
92 bool readEP(uint8_t * buffer, uint16_t * size);
93
94 /*
95 * Read a buffer from a certain endpoint. Warning: non blocking
96 *
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
102 */
103 bool readEP_NB(uint8_t * buffer, uint16_t * size);
104
105 virtual bool USBCallback_request();
106 virtual bool USBCallback_setConfiguration(uint8_t configuration);
107
108 };
109
110 #endif