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

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

?? combi.c

?? usb 鼠標(biāo) 開發(fā)源程序資料 可以直接用于做USB 組件接口
?? C
?? 第 1 頁 / 共 5 頁
字號:
/*
**
** 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
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美日韩综合一区| 国产成人av自拍| 亚洲午夜激情av| 亚洲va国产天堂va久久en| 免费人成在线不卡| 粉嫩13p一区二区三区| 日本久久电影网| gogo大胆日本视频一区| 一本到不卡精品视频在线观看| 欧美日本韩国一区二区三区视频| 精品福利一区二区三区| 亚洲一区二区五区| 偷拍日韩校园综合在线| 美女尤物国产一区| 亚洲电影一区二区| 粉嫩aⅴ一区二区三区四区| www.性欧美| 日韩一级二级三级精品视频| 久久久久国产免费免费| 综合色中文字幕| 久久成人精品无人区| 欧美揉bbbbb揉bbbbb| 久久精品国产色蜜蜜麻豆| av中文一区二区三区| 欧美精品一区男女天堂| 亚洲一区二区三区视频在线| 亚洲国产精品久久艾草纯爱| 国产麻豆91精品| 日韩一区二区三区视频在线观看| 久久久久久影视| 日韩高清在线观看| 在线视频国内自拍亚洲视频| 亚洲国产高清aⅴ视频| 日本免费在线视频不卡一不卡二| 国产一区二区三区av电影| 欧美日韩电影一区| 亚洲色欲色欲www| 国产99久久久国产精品潘金网站| 在线日韩av片| 亚洲欧美日韩在线播放| 高清不卡一二三区| 久久精品亚洲国产奇米99 | 视频一区视频二区中文字幕| 99在线视频精品| 久久综合九色综合欧美98| 调教+趴+乳夹+国产+精品| 欧美私模裸体表演在线观看| 亚洲精品自拍动漫在线| 久久99精品久久久久久| 欧美日韩国产高清一区二区 | 国产精品久久久久影院亚瑟| 国产精品久久久久天堂| gogogo免费视频观看亚洲一| www日韩大片| 国产大陆a不卡| 欧美激情在线看| 成人国产精品视频| 麻豆精品视频在线观看免费| 欧美一级二级三级乱码| 日韩av一二三| 日韩欧美国产电影| 国产综合色视频| 国产精品美女久久久久久| 97se亚洲国产综合自在线| 久久亚洲综合色| 国产精品99久| 国产精品久久久久aaaa樱花| 在线精品视频一区二区三四| 欧美日韩国产小视频| 蜜臀av性久久久久蜜臀aⅴ | 亚洲精品欧美在线| 色琪琪一区二区三区亚洲区| 国产精品久99| 3d动漫精品啪啪一区二区竹菊| 狠狠狠色丁香婷婷综合久久五月| 国产日韩精品视频一区| 欧美偷拍一区二区| 激情久久五月天| 《视频一区视频二区| 欧美一区二区三区小说| 国产成人小视频| 亚洲一级二级在线| 久久精品视频一区二区三区| 色噜噜偷拍精品综合在线| 久久国产精品99久久人人澡| 国产亚洲综合性久久久影院| 欧美亚洲国产怡红院影院| 极品尤物av久久免费看| 日韩欧美在线不卡| 99国产精品久久久久久久久久久| 丝袜美腿亚洲一区二区图片| 国产日韩欧美a| 日韩精品综合一本久道在线视频| 成人av电影在线观看| 日本强好片久久久久久aaa| 亚洲柠檬福利资源导航| 久久综合狠狠综合久久综合88| 91色乱码一区二区三区| 国产精品一区在线| 午夜激情久久久| 中文字幕中文字幕中文字幕亚洲无线| 欧美影院午夜播放| 欧美一级在线免费| 在线亚洲一区观看| 久久www免费人成看片高清| 日韩精品一二三区| 一区二区三区免费网站| 2021中文字幕一区亚洲| 欧美一区二区三区人| 欧洲色大大久久| 高清在线不卡av| 麻豆国产精品一区二区三区| 婷婷国产在线综合| 最新日韩av在线| 欧美国产禁国产网站cc| 久久人人超碰精品| 5566中文字幕一区二区电影| 欧美日韩精品系列| 在线视频你懂得一区| 欧美日韩一区视频| 欧美日韩亚洲不卡| 91国产免费观看| 欧美日韩一级视频| 欧美日韩成人在线| 欧美日韩高清一区二区不卡| 日韩一区二区电影在线| 欧美一区二区三区人| 在线不卡的av| 亚洲精品一区二区三区精华液| 日韩区在线观看| 精品少妇一区二区三区日产乱码 | 大尺度一区二区| 成人在线综合网| 91啪亚洲精品| 91网页版在线| 日本黄色一区二区| 99re66热这里只有精品3直播 | 精品一区二区三区久久| 欧美色综合影院| 欧美精品丝袜久久久中文字幕| 99re热视频精品| 色欧美乱欧美15图片| 日本精品一级二级| 国产日韩欧美在线一区| 久久综合九色综合97婷婷女人| 国产成人精品亚洲日本在线桃色| 日韩欧美成人午夜| 色欧美日韩亚洲| 99精品视频在线观看免费| 欧美在线观看一二区| 日韩一级视频免费观看在线| 久久精品男人的天堂| 亚洲综合无码一区二区| 日韩不卡一区二区| 粉嫩av一区二区三区在线播放 | 欧美日韩国产乱码电影| 欧美mv日韩mv国产| 一色桃子久久精品亚洲| 日韩影院在线观看| 国产成人综合精品三级| 欧美亚日韩国产aⅴ精品中极品| 日韩欧美亚洲国产另类| 亚洲日本欧美天堂| 国内国产精品久久| 欧美午夜精品一区二区三区| 久久综合久久鬼色| 天天av天天翘天天综合网色鬼国产| 国内不卡的二区三区中文字幕| 色一情一伦一子一伦一区| 久久久久久电影| 欧美一卡2卡三卡4卡5免费| 国产精品视频麻豆| 日韩欧美一级精品久久| 亚洲一区二区av电影| 91在线视频免费观看| 亚洲欧洲日产国码二区| 成人免费视频国产在线观看| 国产精品国产三级国产| 欧美主播一区二区三区美女| 蜜臀av一级做a爰片久久| 欧美成人三级电影在线| 99久久精品国产麻豆演员表| 亚洲二区视频在线| 久久综合狠狠综合久久激情| 99久久99久久精品国产片果冻| 亚洲综合精品自拍| 亚洲国产精品黑人久久久| 色老汉av一区二区三区| 久久精品久久精品| 亚洲精品第一国产综合野| 欧美精品一区二区三区在线播放| 色偷偷成人一区二区三区91| 激情另类小说区图片区视频区| 亚洲免费av网站| 国产欧美日韩麻豆91| 欧美tk—视频vk| 欧美乱妇15p| 在线观看亚洲精品| 色呦呦日韩精品| av不卡在线播放|