⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 macro.h

📁 运行于c51单片机上的用keil c创建的C源程序,采用PDIUSBD12接口。
💻 H
字号:
#include <absacc.h>

/*
//*************************************************************************
// D12控制引脚定义
//*************************************************************************
*/
sbit MCU_D12CS	  = P1^5;
sbit MCU_D12RST   = P3^4;
sbit D12SUSPD	  = P3^5;

#define D12_COMMAND	XBYTE[0x7003]	
#define D12_DATA	XBYTE[0x7002]

#define SETBIT(C_Sou,C_Bit)	(C_Sou |= (0x01<<C_Bit))
#define CLRBIT(C_Sou,C_Bit)	(C_Sou &= ~(0x01<<C_Bit))
#define GETBIT(C_Sou,C_Bit)	(C_Sou & (0x01<<C_Bit))

//一般常量定义
#define ENABLE 		EA=1
#define DISABLE		EA=0

#define EP0_PACKET_SIZE		16
#define EP1_PACKET_SIZE		16
#define EP2_PACKET_SIZE		64

#define USB_IDLE           0
#define USB_TRANSMIT       1
#define USB_RECEIVE        2

#define SWAP(x)   ((((x) & 0xFF) << 8) | (((x) >> 8) & 0xFF))

#define MSB(x)    (((x) >> 8) & 0xFF)
#define LSB(x)    ((x) & 0xFF)

#define FALSE   0
#define TRUE    (!FALSE)


//D12的常量定义
#define D12_FULLEMPTY			0x01
#define D12_STALL			0x02

#define D12_INT_ENDP0OUT		0x01
#define D12_INT_ENDP0IN			0x02
#define D12_INT_ENDP1OUT		0x04
#define D12_INT_ENDP1IN			0x08
#define D12_INT_ENDP2OUT		0x10
#define D12_INT_ENDP2IN			0x20
#define D12_INT_BUSRESET		0x40
#define D12_INT_SUSPENDCHANGE		0x80
#define D12_INT_EOT			0x0100

#define D12_NOLAZYCLOCK			0x02
#define D12_CLOCKRUNNING        	0x04
#define D12_INTERRUPTMODE		0x08
#define D12_SOFTCONNECT			0x10
#define D12_ENDP_NONISO			0x00
#define D12_ENDP_ISOOUT			0x40
#define D12_ENDP_ISOIN			0x80
#define D12_ENDP_ISOIO			0xC0

#define D12_CLOCK_12M			0x03
#define D12_CLOCK_4M			0x0b
#define D12_SETTOONE            	0x40
#define D12_SOFONLY			0x80

#define D12_DMASINGLE			0x00
#define D12_BURST_4			0x01
#define D12_BURST_8			0x02
#define D12_BURST_16			0x03
#define D12_DMAENABLE           	0x04
#define D12_DMA_INTOKEN			0x08
#define D12_AUTOLOAD			0x10
#define D12_NORMALPLUSSOF		0x20
#define D12_ENDP4INTENABLE		0x40
#define D12_ENDP5INTENABLE		0x80	// bug fixed in V2.1

#define D12_SETUPPACKET			0x20

#define D12_BUFFER0FULL			0x20
#define D12_BUFFER1FULL			0x40

//usb协议的相关常量

#define USB_RECIPIENT            (unsigned char)0x1F
#define USB_RECIPIENT_DEVICE     (unsigned char)0x00
#define USB_RECIPIENT_INTERFACE  (unsigned char)0x01
#define USB_RECIPIENT_ENDPOINT   (unsigned char)0x02

#define USB_REQUEST_TYPE_MASK    (unsigned char)0x60
#define USB_STANDARD_REQUEST     (unsigned char)0x00
#define USB_CLASS_REQUEST        (unsigned char)0x20
#define USB_VENDOR_REQUEST       (unsigned char)0x40

#define USB_REQUEST_MASK         (unsigned char)0x0F

#define DEVICE_ADDRESS_MASK             0x7F

#define USB_ENDPOINT_DIRECTION_MASK     0x80

#define MAX_CONTROLDATA_SIZE		8		//setup包的数据体大小
#define MAX_ENDPOINTS      3


#define SETUP_DMA_REQUEST 		0x0471
#define GET_FIRMWARE_VERSION    0x0472
#define GET_SET_TWAIN_REQUEST   0x0473
#define GET_BUFFER_SIZE		    0x0474


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -