完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
我找不到一个有用的PS-2键盘程序,它会产生ASCII码。这个项目是这样做的,它包括使用移位键来获取大小写字符和符号。只对主键盘区域进行解码,不解码主屏幕右侧的打印屏幕、插入、删除和其他键。您可以根据需要添加这些文件。您也可以为FX键添加一个值。该示例包括用于大写字母的数组和具有ASCII码的小写字母值的数组。使用0x0保存“空间”,这样您就可以插入一个代码,例如生成0x0C键盘扫描代码的F4键。找到数组中的位置并替换您想要的F4键提供的代码。我已经包含了一个ASCII翻译的键盘表,它列出了两个数组的所有字节,索引在0到0x7f之间。这个信息有助于找到键盘扫描代码,并在按下时插入要生成的ASCII值。我还包括一个流程图,说明代码是如何运行的。
当你按下一个键时,PS-2键盘在一个看起来像UART传输(LSB首)的11位串行流中发送信息。每个密钥都有一个指定的非ASCII代码。当移位或未移位时,此代码保持不变。软件查找Shift键并相应地处理数据。当您释放一个键时,键盘发送一个“密钥释放”字节(0xf0),后面跟着字母的代码。软件也处理这个问题。来自键盘的时钟信号将将这些位选入SPI寄存器。我使用LSB第一和模式1,1,包括在这个项目中。 在典型的使用中,您将使用SPI端口来生成中断,但是示例代码只运行无限的“键盘输入”例程,并将字符与终端程序进行回声。这种设置使得软件易于测试。我使用CY8CKIT-059 5LP原型试剂盒。我用SaleAE逻辑分析仪监视键盘数据,并在我的Win 10PC上运行视差串行终端来检查项目的ASCII输出。玩得高兴。乔恩·提图斯,埃里曼,UT 工作空间03.BultLe01.Zip 1.6兆字节 以上来自于百度翻译 以下为原文 I couldn't find a useful PS-2 keyboard routine that would produce ASCII codes. This project does that and it includes use of the Shift keys to get upper-and lower-case characters and symbols. Decoding works for only the main keyboard area and doesn't decode the Print Screen, Insert, Delete, and other keys on the right side of the main keys. You could add these as needed. You can add a value for the Fx keys, also. The example includes an array for upper-case and an array for lower-case values that have ASCII codes. Spaces are "saved" with 0x0 so you can insert a code for, say, the F4 key that generates the keyboard scan code of 0x0C. Find that location in the array and substitute the code you want the F4 key to provide. I have included a table of the keyboard-to-ASCII translations that lists all the bytes for both arrays with an index between 0 and 0x7F. This information helps you locate a keyboard scan code and insert the ASCII value you want to produce when pressed. I also include a flow chart that shows how the code operates. When you press a key, a PS-2 keyboard sends information in an 11-bit serial stream that looks like a UART transmission (LSB first). Each key has an assigned non-ASCII code. This code remains the same when shifted or unshifted. The software looks for the shift key and handles data accordingly. When you release a key, the keyboard send a "key-release" byte (0xF0) followed by the code for the letter. Software handles this, too. A clock signal from the keyboard will strobe the bits into an SPI register. I used the LSB first and mode 1,1, as included in this project. In typical use you would use the SPI port to generate an interrupt, but the example code simply runs an infinite "keyboard input" routine and echoes characters to a terminal program. This setup makes the software easy to test. I used a CY8CKIT-059 5LP Prototyping Kit. I monitored keyboard data with an Saleae Logic analyzer and ran the Parallax Serial Terminal on my Win-10 PC to check the ASCII output from the project. Have fun. Jon Titus, Herriman, UT
|
|
相关推荐
3个回答
|
|
谢谢你的密码。
你只能使用UART(波特率=12000,奇数)。 我有一个很简单的例子,但是我不再记得细节了:PS2YNUMKEY 40.ZIP 以上来自于百度翻译 以下为原文 Thanks for the code. You can use UART only (baudrate = 12000, Odd) I have a very simple example, but I don't remember the details anymore: PS2_NumKey40.zip |
|
|
|
谢谢你的密码。
查看周围的PS/2文档(HTTP://Reald.BeundLogiC.Org/KeBooDe/KiBr.HTM),它看起来像SPI模式应该是CPHA=0,CPOL=1(时钟空闲高,数据在时钟下降时有效)。 但是代码也是按原样工作的。多谢分享。 JJ 以上来自于百度翻译 以下为原文 Thanks for the code. Looking at the PS/2 documentation around (http://retired.beyondlogic.org/keyboard/keybrd.htm ), it looks like the SPI Mode should rather be CPHA=0,CPOL=1 (Clock idle high, data valid on clock falling). But the code is also working as is. Thanks a lot for sharing. JJ |
|
|
|
感谢分享您的项目,我也在考虑一个解码器的PS-2键盘,但我有兴趣开发它使用UDB可编程硬件,在你的经验,你认为有可能做到这一点,或者我应该很好地使用你的方法?
当做, 卡洛斯 以上来自于百度翻译 以下为原文 Thanks for sharing your project, i was also thinking about a decoder for PS-2 keyboards but i was interested in develop it using the UDB programmable hardware, in your experience, do you think it is possible to do it that way or should i be fine using your approach? Regards, Carlos |
|
|
|
只有小组成员才能发言,加入小组>>
716个成员聚集在这个小组
加入小组1901 浏览 1 评论
1652 浏览 1 评论
3405 浏览 1 评论
请问可以直接使用来自FX2LP固件的端点向主机FIFO写入数据吗?
1568 浏览 6 评论
1380 浏览 1 评论
CX3连接Camera修改分辨率之后,播放器无法播出camera的画面怎么解决?
186浏览 2评论
183浏览 2评论
使用stm32+cyw43438 wifi驱动whd,WHD驱动固件加载失败的原因?
321浏览 2评论
348浏览 1评论
62浏览 1评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-4-24 08:34 , Processed in 0.501690 second(s), Total 45, Slave 39 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号