CY4636 WirelessUSB™ LP Keyboard Mouse Reference Design Kit User Guide, Doc. # 001-70355 Rev. *A
51
Code Examples
Timer.
The module includes busy wait time
Radio Driver.
The radio driver module is a low level module providing basic radio communication
and configuration. Its general application is such that it is likely not to be changed by the firmware
developer. It provides an interface for reading/writing radio registers, setting PN codes and initializa-
tion of the radio and transmitting or receiving packets. See the Radio Driver documentation for
details.
Master Protocol.
The module includes LP RDK master protocol routines to handle ping, button
bind, channel agility and data packets. This module has a dependency on the radio driver for send-
ing and receiving formatted packets and the flash module.
5.1.3.2
Application Code
The group of modules that make up the application code is responsible for implementing the bridge
functionality and behavior.
Bridge Module.
The bridge module is the controlling code for the application. It has many responsi-
bilities in implementing various features and functions offered by the bridge. The function main() is
the entry point for the bridge application. This function is called from the
boot.asm
file. The bridge
first initializes all of the application modules and then initializes the master_protocol module. There is
an order dependency for some of these, so care must be taken in modifying the bridge_init() func-
tion. For example, other modules depend upon the timer facility running in order to perform initializa-
tion.
Once each module has been initialized, then the application checks for entry to the manufacturing
test mode. If the manufacturing test mode is not indicated, then normal bridge operation begins. The
bridge continuously checks the USB idle timer, received packet, the Bind button and the USB sus-
pend.
■
Check the USB Idle Timer
The check_usb_idle() function is called within the main() function to properly handle the USB
Set_Idle command. The USB Set_Idle command from the host PC is used to silence the keyboard or
mouse report until a new event occurs or the specified amount of time passes. If the host PC's
Set_Idle command sets the Idle Duration to '0', the keyboard or mouse endpoint inhibits reporting
forever, only reporting when a change is detected in the report data. This causes the bridge to NAK
any polls on the endpoint while its current report remains unchanged. If the Set_Idle command sets
the Idle Duration to a non-zero number, a single report is generated by the endpoint if the given time
duration elapses with no change in report data (see the HID Specification for more information on
this topic).
The check_usb_idle() function also checks the time out for down key and 'keep alive' packet. A 'keep
alive' packet is transmitted every 65 ms during the time a key is pressed, so that the bridge can
detect if the RF link is lost, and in that unlikely case, the bridge inserts a 'key up' event, to prevent a
'stuck key' state being transmitted to the PC. The number of milliseconds before upkey reports are
generated is defined by DOWNKEY_TIME_OUT.
■
Check the Received Packet
When the bridge receives a valid packet, it parses the packet. If it is a data packet, the bridge for-
mats and sends a USB packet to the USB host. If it is a connect request with an approved device or
a ping request, the bridge sends a response correspondingly.
■
Check the Bind Button
The bridge checks the Bind button frequently. If this button is pressed, the bridge goes into the bind
state.