Designing a low cost CY7C63723 combination mouse(6)

2021-01-20 19:41

sampled high, detect PS2. If SDATA(D-) sampledhigh, disable the USB connect resistor and Delay100uS. If D+ and D- are both 0, detect a USBinterface, else detect a PS2 interface.

void MouseTask(void) - This routine is called

every 4 msec from the main loop. It maintains theidle counter, which determines the rate at whichmouse packets are sent to the host in the

absence of a state change in the mouse itself. Italso sends a mouse packet if either of X, Y, or Zcounts or the buttons have changed state.void Suspend(void) - This routine handles theentrance/exit from suspend. If the mouse isconfigured for remote wakeup, the bus reset,wakeup, and GPIO interrupts are enabled. Theoptical inputs are sampled once. The code thenenters a loop in which the chip is suspended, andwill wake at least as often as the wakeup ISR, butperhaps due to a GPIO or a USB bus reset

interrupt. Each time the chip wakes up, the LEDdrive is re-enabled, and the switches and opticalinputs are sampled to see if a change occured,and bus activity is monitored. Any of these

conditions will cause the firmware to exit the loop.If the device is not enabled for remote wakeup, allports are put into the high-Z state, only the USBbus reset interrupt is enabled, and the part issuspended. If the resume was due to bus

activity, the firmware returns to the main loop. Ifthe resume was due to mouse movement or abutton press, a K state is driven upstream for 14milliseconds prior to returning to the main loop.void usbmain(void) – This function spins in aninfinite loop waiting for an event that needs

servicing. Main is entered from either the power-on reset or the USB bus reset. Both of these

reset routines insures that all USB variables havebeen initialized prior to calling usbmain().void HandleSetup(void) - This routine is enteredwhenever an SETUP packet has come in onendpoint 0. It performs some preliminary

validation on the packet, then parses the packetand calls the appropriate routine to handle thepacket.

void HandleIn(void) - This routine is enteredwhenever an IN packet has come in on endpoint0.

void USB_control_read(void) - This routine iscalled after a SETUP has been received that is

entry, XmtBuff has been initialized to point to thedata buffer that needs to be transmitted. Thisfunction adjusts the length of the data to be

returned if the host requested less data than theactual length of the buffer. It then loads the FIFOwith the first packet of data and prepares the SIEto ACK with the data.

char LoadEP0Fifo(void) - This routine loads theUSB endpoint 0 FIFO with data pointed to byXmtBuff. It then returns the length of dataactually loaded into the FIFO.

void SetConfiguration(void) - This routine is

entered when a SET CONFIGURATION requesthas been received from the host.

void SetAddress(void) - This routine is enteredwhenever a SET ADDRESS request has beenreceived. The address change cannot actuallytake place until after the status stage of this no-data control transaction, so we just save theaddress and set a flag to indicate that a newaddress was just received. The code that

handles IN transactions will recognize this andset the address properly.

void GetDescriptor(void) - This routine is enteredwhen a GET DESCRIPTOR request is receivedfrom the host. This function decodes the

descriptor request and initializes XmtBuff to theproper descriptor, then initiates the transfer bycalling USB_control_read().

void SetIdle(void) - This routine is entered

whenever a SET IDLE request is received. Seethe HID spec for the rules on setting idle periods.This function sets the HID idle time. See the HIDdocumentation for details on handling the idletimer.

void SetProtocol(void) - This routine is enteredwhenever an SET PROTOCOL request isreceived. This no-data control transactionenables boot or report protocol.

void GetReport(void) - This routine is enteredwhenever a GET REPORT request to get a reportis received. The most recent mouse data reportis sent to the host via a control-read transactionon endpoint 0, instead of endpoint 1.

void GetIdle(void) - This routine is entered

whenever a GET IDLE request is received. Thisfunction then initiates a control-read transaction


Designing a low cost CY7C63723 combination mouse(6).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:火电厂各系统流程图05(主系统)

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: