device.h 1.46 KB
#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_ */