device.h
1.46 KB
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
#ifndef _device_h_
#define _device_h_ 1
#ifdef USB_DEBUG
#ifndef PRINTF
extern int dramPrintf(const char *fmt, ...);
extern void drambufswitch(int);
#define PRINTF dramPrintf
#define printf dramPrintf
#endif
#else
#define printf(format, args...)
#define PRINTF(format, args...)
#define drambufswitch(i)
#endif /* !USB_DEBUG */
/* USB 1.1 Setup Packet */
typedef struct setup_struct {
uint_8 REQUESTTYPE;
uint_8 REQUEST;
uint_16 VALUE;
uint_16 INDEX;
uint_16 LENGTH;
} SETUP_STRUCT, _PTR_ SETUP_STRUCT_PTR;
/*
* Device specific functions provided by slave USB drivers
*/
struct usbdevfuncs {
void (*reset_ep0)(_usb_device_handle,boolean,uint_8,uint_8_ptr,uint_32);
void (*get_desc)(_usb_device_handle,boolean,SETUP_STRUCT_PTR);
void (*vendor)(_usb_device_handle,boolean,SETUP_STRUCT_PTR);
void (*initeps)(_usb_device_handle);
void (*query)(OSBbUsbInfo *);
void (*stall_ep)(_usb_device_handle, uint_8, boolean);
};
/*
* Generic device state
*/
typedef struct dev_global_struct_s {
uint_8 dev_state;
uint_8 FIRST_SOF;
uint_8 num_ifcs;
struct usbdevfuncs *funcs;
} DEV_GLOBAL_STRUCT, _PTR_ DEV_GLOBAL_STRUCT_PTR;
extern DEV_GLOBAL_STRUCT dev_global_struct;
#define USB_DEV_STATE_INIT 0
#define USB_DEV_STATE_RESET 1
#define USB_DEV_STATE_ATTACHED 2
#ifdef __cplusplus
extern "C" {
#endif
extern void dev_bus_suspend(_usb_device_handle, boolean, uint_8, uint_8_ptr, uint_32);
#ifdef __cplusplus
}
#endif
#endif /* _device_h_ */