Summaries of keyboard

Source: Internet
Author: User

I8048

Although most set two make codes are only one-byte wide, there are a Handfull of "extended keys" whose make codes are two or four bytes wide. these make codes can be identified by the fact that their first byte is e0h.

You won't always have to use Lookup tables to figure out a key's break code -- certain relationships do exist between make codes and break codes. most set two break codes are two bytes long where the first byte is f0h and the second byte is the make code for that key. break codes for extended keys are usually three bytes long where the first two bytes are e0h, f0h, And the last byte is the last byte of that key's make code.

Key (Set 2)
Make code
(Set 2)
Break Code
"" 1C F0, 1C
"5" 2E F0, 2E
"F10" 09 F0, 09
Right Arrow E0, 74 E0, F0, 74
Right "Ctrl" E0, 14 E0, F0, 14

There are two important parameters here:Typematic delay, Which is the short delay between the first and second "A", andTypematic rate, Which is how many characters per second will appear on your screen after the typematic delay. the typematic delay can range from 0.25 seconds to 1.00 second and the typematic rate can range from 2.0 cps (characters per second) to 30.0 cps. you may change the typematic rate and delay using the "Set Typematic Rate/Delay" (0xF3) command.

At power-on or software reset (see the "Reset" command) the keyboard performs a diagnostic self-test referred to as BAT (Basic Assurance Test) and loads the following default values:

  • Typematic delay 500 ms.
  • The Typematic rate is 10.9 cps.
  • Scan code set 2.
  • Set all keys typematic/make/break.

When entering BAT, the keyboard enables its three LED indicators, and turns them off when BAT has completed. at this time, a BAT completion code of either 0xAA (BAT successful) or 0xFC (Error) is sent to the host. this BAT completion code must be sent 500 ~ 750 milliseconds after power-on.

Command Set:

A few notes regarding commands the host can issue to the keyboard:

  • The keyboard clears its output buffer when it recieves any command.
  • If the keyboard has es an invalid command or argument, it must respond with "resend" (0xFE ).
  • The keyboard must not send any scancodes while processing a command.
  • If the keyboard is waiting for an argument byte and it instead has es a command, it shoshould discard the previous command and process this new one.

Below are all the commands the host may send to the keyboard:

  • 0xFF (Reset)-Keyboard responds with "ack" (0xFA), then enters "Reset" mode. (See "Reset" section .)
  • 0xFE (Resend)-Keyboard responds by resending the last-sent byte. the exception to this is if the last-sent byte was "resend" (0xFE ). if this is the case, the keyboard resends the last non-0xFE byte. this command is used by the host to indicate an error in injection.

The next six commands can be issued when the keyboard is in any mode, but it only effects the behavior of the keyboard when in "mode 3" (ie, set to scan code set 3 .)

  • * 0xFD (Set Key Type Make)-Disable break codes and typematic repeat for specified keys. keyboard responds with "ack" (0xFA), then disables scanning (if enabled) and reads a list of keys from the host. these keys are specified by their set 3 make codes. keyboard responds to each make code with "ack ". host terminates this list by sending an invalid set 3 make code (eg, a valid command .) the keyboard then re-enables scanning (if previusly disabled ).
  • * 0xFC (Set Key Type Make/Break)-Similar to previous command, except t this one only disables typematic repeat.
  • * 0xFB (Set Key Type Typematic)-Similar to previous two, except t this one only disables break codes.
  • * 0xfa (set all keys typematic/make/break)-keyboard responds with "Ack" (0xfa ). sets all keys to their normal setting (generate scan codes on make, break, and typematic repeat)
  • * 0xf9 (set all keys make)-keyboard responds with "Ack" (0xfa). Similar to 0xfd, using t applies to all keys.
  • * 0xf8 (set all keys make/break)-keyboard responds with "Ack" (0xfa). Similar to 0xfc, using t applies to all keys.
  • * 0xf7 (set all keys typematic)-keyboard responds with "Ack" (0xfa). Similar to 0xfb, doesn't applies to all keys.
  • 0xf6 (Set Default)-load default typematic rate/delay (10.9cps/500 ms), key types (all keys typematic/make/break), and scan code set (2 ).
  • 0xf5 (disable)-keyboard stops scanning, loads default values (see "Set Default" command), and waits further instructions.
  • 0xf4 (enable)-re-enables keyboard after disabled using previous command.
  • 0xF3 (Set Typematic Rate/Delay)-Host follows this command with one argument byte that defines the typematic rate and delay as follows:
    . Repeat rate
    Bits 0-4 Rate (CPS)   Bits 0-4 Rate (CPS)   Bits 0-4 Rate (CPS)   Bits 0-4 Rate (CPS)
    00 h 30.0   08 h 15.0   10 h 7.5   18 h 3.7
    01 h 26.7   09 h 13.3   11 h 6.7   19 h 3.3
    02 h 24.0   0Ah 12.0   12 h 6.0   1Ah 3.0
    03 h 21.8   0Bh 10.9   13 h 5.5   1Bh 2.7
    04 h 20.7   0Ch 10.0   14 h 5.0   1Ch 2.5
    05 h 18.5   0Dh 9.2   15 h 4.6   1Dh 2.3
    06 h 17.1   0Eh 8.6   16 h 4.3   1Eh 2.1
    07 h 16.0   0Fh 8.0   17 h 4.0   1Fh 2.0

    Delay

    Bits 5-6 Delay (seconds)
    00b 0.25
    01b 0.50
    10b 0.75
    11b 1.00


  • * 0xF2 (Read ID)-The keyboard responds by sending a two-byte device ID of 0xAB, 0x83. (0xAB is sent first, followed by 0x83 .)
  • * 0xF0 (Set Scan Code Set)-Keyboard responds with "ack", then reads argument byte from the host. this argument byte may be 0x01, 0x02, or 0x03 to select scan code set 1, 2, or 3, respectively. the keyboard responds to this argument byte with "ack ". if the argument byte is 0x00, the keyboard responds with "ack" followed by the current scan code set.
  • 0xEE (Echo)-The keyboard responds with "Echo" (0xEE ).
  • 0xed (Set/Reset LEDs)-the host follows this command with one argument byte, that specifies the state of the keyboard's Num Lock, caps lock, and scroll lock LEDs. this argument byte is defined as follows:

MSb LSb

Always 0 Always 0 Always 0 Always 0 Always 0 Caps Lock Num Lock Scroll Lock


    • "Scroll Lock"-Scroll Lock LED off (0)/on (1)
    • "Num Lock"-Num Lock LED off (0)/on (1)
    • "Caps Lock"-Caps Lock LED off (0)/on (1)

* Originally available in PS/2 keyboards only.

I8042

The 8042 contains the following registers:

  • A one-byte input buffer-contains byte read from keyboard; read-only
  • A one-byte output buffer-contains byte to-be-written to keyboard; write-only
  • A one-byte Status Register-8 Status flags; read-only
  • A one-byte control register-7 control flags; read/write

The first three registers (input, output, status) are directly accessible via ports 0x60 and 0x64.

Port Read/
Write
Function
0x60 Read Read input buffer
0x60 Write Write output buffer
0x64 Read Read Status Register
0x64 Write Send command

Writing to port 0x64 doesn't write to any specific register, but sends a command for the 8042 to interpret. if the command accepts a parameter, this parameter is sent to port 0x60. likewise, any results returned by the command may be read from port 0x60.

To be continued ...........

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.