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

📄 mainloop.h

📁 usbhost 开发码
💻 H
字号:
//MIANLOOP.H
#ifndef __MAINLOOP_H__
#define __MAINLOOP_H__
/*
   //*************************************************************************
   // basic #defines
   //*************************************************************************
   */
#define MAX_ENDPOINTS      (unsigned char)0x3

#define EP0_TX_FIFO_SIZE   16
#define EP0_RX_FIFO_SIZE   16
#define EP0_PACKET_SIZE    16

#define EP1_TX_FIFO_SIZE   16
#define EP1_RX_FIFO_SIZE   16
#define EP1_PACKET_SIZE    16

#define EP2_TX_FIFO_SIZE   64
#define EP2_RX_FIFO_SIZE   64
#define EP2_PACKET_SIZE    64


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

#define USB_CLASS_CODE_TEST_CLASS_DEVICE                    0xdc
#define USB_SUBCLASS_CODE_TEST_CLASS_D12                    0xA0
#define USB_PROTOCOL_CODE_TEST_CLASS_D12                    0xB0

/*
   //*************************************************************************
   // masks
   //*************************************************************************
*/

#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

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

/*
   //*************************************************************************
   // structure and union definitions
   //*************************************************************************
*/
typedef union _epp_flags
{
	struct _flags
	{
		unsigned char timer               	: 1;
		unsigned char bus_reset           	: 1;
		unsigned char suspend             	: 1;
		unsigned char setup_packet  	  	: 1;
		unsigned char remote_wakeup		   	: 1;
		unsigned char in_isr		      	: 1;
		unsigned char control_state			: 2;

		unsigned char configuration			: 1;
		unsigned char verbose				: 1;
		unsigned char ep1_rxdone			: 1;
		unsigned char setup_dma				: 2; // V2.3
		unsigned char dma_state      		: 2;
		unsigned char power_down			: 1; // Smart Board
		uchar command		:1;
		uchar ep2_rxdone	:1;
		uchar ep1buf_full	:1;
		uchar ep2buf_full	:1;	

	} bits;
	unsigned short value;
} EPPFLAGS;


/*
typedef struct _IO_REQUEST {
	unsigned short	uAddressL;
	unsigned char	bAddressH;
	unsigned short	uSize;
	unsigned char	bCommand;
} IO_REQUEST, *PIO_REQUEST;

/*
   //*************************************************************************
   // USB utility functions
   //*************************************************************************
*/



#define IN_TOKEN_DMA 	1
#define OUT_TOKEN_DMA 	0

#define DMA_BUFFER_SIZE		256

#define DMA_IDLE	0
#define DMA_RUNNING	1
#define DMA_PENDING	2

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


	sbit MCU_SWM0     = P1^0;
	sbit MCU_SWM1     = P1^1;
	sbit MCU_LED0	  = P1^2;
	sbit MCU_LED1	  = P1^3;
//	sbit MCU_D12CS	  = P1^6;
//	sbit MCU_D12RST   = P1^7;
	sbit D12SUSPD	  = P3^5;

void init_timer0(void);
void init_special_interrupts(void);
void init_port();
void disconnect_USB(void);
void connect_USB(void);
void reconnect_USB(void);
void check_key_LED(void);

#endif//__MAINLOOP_H__

⌨️ 快捷键说明

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