Code/Resource
Windows Develop
Linux-Unix program
Internet-Socket-Network
Web Server
Browser Client
Ftp Server
Ftp Client
Browser Plugins
Proxy Server
Email Server
Email Client
WEB Mail
Firewall-Security
Telnet Server
Telnet Client
ICQ-IM-Chat
Search Engine
Sniffer Package capture
Remote Control
xml-soap-webservice
P2P
WEB(ASP,PHP,...)
TCP/IP Stack
SNMP
Grid Computing
SilverLight
DNS
Cluster Service
Network Security
Communication-Mobile
Game Program
Editor
Multimedia program
Graph program
Compiler program
Compress-Decompress algrithms
Crypt_Decrypt algrithms
Mathimatics-Numerical algorithms
MultiLanguage
Disk/Storage
Java Develop
assembly language
Applications
Other systems
Database system
Embeded-SCM Develop
FlashMX/Flex
source in ebook
Delphi VCL
OS Develop
MiddleWare
MPI
MacOS develop
LabView
ELanguage
Software/Tools
E-Books
Artical/Document
mouse.c
Package: str711USB.rar [view]
Upload User: yyyd609
Upload Date: 2022-07-18
Package Size: 183k
Code Size: 4k
Category:
ARM-PowerPC-ColdFire-MIPS
Development Platform:
C/C++
- /******************** (C) COPYRIGHT 2003 STMicroelectronics ********************
- * File Name : mouse.c
- * Author : MCD Application Team
- * Date First Issued : 27/10/2003
- * Description : USB Mouse demo main file
- ********************************************************************************/
- #include "mouse.h"
- #include "71x_lib.h"
- #include "USB_lib.h"
- #include "USB_conf.h"
- #include "USB_prop.h"
- #include "USB_pwr.h"
- // directions of transfer for CopyBuffer
- #define USR_TO_PMA 0
- #define PMA_TO_USR 1
- extern BOOL fCellSuspended;
- /*******************************************************************************
- * Function Name : gInit
- * Description : Hardware initialisation
- * Input : None
- * Output : None
- * Return value : None
- *******************************************************************************/
- void gInit(void)
- {
- wInterrupt_Mask = IMR_MSK;
- } /* gInit */
- /*******************************************************************************
- * Function Name : CopyBuffer
- * Description : Transfers a packet of data from/to PMA to/from user memory
- * Input 1 : iTrDirection: USR_TO_PMA or PMA_TO_USR
- * Input 2 : EpNum: endpoint number
- * Input 3 : Usr_buffer: a pointer to user memory
- * Input 4 : Nbytes: number of bytes to transfer
- * Output : None
- * Return value : None
- *******************************************************************************/
- void CopyBuffer(int iTrDirection, BYTE EpNum, BYTE *Usr_buffer, int Nbytes)
- {
- DWORD *pTxBuff;
- WORD wTra;
- BYTE *pbTra;
- int i;
- if (iTrDirection == USR_TO_PMA)
- {
- pTxBuff = (DWORD *)(PMAAddr + (BYTE *)(GetEPTxAddr(EpNum)*2));
- for(i = 0; i < Nbytes;)
- {
- pbTra = (BYTE *)&wTra;
- *pbTra++ = *Usr_buffer++;
- i++;
- if (i < Nbytes) /* check for ODD transfers */
- *pbTra = *Usr_buffer++;
- else
- *pbTra = 0;
- *pTxBuff++ = wTra;
- i++;
- }
- }
- } /* CopyBuffer */
- /*******************************************************************************
- * Function Name : Mouse_Send
- * Description : Decodes commands arriving from serial and
- * prepares buffer to be sent containing mouse event infos
- * Input 1 : deltaX: cursor delta X
- * Input 2 : deltaY: cursor delta Y
- * Input 3 : buttons: mouse buttons status
- * Output : None
- * Return value : None
- *******************************************************************************/
- void Mouse_Send(int deltaX, int deltaY, int buttons)
- {
- BYTE Mouse_Buffer[3];
- /* prepare buffer to send */
- Mouse_Buffer[0] = buttons;
- Mouse_Buffer[1] = deltaX;
- Mouse_Buffer[2] = deltaY;
- CopyBuffer(USR_TO_PMA, ENDP1, Mouse_Buffer, 3);
- /* enable endpoint for transmission */
- SetEPTxAddr(ENDP1, ENDP1_TXADDR);
- SetEPTxCount(ENDP1, 4);
- SetEPTxValid(ENDP1);
- } /* Mouse_Send */
- /*******************************************************************************
- * Function Name : Keys_Read
- * Description : Checks if a new character from terminal has arrived
- * Input 1 : deltaX: cursor delta X
- * Input 2 : deltaY: cursor delta Y
- * Input 3 : buttons: mouse buttons status
- * Output : None
- * Return value : None
- *******************************************************************************/
- void Mouse_Action(int deltaX, int deltaY, int buttons)
- {
- if (fCellSuspended)
- Resume(RESUME_INTERNAL); // remote wake-up
- else
- Mouse_Send(deltaX, deltaY, buttons);
- }
- void Mouse_Init(void)
- {
- XTI_Init();
- GPIO_Config(GPIO2, 1<<8, GPIO_INOUT_WP);
- XTI_LineModeConfig(XTI_Line2, XTI_FallingEdge);
- XTI_LineConfig(XTI_Line2, ENABLE);
- XTI_ModeConfig(XTI_Interrupt, ENABLE);
- EIC_IRQChannelPriorityConfig(XTI_IRQChannel, 1);
- EIC_IRQChannelConfig(XTI_IRQChannel, ENABLE);
- gInit(); /* init hardware */
- USB_Init();
- }