亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? combi.c

?? 這是使用CYPRESS的7C637xx芯片完成USB鼠標(biāo)的例子。
?? C
?? 第 1 頁 / 共 5 頁
字號:
/*
**
** FILE: combi.c
**
**
** purpose: USB firmware for Cypress USB/PS2 mouse reference design
**			   
**
** revision history:
** 10/31/00 vqt : resolve compiling/linking errors with ByCraft C version 1.10
** 6/27/00  bth : modified ps2 scaling algorithm
** 7/11/00  sea : modified ps2 resolution constants and 
**					ps2_send() start bit inhibit response
**
*/



#pragma option INSTRUCTIONTIMING			//needed for Cypress debugger to work properly
#pragma option f0							//do not insert page breaks in listing file 
#pragma option REGSAVEOFF;					//do not automatically save AC and IX in interrupts
#pragma option NOINIT;
#define DEBUG 


#include "chip.h"
#include "usbdefs.h"
#include "ps2defs.h"




#define BIT0 1
#define BIT1 2
#define BIT2 4
#define BIT3 8
#define BIT4 0x10
#define BIT5 0x20
#define BIT6 0x40
#define BIT7 0x80


//*************************************************************************************************
//USER_DEFINES
/*
**
** the following defines can be changed to accomodate different I/O pinouts.  It is assumed that
** all 6 quadrature inputs (optics) are connected to the same port.
**
*/

#define OPTICS_PORT				PORT0				//optics port
#define OPTICS_MASK				0x3f				//mask of all optics inputs
/*
** for each set of x,y, and z optics, define a macro that will move the corresponding 2 quadrature bits
** into bit1 and bit0.  For instance, in the reference design
** the y- quadrature inputs are at bits 3 and 2, so the macro shifts the bits by 2 and
** masks them.
*/

#define GET_X_OPTICS(x) ((x >> 0) & 0x3)			//no shift necessary					
#define GET_Y_OPTICS(x) ((x >> 2) & 0x3)			//shift bits [3:2] into [1:0]
#define GET_Z_OPTICS(x) ((x >> 4) & 0x3)			//shift bits [5:4] into [1:0]


/*
** define each switch's port and bit position
*/
#define LEFT_SWITCH_PORT		PORT0
#define LEFT_SWITCH_MASK		BIT7
#define RIGHT_SWITCH_PORT		PORT1
#define RIGHT_SWITCH_MASK		BIT0
#define MIDDLE_SWITCH_PORT		PORT1
#define MIDDLE_SWITCH_MASK		BIT1


/*
**define masks for the port pin functions.  This information is used to establish the mode
**settings for the GPIO pins
**
*/
#define PORT0_OPTICS_MASK		0b00111111			//optics pins [5:0] on port 0
#define PORT1_OPTICS_MASK		0b00000000			//no optics on port 1
#define PORT0_LED_MASK		    0b01000000			//led drive at pin [6] on port 0
#define PORT1_LED_MASK			0b00000000			//no led drive on port 1
#define PORT0_SWITCH_MASK		0b10000000			//switch input at pin [7] on port 0
#define PORT1_SWITCH_MASK		0b00000011			//switch inputs at [1:0] on port 1




//comment the following lines if you do not want PS2 resolution and scaling commands to be implemented 
//in the code.
#define ENABLE_RESOLUTION
#define ENABLE_SCALING
//END OF USER DEFINES
//*************************************************************************************************





//*************************************************************************************************
//COMMON DECLARATIONS USED BY BOTH INTERFACES

#include "macros.h"							

/*
** define port data and mode initial values for the 3 operating states -- normal, suspend, and suspend with remote
** wakeup -- based on the masks provided by the user
*/
/*
**normal operating mode
*/
#define PORT0_INIT				PORT0_SWITCH_MASK
#define PORT1_INIT				PORT1_SWITCH_MASK
#define PORT0_MODE1_INIT		PORT0_SWITCH_MASK
#define PORT1_MODE1_INIT		PORT1_SWITCH_MASK
#define PORT0_MODE0_INIT		PORT0_LED_MASK
#define PORT1_MODE0_INIT		PORT1_LED_MASK

/*
** suspend mode (no remote wakeup)
*/


