]> git.gir.st - tmk_keyboard.git/blob - tmk_core/tool/mbed/mbed-sdk/libraries/USBDevice/USBSerial/USBCDC.h
Merge commit '1fe4406f374291ab2e86e95a97341fd9c475fcb8'
[tmk_keyboard.git] / tmk_core / tool / mbed / mbed-sdk / libraries / 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 class USBCDC: public USBDevice {
30 public:
31
32 /*
33 * Constructor
34 *
35 * @param vendor_id Your vendor_id
36 * @param product_id Your product_id
37 * @param product_release Your preoduct_release
38 * @param connect_blocking define if the connection must be blocked if USB not plugged in
39 */
40 USBCDC(uint16_t vendor_id, uint16_t product_id, uint16_t product_release, bool connect_blocking);
41
42 protected:
43
44 /*
45 * Get device descriptor. Warning: this method has to store the length of the report descriptor in reportLength.
46 *
47 * @returns pointer to the device descriptor
48 */
49 virtual uint8_t * deviceDesc();
50
51 /*
52 * Get string product descriptor
53 *
54 * @returns pointer to the string product descriptor
55 */
56 virtual uint8_t * stringIproductDesc();
57
58 /*
59 * Get string interface descriptor
60 *
61 * @returns pointer to the string interface descriptor
62 */
63 virtual uint8_t * stringIinterfaceDesc();
64
65 /*
66 * Get configuration descriptor
67 *
68 * @returns pointer to the configuration descriptor
69 */
70 virtual uint8_t * configurationDesc();
71
72 /*
73 * Send a buffer
74 *
75 * @param endpoint endpoint which will be sent the buffer
76 * @param buffer buffer to be sent
77 * @param size length of the buffer
78 * @returns true if successful
79 */
80 bool send(uint8_t * buffer, uint32_t size);
81
82 /*
83 * Read a buffer from a certain endpoint. Warning: blocking
84 *
85 * @param endpoint endpoint to read
86 * @param buffer buffer where will be stored bytes
87 * @param size the number of bytes read will be stored in *size
88 * @param maxSize the maximum length that can be read
89 * @returns true if successful
90 */
91 bool readEP(uint8_t * buffer, uint32_t * size);
92
93 /*
94 * Read a buffer from a certain endpoint. Warning: non blocking
95 *
96 * @param endpoint endpoint to read
97 * @param buffer buffer where will be stored bytes
98 * @param size the number of bytes read will be stored in *size
99 * @param maxSize the maximum length that can be read
100 * @returns true if successful
101 */
102 bool readEP_NB(uint8_t * buffer, uint32_t * size);
103
104 /*
105 * Called by USBCallback_requestCompleted when CDC line coding is changed
106 * Warning: Called in ISR
107 *
108 * @param baud The baud rate
109 * @param bits The number of bits in a word (5-8)
110 * @param parity The parity
111 * @param stop The number of stop bits (1 or 2)
112 */
113 virtual void lineCodingChanged(int baud, int bits, int parity, int stop) {};
114
115 protected:
116 virtual bool USBCallback_request();
117 virtual void USBCallback_requestCompleted(uint8_t *buf, uint32_t length);
118 virtual bool USBCallback_setConfiguration(uint8_t configuration);
119 volatile bool terminal_connected;
120
121 };
122
123 #endif
Imprint / Impressum