User manual

44 CY4672 Reference Design Guide, Document # 001-16968 Revision **
Mouse
observing packet data on a Listener, a correlation can be made with a USB protocol analyzer. This is
useful for debugging data loss since the test mode guarantees packet delivery.
Entry to this test mode can be changed by modifying the macro TESTMODE_BUTTONS in the test-
mode.c
file. The button macros are defined in the buttons.h file.
3.3.5.4 Buttons Module
The buttons module provides an API for handling both the bind and mouse buttons. This module
must be changed when adding or removing buttons for a new mouse design. The button portion of
the packet payload is formatted by this module and needs to change if more buttons are added. See
the Mouse Module on page 42 module for a definition of the packet payload format.
This module manages power configurations that may be implemented to conserve power related to
button presses. For example, button polling is turned off and interrupts are used to detect button
presses in the idle state. It also manages the acquisition of button information depending on the
implementation: interrupts or polling.
When changes in a button state are detected, the mouse module is notified for collection and report-
ing of the data.
Note It is important for the buttons module to always report the button state when a
button is pressed. This condition frequently occurs when the mouse is moved with the button held
down.
3.3.5.5 Mfgtest Module
The manufacturing test module may be optionally compiled in, at the expense of code space, by
defining the macro MFG_TEST_CODE. In addition, a more complete version may be compiled in by
defining MFG_TX_MODES. The TX modes include code to perform a carrier test as well as a ran-
dom data test.
The manufacturing test code is designed to be compatible with the CY3631 Manufacturing Test Kit
Tester. Entry into this mode on the mouse is performed by placing a shorting block over pins four and
five of the ISSP programming header and then inserting the batteries. The test mode may only be
exited by removing the batteries and shorting block. For more information on how to use this test
mode, refer to the CY3631 Manufacturing Test Kit documentation.
It is recommended that you not make changes to this module unless similar changes are made to
the CY3631 Tester.
3.3.5.6 Wheel Module
The wheel module implements the functionality of the z-wheel. It is responsible for power modes
associated with the z-wheel, polling, z-wheel interrupts, wheel position tracking, and partial packet
formatting for z-wheel reports.
When the z-wheel is being polled, the GPIO pins are turned on with internal pull up resistors just
long enough to read the state. This is done to conserve power when the mouse is active. When the
polling timer has been turned off the wheel_poll_sleep() function is called which only looks for
change from the last state; it does not keep track of wheel position.
Z-wheel position tracking is done by comparing debounced wheel input to the previous two states.
Depending upon the wheel input phase transition the direction of the wheel can be determined. The
poll rate must be frequent enough to debounce and catch these transitions for a smooth response.
The RDK mouse is shipped with a mechanical encoder. It is typical for this decoder to rest on a
detent such that the z-wheel inputs are either both high or both low, hence the reason for only turning
on the pull ups when polling the input. Transition from one of these states to the other is reported as
a +/-1 motion.
Note Sometimes the mechanical detents do not align with the high-high or low-low
state and movement may not be seen every time from detent to detent.
[+] Feedback