#define PORT0_SUSPEND					PORT0_LED_MASK
#define PORT1_SUSPEND					PORT1_LED_MASK
#define PORT0_MODE1_SUSPEND				PORT0_LED_MASK
#define PORT1_MODE1_SUSPEND				PORT1_LED_MASK
#define PORT0_MODE0_SUSPEND				PORT0_SWITCH_MASK
#define PORT1_MODE0_SUSPEND				PORT1_SWITCH_MASK
/*
** remote wakeup
*/
#define PORT0_RW						(PORT0_LED_MASK | PORT0_SWITCH_MASK)
#define PORT1_RW						(PORT1_LED_MASK | PORT1_SWITCH_MASK)
#define PORT0_MODE1_RW					(PORT0_SWITCH_MASK | PORT0_LED_MASK)
#define PORT1_MODE1_RW					(PORT1_SWITCH_MASK | PORT1_LED_MASK)
#define PORT0_MODE0_RW					0
#define PORT1_MODE0_RW					0


#define LEFT_SWITCH_ASSERTED		(!(LEFT_SWITCH_PORT & LEFT_SWITCH_MASK))
#define MIDDLE_SWITCH_ASSERTED		(!(MIDDLE_SWITCH_PORT & MIDDLE_SWITCH_MASK))
#define RIGHT_SWITCH_ASSERTED		(!(RIGHT_SWITCH_PORT & RIGHT_SWITCH_MASK))


/*
** switches are debounced in a routine that is called every 4 msec.  10
** successive stable samples are required for a switch change to be reported.
*/
#define DEBOUNCE_COUNT				10		  //10 identical samples must be taken to recognize switch changes





/*
** define a structure containing variables updated in the 1-msec interrupt
*/

typedef struct
{
	char b1msCounter;				//incremented inside 1msec interrupt for general timing
	char b1msFlags;					//flag set inside 1msec interrupt
}ONE_MSEC_STATUS;
#define ONE_MSEC_FLAG 1


/*
** Quadrature inputs are sampled inside the 128 usec interrupt and placed in a queue for later
** processing in the main loop.
**
*/
typedef struct
{
	char near *headP;					//head of queue
	char near *tailP;					//tail of queue
	char bLen;							//length of queue
}QUEUE_STRUCT;


/*
** current state of each quadrature pair is stored to compare with the next sample.
**
*/
 
typedef struct
{
	char bXstate;						//current state of X optics
	char bYstate;						//current state of Y optics
	char bZstate;						//current state of Z optics
			
}OPTICS_STATE;



/*
** the order of the bytes in this structure is important! These bytes are in the
** proper order for a packet returned to a USB host in response to a Get_Report command.
*/
typedef struct
{
	char bChange;						//set to 1 if mouse state has changed
	char bButtons;						//current state of mouse buttons
	signed char bXcount;						//current accumulation of X counts
	signed char bYcount;						//current accumulation of Y counts
	signed char bZcount;						//current accumulation of Z counts
}MOUSE_STATE;



/*
** global variables used by both USB and PS2 interfaces
*/

QUEUE_STRUCT		OpticsQueue;		//optics queue		

ONE_MSEC_STATUS		MsecStatus;			//status of 1msec interrupt
OPTICS_STATE		Optics;				//current state of optics
MOUSE_STATE			Mouse;				//current state of mouse (buttons, x,y,z)
char bLastButtons;
char bDebounceCount;


char bOpticsArray[16];					//16-byte array used for optics queue data


const signed char quad_table[] = 
/*
;***
; Quadrature state table. This table assists processing of quadrature state
; transitions. The table index is calculated as:
;       [(last_state)*4 + current_state],
; and the table entry at that point is 1, 0 or -1 indicating increment, hold
; or decrement the count, respectively.
;***
*/
{
	0,					//;State 0 => state 0 (NoChange)
	1,					//;        => state 1 (Increment)
	0xff,				//;        => state 2 (Decrement)
	0,					//;        => state 3 (Fault)
	
	0xff,				//;State 1 => state 0 (Decrement)
	0,					//;       => state 1  (NoChange)
	0,					//;       => state 2  (Fault)
	1,    				//;       => state 3  (Increment)
	
	1,					//;State 2 => state 0 (Increment)
	0,					//;       => state 1  (Fault)
	0,					//;     => state 2    (NoChange)
	0xff,				//;       => state 3  (Decrement)
	
	0,					//;State 3 => state 0 (Fault)
	0xff,				//;       => state 1  (Decrement)
	1,					//;       => state 2  (Increment)
	0					//;      => state 3   (NoChange)
};

