summaries of keyboard

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
"A"
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:  the typematic delay, which is the short delay between the first and second "a", and the typematic 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.
  • Typematic rate 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 receives 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 receives a command, it should 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 reception.
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 previously disabled).
  • *0xFC (Set Key Type Make/Break) - Similar to previous command, except this one only disables typematic repeat.
  • *0xFB (Set Key Type Typematic) - Similar to previous two, except 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, except applies to all keys.
  • *0xF8 (Set All Keys Make/Break) - Keyboard responds with "ack" (0xFA).  Similar to 0xFC, except applies to all keys.
  • *0xF7 (Set All Keys Typematic) - Keyboard responds with "ack" (0xFA).  Similar to 0xFB, except applies to all keys.
  • 0xF6 (Set Default) - Load default typematic rate/delay (10.9cps / 500ms), 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)
    00h
    30.0
     
    08h
    15.0
     
    10h
    7.5
     
    18h
    3.7
    01h
    26.7
     
    09h
    13.3
     
    11h
    6.7
     
    19h
    3.3
    02h
    24.0
     
    0Ah
    12.0
     
    12h
    6.0
     
    1Ah
    3.0
    03h
    21.8
     
    0Bh
    10.9
     
    13h
    5.5
     
    1Bh
    2.7
    04h
    20.7
     
    0Ch
    10.0
     
    14h
    5.0
     
    1Ch
    2.5
    05h
    18.5
     
    0Dh
    9.2
     
    15h
    4.6
     
    1Dh
    2.3
    06h
    17.1
     
    0Eh
    8.6
     
    16h
    4.3
     
    1Eh
    2.1
    07h
    16.0
     
    0Fh
    8.0
     
    17h
    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 0Always 0Always 0Always 0Always 0Caps LockNum LockScroll 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
0x60ReadRead Input Buffer
0x60WriteWrite Output Buffer
0x64ReadRead Status Register
0x64WriteSend 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 ...........

资源下载链接为: https://pan.quark.cn/s/0c983733fad2 本文主要回顾了2021年之前及2021年中国科学技术大学软件学院(简称“中科大软院”)高级软件工程(MN)专业的考试情况,重点聚焦于编程题。编程题在考试中的占比不断提高,因此考生需要深入理解这些题目及其解题方法。 中科大软院的高级软件工程专业致力于培养具备深厚理论基础和强大实践能力的高级软件人才。课程设计注重理论与实践相结合,以满足软件行业对高素质工程师的需求。考试内容通常涵盖计算机基础知识、软件工程理论、编程语言、数据结构与算法、操作系统、数据库系统等多个领域。2021年的考试中,编程题的比重进一步提升,这体现了学院对学生实际编程能力和问题解决能力的重视。 编程题通常涉及常见的编程问题,例如字符串处理、数组操作、递归算法、图论问题等,也可能包括网络编程、数据库查询或系统设计等特定领域的应用。考生需要熟练掌握至少一种编程语言,如C++、Java、Python等,并具备较强的算法分析和实现能力。在解题过程中,考生需要注意以下几点:一是准确理解题目要求,避免因误解而导致错误;二是合理选择并设计算法,考虑时间复杂度和空间复杂度,追求高效性;三是遵循良好的编程规范,注重代码的可读性和可维护性;四是考虑边界条件和异常情况,编写健壮的代码;五是编写测试用例,对代码进行充分测试,及时发现并修复问题。 对于备考的同学,建议多做历年试题,尤其是编程题,以熟悉题型和解题思路。同时,可以参加编程竞赛或在在线编程平台(如LeetCode、HackerRank)进行实战训练,提升编程和问题解决能力。此外,关注PPT中的编程代码也很关键,因为这些代码可能是老师给出的示例或解题思路,能够帮助学生更好地理解和掌握编程题的解法。因此,考生需要深入学习PPT内容,理解代码逻辑,并学会将其应用到实际编程题目中。 总之,对于
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值