openpcd/firmware/src/os/pcd_enumerate.h @ master
1 |
#ifndef _OPCD_USB_H
|
---|---|
2 |
#define _OPCD_USB_H
|
3 |
|
4 |
#include <lib_AT91SAM7.h>
|
5 |
#include <sys/types.h>
|
6 |
#include <asm/atomic.h>
|
7 |
#include "openpcd.h"
|
8 |
#include <dfu/dfu.h>
|
9 |
|
10 |
#define AT91C_EP_OUT 1
|
11 |
#define AT91C_EP_OUT_SIZE 0x40
|
12 |
#define AT91C_EP_IN 2
|
13 |
#define AT91C_EP_IN_SIZE 0x40
|
14 |
#define AT91C_EP_INT 3
|
15 |
|
16 |
|
17 |
struct req_ctx; |
18 |
|
19 |
extern void udp_open(void); |
20 |
extern int udp_refill_ep(int ep); |
21 |
extern void udp_unthrottle(void); |
22 |
extern void udp_reset(void); |
23 |
|
24 |
extern void udp_pullup_off(void); |
25 |
extern void udp_pullup_on(void); |
26 |
|
27 |
struct ep_ctx { |
28 |
atomic_t pkts_in_transit; |
29 |
struct { |
30 |
struct req_ctx *rctx; |
31 |
unsigned int bytes_sent; |
32 |
} incomplete; |
33 |
};
|
34 |
|
35 |
struct udp_pcd { |
36 |
AT91PS_UDP pUdp; |
37 |
enum usb_device_state state; |
38 |
unsigned char cur_config; |
39 |
unsigned char cur_interface; |
40 |
unsigned char cur_altsett; |
41 |
unsigned int cur_rcv_bank; |
42 |
struct ep_ctx ep[4]; |
43 |
};
|
44 |
|
45 |
/* USB standard request code */
|
46 |
|
47 |
#define STD_GET_STATUS_ZERO 0x0080
|
48 |
#define STD_GET_STATUS_INTERFACE 0x0081
|
49 |
#define STD_GET_STATUS_ENDPOINT 0x0082
|
50 |
|
51 |
#define STD_CLEAR_FEATURE_ZERO 0x0100
|
52 |
#define STD_CLEAR_FEATURE_INTERFACE 0x0101
|
53 |
#define STD_CLEAR_FEATURE_ENDPOINT 0x0102
|
54 |
|
55 |
#define STD_SET_FEATURE_ZERO 0x0300
|
56 |
#define STD_SET_FEATURE_INTERFACE 0x0301
|
57 |
#define STD_SET_FEATURE_ENDPOINT 0x0302
|
58 |
|
59 |
#define STD_SET_ADDRESS 0x0500
|
60 |
#define STD_GET_DESCRIPTOR 0x0680
|
61 |
#define STD_SET_DESCRIPTOR 0x0700
|
62 |
#define STD_GET_CONFIGURATION 0x0880
|
63 |
#define STD_SET_CONFIGURATION 0x0900
|
64 |
#define STD_GET_INTERFACE 0x0A81
|
65 |
#define STD_SET_INTERFACE 0x0B01
|
66 |
#define STD_SYNCH_FRAME 0x0C82
|
67 |
|
68 |
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
|
69 |
|
70 |
|
71 |
#endif
|
72 |
|