]> git.donarmstrong.com Git - qmk_firmware.git/blobdiff - Custom-Quantum-Functions.md
Updated Custom Quantum Functions (markdown)
[qmk_firmware.git] / Custom-Quantum-Functions.md
index 1babb3cda20ad51e44f179ea05e1f173decd0ef8..bdacd31d3c3b476f67012bfe90072194f2b81c8b 100644 (file)
@@ -8,17 +8,42 @@ We have structured QMK as a hierarchy:
   * Keyboard/Revision (`_kb`)
     * Keymap (`_user`)
 
-Each of the functions described below can be defined with a `_kb()` suffix or an `_user()` suffix. We intend for you to use the `_kb()` suffix at the Keyboard/Revision level, while the `_user()` suffix should be used at the keymap level.
+Each of the functions described below can be defined with a `_kb()` suffix or an `_user()` suffix. We intend for you to use the `_kb()` suffix at the Keyboard/Revision level, while the `_user()` suffix should be used at the Keymap level.
 
 When defining functions at the Keyboard/Revision level it is important that your `_kb()` implementation call `*_user()` before executing anything else- otherwise the keymap level function will never be called.
 
-## `void matrix_init_kb(void)` and `void matrix_init_user(void)`
+## Matrix Initialization Code
 
-This function gets called when the matrix is initiated, and can contain start-up code for your keyboard/keymap.
+* Keyboard/Revision: `void matrix_init_kb(void)` 
+* Keymap: `void matrix_init_user(void)`
 
-You should use this function to initialize any custom hardware you may have, such as speakers, LED drivers, or other features which need to be setup after the keyboard powers on.
+This function gets called when the matrix is initiated. You should use this function to initialize any custom hardware you may have, such as speakers, LED drivers, or other features which need to be setup after the keyboard powers on.
 
-## `void matrix_scan_kb(void)` and `void matrix_scan_user(void)`
+#### Example
+
+```
+void matrix_init_kb(void) {
+        // put your keyboard start-up code here
+        // runs once when the firmware starts up
+        matrix_init_user();
+
+        // JTAG disable for PORT F. write JTD bit twice within four cycles.
+        MCUCR |= (1<<JTD);
+        MCUCR |= (1<<JTD);
+
+        // * Set our LED pins as output
+        DDRB |= (1<<0);
+        DDRB |= (1<<1);
+        DDRB |= (1<<2);
+        DDRB |= (1<<3);
+        DDRB |= (1<<4);
+}
+```
+
+## Matrix Scanning Code
+
+* Keyboard/Revision: `void matrix_scan_kb(void)`
+* Keymap: `void matrix_scan_user(void)`
 
 This function gets called at every matrix scan, which is basically as often as the MCU can handle. Be careful what you put here, as it will get run a lot.