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

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

?? combi.c

?? USB/PS2鼠標(biāo)驅(qū)動(dòng)
?? C
?? 第 1 頁 / 共 5 頁
字號(hào):
/*
**
** FILE: combi.c
**
**
** purpose: USB firmware for Cypress USB/PS2 mouse reference design
**			   
**
** revision history:
** 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"								//include macro definitions

/*
** 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);
void ReadData(void);
void SetStreamMode(void);
void StatusRequest(void);
char SetResolution(char p);
void SetScaling(void);

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
91精品国产综合久久香蕉的特点 | 欧美视频精品在线观看| 午夜精品一区二区三区电影天堂| 26uuu亚洲综合色| 欧美亚洲尤物久久| 国产成人精品综合在线观看| 午夜日韩在线观看| 亚洲欧美日韩在线| www激情久久| 日韩欧美二区三区| 99国产精品久久久久久久久久久| 久久精品国产77777蜜臀| 亚洲另类在线制服丝袜| 久久精品一区二区三区四区| 欧美日韩高清不卡| 在线一区二区视频| 成人国产精品免费观看视频| 黄色小说综合网站| 麻豆91在线观看| 亚洲福利一二三区| 亚洲一区二区三区四区五区中文| 国产精品拍天天在线| 精品动漫一区二区三区在线观看| 欧美日韩精品欧美日韩精品一综合| 成人的网站免费观看| 国产凹凸在线观看一区二区| 久久国产成人午夜av影院| 午夜精品一区二区三区电影天堂| 亚洲欧洲制服丝袜| 国产精品久久久久久久裸模| 久久亚洲精品国产精品紫薇| 日韩美女在线视频| 欧美一区二区三区免费观看视频| 欧美日韩中文字幕一区| 欧美在线不卡视频| 在线免费观看视频一区| 在线免费一区三区| 欧美日韩亚洲另类| 欧美精品在线一区二区三区| 在线观看日韩电影| 一本到不卡免费一区二区| 91小视频在线免费看| 91麻豆国产自产在线观看| 一本大道久久a久久精品综合| 成+人+亚洲+综合天堂| 91玉足脚交白嫩脚丫在线播放| av男人天堂一区| 色综合网色综合| 欧美在线不卡视频| 91精品国产入口| 日韩精品一区二区在线观看| 2024国产精品| 国产精品私人影院| 亚洲蜜桃精久久久久久久| 亚洲欧美日韩久久精品| 一区二区三区在线视频观看58 | 欧美精品丝袜中出| 日韩欧美国产wwwww| 欧美不卡一区二区| 欧美激情中文不卡| 亚洲三级久久久| 亚洲h在线观看| 免费xxxx性欧美18vr| 国产一区二区三区观看| 不卡电影一区二区三区| 欧美三区在线观看| 欧美成人欧美edvon| 日本一区免费视频| 亚洲精品国产无套在线观| 亚洲电影视频在线| 精品一区二区在线观看| 国产suv一区二区三区88区| 91色综合久久久久婷婷| 欧美欧美欧美欧美首页| 久久先锋影音av鲁色资源| **欧美大码日韩| 视频一区免费在线观看| 国产999精品久久久久久| 欧洲激情一区二区| 精品噜噜噜噜久久久久久久久试看| 国产欧美日韩视频一区二区| 亚洲男人的天堂网| 美女精品一区二区| 成人精品小蝌蚪| 欧美一区日韩一区| 国产精品久久久久一区| 天堂蜜桃91精品| 国产成a人无v码亚洲福利| 欧美色图第一页| 国产亚洲婷婷免费| 午夜精品一区二区三区三上悠亚| 国产高清精品在线| 欧美福利视频导航| 国产精品免费视频一区| 日韩有码一区二区三区| 成人动漫一区二区在线| 精品少妇一区二区三区免费观看 | 久久综合99re88久久爱| 亚洲精品成人在线| 国产一区二区日韩精品| 欧美精品高清视频| 亚洲三级小视频| 国产白丝网站精品污在线入口| 这里只有精品视频在线观看| 亚洲欧洲日产国产综合网| 九九久久精品视频| 欧美日韩电影在线| 有码一区二区三区| 国产mv日韩mv欧美| 日韩精品一区二区三区三区免费| 一区二区三区免费在线观看| 粉嫩绯色av一区二区在线观看| 欧美一区二区网站| 亚洲国产精品一区二区尤物区| 懂色av一区二区在线播放| 日韩精品一区二区三区视频播放 | 亚洲欧洲日产国码二区| 国产黄色91视频| 精品第一国产综合精品aⅴ| 天天综合色天天综合| 色哟哟亚洲精品| 国产精品国产自产拍高清av | 欧美色偷偷大香| 亚洲激情图片qvod| 成人福利视频网站| 中文字幕免费观看一区| 国产一区999| 2021国产精品久久精品 | 91免费国产在线观看| 久久久精品蜜桃| 国产精品一区在线| 久久精品欧美一区二区三区不卡 | 中文字幕一区二区三区在线播放| 国产一区二区看久久| 久久综合久久综合久久| 久久国产成人午夜av影院| 精品久久五月天| 狠狠狠色丁香婷婷综合久久五月| 日韩精品一区二区三区视频 | 欧美羞羞免费网站| 亚洲一区二区三区精品在线| 91女厕偷拍女厕偷拍高清| 亚洲欧美日韩精品久久久久| 色狠狠综合天天综合综合| 一区二区在线观看视频| 91美女在线看| 亚洲网友自拍偷拍| 欧美区在线观看| 久久99国产乱子伦精品免费| 2024国产精品| 成人免费的视频| 亚洲视频小说图片| 欧美视频在线播放| 日韩国产一二三区| 精品电影一区二区三区| 色噜噜狠狠成人网p站| 亚洲福利电影网| 日韩一区二区电影网| 国产在线播放一区三区四| 日本一区二区久久| 色系网站成人免费| 日韩vs国产vs欧美| 国产片一区二区| 91成人免费电影| 美日韩一区二区三区| 久久夜色精品国产噜噜av| 不卡视频一二三四| 午夜视频一区二区三区| 久久久久久电影| 91亚洲资源网| 日本成人在线网站| 日本一区二区视频在线| 欧美日韩一二三区| 国产精品一区久久久久| 亚洲影院久久精品| 久久久久久一二三区| 日本精品视频一区二区| 久国产精品韩国三级视频| 国产精品―色哟哟| 欧美一级片免费看| 成人免费av在线| 日韩精品一级二级| 国产精品乱码妇女bbbb| 色婷婷一区二区三区四区| 蜜臀久久99精品久久久久宅男| 国产婷婷一区二区| 精品视频在线视频| 成人三级在线视频| 秋霞电影一区二区| 一区二区三区四区激情| 精品1区2区在线观看| 色久优优欧美色久优优| 国产高清久久久久| 天天av天天翘天天综合网色鬼国产 | 久久99这里只有精品| 国产精品第13页| 精品av久久707| 欧美探花视频资源| 成人精品视频网站| 蜜桃av一区二区|