键盘基本工作原理 - 图文 联系客服

发布时间 : 星期一 文章键盘基本工作原理 - 图文更新完毕开始阅读efc45365783e0912a2162aea

终止传输的最后一个检查 要持续至少5us

The system can hold the 'clock' signal inactive to inhibit the next transmission. 系统拉低时钟线,将禁止下一次传输

The system can set the 'data' line inactive if it has a byte to transmit to the device. The 'data' line is set inactive when the start bit (always 0) is placed on the 'data' line. 系统如果有一个字节要传输给设备,可以拉低数据线。当开始位(总是0)放置到数据线时,数据线被拉低。

The system raises the 'clock' line to allow the next transmission. 系统拉高时钟将允许下一次传输

Host-to-Device主机到设备的通信

First of all, the PS/2 device always generates the clock signal. 首先,PS/2设备总是产生时钟信号

If the host wants to send data, it must first put the Clock and Data lines in a \

如果主机想发送数据,它必须先将时钟线和数据线设置成\状态: 1) Inhibit communication by pulling Clock low for at least 100 microseconds. 拉低时钟线至少100us来禁止通信

2) Apply \拉低数据线,请求 \然后释放时钟 .

The device should check for this state at intervals not to exceed 10 milliseconds. 设备应该在不超过10ms(注意,是毫秒)的间隔内就要检查一次这个状态。

When the device detects this state, it will begin generating Clock signals and clock in eight data bits and one stop bit.

当设备检测到这个状态,它将开始产生时钟信号,

The host changes the Data line only when the Clock line is low, and data is read by the device when Clock is high.

只有当时钟线 为低的时候,主机才可以改变数据线(也就是将数据写入到数据线)。数据将在时钟为高电平的时候 被 设备读取。

After the stop bit is received, the device will acknowledge the received byte by bringing the Data line low and generating one last clock pulse.

在收到停止位之后,设备将通过拉低数据线,生成最后一个时钟脉冲 来 应答收到的字节

If the host does not release the Data line after the 11th clock pulse, the device will continue to generate clock pulses until the the Data line is released (the device will then generate an error.)

在第11个时钟脉冲之后,如果主机并没有释放数据线,设备将继续产生时钟脉冲,直到数据线被释放(然后 设备将产生一个错误)

The host may abort transmission at time before the 11th clock pulse (acknowledge bit) by holding Clock low for at least 100 microseconds.

在第11个脉冲之前(回应位),主机可以随时中止传输,只要拉低时钟持续100us即可

时间参数 最大值/最小值 T7 时钟低电平 30-50 us T8 时钟高电平 30-50 us

T9 30-50 us

T9 == Time from inactive to active CLK transition, used to time when the auxiliary device samples DATA

FreeScale(Moto)提供的时序图 主机到键盘的数据传输

1.主机 通过拉低 时钟线 来 启动一个主机到键盘的数据传输。大约35us后,主机拉低数据线

。这个事件序列 就是 通知 键盘,主机要传输一个命令了。在数据信号的下降沿大约 125us 后 时钟信号释放,就被键盘内部的上拉电阻拉为高电平 。

2. 在时钟信号的上升沿 约 1ms ,数据传输开始。这个期间,数据线保持低电平。键盘拉低时钟线,clocking in the low data line. 这个就做传输的起始位。

3. 键盘用时钟驱动 8个数据位从主机传输到自己这边。 这个时钟有50%的占空比(duty cycle).高电平和低电平的时间都在30~50us之间。主机在每个周期的低电平的时候改变数据线上的数据。在每个时钟的上升沿5~25us之后键盘 开始从数据线上取样,取出主机发来的数据。

4.数据位之后是一个奇偶校验位(采用奇校验)

5.最后是停止位

6.如果键盘读到一个高电平的停止位,键盘就在 取样停止位的那个时钟的下降沿 之后的低电平期间 拉低数据线。这个行为叫做 键盘给主机的应答信号。 键盘拉高时钟之后,也拉高数据线。

7.在收到一个字节后,键盘对接收的数据执行一个奇偶校验。如果奇偶校验错误,或者

接收的数据无法识别为有效的命令,那么键盘请求重新发送(发送0xFE给主机)

1. 键盘发送数据前,首先必须让时钟 和数据线都在键盘内部的上拉电阻作用下 拉成高电平。然后键盘拉低数据线,5-25us之后,键盘拉低时钟线。在时钟的下降沿,开始传输起始位The falling edge of the clock line clocks in the transfer’s start bit.

2. 键盘用时钟驱动 8个数据位到主机。 这个时钟有50%的占空比(duty cycle).高电平和低电平的时间都在30~50us之间。键盘在每个周期的高电平的时候改变数据线上的数据。这个改变出现在时钟的上升沿的5us后 和 下降沿的5us前。键盘的数据在时钟的下降沿被锁存进主机。

3.数据位之后是一个奇校验位

4.最后是停止位。在时钟的下降沿 0~50us之间 主机拉低时钟 来锁存停止位。这就告诉键盘主机现在忙,不能在接收 其他的键盘传输数据。在处理完接收的数据,准备好接收下一个数据之前,主机释放时钟。

6.在键盘传输数据到主机的过程中,主机任何时候都可以中断这个传输,发送一个命令到键盘。主机拉低时钟和数据线 即可中止传输。所以,键盘在时钟为 低电平的时候必须取样数据线。(无论什么时候输出高数据位的时候)。在产生时钟的上升沿时,必须