📄 chap_9.c
字号:
/********************************************************************
COPYRIGHT (c) 2007 BY ROCK-CHIP FUZHOU
-- ALL RIGHTS RESERVED --
* File Name: Chap_9.c
* Author: Oliver Miao
* Created: 2007-6-20 9:59
* Modified:
* Revision: 1.00
*
*********************************************************************
* USBTesting has the ability to test the USB core in Bus
* enumeration or in MSC bulk_only mode.
*********************************************************************
* Module History
********************
*2007-6-20 10:10 Created by Oli
*********************************************************************/
/********************************************************************
Include Files Definition
*********************************************************************/
//#define IN_CHAP
//#define CHIPIDEA
#include "usb.h"
#include "hw_memmap.h"
#include "hw_common.h"
//#include "hw_sd.h"
//#define DEBUG
/********************************************************************
Variable Definition
*********************************************************************/
extern setup_request_t SetupRequestData;
extern BOOL bIsFullSpeed; // bus connected speed status, true -> Full Speed (USB 1.1), false -> High Speed (USB 2.0)
extern UINT32 uControlDataSize; // control data need to trasmit to host
extern BOOL bRequestError; // get descriptor error flag
__align(4) UINT8 Ctr_buf[256]; //控制传输使用
__align(4) UINT8 *CtrlInBuffer ; // control in buffer
__align(4) UINT8 scUsbDscr[] =
{
/* Device Descriptor */
18, /* Descriptor length */
DEV_DSCR_TYPE, /* Descriptor type */
00, 02, /* Specification Version (BCD) */
00, /* Device class */
00, /* Device sub-class */
00, /* Device sub-sub-class */
CTL_MAX_PKT, /* Maximum packet size */
0x1b, 0x07, /* Vendor ID */ //add by lxs @2008.03.04
0x03, 0x32, /* Product ID (Sample Device) */
0x00, 0x00, /* Product version ID */
1, /* Manufacturer string index */
2, /* Product string index */
3, /* Serial number string index */
1, /* Number of configurations */
/* DeviceQualDscr */
10, /* Descriptor length */
QUAL_DSCR_TYPE, /* Descriptor type */
0x00, 0x02, /* Specification Version (BCD) */
00, /* Device class */
00, /* Device sub-class */
00, /* Device sub-sub-class */
CTL_MAX_PKT, /* Maximum packet size */
1, /* Number of configurations */
0, /* Reserved */
/* HighSpeedConfigDscr */
9, /* Descriptor length */
CFG_DSCR_TYPE, /* Descriptor type */
#if END_POINTER_NUM == 4
39, /* Total Length (LSB) */
#elif END_POINTER_NUM == 16
123, /* Total Length (LSB) */
#else
#error "****** END_POINTER_NUM is not well defined!"
#endif
0, /* Total Length (MSB) */
1, /* Number of interfaces */
1, /* Configuration number */
0, /* Configuration string */
#ifdef SUPPORT_REMOTE_WAKEUP
0xE0, /* Attributes (b7 : 1, b6 - selfpwr, b5 - with rwu) */
#else
0xC0, /* Attributes (b7 : 1, b6 - selfpwr, b5 - no rwu) */
#endif
50 , /* Power requirement (div 2 ma) */
/* Interface Descriptor */
9, /* Descriptor length */
INTF_DSCR_TYPE, /* Descriptor type */
0, /* Zero-based index of this interface */
0, /* Alternate setting */
#if END_POINTER_NUM == 4
3, /* Number of end points */
#elif END_POINTER_NUM == 16
15, /* Number of end points */
#else
#error "****** END_POINTER_NUM is not well defined!"
#endif
#ifdef USE_USBPRINT_SYS
0x07, /* Interface class: printer */
0x01, /* Interface sub class: printer */
0x02, /* Interface protocol: bidirectional */
#else /* USE BULKUSB.SYS */
0x08,//0xff,
0x06,//0x00,
0x50,//0x00,
#endif
0, /* Interface descriptor string index */
#if END_POINTER_NUM == 4
/* Endpoint Descriptor */
7, /* Descriptor length */
EDP_DSCR_TYPE, /* Descriptor type */
#ifdef CHIPIDEA
BLKOUT_ENDP_NUM_SET5, /*0x01*/
#else
BLKOUT_ENDP_NUM_SET5, /*0x0d*/
#endif
//BLKOUT_ENDP_NUM_SET5, /* Endpoint number, and direction: OUT */
2, /* Endpoint type : Bulk */
BULK_PKT_LSB, /* Maximum packet size (LSB) */
BULK_PKT_MSB, /* Max packet size (MSB) */
0x00, /* Polling interval */
/* Endpoint Descriptor */
7, /* Descriptor length */
EDP_DSCR_TYPE, /* Descriptor type */
#ifdef CHIPIDEA
BLKIN_ENDP_NUM_SET5,
#else
BLKIN_ENDP_NUM_SET5,
#endif
//BLKIN_ENDP_NUM_SET5, /* Endpoint number, and direction: IN */
2, /* Endpoint type : Bulk */
BULK_PKT_LSB, /* Maximum packet size (LSB) */
BULK_PKT_MSB, /* Max packet size (MSB) */
0x00, /* Polling interval */
/* Endpoint Descriptor */
7, /* Descriptor length */
EDP_DSCR_TYPE, /* Descriptor type */
#ifdef CHIPIDEA
INTRIN_ENDP_NUM_SET5,
#else
INTRIN_ENDP_NUM_SET5,
#endif
//INTRIN_ENDP_NUM_SET5, /* Endpoint number, and direction: IN */
3, /* Endpoint type : Interrupt */
INTRIN_PKT_LSB, /* Maximum packet size (LSB) */
INTRIN_PKT_MSB, /* Max packet size (MSB) */
0x0b, /* Polling interval */
#elif END_POINTER_NUM == 16
/* Endpoint Descriptor */
7, /* Descriptor length */
EDP_DSCR_TYPE, /* Descriptor type */
BLKOUT_ENDP_NUM_SET1, /* Endpoint number, and direction : OUT */
2, /* Endpoint type */
BULK_PKT_LSB, /* Maximum packet size (LSB) */
BULK_PKT_MSB, /* Max packet size (MSB) */
0x00, /* Polling interval */
/* Endpoint Descriptor */
7, /* Descriptor length */
EDP_DSCR_TYPE, /* Descriptor type */
BLKIN_ENDP_NUM_SET1, /* Endpoint number, and direction : IN */
2, /* Endpoint type */
BULK_PKT_LSB, /* Maximum packet size (LSB) */
BULK_PKT_MSB, /* Max packet size (MSB) */
0x00, /* Polling interval */
/* Endpoint Descriptor */
7, /* Descriptor length */
EDP_DSCR_TYPE, /* Descriptor type */
INTRIN_ENDP_NUM_SET1, /* Endpoint number, and direction : IN */
3, /* Endpoint type */
INTRIN_PKT_LSB, /* Maximum packet size (LSB) */
INTRIN_PKT_MSB, /* Max packet size (MSB) */
0x0b, /* Polling interval */
/* Endpoint Descriptor */
7, /* Descriptor length */
EDP_DSCR_TYPE, /* Descriptor type */
BLKOUT_ENDP_NUM_SET2, /* Endpoint number, and direction : OUT */
2, /* Endpoint type */
BULK_PKT_LSB, /* Maximum packet size (LSB) */
BULK_PKT_MSB, /* Max packet size (MSB) */
0x00, /* Polling interval */
/* Endpoint Descriptor */
7, /* Descriptor length */
EDP_DSCR_TYPE, /* Descriptor type */
BLKIN_ENDP_NUM_SET2, /* Endpoint number, and direction : IN */
2, /* Endpoint type */
BULK_PKT_LSB, /* Maximum packet size (LSB) */
BULK_PKT_MSB, /* Max packet size (MSB) */
0x00, /* Polling interval */
/* Endpoint Descriptor */
7, /* Descriptor length */
EDP_DSCR_TYPE, /* Descriptor type */
INTRIN_ENDP_NUM_SET2, /* Endpoint number, and direction : IN */
3, /* Endpoint type */
INTRIN_PKT_LSB, /* Maximum packet size (LSB) */
INTRIN_PKT_MSB, /* Max packet size (MSB) */
0x0b, /* Polling interval */
/* Endpoint Descriptor */
7, /* Descriptor length */
EDP_DSCR_TYPE, /* Descriptor type */
BLKOUT_ENDP_NUM_SET3, /* Endpoint number, and direction : OUT */
2, /* Endpoint type */
BULK_PKT_LSB, /* Maximum packet size (LSB) */
BULK_PKT_MSB, /* Max packet size (MSB) */
0x00, /* Polling interval */
/* Endpoint Descriptor */
7, /* Descriptor length */
EDP_DSCR_TYPE, /* Descriptor type */
BLKIN_ENDP_NUM_SET3, /* Endpoint number, and direction : IN */
2, /* Endpoint type */
BULK_PKT_LSB, /* Maximum packet size (LSB) */
BULK_PKT_MSB, /* Max packet size (MSB) */
0x00, /* Polling interval */
/* Endpoint Descriptor */
7, /* Descriptor length */
EDP_DSCR_TYPE, /* Descriptor type */
INTRIN_ENDP_NUM_SET3, /* Endpoint number, and direction : IN */
3, /* Endpoint type */
INTRIN_PKT_LSB, /* Maximum packet size (LSB) */
INTRIN_PKT_MSB, /* Max packet size (MSB) */
0x0b, /* Polling interval */
/* Endpoint Descriptor */
7, /* Descriptor length */
EDP_DSCR_TYPE, /* Descriptor type */
BLKOUT_ENDP_NUM_SET4, /* Endpoint number, and direction : OUT */
2, /* Endpoint type */
BULK_PKT_LSB, /* Maximum packet size (LSB) */
BULK_PKT_MSB, /* Max packet size (MSB) */
0x00, /* Polling interval */
/* Endpoint Descriptor */
7, /* Descriptor length */
EDP_DSCR_TYPE, /* Descriptor type */
BLKIN_ENDP_NUM_SET4, /* Endpoint number, and direction : IN */
2, /* Endpoint type */
BULK_PKT_LSB, /* Maximum packet size (LSB) */
BULK_PKT_MSB, /* Max packet size (MSB) */
0x00, /* Polling interval */
/* Endpoint Descriptor */
7, /* Descriptor length */
EDP_DSCR_TYPE, /* Descriptor type */
INTRIN_ENDP_NUM_SET4, /* Endpoint number, and direction : IN */
3, /* Endpoint type */
INTRIN_PKT_LSB, /* Maximum packet size (LSB) */
INTRIN_PKT_MSB, /* Max packet size (MSB) */
0x0b, /* Polling interval */
/* Endpoint Descriptor */
7, /* Descriptor length */
EDP_DSCR_TYPE, /* Descriptor type */
BLKOUT_ENDP_NUM_SET5, /* Endpoint number, and direction : OUT */
2, /* Endpoint type */
BULK_PKT_LSB, /* Maximum packet size (LSB) */
BULK_PKT_MSB, /* Max packet size (MSB) */
0x00, /* Polling interval */
/* Endpoint Descriptor */
7, /* Descriptor length */
EDP_DSCR_TYPE, /* Descriptor type */
BLKIN_ENDP_NUM_SET5, /* Endpoint number, and direction : IN */
2, /* Endpoint type */
BULK_PKT_LSB, /* Maximum packet size (LSB) */
BULK_PKT_MSB, /* Max packet size (MSB) */
0x00, /* Polling interval */
/* Endpoint Descriptor */
7, /* Descriptor length */
EDP_DSCR_TYPE, /* Descriptor type */
INTRIN_ENDP_NUM_SET5, /* Endpoint number, and direction : IN */
3, /* Endpoint type */
INTRIN_PKT_LSB, /* Maximum packet size (LSB) */
INTRIN_PKT_MSB, /* Max packet size (MSB) */
0x0b, /* Polling interval */
#else
#error "****** END_POINTER_NUM is not well defined!"
#endif
/* FullSpeedConfigDscr */
9, /* Descriptor length */
CFG_DSCR_TYPE, /* Descriptor type */
#if END_POINTER_NUM == 4
39, /* Total Length (LSB) */
#elif END_POINTER_NUM == 16
123, /* Total Length (LSB) */
#else
#error "****** END_POINTER_NUM is not well defined!"
#endif
0, /* Total Length (MSB) */
1, /* Number of interfaces */
1, /* Configuration number */
0, /* Configuration string */
#ifdef SUPPORT_REMOTE_WAKEUP
0xE0, /* Attributes (b7 : 1, b6 - selfpwr, b5 - with rwu) */
#else
0xC0, /* Attributes (b7 : 1, b6 - selfpwr, b5 - no rwu) */
#endif
50, /* Power requirement (div 2 ma) */
/* Interface Descriptor */
9, /* Descriptor length */
INTF_DSCR_TYPE, /* Descriptor type */
0, /* Zero-based index of this interface */
0, /* Alternate setting */
#if END_POINTER_NUM == 4
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -