super_star

Customized pc keypad, CH552 microcontroller HID keyboard, computer multimedia keypad

 
Overview

A custom keyboard made using Qinheng CH552G 51 microcontroller (CH551G can also be used), using 3 Kaihua low axes and an EC16 incremental rotary encoder (EC11 can also be used, there is a project for EC11 in the attachment, and the program for EC16 is more general ), the interface uses MICRO-USB with positioning posts. The H1 next to the MICRO-USB is used for short-circuit plugging into the computer for program downloading (no need to solder the pins, just use tweezers to short-circuit). In order to avoid problems when using different rotary encoder drivers, the attachment provides links to the two rotary encoders I use, program source code, component list, HID protocol, and HID usage table.

Program download tool: http://www.wch.cn/download/WCHISPTool_Setup_exe.html

Button function customization:

  • Normal keyboard keys:
  • For the hid value of ordinary keys, you can see the Usage ID (Hex) of the Keyboard/Keypad Page  in the HID usage table 1.12.pdf provided in my attachment. The 06 of C is 0x06.
键盘发送给PC的数据每次8个字节:BYTE1 BYTE2 BYTE3 BYTE4 BYTE5 BYTE6 BYTE7 BYTE8。定义分别是:
BYTE1 --
       |--bit0:   Left Control     0x01 
       |--bit1:   Left Shift       0x02 
       |--bit2:   Left Alt         0x04 
       |--bit3:   Left GUI(win键)  0x08 
       |--bit4:   Right Control    0x10
       |--bit5:   Right Shift      0x20 
       |--bit6:   Right Alt        0x40
       |--bit7:   Right GUI        0x80
BYTE2 -- 暂不清楚,有的地方说是保留位
BYTE3--BYTE8 -- 这六个为普通按键
以按键1修改为例:
  按键功能:ctrl + c 
if(keyCode == 0x31)//按键1
{
    HIDKey[0] = 0x01; //HIDKey[0]放Ctrl、Shift、Alt这些。这里为  左Ctrl 0x01
        HIDKey[2] = 0x06; //HIDKey[2]-HIDKey[7]为按下的第一个按键到第六个,这里0x06为c
    if(Ready) //枚举成功
        {
            HIDValueHandle1(); //多媒体按键HID值上传
        }
}
  • Multimedia buttons:

BYTE1: Vol- to Scan Pre Track BYTE2: 8 from the beginning of Scan Next Track. For the value, refer to BYTE1 below to compare the KeyMULRepDesc ​​number sequence.

BYTE1 BYTE2 BYTE3 这3个字节分成24位,每个位代表一个按键,1代表按下,0抬起。
BYTE1 --
       |--bit0:  Vol-                 0x01
       |--bit1:  Vol+                 0x02 
       |--bit2:  Mute                 0x04
       |--bit3:  Email                0x08 
       |--bit4:  Media                0x10
       |--bit5:  WWW Home             0x20 
       |--bit6:  Play/Pause           0x40 
       |--bit7:  Scan Pre Track       0x80 
BYTE2 BYTE3按下面的顺序排下去,BYTE3 bit7:最后一个Usage( NULL )。
BYTE4 --
    系统功能按键,关机(0x81),休眠(0x82),唤醒(0x83)
以按键1修改为例:
if(keyCode == 0x31)//按键1
{
    HIDKeyMUL[0] = 0x02; //音量+
    if(Ready) //枚举成功
        {
            HIDValueHandle2(); //多媒体按键HID值上传
        }
}

Program download steps: Short-circuit H1 first and then plug it into the computer. See the picture below. The CH552G is used in the project (if you use other models, just choose the corresponding model). The computer can't recognize it when I plug it into the USB hub.

  1. Choose the 8-bit CH55X series.
  2. Select CH552.
  3. Mark the √ of (Run the target program after downloading is completed) so that you don’t need to unplug and restart.
  4. Look at the USB device list and if the device appears, you can proceed to the next step.
  5. Select the compiled program CH552E.hex.
  6. Click Download, and the download will start when the download progress bar at the bottom is finished.
  7. Remember to select usb as the download method

QQ screenshot 20200819130054.jpg 1. Modification date: 2021-01-02 10:54 2. Modification date: 2021-08-13 16:07 I accidentally sent the wrong modified source code for correction, and fixed the problem with the type-c port board file 3. Modification date : 2021-08-14 11:28 The EC16 purchase link has expired. The EC16 purchase address has been removed in the attachment update. The EC16 program is more common for other models of rotary encoders 4. Modification date: 2021-12-05 19:08 Attachment added The WS2812 driver of CH55x is installed for friends who need to add WS2812.

参考设计图片
×
 
 
Search Datasheet?

Supported by EEWorld Datasheet

Forum More
Update:2025-06-24 05:48:12

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
community

Robot
development
community

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号