const signed char z_quad_table[] = 
/*
;***
; Quadrature state table. This table assists processing of quadrature state
; transitions. The table index is calculated as:
;       [(last_state)*4 + current_state],
; and the table entry at that point is 1, 0 or -1 indicating increment, hold
; or decrement the count, respectively.
;***
*/
{
	0,					//;State 0 => state 0 (NoChange)
	0,					//;        => state 1 (NoChange)
	0,		  			//;        => state 2 (NoChange)
	0,					//;        => state 3 (Fault)
	
	0,				//;State 1 => state 0 (NoChange)
	0,					//;       => state 1 (NoChange)
	0,					//;       => state 2 (NoChange)
	1,    				//;       => state 3 (Increment)
	
	1,					//;State 2 => state 0 (Increment)
	0,					//;       => state 1 (Fault)
	0,					//;     => state 2 (NoChange)
	0xff,				//;       => state 3 (Decrement)
	
	0,					//;State 3 => state 0 (Fault)
	0xff,				//;       => state 1 (Decrement)
	0,					//;       => state 2 (NoChange)
	0					//;      => state 3 (NoChange)
};
/*
** function prototypes for shared functions
*/
void main(void);
void ClearRam(void);
void Delay(char delay);
//void delay(void);

//*************************************************************************************************
//USB DECLARATIONS 

#include "usb_desc.h"						//include usb descriptors



#define SET_EP0_MODE(x) EP_A0_MODE = x		//set mode register for EP0


/*
** define a structure that will maintain the parameters of multibyte data that is returned
** to the host in response to successive IN commands on endpoint 0 (descriptors, status, reports, etc).
*/
typedef struct
{
	char bLength;							//length of data remaining to be returned		
	far char *p;							//pointer to the data
    char dummy;								//padding -- compiler bug doesn't allocate enough space for a far *
}TRANSMIT_STRUCT;


/*
** define a structure that contains the current USB device status
*/
typedef struct
{
	char bConfiguration;					//configured or not
	char bRemoteWakeup;						//remote wakeup enabled or not
	char bDeviceStatus;						//spare, do not remove! this byte is a placeholder
											//for the 2nd byte of device status.
	char bEP1Stall;							//endpoint 1 stalled or not
	char bEPStatus;							//spare, do not remove! this byte is a placeholder
											//for the 2nd byte of device status
	char bAddress;							//current address
	char bProtocol;							//boot protocol or report protocol
}DEVICE_STATUS;


/*
** define a structure for mouse transmit status
*/

typedef struct
{
	char bIdlePeriod;						//current idle period setting
	char bIdleCounter;						//counter for idle period
}
MOUSE_STATUS;




MOUSE_STATUS		MouseStatus;			//status of mouse
TRANSMIT_STRUCT		XmtBuff;				//EP0 transmit buffer parameters

DEVICE_STATUS		DeviceStatus;			//device status
char				bSuspendCounter;		//counter for keeping track of suspend interval

//declare the following registers global. They are used by ISRs to avoid compiler issues.
char byte_count;
char byte_count1;
char bWakeupCount;


/*
** USB function prototypes
*/
void UsbReInitialize(void);
void MouseTask(void);
void Suspend(void);
void usbmain(void);
void HandleSetup(void);
void HandleIn(void);
void USB_control_read(void);
char LoadEP0Fifo(void);
void ClearRemoteWakeup(void);
void SetRemoteWakeup(void);
void SetConfiguration(void);
void SetAddress(void);
void ClearEndpointStall(void);
void SetEndpointStall(void);
void GetDeviceStatus(void);
void GetDescriptor(void);
void GetInterfaceStatus(void);
void GetEndpointStatus(void);
void SetIdle(void);
void SetProtocol(void);
void GetReport(void);
void GetIdle(void);
void GetProtocol(void);
void GetConfiguration(void);
void USB_Stall_In_Out(void);
char BusInactive(void);



