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:
键盘发送给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值上传
}
}
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. 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.
All reference designs on this site are sourced from major semiconductor manufacturers or collected online for learning and research. The copyright belongs to the semiconductor manufacturer or the original author. If you believe that the reference design of this site infringes upon your relevant rights and interests, please send us a rights notice. As a neutral platform service provider, we will take measures to delete the relevant content in accordance with relevant laws after receiving the relevant notice from the rights holder. Please send relevant notifications to email: bbs_service@eeworld.com.cn.
It is your responsibility to test the circuit yourself and determine its suitability for you. EEWorld will not be liable for direct, indirect, special, incidental, consequential or punitive damages arising from any cause or anything connected to any reference design used.
Supported by EEWorld Datasheet