Pico-Arduino
USBAPI.h
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 namespace arduino {
26 //================================================================================
27 //================================================================================
28 // Low level API
29 
30 typedef struct __attribute__((packed))
31 {
32  union {
33  uint8_t bmRequestType;
34  struct {
35  uint8_t direction : 5;
36  uint8_t type : 2;
37  uint8_t transferDirection : 1;
38  };
39  };
40  uint8_t bRequest;
41  uint8_t wValueL;
42  uint8_t wValueH;
43  uint16_t wIndex;
44  uint16_t wLength;
45 } USBSetup;
46 
47 }
48 
49 //================================================================================
50 // USB APIs (C scope)
51 //================================================================================
52 
53 int USB_SendControl(uint8_t flags, const void* d, int len);
54 int USB_RecvControl(void* d, int len);
55 int USB_RecvControlLong(void* d, int len);
56 
57 uint8_t USB_Available(uint8_t ep);
58 uint8_t USB_SendSpace(uint8_t ep);
59 int USB_Send(uint8_t ep, const void* data, int len); // blocking
60 int USB_Recv(uint8_t ep, void* data, int len); // non-blocking
61 int USB_Recv(uint8_t ep); // non-blocking
62 void USB_Flush(uint8_t ep);
63 
64 #endif