CY4636 WirelessUSB™ LP Keyboard Mouse Reference Design Kit User Guide, Doc. # 001-70355 Rev. *A
71
Code Examples
In the active state the mouse attempts to deliver a packet for the amount of time designated in
MOUSE_TX_TIMEOUT_MS. If it is unable to send the packet in this time, then it transitions to the
disconnected state.
The mouse application is responsible for detecting the Bind button press and then calling the bind
function in the protocol module.
The mouse application sends mouse reports as frequently as events arrive, but not any faster than
the time defined in the macro MOUSE_REPORT_IN_MS. Care must be used when setting this time
so that the report rate does not exceed that which the USB bus is capable of handling. Keep in mind
that the report rate varies slightly due to drift of the internal oscillator used to keep track of time.
Optical Module.
The optical sensor module encapsulates the initialization, calibration and reading
of the optical sensor. This module also handles any power management required by the sensor,
along with motion detection if supported. The contents of this module potentially change with every
design and are unique to the sensor used.
This module has the responsibility to format the X and Y data into the mouse packet payload. Refer
to section Wireless Protocol Data Payload for a definition of the packet payload.
Battery Module.
The battery module is responsible for measuring the battery voltage and convert-
ing it into a level between one and ten using an A/D.
The battery monitor circuit is implemented using a resistor and capacitor to filter out ripple from the
switcher, and is routed to an analog input on the enCoRe III LV microcontroller. This input is then
connected to a 10 bit single slope analog to digital converter User Module. The firmware has been
implemented to read the battery voltage and then provide a ten level mapping of the battery voltage.
The battery level is periodically measured and changes in level are transmitted to the bridge; see the
mouse module for the algorithm.
The battery module must be calibrated at power on reset prior to use in order to compensate for
partto- part differences. Calibration is accomplished by calling:
BatteryV_iCal(BATT_CAL_SET_POINT, BatteryV_CAL_VBG) prior to each use. This forces the A/D
to calibrate as close as possible to 1.3 V.
BATT_CAL_SET_POINT is = 475 (1.3V /2.8 V * 1023) which is the digital representation of 1.3 volts
using the internal band gap reference.
Testmode Module.
The Testmode module provides code to continuously perform a vector drawing
test within a drawing application. This test mode is used to check radio range, co-location and inter-
operability of the mouse with the keyboard.
The test mode, when compiled in, is entered by holding down the left and right button while inserting
the batteries. The buttons must be held down until the optical sensor begins to flash. As soon as the
buttons are released the mouse repeatedly draws 'LP' in the drawing application. Each successive
'LP' should be drawn on top of the previous one. The test mode may only be exited by removing the
batteries. All button presses and mouse movement are ignored when in the test mode. However,
care must be taken not to bump other mice connected to the PC.
Note the mouse 'acceleration' or 'enhance pointer precision' option must to be turned off in the Win-
dows mouse Control Panel for this test to execute properly. If the letters are drawn erratically with
uneven sides or excessive amounts of space in between them, then check this setting or its equiva-
lent (based upon your PC operating system).