📄 gfd_usb_irq.h
字号:
/**************************************************************************************
*
* (c) 2004 ASIC,all rights reserved
*
*
* This source code and any compilation or derivative thereof
*is proprietary information and is confidential in nature.
* Under no circumstance is this software to be exposed or placed
*under an open source License of any type without expressed
*written permission of ASIC.
*
*filename: HA_usbirq.h
*history:
*
* Version Date Author Comments
*------------------------------------------------------------------------------------
* 1.0 2004.9.24 lmq Initial Creation
* 1.1 2005.3.24 xl make all global var in a USBDevice struct including USBStat,USBTrans
CtrlTrans ,BulkStat,CBW,BulkData,CSW 7 sub-structs.
**************************************************************************************/
#ifndef __HA_usbirq_h__
#define __HA_usbirq_h__
#include "HA_TypeDef.h"
//**********************************************************************************************************
// D E F I N E S
//**********************************************************************************************************
#ifndef GFD_USB
#define GFD_USB
#define UDISK
#define CHAN1
#ifdef CHAN1
#define CHAN 1
#define DMACCConfiguration DMACC1Configuration
#endif
#ifdef CHAN0
#define CHAN 0
#define DMACCConfiguration DMACC0Configuration
#endif
#ifdef CHAN2
#define CHAN 2
#define DMACCConfiguration DMACC2Configuration
#endif
#ifdef CHAN3
#define CHAN 3
#define DMACCConfiguration DMACC3Configuration
#endif
#ifdef CHAN4
#define CHAN 4
#define DMACCConfiguration DMACC4Configuration
#endif
#ifdef CHAN5
#define CHAN 5
#define DMACCConfiguration DMACC5Configuration
#endif
#define USBRAMDISK
//
// 端点0 bmRequestType寄存器
//
#define descty 0x1f
#define reqty 0x60
/* 读写成功标志*/
#define write_success 0x80000000
#define read_success 0x40000000
/*USB 中断类型*/
#define irq_none 0x00
#define irq_setup 0x80
#define irq_in 0x40
#define irq_out 0x20
#define irq_ping 0x10
#define irq_error 0x08
#define irq_ack 0x04
#define irq_stat_ov 0x02
#define irq_ctrl_err 0x01
/* 厂商和厂品ID 描述*/
#define gfd_vendor_id 0x04CC //0x6680
#define gfd_product_id 0x1A62 // 0x0100
#define gfd_product_string { 60,3, \
'1',0, '3',0, '6',0, '2',0, '-',0, 'O',0, 'T',0, 'G',0, ' ',0, \
'M',0, 'A',0, 'S',0, 'S',0, ' ',0, \
'S',0, 't',0, 'o',0, 'r',0, 'a',0, 'g',0, 'e',0, ' ',0, \
'P',0, 'C',0, 'I',0, \
' ',0, 'K',0, 'i',0, 't',0 }
#define LENGH 4/* 传输BUFFER 的大小为 LENGH*512 BYTE*/
/*长短批传输标志*/
#define LONGBLK 0
#define SHORTBLK 1
#define UNSINGLE 0
#define SINGLE 1
//
//USB状态标志
//
#define USBDEF 0
#define USBAD 1
#define USBCG 2
//
//批传输方向标志
//
#define BULKIN 0
#define BULKOUT 1
//
//批传输状态标志
//
#define BLKCMD 0
#define BLKPRO 1
#define BLKEND 2
//
//USB 设置标志
//
#define NSETCONFIG 0
#define SETCONFIG 1
//
//空包标志
//
#define NEMPTY 0
#define EMPTY 1
//
//
//长短包标志
//
#define LONGPKSTATE 0
#define SHORTPK 1
//
//控制传输状态标志
//
#define STALLINIT 0
#define STALLSET 1
#define NOSPINIT 0
#define NOSPSET 1
//
//端点标识
//
#define EPCL 0
#define EPBULK 1
//
//批传输状态标识
//
#define BULKOUTSTAT 0
#define BULKINSTAT 1
#define BULKACKSTAT 2
#define BULKINDO 0
#define BULKINEND 1
#define TRANSBG 0
#define TRANSEND 1
//
//USB 中断位标志
//
#define SETUP 0x01
#define IN 0x02
#define OUT 0x04
#define PING 0x08
#define TRAERR 0x10
#define ACK 0x20
#define STCOV 0x40
#define CTRAERR 0x80
#define RESET 0x200
#define SUSPEND 0x100
//
//端点寄存器标志
//
#define ep0out 0x00
#define ep0in 0x01
#define ep1out 0x02
#define ep1in 0x03
#define ep2out 0x04
#define ep2in 0x05
#define Trt 0x00d000c8
#define Uplop 0X1f0f
//
//
//USB 协议宏定义
//
#define NAPP 0
#define APP 1
/*
* SI
*/
#define SI 0
#define UNSI 1
//
//
//控制传输请求
//
#define STANDARD_REQUEST 0x00
#define CLASS_REQUEST 0x20
#define VENDOR_REQUEST 0x40
//
// bRequest
//
#define CLEAR_FEATURE 0X01
#define GET_CONFIGURATION 0X08
#define GET_DESCRIPTOR 0X06
#define GET_INTERFACE 0X0A
#define GET_STATUS 0X00
#define SET_ADDRESS 0X05
#define SET_CONFIGURATION 0X09
#define SET_FEATURE 0X03
#define SET_INTERFACE 0X0B
//
//desc type
//
#define GFD_DEV_DESC_TYPE 0x01
#define GFD_CONFIG_DESC_TYPE 0x02
#define GFD_STRING_DESC_TYPE 0x03
#define GFD_INTF_DESC_TYPE 0x04
#define GFD_EP_DESC_TYPE 0x05
//
//desc_len
//
#define GFD_DEV_DESC_LEN 0x12
#define GFD_CONFIG_DESC_LEN 0x09
#define GFD_INTF_DESC_LEN 0x09
#define GFD_EP_DESC_LEN 0x07
//
//mps
//
#define GFD_BUS_NUM_CONFIG 0x01
#define GFD_BUS_NUM_INTF 0x01
#define GFD_BUS_NUM_STRINGS 0x03
#define GFD_CONFIG_PIPE_MPS GFD_CTRL_MPS
#define GFD_CTRL_MPS 0x08
#define pdc_fill_non_iso_urb(urb_req,desc_ptr,desc_len)\
urb_req->next = NULL; \
urb_req->len= desc_len; \
urb_req->fifo = desc_ptr
#endif
//**********************************************************************************************************
// 全局变量定义 --具体说明请参看文档
//**********************************************************************************************************
/*USBStat defines global var used for indicating USB device status*/
struct USBStat{
U32 usbstate;//flag indicating device is power-status or default-status
U32 setconstate;//flag indicating device whether set configaration
U32 epstate;//flag indicating endpoint is control or bulk
U32 usbdmapp;//flag indicating usb int_handle needed dma int_handle
};
/*USBTrans defines global var used in byte-level trans */
struct USBTrans{
U32 *head_temp;//pointer to data buffer
S32 desc_len;//total length of data (in byte) will be transfered
U32 usbmod;//mod=desc_len%64(bulk_only) or mod=desc_len%8(control trans)
U32 longpk;//flag indicating the length (in byte) of data whether greater than
// the storage of endpoint(8 - control endpoint or 64 - bulk endpoint )
U8 *longurb;//pointer to buffer
U32 *bulkindatebuf;//start address of the buffer in device
};
/*CtrlTrans defines global var used in control trans */
struct CtrlTrans{
U32 statempty;//flag indicating device needing to output a empty pocket
U8 command_request[8];//stores the request command
};
/*BulkStat defines global var used in bulk_only trans,added by xl on 3.21*/
struct BulkStat{
U32 blkstate;//flag indicating in which stage of bulk_only trans:CBW,CSW or data
U32 blktrasstate;//flag indicating data-in or data-out trans
U32 unsinglepocket;//flag indicating whether needing to trans data
S32 descactu_len;//actual length(byte) of data in bulk trans
U8 cbw[31];
U32 csw[4];
};
/*CBW defines global var used in bulk cbw transfer*/
struct CBW{
U8 cbw_direct;//defines data transfer direction
U32 cbw_dtl;//defines the length(in byte) of data in bulk_only trans specification
U8 ufi_cmd[12];
S32 requlen;//defines the length(in byte) of data in ufi specification
U8 RX[64];//stores the CBW recieved from host
};
/*CSW defines global var used in bulk csw transfer*/
struct CSW{
U32 tlengh;//length of csw wrapper(13 bytes)
U32 sing;//flag indicating the sucess or failuretrans just as bCSWStatus field in CSW
};
/*BulkData defines global var used in bulk data-in or data-out transfer */
struct BulkData {
U8 temblklen; //total number of block(512 bytes) transferred
U32 longblk; //flag indicating whether the sum of data greater than Buffer(2k)
U32 lblkaddr;//address of storage device(eg. mmc,u-flash)
U16 blktmp;// number of block(512 bytes) transferred in each time of bulk trans
};
/*USBDevice defines the total global var used in usb_int_handle and usb_dma_int handle*/
struct USBDevice{
struct USBStat dUSBStat;
struct USBTrans dUSBTrans;
struct CtrlTrans dCtrlTrans;
struct BulkStat dBulkStat;
struct CBW dCBW;
struct BulkData dBulkData;
struct CSW dCSW;
};
typedef struct urb
{
U16 len;
U8 *fifo;
struct urb *next;
}urb;
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -