1
+ /*
2
+ USBAPI.h
3
+ Copyright (c) 2005-2014 Arduino. All right reserved.
4
+
5
+ This library is free software; you can redistribute it and/or
6
+ modify it under the terms of the GNU Lesser General Public
7
+ License as published by the Free Software Foundation; either
8
+ version 2.1 of the License, or (at your option) any later version.
9
+
10
+ This library is distributed in the hope that it will be useful,
11
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
+ Lesser General Public License for more details.
14
+
15
+ You should have received a copy of the GNU Lesser General Public
16
+ License along with this library; if not, write to the Free Software
17
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18
+ */
19
+
20
+ #ifndef __USBAPI__
21
+ #define __USBAPI__
22
+
23
+ #include < stdint.h>
24
+
25
+ class USBDevice_
26
+ {
27
+ public:
28
+ USBDevice_ ();
29
+ bool configured ();
30
+
31
+ void attach ();
32
+ void detach (); // Serial port goes down too...
33
+ void poll ();
34
+ bool wakeupHost (); // returns false, when wakeup cannot be processed
35
+ };
36
+ extern USBDevice_ USBDevice;
37
+
38
+ // ================================================================================
39
+ // ================================================================================
40
+ // Low level API
41
+
42
+ typedef struct __attribute__ ((packed))
43
+ {
44
+ uint8_t bmRequestType;
45
+ uint8_t bRequest;
46
+ uint8_t wValueL;
47
+ uint8_t wValueH;
48
+ uint16_t wIndex;
49
+ uint16_t wLength;
50
+ } USBSetup;
51
+
52
+ // ================================================================================
53
+ // ================================================================================
54
+
55
+ #define TRANSFER_PGM 0x80
56
+ #define TRANSFER_RELEASE 0x40
57
+ #define TRANSFER_ZERO 0x20
58
+
59
+ int USB_SendControl (uint8_t flags, const void * d, int len);
60
+ int USB_RecvControl (void * d, int len);
61
+ int USB_RecvControlLong (void * d, int len);
62
+
63
+ uint8_t USB_Available (uint8_t ep);
64
+ uint8_t USB_SendSpace (uint8_t ep);
65
+ int USB_Send (uint8_t ep, const void * data, int len); // blocking
66
+ int USB_Recv (uint8_t ep, void * data, int len); // non-blocking
67
+ int USB_Recv (uint8_t ep); // non-blocking
68
+ void USB_Flush (uint8_t ep);
69
+
70
+ #endif
0 commit comments