[Kinetis] 【YL-KL26Z】USB键盘测试

[复制链接]
 楼主| 舒斯特尔 发表于 2015-12-23 17:15 | 显示全部楼层 |阅读模式
KL26Z带有USB接口,可以做USB设备。我们先试试USB键盘吧,还是利用Mbed,几分钟就可以做出一个USB键盘。按下K3,输出“Hello World from Mbed”;按下K4,输出字母s。可以先打开记事本,在按下K3或K4,就可以在记事本上看到输出了。
  1. #include "mbed.h"
  2. #include "USBKeyboard.h"

  3. DigitalIn Key1(PTD6);
  4. DigitalIn Key2(PTA4);

  5. uint8_t cnt = 0;

  6. //USBKeyboard
  7. USBKeyboard keyboard;

  8. int main(void) {
  9.     while (1) {
  10.       if(Key1 == 0)
  11.       {
  12.         keyboard.printf("Hello World from Mbed\r\n");
  13.       }
  14.       if(Key2 == 0)
  15.       {
  16.         keyboard.keyCode('s', 0);
  17.       }
  18.       wait(0.1);
  19.     }
  20. }


 楼主| 舒斯特尔 发表于 2015-12-23 17:16 | 显示全部楼层
代码在这里

USBKeyboard_HelloWorld.zip

506.18 KB, 下载次数: 7

追逐浪花 发表于 2015-12-23 20:02 | 显示全部楼层
这个USB设备是从设备还是主设备?
154220738 发表于 2016-1-20 21:29 | 显示全部楼层
出价买usb键盘例程的代码!
154220738 发表于 2016-1-20 21:31 | 显示全部楼层
你发的不能用
Tennasi 发表于 2016-1-21 08:27 | 显示全部楼层
我来看看,正研究stm32的USB键盘,应该有用
dentsgot 发表于 2016-1-21 18:17 | 显示全部楼层
键盘扫描和USB发送这块如何操作的,我的总是会发好多的东西
您需要登录后才可以回帖 登录 | 注册

本版积分规则

25

主题

277

帖子

1

粉丝
快速回复 在线客服 返回列表 返回顶部