-
Notifications
You must be signed in to change notification settings - Fork 52
/
usbcore.h
68 lines (53 loc) · 1.01 KB
/
usbcore.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#ifndef _USBCORE_H
#define _USBCORE_H
#ifdef __cplusplus
extern "C"
{
#endif
#include <stdint.h>
// standard requests
typedef enum
{
REQ_GET_STATUS = 0,
REQ_CLEAR_FEATURE = 1,
REQ_SET_FEATURE = 3,
REQ_SET_ADDRESS = 5,
REQ_GET_DESCRIPTOR = 6,
REQ_SET_DESCRIPTOR = 7,
REQ_GET_CONFIGURATION = 8,
REQ_SET_CONFIGURATION = 9,
} USB_REQUEST;
#define DATA_DIRECTION_HOST_TO_DEVICE 0
#define DATA_DIRECTION_DEVICE_TO_HOST 1
typedef struct
__attribute__ ((packed))
{
union {
struct {
uint8_t bmRequestType_Recipient:5;
uint8_t bmRequestType_Type:2;
uint8_t bmRequestType_Data_Transfer_Direction:1;
};
uint8_t bmRequestType;
};
uint8_t bRequest;
uint16_t wValue;
uint16_t wIndex;
uint16_t wLength;
} SETUP_PACKET;
typedef struct
{
void *buffer;
int bufferlen;
uint8_t zlp;
uint8_t complete;
SETUP_PACKET setup;
} CONTROL_TRANSFER;
void usb_provideDescriptors(void *d);
void EP0setup(void);
void EP0in(void);
void EP0out(void);
#ifdef __cplusplus
}
#endif
#endif /* _USBCORE_H */