//*************************************************************************************************
//PS2 DECLARATIONS 


/*
** define a structure that contains all mouse parameters that can be set via host commands
*/
typedef struct
{
	char bReportRate;								
	char bReportInterval;							
	char bScale;
	char bStream;
	char bResolution;
	char bEnabled;
	char bZmouse;
	char bWrap;
}MOUSEPARMS;

/*
** define a structure to hold messages to be sent back to the host.  This can be either a mouse packet
** or a response to a command (device id, BAT response, etc).
*/
typedef struct
{
	char bMsgBuff[5];						//array of bytes
	char bMsgLen;							//initial length of message
	char bXmtLen;							//length of bytes remaining to send
}PS2_XMT_STRUCT;


int16 bBatDelay;							//bat delay, in msec.

char ConsecutiveSetSamples;					//keeps track of number of consecutive set-sample commands
											//received from the host (for enabling z-mice)
char  bIntervalCount;						//interval count, in msec, for reporting mouse packets

MOUSEPARMS  MouseParms;						//mouse parameters
PS2_XMT_STRUCT Ps2Xmt;						//transmit buffer
char ksc_delay;								//storage for assembly routines
char ps2_temp0;								//storage for assembly routines




/*
** function prototypes for PS2 routines
*/

void ps2BAT(void);
void ps2_send(char data);
char ps2_receive(void);
void Reset(void);
void Resend(void);
void SetDefault(void);
void Disable(void);
void Enable(void);
char SetSampleRate(char p);
void ReadDeviceType(void);
void SetRemoteMode(void);
void SetWrapMode(void);

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
91精品国产91久久久久久最新毛片| 国产米奇在线777精品观看| 97se亚洲国产综合自在线观| 国产精品丝袜91| 99麻豆久久久国产精品免费| 国产精品久久久久婷婷二区次| 成人激情免费网站| 一区二区免费在线| 欧美专区亚洲专区| 日韩黄色片在线观看| 精品动漫一区二区三区在线观看| 国产精品白丝av| 亚洲欧美经典视频| 欧美一区二区三区视频在线 | 亚洲欧美日韩电影| 在线视频观看一区| 六月丁香婷婷色狠狠久久| 久久久久久久久免费| 9i看片成人免费高清| 婷婷久久综合九色综合绿巨人| 日韩一区二区在线观看视频| 成人性生交大合| 亚洲一区二区三区中文字幕| 欧美不卡一区二区三区四区| av激情成人网| 奇米色777欧美一区二区| 亚洲国产岛国毛片在线| 欧美系列一区二区| 狠狠色狠狠色合久久伊人| 亚洲婷婷综合色高清在线| 欧美一区二区视频观看视频| 成人在线一区二区三区| 亚洲国产成人高清精品| 久久精品男人天堂av| 欧美日韩免费观看一区三区| 国产精品996| 日韩精品一卡二卡三卡四卡无卡| 国产天堂亚洲国产碰碰| 5858s免费视频成人| 播五月开心婷婷综合| 蜜桃一区二区三区四区| 1024成人网色www| 26uuu亚洲| 欧美日韩另类国产亚洲欧美一级| 国产高清不卡一区| 丝袜美腿亚洲色图| 亚洲欧美视频一区| 国产色产综合产在线视频| 欧美人体做爰大胆视频| 色综合久久中文字幕综合网| 国产精品18久久久久久久网站| 天天影视涩香欲综合网| 亚洲精品国产a| 国产精品三级av在线播放| 日韩精品一区二区三区蜜臀| 欧美三级一区二区| 97精品超碰一区二区三区| 国产盗摄一区二区| 另类人妖一区二区av| 五月天欧美精品| 亚洲精品ww久久久久久p站| 中文字幕 久热精品 视频在线| 日韩一区二区在线观看| 欧美视频三区在线播放| 99久久99精品久久久久久| 成人视屏免费看| 国产成人一区二区精品非洲| 国产在线播放一区三区四| 六月丁香婷婷色狠狠久久| 蜜臀久久99精品久久久画质超高清| 亚洲成人你懂的| 亚洲va欧美va国产va天堂影院| 亚洲最大的成人av| 亚洲亚洲精品在线观看| 亚洲久草在线视频| 一区二区三区成人| 亚洲免费伊人电影| 一区二区三区欧美视频| 一区二区三区四区视频精品免费 | 91污在线观看| 99久久精品免费精品国产| av色综合久久天堂av综合| 成人app在线观看| 99久久精品免费看国产免费软件| 9l国产精品久久久久麻豆| 不卡的av在线| 在线精品视频一区二区三四| 欧美视频一二三区| 日韩欧美一二三四区| 欧美成人女星排行榜| 久久久蜜桃精品| 国产精品伦一区| 伊人一区二区三区| 污片在线观看一区二区| 麻豆成人久久精品二区三区红 | 欧美tk丨vk视频| 国产日韩欧美a| 中文字幕日韩欧美一区二区三区| 亚洲精品国产第一综合99久久| 亚洲超丰满肉感bbw| 蜜臀av一区二区三区| 国产成人啪午夜精品网站男同| av激情成人网| 911国产精品| 久久众筹精品私拍模特| 亚洲欧洲一区二区在线播放| 一区二区三区精品在线| 看国产成人h片视频| 粉嫩欧美一区二区三区高清影视 | 国模无码大尺度一区二区三区| 国产成人精品一区二| 91老师国产黑色丝袜在线| 欧美日韩在线播放三区| 久久影院视频免费| 亚洲色欲色欲www| 美女视频黄a大片欧美| 成人永久aaa| 777久久久精品| 久久久久九九视频| 亚洲va国产va欧美va观看| 国产精品一区二区男女羞羞无遮挡 | 自拍偷自拍亚洲精品播放| 婷婷久久综合九色综合绿巨人| 国产成人免费av在线| 欧美丰满嫩嫩电影| 国产精品午夜电影| 麻豆免费看一区二区三区| 99久久免费国产| 久久综合资源网| 午夜在线成人av| 99视频超级精品| 久久免费国产精品| 日日摸夜夜添夜夜添亚洲女人| 99re成人在线| 国产女人aaa级久久久级| 日本vs亚洲vs韩国一区三区二区| 91蜜桃婷婷狠狠久久综合9色| 精品人伦一区二区色婷婷| 亚洲国产精品人人做人人爽| 粉嫩一区二区三区在线看| 日韩情涩欧美日韩视频| 午夜视频在线观看一区| 99国产精品国产精品久久| 久久久久久亚洲综合影院红桃| 日韩精品91亚洲二区在线观看| 欧洲视频一区二区| 亚洲视频在线一区观看| 国产99久久久国产精品免费看| 欧美一区二区三区影视| 亚洲永久精品国产| 91丨porny丨在线| 中文字幕免费在线观看视频一区| 精品一区二区三区久久久| 91麻豆精品国产无毒不卡在线观看 | 婷婷成人综合网| 精品视频一区二区三区免费| 亚洲女同一区二区| 99天天综合性| 亚洲欧美另类久久久精品2019| caoporm超碰国产精品| 国产精品网站在线| 国产999精品久久| 欧美国产国产综合| 成人免费视频视频| 国产精品久久久久久久久免费桃花| 国产麻豆91精品| 欧美精品一区二区三区在线播放| 久久丁香综合五月国产三级网站| 欧美一区二区二区| 免费成人在线影院| 日韩欧美一级二级三级久久久| 免费成人av在线| 精品国产1区二区| 国产精品123| 国产欧美日韩在线| 国产91高潮流白浆在线麻豆| 国产精品色哟哟网站| av在线不卡电影| 亚洲韩国精品一区| 欧美一区二区观看视频| 国产一区二区三区| 国产精品久久久久久久午夜片| 91色porny| 亚洲成人先锋电影| 日韩一级视频免费观看在线| 黑人巨大精品欧美一区| 中文字幕av资源一区| 色琪琪一区二区三区亚洲区| 天天影视网天天综合色在线播放| 日韩你懂的在线播放| 国产91精品精华液一区二区三区| 中文字幕一区二区三区不卡在线| 一本色道a无线码一区v| 石原莉奈在线亚洲三区| 久久久久九九视频| 欧洲一区在线电影| 久草在线在线精品观看| 国产精品毛片a∨一区二区三区| 欧美性大战xxxxx久久久| 激情深爱一区二区|