📄 usbpriv.h
字号:
USB_REGISTER USB_FRINDEX; /* Frame index */
USB_REGISTER CTRLDSSEGMENT; /* 4G segment selector */
USB_REGISTER DEVICE_ADDR; /* Device Address */
USB_REGISTER EP_LIST_ADDR; /* Endpoint List Address */
USB_REGISTER RESERVED0[9];
USB_REGISTER CONFIG_FLAG; /* Configured Flag register */
USB_REGISTER PORTSCX[8]; /* Port Status/Control x, x = 1..8 */
USB_REGISTER RESERVED1;
USB_REGISTER USB_MODE; /* USB Device mode */
USB_REGISTER ENDPT_SETUP_STAT; /* Endpoint Setup Status */
USB_REGISTER ENDPTPRIME; /* Endpoint Initialize */
USB_REGISTER ENDPTFLUSH; /* Endpoint De-initialize */
USB_REGISTER ENDPTSTATUS; /* Endpoint Status */
USB_REGISTER ENDPTCOMPLETE; /* Endpoint Interrupt On Complete */
USB_REGISTER ENDPTCTRLX[16]; /* Endpoint Control, where x = 0.. 15 */
} VUSB20_OPREG_STRUCT;
typedef struct {
VUSB_FIELD_TYPE MAX_PKT_LENGTH; /* Bits 16..26 Bit 15 is Interrupt
** On Setup
*/
VUSB_FIELD_TYPE CURR_DTD_PTR; /* Current dTD Pointer */
VUSB_FIELD_TYPE NEXT_DTD_PTR; /* Next dTD Pointer */
VUSB_FIELD_TYPE SIZE_IOC_INT_STS; /* Total bytes (16..30), IOC (15),
** INT (8), STS (0-7)
*/
VUSB_FIELD_TYPE BUFF_PTR0; /* Buffer pointer Page 0 (12-31) */
VUSB_FIELD_TYPE BUFF_PTR1; /* Buffer pointer Page 1 (12-31) */
VUSB_FIELD_TYPE BUFF_PTR2; /* Buffer pointer Page 2 (12-31) */
VUSB_FIELD_TYPE BUFF_PTR3; /* Buffer pointer Page 3 (12-31) */
VUSB_FIELD_TYPE BUFF_PTR4; /* Buffer pointer Page 4 (12-31) */
VUSB_FIELD_TYPE RESERVED1;
Uint8 SETUP_BUFFER[8]; /* 8 bytes of setup data that follows
** the Setup PID
*/
VUSB_FIELD_TYPE RESERVED2[4]; /* Pad to exactly 64 bytes */
} dQH_STRUCT;
typedef struct {
VUSB_FIELD_TYPE NEXT; /* Memory address of next
** dTD to be processed (5-31)
** and the T (bit 0) indicating
** pointer validity
*/
VUSB_FIELD_TYPE SIZE_IOC_STS; /* total bytes (16-30),
** IOC (15), Status (0-7)
*/
VUSB_FIELD_TYPE BUFF_PTR0; /* Buffer pointer Page 0 */
VUSB_FIELD_TYPE BUFF_PTR1; /* Buffer pointer Page 1 */
VUSB_FIELD_TYPE BUFF_PTR2; /* Buffer pointer Page 2 */
VUSB_FIELD_TYPE BUFF_PTR3; /* Buffer pointer Page 3 */
VUSB_FIELD_TYPE BUFF_PTR4; /* Buffer pointer Page 4 */
Uint16 LENGTH; /* Number of bytes to send/recv */
Uint16 PAD; /* MUST pad to exactly 32 bytes */
} dDT_STRUCT;
/* The USB Device State Structure */
typedef struct {
Uint8 SPEED; /* High Speed (1),
** Full Speed (2)
*/
Uint8 USB_CURR_CONFIG;
Uint8 DEVICE_ADDRESS;
Uint16 USB_STATE;
Uint16 USB_DEVICE_STATE;
Uint16 USB_SUSPEND;
Uint16 ERRORS;
dQH_STRUCT *EP_QUEUE_HEAD_PTR; /* Endpoint Queue
** head
*/
dDT_STRUCT *DTD_ALIGNED_BASE_PTR; /* Aligned transfer
** descriptor pool
** address
*/
dDT_STRUCT *DTD_POOL;
Boolean EP_INIT[USB_MAX_ENDPOINTS*2];
dDT_STRUCT *EP_DTD_HEADS[USB_MAX_ENDPOINTS*2];
dDT_STRUCT *EP_DTD_TAILS[USB_MAX_ENDPOINTS*2];
} USB_DEV_STATE_STRUCT;
/* USB 2.0 Setup Packet */
typedef struct setup_struct {
Uint8 REQUESTTYPE;
Uint8 REQUEST;
Uint16 VALUE;
Uint16 INDEX;
Uint16 LENGTH;
} SETUP_STRUCT;
/****************************************************************/
/* USB Configuration and Packet Size definitions: */
#define FS_CTRL_SIZE 64
#define HS_CTRL_SIZE 64
#define FS_BULK_SIZE 64
#ifndef HS_BULK_SIZE
#ifdef DEFAULT_ARBITER
#define HS_BULK_SIZE 64 /* only for test, not valid USB2.0 */
#else
#define HS_BULK_SIZE 512 /* default now 512 */
#endif
#endif
#define INT_BSIZE 8
/*
* This is a nominal limit for total number of string descriptors.
* If this value is exceeded a compile error will result with instructions
* to increase this value.
*/
#define MAX_STR_DESC_COUNT 11
/* These defines are for array sizes; can be increased if needs change */
#define CONFIG_SIZE_MAX 256
/*
* CHARISMATIC builds can selectively not include scanner or
* debug endpoints. If neither are present, then Interface 0
* will not be present and succussive interfaces are shuffled up
* to fill the slot.
*/
#ifdef CHARISMATIC
#ifdef CH_SCAN_EPS
#define SCANNER_EPS 2
#else
#define SCANNER_EPS 0
#endif
#ifdef CH_DEBUG_EPS
#define DEBUG_EPS 2
#else
#define DEBUG_EPS 0
#endif
#else
#define SCANNER_EPS 2
#define DEBUG_EPS 2
#endif
#if (SCANNER_EPS || DEBUG_EPS)
#define SCAN_DB_IFACE 0
#define PRINTER_IFACE 1
#define HID_IFACE 2
#else
#define PRINTER_IFACE 0
#define HID_IFACE 1
#endif
#ifdef MEMORY_CARD_READER
void USBMassStorage(void);
void USBConsumeWriteCard(Uint8 *buff);
#define CARD_IFACE (HID_IFACE+1)
#define MAX_IFACE CARD_IFACE
#else
#define MAX_IFACE HID_IFACE
#endif
/*
* USB Configuration structure: passes configuration initialization
* from USBConfigurationInit().
*/
typedef struct {
int MaxAltIface; /* Maximum no. of alternate interfaces */
Uint8 FSConfDesc[CONFIG_SIZE_MAX]; /* Full Speed */
Uint8 HSConfDesc[CONFIG_SIZE_MAX]; /* High Speed */
int ConfigurationSize;
const Uint8 *DevDesc; /* Device Descriptor */
const Uint8 *DevQualifierDesc;/* Device Qualifier */
/* Table of String Descriptors */
const Uint8 *StrDescTable[MAX_STR_DESC_COUNT];
int StrDescCount; /* No. of string descriptors not including
* language, illegal index or language error
* string descriptors
*/
int StrErrorIndex; /* Index of "illegal index" string desc */
int StrErrorLanguage; /* Index of language error string desc */
Uint8 *DeviceID;
Uint8 *HIDDescriptor;
Uint8 HIDDescriptor_size;
Uint8 *HIDClassReportDesc;
Uint8 HIDClassReportDesc_size;
Uint8 HIDinterface;
} USB_CONFIGURATION;
/****************************************************************/
#define EP_DIRECTION(_epx) ((_epx) & 1)
#define EP_NUM(_epx) ((_epx)>>1)
#define EP_REGBIT(_epx) (1 << (16*EP_DIRECTION(_epx) + EP_NUM(_epx)))
#define ENDPOINT_NOT_PRIMED(_epx) \
(((usb_opreg->ENDPTPRIME | usb_opreg->ENDPTSTATUS) & EP_REGBIT(_epx)) == 0)
#define ENDPOINT_PRIMED(_epx) \
((usb_opreg->ENDPTPRIME | usb_opreg->ENDPTSTATUS) & EP_REGBIT(_epx))
#define EP0_RECV (2*0 + 0) /* 0 */
#define EP0_SEND (2*0 + 1) /* 1 */
#define PRN_EP 1 /* Printer endpoint */
#define HID_EP 3 /* HID endpoint */
#define DBG_EP 7 /* Debug endpoint */
#ifdef SEA
/* SE* driver doesn't support changed endpoints yet so change off by default */
# ifndef USB_PHY_EP_FIX
# define USB_PHY_EP_FIX 1
# endif
#else
/* TI* driver OK so make change on by default */
# ifndef USB_PHY_EP_FIX
# define USB_PHY_EP_FIX 1
# endif
#endif
#if USB_PHY_EP_FIX
#define SCN_EP 6 /* Scanner endpoint */
#define MEM_EP 8 /* Memory Card endpoint */
#else
#define SCN_EP 2 /* Scanner endpoint */
#define MEM_EP 4 /* Memory Card endpoint */
#endif
/* Values for USB_ForceReset */
#define NO_RESET 0
#define RESET_SW 1
#define RESET_HW 3
/*****************************************************************************/
/*****************************************************************************/
/* ---------------------------------------------------------------- */
/* USB 2.0 intermodule API */
/* ---------------------------------------------------------------- */
/* usbch9.c: */
void USB_deconfigure_current_interface(void);
void USB_speed_change(void);
void USB_WakeUpUSB_Task(void);
/* usbd20.c: */
void USB_init(void);
void USB_ISR_io_request(Uint16, Uint8 *, Uint16);
Uint8 USB_task_io_request(Uint16, Uint8 *, Uint16);
void USB_assert_resume(void);
void USB_init_endpoint(Uint16, Uint16, Uint8, Uint8);
void USB_ISR_deinit_endpoint(Uint16);
void USB_lisr(int interruptBit);
void USB_task_process_reset(void);
void USB_shutdown(void);
void USB_ISR_set_address(Uint8);
Uint8 USB_ISR_get_endpoint_status(Uint8);
void USB_ISR_set_endpoint_status(Uint8 ep, Uint8 stall);
void USB_ISR_set_test_mode(Uint16);
/* usbconf.c */
void USBConfigurationInit(void);
/*****************************************************************************/
/* Nucleus O/S defines for stack sizes; probably belongs elsewhere */
#define HISR_STACKSIZE 400
#ifndef USBTASK_STACKSIZE
#define USBTASK_STACKSIZE 2500 /* Largest needed was 1508 bytes */
#endif
#ifndef USBTASK_PRIORITY
#define USBTASK_PRIORITY 41
#endif
#ifndef USBTASK_VBUS_PRIORITY
#define USBTASK_VBUS_PRIORITY 42
#endif
#ifndef USBTASK_CARD_PRIORITY
#define USBTASK_CARD_PRIORITY 43
#endif
#endif /* USBPRIV_INCLUDED */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -