new USB framework
[clinton/Smoothieware.git] / src / libs / USBDevice / USBSerial / USBCDC.h
CommitLineData
47b0bbd2
MM
1/* Copyright (c) 2010-2011 mbed.org, MIT License\r
2*\r
3* Permission is hereby granted, free of charge, to any person obtaining a copy of this software\r
4* and associated documentation files (the "Software"), to deal in the Software without\r
5* restriction, including without limitation the rights to use, copy, modify, merge, publish,\r
6* distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the\r
7* Software is furnished to do so, subject to the following conditions:\r
8*\r
9* The above copyright notice and this permission notice shall be included in all copies or\r
10* substantial portions of the Software.\r
11*\r
12* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING\r
13* BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r
14* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\r
15* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r
16* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
17*/\r
18\r
19#ifndef USBCDC_H\r
20#define USBCDC_H\r
21\r
22#include "USB.h"\r
23\r
24/* These headers are included for child class. */\r
25#include "USBEndpoints.h"\r
26#include "USBDescriptor.h"\r
27#include "USBDevice_Types.h"\r
28\r
29#include "descriptor_cdc.h"\r
30\r
31class USBCDC: public USB_Endpoint_Receiver {\r
32public:\r
33\r
34 /*\r
35 * Constructor\r
36 *\r
37 * @param vendor_id Your vendor_id\r
38 * @param product_id Your product_id\r
39 * @param product_release Your preoduct_release\r
40 */\r
41 USBCDC(USB *);\r
42\r
43protected:\r
44\r
45 /*\r
46 * Get device descriptor. Warning: this method has to store the length of the report descriptor in reportLength.\r
47 *\r
48 * @returns pointer to the device descriptor\r
49 */\r
50// virtual uint8_t * deviceDesc();\r
51\r
52 /*\r
53 * Get string product descriptor\r
54 *\r
55 * @returns pointer to the string product descriptor\r
56 */\r
57// virtual uint8_t * stringIproductDesc();\r
58\r
59 /*\r
60 * Get string interface descriptor\r
61 *\r
62 * @returns pointer to the string interface descriptor\r
63 */\r
64// virtual uint8_t * stringIinterfaceDesc();\r
65\r
66 /*\r
67 * Get configuration descriptor\r
68 *\r
69 * @returns pointer to the configuration descriptor\r
70 */\r
71// virtual uint8_t * configurationDesc();\r
72\r
73 /*\r
74 * Send a buffer\r
75 *\r
76 * @param endpoint endpoint which will be sent the buffer\r
77 * @param buffer buffer to be sent\r
78 * @param size length of the buffer\r
79 * @returns true if successful\r
80 */\r
81 bool send(uint8_t * buffer, uint32_t size);\r
82\r
83 /*\r
84 * Read a buffer from a certain endpoint. Warning: blocking\r
85 *\r
86 * @param endpoint endpoint to read\r
87 * @param buffer buffer where will be stored bytes\r
88 * @param size the number of bytes read will be stored in *size\r
89 * @param maxSize the maximum length that can be read\r
90 * @returns true if successful\r
91 */\r
92 bool readEP(uint8_t * buffer, uint32_t * size);\r
93\r
94 /*\r
95 * Read a buffer from a certain endpoint. Warning: non blocking\r
96 *\r
97 * @param endpoint endpoint to read\r
98 * @param buffer buffer where will be stored bytes\r
99 * @param size the number of bytes read will be stored in *size\r
100 * @param maxSize the maximum length that can be read\r
101 * @returns true if successful\r
102 */\r
103 bool readEP_NB(uint8_t * buffer, uint32_t * size);\r
104\r
105// virtual bool USBCallback_request(CONTROL_TRANSFER *);\r
106// virtual bool USBCallback_setConfiguration(uint8_t configuration);\r
107\r
108// virtual bool EpCallback(uint8_t, uint8_t);\r
109// virtual bool USB_Setup_Callback(CONTROL_TRANSFER *);\r
110\r
111 virtual bool USBEvent_Request(CONTROL_TRANSFER&);\r
112 virtual bool USBEvent_RequestComplete(CONTROL_TRANSFER&, uint8_t*, uint32_t);\r
113\r
114// virtual bool USBEvent_EPIn(uint8_t, uint8_t) = 0;\r
115// virtual bool USBEvent_EPOut(uint8_t, uint8_t)= 0;\r
116\r
117\r
118 USB *usb;\r
119\r
120 // USB Descriptors\r
121 usbdesc_interface CDC_if;\r
122 usbcdc_header CDC_header;\r
123 usbcdc_callmgmt CDC_callmgmt;\r
124 usbcdc_acm CDC_acm;\r
125 usbcdc_union CDC_union;\r
126\r
127 usbdesc_interface CDC_slaveif;\r
128\r
129 usbdesc_endpoint CDC_intep;\r
130 usbdesc_endpoint CDC_BulkIn;\r
131 usbdesc_endpoint CDC_BulkOut;\r
132};\r
133\r
134#endif\r