Search
Try Notion
QMK
Overview
原理图( chain of actions taking place: )
+------+ +-----+ +----------+ +----------+ +----+ | User |-------->| Key |------>| Firmware |----->| USB wire |---->| OS | +------+ +-----+ +----------+ +----------+ +----+
Copy
C
quantum/main.c
💻Main.c
int main(void) { platform_setup(); protocol_setup(); keyboard_setup(); protocol_init(); /* Main loop */ while (true) { protocol_task(); #ifdef DEFERRED_EXEC_ENABLE // Run deferred executions deferred_exec_task(); #endif // DEFERRED_EXEC_ENABLE housekeeping_task(); }
Copy
C
main init
和一般程序一样都是从main 开始运行 You can think of QMK as no different from any other computer program. It is started and performs its tasks, but this program never finishes. Like other C programs, the entry point is the main()
最开始是初始化硬件和配置 hardware that has been configured(including USB to the host)
最常见的平台 platform for QMK is lufa (AVR processors such as the atmega32u4)
it will invoke for example platform_setup() in platforms/avr/platform.c 
and protocol_setup() in tmk_core/protocol/lufa/lufa.c
同理 chibios vusb 也是一样的原理
main loop
main loop 中调用  protocol_task()
而又会调用 call keyboard_task() in quantum/keyboard.c
keyboard_task() 内容
Matrix Scan • Matrix Scanning
Mouse Handling
Keyboard status LEDs (Caps Lock, Num Lock, Scroll Lock)