CY4636 WirelessUSB™ LP Keyboard Mouse Reference Design Kit User Guide, Doc. # 001-70355 Rev. *A
91
Code Examples
5.3.3.9
Code Performance Analysis
A key press report is used to analyze the code performance. A typical key press report contains the
following steps:
■
A key press interrupts the MCU. The prior section has calculated that it takes 3.667 µs for MCU to
responds to this Interrupt.
■
MCU exits the sleep state, scans the Bind button and turns on the timer. It takes 40.8 µs.
■
MCU calls function scan_keyboard() to detect which key is pressed. This function consumes
1.15 ms.
■
MCU calls function generate_standard_report () to format the report and send the report to the
bridge. This step takes 2.01 ms, which includes 1.66 ms radio transmission time.
As a result, it takes 3.20 ms for the keyboard to report a key press to the bridge.
5.3.3.10
Modifying the Keyboard Matrix or Adding New Keys
The current keyboard matrix with the USB scan codes are shown in Table A.6-1. Customers may
modify the keyboard matrix or they may add new keys to their keyboard. The following sections
explain the procedure.
Modifying the Keyboard Matrix.
In the file
kdefs.h,
a table called default_keyboard_scan_table
matches the keyboard matrix shown in Table A.6-1. By modifying this table, the keyboard matrix is
automatically modified.
Adding New Keys.
Example: The customer wants to add a multimedia key called My Computer,
which is located at Column 15 and Row 6 and has a scan code of 0x0194. The following steps must
be performed:
1. Go to file kdefs.h, and search for default_keyboard_scan_table. In the Col 15 (0xF) section, mod-
ify line 7 from {NO_DEVICE, NOKEY} to {DEVICE_2, 0x000E}. The 0x000E is the index into the
device 2 table.
2. Go to the table called device_2_keyboard_scan_table within the same file and add the scan code
of 0x0194 to the end of the table, as shown:
const UINT16 device_2_keyboard_scan_table[] =
{
0x0192, // Calculator
0x0223, // WWW Home
0x00CD, // Play/Pause
0x0221, // WWW Search
0x018A, // Mail
0x00E9, // Volume Up
0x00E2, // Mute
0x00B7, // Stop
0x00EA, // Volume Down
0x022A, // WWW Favorites
0x0225, // WWW Forward
0x0224, // WWW Back