aboutsummaryrefslogtreecommitdiff
path: root/tmk_core
diff options
context:
space:
mode:
Diffstat (limited to 'tmk_core')
-rw-r--r--tmk_core/common/action.c63
-rw-r--r--tmk_core/common/action_code.h34
-rw-r--r--tmk_core/common/action_layer.c101
-rw-r--r--tmk_core/common/action_macro.c4
-rw-r--r--tmk_core/common/action_tapping.c37
-rw-r--r--tmk_core/common/action_util.c113
-rw-r--r--tmk_core/common/avr/bootloader.c15
-rw-r--r--tmk_core/common/avr/sleep_led.c19
-rw-r--r--tmk_core/common/avr/suspend.c20
-rw-r--r--tmk_core/common/avr/timer.c24
-rw-r--r--tmk_core/common/backlight.c28
-rw-r--r--tmk_core/common/bootmagic.c14
-rw-r--r--tmk_core/common/bootmagic.h2
-rw-r--r--tmk_core/common/chibios/bootloader.c8
-rw-r--r--tmk_core/common/chibios/eeprom.c44
-rw-r--r--tmk_core/common/chibios/suspend.c18
-rw-r--r--tmk_core/common/command.h4
-rw-r--r--tmk_core/common/eeconfig.c56
-rw-r--r--tmk_core/common/keyboard.c32
-rw-r--r--tmk_core/common/keycode.h1
-rw-r--r--tmk_core/common/led.h3
-rw-r--r--tmk_core/common/magic.c4
-rw-r--r--tmk_core/common/report.c36
-rw-r--r--tmk_core/protocol/lufa/lufa.c106
-rw-r--r--tmk_core/protocol/lufa/outputselect.c16
25 files changed, 732 insertions, 70 deletions
diff --git a/tmk_core/common/action.c b/tmk_core/common/action.c
index 33d920554..fff834791 100644
--- a/tmk_core/common/action.c
+++ b/tmk_core/common/action.c
@@ -44,6 +44,10 @@ int retro_tapping_counter = 0;
44#include <fauxclicky.h> 44#include <fauxclicky.h>
45#endif 45#endif
46 46
47/** \brief Called to execute an action.
48 *
49 * FIXME: Needs documentation.
50 */
47void action_exec(keyevent_t event) 51void action_exec(keyevent_t event)
48{ 52{
49 if (!IS_NOEVENT(event)) { 53 if (!IS_NOEVENT(event)) {
@@ -95,6 +99,10 @@ void action_exec(keyevent_t event)
95bool swap_hands = false; 99bool swap_hands = false;
96bool swap_held = false; 100bool swap_held = false;
97 101
102/** \brief Process Hand Swap
103 *
104 * FIXME: Needs documentation.
105 */
98void process_hand_swap(keyevent_t *event) { 106void process_hand_swap(keyevent_t *event) {
99 static swap_state_row_t swap_state[MATRIX_ROWS]; 107 static swap_state_row_t swap_state[MATRIX_ROWS];
100 108
@@ -134,7 +142,10 @@ bool process_record_quantum(keyrecord_t *record) {
134} 142}
135 143
136#ifndef NO_ACTION_TAPPING 144#ifndef NO_ACTION_TAPPING
137// Allows for handling tap-hold actions immediately instead of waiting for TAPPING_TERM or another keypress. 145/** \brief Allows for handling tap-hold actions immediately instead of waiting for TAPPING_TERM or another keypress.
146 *
147 * FIXME: Needs documentation.
148 */
138void process_record_tap_hint(keyrecord_t *record) 149void process_record_tap_hint(keyrecord_t *record)
139{ 150{
140 action_t action = layer_switch_get_action(record->event.key); 151 action_t action = layer_switch_get_action(record->event.key);
@@ -154,6 +165,10 @@ void process_record_tap_hint(keyrecord_t *record)
154} 165}
155#endif 166#endif
156 167
168/** \brief Take a key event (key press or key release) and processes it.
169 *
170 * FIXME: Needs documentation.
171 */
157void process_record(keyrecord_t *record) 172void process_record(keyrecord_t *record)
158{ 173{
159 if (IS_NOEVENT(record->event)) { return; } 174 if (IS_NOEVENT(record->event)) { return; }
@@ -172,6 +187,10 @@ void process_record(keyrecord_t *record)
172 process_action(record, action); 187 process_action(record, action);
173} 188}
174 189
190/** \brief Take an action and processes it.
191 *
192 * FIXME: Needs documentation.
193 */
175void process_action(keyrecord_t *record, action_t action) 194void process_action(keyrecord_t *record, action_t action)
176{ 195{
177 keyevent_t event = record->event; 196 keyevent_t event = record->event;
@@ -674,8 +693,9 @@ void process_action(keyrecord_t *record, action_t action)
674 693
675 694
676 695
677/* 696/** \brief Utilities for actions. (FIXME: Needs better description)
678 * Utilities for actions. 697 *
698 * FIXME: Needs documentation.
679 */ 699 */
680void register_code(uint8_t code) 700void register_code(uint8_t code)
681{ 701{
@@ -755,6 +775,10 @@ void register_code(uint8_t code)
755 } 775 }
756} 776}
757 777
778/** \brief Utilities for actions. (FIXME: Needs better description)
779 *
780 * FIXME: Needs documentation.
781 */
758void unregister_code(uint8_t code) 782void unregister_code(uint8_t code)
759{ 783{
760 if (code == KC_NO) { 784 if (code == KC_NO) {
@@ -810,6 +834,10 @@ void unregister_code(uint8_t code)
810 } 834 }
811} 835}
812 836
837/** \brief Utilities for actions. (FIXME: Needs better description)
838 *
839 * FIXME: Needs documentation.
840 */
813void register_mods(uint8_t mods) 841void register_mods(uint8_t mods)
814{ 842{
815 if (mods) { 843 if (mods) {
@@ -818,6 +846,10 @@ void register_mods(uint8_t mods)
818 } 846 }
819} 847}
820 848
849/** \brief Utilities for actions. (FIXME: Needs better description)
850 *
851 * FIXME: Needs documentation.
852 */
821void unregister_mods(uint8_t mods) 853void unregister_mods(uint8_t mods)
822{ 854{
823 if (mods) { 855 if (mods) {
@@ -826,12 +858,20 @@ void unregister_mods(uint8_t mods)
826 } 858 }
827} 859}
828 860
861/** \brief Utilities for actions. (FIXME: Needs better description)
862 *
863 * FIXME: Needs documentation.
864 */
829void clear_keyboard(void) 865void clear_keyboard(void)
830{ 866{
831 clear_mods(); 867 clear_mods();
832 clear_keyboard_but_mods(); 868 clear_keyboard_but_mods();
833} 869}
834 870
871/** \brief Utilities for actions. (FIXME: Needs better description)
872 *
873 * FIXME: Needs documentation.
874 */
835void clear_keyboard_but_mods(void) 875void clear_keyboard_but_mods(void)
836{ 876{
837 clear_weak_mods(); 877 clear_weak_mods();
@@ -848,6 +888,10 @@ void clear_keyboard_but_mods(void)
848#endif 888#endif
849} 889}
850 890
891/** \brief Utilities for actions. (FIXME: Needs better description)
892 *
893 * FIXME: Needs documentation.
894 */
851bool is_tap_key(keypos_t key) 895bool is_tap_key(keypos_t key)
852{ 896{
853 action_t action = layer_switch_get_action(key); 897 action_t action = layer_switch_get_action(key);
@@ -880,14 +924,19 @@ bool is_tap_key(keypos_t key)
880} 924}
881 925
882 926
883/* 927/** \brief Debug print (FIXME: Needs better description)
884 * debug print 928 *
929 * FIXME: Needs documentation.
885 */ 930 */
886void debug_event(keyevent_t event) 931void debug_event(keyevent_t event)
887{ 932{
888 dprintf("%04X%c(%u)", (event.key.row<<8 | event.key.col), (event.pressed ? 'd' : 'u'), event.time); 933 dprintf("%04X%c(%u)", (event.key.row<<8 | event.key.col), (event.pressed ? 'd' : 'u'), event.time);
889} 934}
890 935
936/** \brief Debug print (FIXME: Needs better description)
937 *
938 * FIXME: Needs documentation.
939 */
891void debug_record(keyrecord_t record) 940void debug_record(keyrecord_t record)
892{ 941{
893 debug_event(record.event); 942 debug_event(record.event);
@@ -896,6 +945,10 @@ void debug_record(keyrecord_t record)
896#endif 945#endif
897} 946}
898 947
948/** \brief Debug print (FIXME: Needs better description)
949 *
950 * FIXME: Needs documentation.
951 */
899void debug_action(action_t action) 952void debug_action(action_t action)
900{ 953{
901 switch (action.kind.id) { 954 switch (action.kind.id) {
diff --git a/tmk_core/common/action_code.h b/tmk_core/common/action_code.h
index fe2735b97..d836b7a8a 100644
--- a/tmk_core/common/action_code.h
+++ b/tmk_core/common/action_code.h
@@ -17,10 +17,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
17#ifndef ACTION_CODE_H 17#ifndef ACTION_CODE_H
18#define ACTION_CODE_H 18#define ACTION_CODE_H
19 19
20/* Action codes 20/** \brief Action codes
21 * ============
22 * 16bit code: action_kind(4bit) + action_parameter(12bit)
23 * 21 *
22 * 16bit code: action_kind(4bit) + action_parameter(12bit)
24 * 23 *
25 * Key Actions(00xx) 24 * Key Actions(00xx)
26 * ----------------- 25 * -----------------
@@ -38,7 +37,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
38 * 001r|mods|0000 00xx (reserved) 37 * 001r|mods|0000 00xx (reserved)
39 * 001r|mods| keycode Modifiers with Tap Key(Dual role) 38 * 001r|mods| keycode Modifiers with Tap Key(Dual role)
40 * 39 *
41 *
42 * Other Keys(01xx) 40 * Other Keys(01xx)
43 * ---------------- 41 * ----------------
44 * ACT_USAGE(0100): TODO: Not needed? 42 * ACT_USAGE(0100): TODO: Not needed?
@@ -47,17 +45,14 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
47 * 0100|10| usage(10) (reserved) 45 * 0100|10| usage(10) (reserved)
48 * 0100|11| usage(10) (reserved) 46 * 0100|11| usage(10) (reserved)
49 * 47 *
50 *
51 * ACT_MOUSEKEY(0101): TODO: Merge these two actions to conserve space? 48 * ACT_MOUSEKEY(0101): TODO: Merge these two actions to conserve space?
52 * 0101|xxxx| keycode Mouse key 49 * 0101|xxxx| keycode Mouse key
53 * 50 *
54 * ACT_SWAP_HANDS(0110): 51 * ACT_SWAP_HANDS(0110):
55 * 0110|xxxx| keycode Swap hands (keycode on tap, or options) 52 * 0110|xxxx| keycode Swap hands (keycode on tap, or options)
56 * 53 *
57 *
58 * 0111|xxxx xxxx xxxx (reserved) 54 * 0111|xxxx xxxx xxxx (reserved)
59 * 55 *
60 *
61 * Layer Actions(10xx) 56 * Layer Actions(10xx)
62 * ------------------- 57 * -------------------
63 * ACT_LAYER(1000): 58 * ACT_LAYER(1000):
@@ -84,7 +79,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
84 * 101E|LLLL|1111 xxxx Reserved (0xF5-FF) 79 * 101E|LLLL|1111 xxxx Reserved (0xF5-FF)
85 * ELLLL: layer 0-31(E: extra bit for layer 16-31) 80 * ELLLL: layer 0-31(E: extra bit for layer 16-31)
86 * 81 *
87 *
88 * Extensions(11xx) 82 * Extensions(11xx)
89 * ---------------- 83 * ----------------
90 * ACT_MACRO(1100): 84 * ACT_MACRO(1100):
@@ -126,7 +120,7 @@ enum action_kind_id {
126}; 120};
127 121
128 122
129/* Action Code Struct 123/** \brief Action Code Struct
130 * 124 *
131 * NOTE: 125 * NOTE:
132 * In avr-gcc bit field seems to be assigned from LSB(bit0) to MSB(bit15). 126 * In avr-gcc bit field seems to be assigned from LSB(bit0) to MSB(bit15).
@@ -198,10 +192,9 @@ typedef union {
198#define ACTION(kind, param) ((kind)<<12 | (param)) 192#define ACTION(kind, param) ((kind)<<12 | (param))
199 193
200 194
201/* 195/** \brief Key Actions
202 * Key Actions 196 *
203 */ 197 * Mod bits: 43210
204/* Mod bits: 43210
205 * bit 0 ||||+- Control 198 * bit 0 ||||+- Control
206 * bit 1 |||+-- Shift 199 * bit 1 |||+-- Shift
207 * bit 2 ||+--- Alt 200 * bit 2 ||+--- Alt
@@ -230,8 +223,7 @@ enum mods_codes {
230#define ACTION_MODS_TAP_TOGGLE(mods) ACTION(ACT_MODS_TAP, ((mods)&0x1f)<<8 | MODS_TAP_TOGGLE) 223#define ACTION_MODS_TAP_TOGGLE(mods) ACTION(ACT_MODS_TAP, ((mods)&0x1f)<<8 | MODS_TAP_TOGGLE)
231 224
232 225
233/* 226/** \brief Other Keys
234 * Other Keys
235 */ 227 */
236enum usage_pages { 228enum usage_pages {
237 PAGE_SYSTEM, 229 PAGE_SYSTEM,
@@ -243,20 +235,25 @@ enum usage_pages {
243 235
244 236
245 237
246/* 238/** \brief Layer Actions
247 * Layer Actions
248 */ 239 */
249enum layer_param_on { 240enum layer_param_on {
250 ON_PRESS = 1, 241 ON_PRESS = 1,
251 ON_RELEASE = 2, 242 ON_RELEASE = 2,
252 ON_BOTH = 3, 243 ON_BOTH = 3,
253}; 244};
245
246/** \brief Layer Actions
247 */
254enum layer_param_bit_op { 248enum layer_param_bit_op {
255 OP_BIT_AND = 0, 249 OP_BIT_AND = 0,
256 OP_BIT_OR = 1, 250 OP_BIT_OR = 1,
257 OP_BIT_XOR = 2, 251 OP_BIT_XOR = 2,
258 OP_BIT_SET = 3, 252 OP_BIT_SET = 3,
259}; 253};
254
255/** \brief Layer Actions
256 */
260enum layer_param_tap_op { 257enum layer_param_tap_op {
261 OP_TAP_TOGGLE = 0xF0, 258 OP_TAP_TOGGLE = 0xF0,
262 OP_ON_OFF, 259 OP_ON_OFF,
@@ -296,8 +293,7 @@ enum layer_param_tap_op {
296#define ACTION_DEFAULT_LAYER_BIT_SET(part, bits) ACTION_LAYER_BITOP(OP_BIT_SET, (part), (bits), 0) 293#define ACTION_DEFAULT_LAYER_BIT_SET(part, bits) ACTION_LAYER_BITOP(OP_BIT_SET, (part), (bits), 0)
297 294
298 295
299/* 296/** \brief Extensions
300 * Extensions
301 */ 297 */
302enum backlight_opt { 298enum backlight_opt {
303 BACKLIGHT_INCREASE = 0, 299 BACKLIGHT_INCREASE = 0,
diff --git a/tmk_core/common/action_layer.c b/tmk_core/common/action_layer.c
index 22331376a..f3cd381ab 100644
--- a/tmk_core/common/action_layer.c
+++ b/tmk_core/common/action_layer.c
@@ -11,16 +11,23 @@
11#endif 11#endif
12 12
13 13
14/* 14/** \brief Default Layer State
15 * Default Layer State
16 */ 15 */
17uint32_t default_layer_state = 0; 16uint32_t default_layer_state = 0;
18 17
18/** \brief Default Layer State Set At Keyboard Level
19 *
20 * FIXME: Needs docs
21 */
19__attribute__((weak)) 22__attribute__((weak))
20uint32_t default_layer_state_set_kb(uint32_t state) { 23uint32_t default_layer_state_set_kb(uint32_t state) {
21 return state; 24 return state;
22} 25}
23 26
27/** \brief Default Layer State Set
28 *
29 * FIXME: Needs docs
30 */
24static void default_layer_state_set(uint32_t state) 31static void default_layer_state_set(uint32_t state)
25{ 32{
26 state = default_layer_state_set_kb(state); 33 state = default_layer_state_set_kb(state);
@@ -31,25 +38,45 @@ static void default_layer_state_set(uint32_t state)
31 clear_keyboard_but_mods(); // To avoid stuck keys 38 clear_keyboard_but_mods(); // To avoid stuck keys
32} 39}
33 40
41/** \brief Default Layer Print
42 *
43 * FIXME: Needs docs
44 */
34void default_layer_debug(void) 45void default_layer_debug(void)
35{ 46{
36 dprintf("%08lX(%u)", default_layer_state, biton32(default_layer_state)); 47 dprintf("%08lX(%u)", default_layer_state, biton32(default_layer_state));
37} 48}
38 49
50/** \brief Default Layer Set
51 *
52 * FIXME: Needs docs
53 */
39void default_layer_set(uint32_t state) 54void default_layer_set(uint32_t state)
40{ 55{
41 default_layer_state_set(state); 56 default_layer_state_set(state);
42} 57}
43 58
44#ifndef NO_ACTION_LAYER 59#ifndef NO_ACTION_LAYER
60/** \brief Default Layer Or
61 *
62 * FIXME: Needs docs
63 */
45void default_layer_or(uint32_t state) 64void default_layer_or(uint32_t state)
46{ 65{
47 default_layer_state_set(default_layer_state | state); 66 default_layer_state_set(default_layer_state | state);
48} 67}
68/** \brief Default Layer And
69 *
70 * FIXME: Needs docs
71 */
49void default_layer_and(uint32_t state) 72void default_layer_and(uint32_t state)
50{ 73{
51 default_layer_state_set(default_layer_state & state); 74 default_layer_state_set(default_layer_state & state);
52} 75}
76/** \brief Default Layer Xor
77 *
78 * FIXME: Needs docs
79 */
53void default_layer_xor(uint32_t state) 80void default_layer_xor(uint32_t state)
54{ 81{
55 default_layer_state_set(default_layer_state ^ state); 82 default_layer_state_set(default_layer_state ^ state);
@@ -58,21 +85,32 @@ void default_layer_xor(uint32_t state)
58 85
59 86
60#ifndef NO_ACTION_LAYER 87#ifndef NO_ACTION_LAYER
61/* 88/** \brief Keymap Layer State
62 * Keymap Layer State
63 */ 89 */
64uint32_t layer_state = 0; 90uint32_t layer_state = 0;
65 91
92/** \brief Layer state set user
93 *
94 * FIXME: Needs docs
95 */
66__attribute__((weak)) 96__attribute__((weak))
67uint32_t layer_state_set_user(uint32_t state) { 97uint32_t layer_state_set_user(uint32_t state) {
68 return state; 98 return state;
69} 99}
70 100
101/** \brief Layer state set keyboard
102 *
103 * FIXME: Needs docs
104 */
71__attribute__((weak)) 105__attribute__((weak))
72uint32_t layer_state_set_kb(uint32_t state) { 106uint32_t layer_state_set_kb(uint32_t state) {
73 return layer_state_set_user(state); 107 return layer_state_set_user(state);
74} 108}
75 109
110/** \brief Layer state set
111 *
112 * FIXME: Needs docs
113 */
76void layer_state_set(uint32_t state) 114void layer_state_set(uint32_t state)
77{ 115{
78 state = layer_state_set_kb(state); 116 state = layer_state_set_kb(state);
@@ -83,54 +121,98 @@ void layer_state_set(uint32_t state)
83 clear_keyboard_but_mods(); // To avoid stuck keys 121 clear_keyboard_but_mods(); // To avoid stuck keys
84} 122}
85 123
124/** \brief Layer clear
125 *
126 * FIXME: Needs docs
127 */
86void layer_clear(void) 128void layer_clear(void)
87{ 129{
88 layer_state_set(0); 130 layer_state_set(0);
89} 131}
90 132
133/** \brief Layer state is
134 *
135 * FIXME: Needs docs
136 */
91bool layer_state_is(uint8_t layer) 137bool layer_state_is(uint8_t layer)
92{ 138{
93 return layer_state_cmp(layer_state, layer); 139 return layer_state_cmp(layer_state, layer);
94} 140}
95 141
142/** \brief Layer state compare
143 *
144 * FIXME: Needs docs
145 */
96bool layer_state_cmp(uint32_t cmp_layer_state, uint8_t layer) { 146bool layer_state_cmp(uint32_t cmp_layer_state, uint8_t layer) {
97 if (!cmp_layer_state) { return layer == 0; } 147 if (!cmp_layer_state) { return layer == 0; }
98 return (cmp_layer_state & (1UL<<layer)) != 0; 148 return (cmp_layer_state & (1UL<<layer)) != 0;
99} 149}
100 150
151/** \brief Layer move
152 *
153 * FIXME: Needs docs
154 */
101void layer_move(uint8_t layer) 155void layer_move(uint8_t layer)
102{ 156{
103 layer_state_set(1UL<<layer); 157 layer_state_set(1UL<<layer);
104} 158}
105 159
160/** \brief Layer on
161 *
162 * FIXME: Needs docs
163 */
106void layer_on(uint8_t layer) 164void layer_on(uint8_t layer)
107{ 165{
108 layer_state_set(layer_state | (1UL<<layer)); 166 layer_state_set(layer_state | (1UL<<layer));
109} 167}
110 168
169/** \brief Layer off
170 *
171 * FIXME: Needs docs
172 */
111void layer_off(uint8_t layer) 173void layer_off(uint8_t layer)
112{ 174{
113 layer_state_set(layer_state & ~(1UL<<layer)); 175 layer_state_set(layer_state & ~(1UL<<layer));
114} 176}
115 177
178/** \brief Layer invert
179 *
180 * FIXME: Needs docs
181 */
116void layer_invert(uint8_t layer) 182void layer_invert(uint8_t layer)
117{ 183{
118 layer_state_set(layer_state ^ (1UL<<layer)); 184 layer_state_set(layer_state ^ (1UL<<layer));
119} 185}
120 186
187/** \brief Layer or
188 *
189 * FIXME: Needs docs
190 */
121void layer_or(uint32_t state) 191void layer_or(uint32_t state)
122{ 192{
123 layer_state_set(layer_state | state); 193 layer_state_set(layer_state | state);
124} 194}
195/** \brief Layer and
196 *
197 * FIXME: Needs docs
198 */
125void layer_and(uint32_t state) 199void layer_and(uint32_t state)
126{ 200{
127 layer_state_set(layer_state & state); 201 layer_state_set(layer_state & state);
128} 202}
203/** \brief Layer xor
204 *
205 * FIXME: Needs docs
206 */
129void layer_xor(uint32_t state) 207void layer_xor(uint32_t state)
130{ 208{
131 layer_state_set(layer_state ^ state); 209 layer_state_set(layer_state ^ state);
132} 210}
133 211
212/** \brief Layer debug printing
213 *
214 * FIXME: Needs docs
215 */
134void layer_debug(void) 216void layer_debug(void)
135{ 217{
136 dprintf("%08lX(%u)", layer_state, biton32(layer_state)); 218 dprintf("%08lX(%u)", layer_state, biton32(layer_state));
@@ -172,7 +254,8 @@ uint8_t read_source_layers_cache(keypos_t key)
172} 254}
173#endif 255#endif
174 256
175/* 257/** \brief Store or get action (FIXME: Needs better summary)
258 *
176 * Make sure the action triggered when the key is released is the same 259 * Make sure the action triggered when the key is released is the same
177 * one as the one triggered on press. It's important for the mod keys 260 * one as the one triggered on press. It's important for the mod keys
178 * when the layer is switched after the down event but before the up 261 * when the layer is switched after the down event but before the up
@@ -201,6 +284,10 @@ action_t store_or_get_action(bool pressed, keypos_t key)
201} 284}
202 285
203 286
287/** \brief Layer switch get layer
288 *
289 * FIXME: Needs docs
290 */
204int8_t layer_switch_get_layer(keypos_t key) 291int8_t layer_switch_get_layer(keypos_t key)
205{ 292{
206#ifndef NO_ACTION_LAYER 293#ifndef NO_ACTION_LAYER
@@ -224,6 +311,10 @@ int8_t layer_switch_get_layer(keypos_t key)
224#endif 311#endif
225} 312}
226 313
314/** \brief Layer switch get layer
315 *
316 * FIXME: Needs docs
317 */
227action_t layer_switch_get_action(keypos_t key) 318action_t layer_switch_get_action(keypos_t key)
228{ 319{
229 return action_for_key(layer_switch_get_layer(key), key); 320 return action_for_key(layer_switch_get_layer(key), key);
diff --git a/tmk_core/common/action_macro.c b/tmk_core/common/action_macro.c
index 7726b1190..12bef2958 100644
--- a/tmk_core/common/action_macro.c
+++ b/tmk_core/common/action_macro.c
@@ -29,6 +29,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
29#ifndef NO_ACTION_MACRO 29#ifndef NO_ACTION_MACRO
30 30
31#define MACRO_READ() (macro = MACRO_GET(macro_p++)) 31#define MACRO_READ() (macro = MACRO_GET(macro_p++))
32/** \brief Action Macro Play
33 *
34 * FIXME: Needs doc
35 */
32void action_macro_play(const macro_t *macro_p) 36void action_macro_play(const macro_t *macro_p)
33{ 37{
34 macro_t macro = END; 38 macro_t macro = END;
diff --git a/tmk_core/common/action_tapping.c b/tmk_core/common/action_tapping.c
index 6280c6c36..8adf013e1 100644
--- a/tmk_core/common/action_tapping.c
+++ b/tmk_core/common/action_tapping.c
@@ -36,6 +36,10 @@ static void debug_tapping_key(void);
36static void debug_waiting_buffer(void); 36static void debug_waiting_buffer(void);
37 37
38 38
39/** \brief Action Tapping Process
40 *
41 * FIXME: Needs doc
42 */
39void action_tapping_process(keyrecord_t record) 43void action_tapping_process(keyrecord_t record)
40{ 44{
41 if (process_tapping(&record)) { 45 if (process_tapping(&record)) {
@@ -70,7 +74,7 @@ void action_tapping_process(keyrecord_t record)
70} 74}
71 75
72 76
73/* Tapping 77/** \brief Tapping
74 * 78 *
75 * Rule: Tap key is typed(pressed and released) within TAPPING_TERM. 79 * Rule: Tap key is typed(pressed and released) within TAPPING_TERM.
76 * (without interfering by typing other key) 80 * (without interfering by typing other key)
@@ -289,8 +293,9 @@ bool process_tapping(keyrecord_t *keyp)
289} 293}
290 294
291 295
292/* 296/** \brief Waiting buffer enq
293 * Waiting buffer 297 *
298 * FIXME: Needs docs
294 */ 299 */
295bool waiting_buffer_enq(keyrecord_t record) 300bool waiting_buffer_enq(keyrecord_t record)
296{ 301{
@@ -310,12 +315,20 @@ bool waiting_buffer_enq(keyrecord_t record)
310 return true; 315 return true;
311} 316}
312 317
318/** \brief Waiting buffer clear
319 *
320 * FIXME: Needs docs
321 */
313void waiting_buffer_clear(void) 322void waiting_buffer_clear(void)
314{ 323{
315 waiting_buffer_head = 0; 324 waiting_buffer_head = 0;
316 waiting_buffer_tail = 0; 325 waiting_buffer_tail = 0;
317} 326}
318 327
328/** \brief Waiting buffer typed
329 *
330 * FIXME: Needs docs
331 */
319bool waiting_buffer_typed(keyevent_t event) 332bool waiting_buffer_typed(keyevent_t event)
320{ 333{
321 for (uint8_t i = waiting_buffer_tail; i != waiting_buffer_head; i = (i + 1) % WAITING_BUFFER_SIZE) { 334 for (uint8_t i = waiting_buffer_tail; i != waiting_buffer_head; i = (i + 1) % WAITING_BUFFER_SIZE) {
@@ -326,6 +339,10 @@ bool waiting_buffer_typed(keyevent_t event)
326 return false; 339 return false;
327} 340}
328 341
342/** \brief Waiting buffer has anykey pressed
343 *
344 * FIXME: Needs docs
345 */
329__attribute__((unused)) 346__attribute__((unused))
330bool waiting_buffer_has_anykey_pressed(void) 347bool waiting_buffer_has_anykey_pressed(void)
331{ 348{
@@ -335,7 +352,10 @@ bool waiting_buffer_has_anykey_pressed(void)
335 return false; 352 return false;
336} 353}
337 354
338/* scan buffer for tapping */ 355/** \brief Scan buffer for tapping
356 *
357 * FIXME: Needs docs
358 */
339void waiting_buffer_scan_tap(void) 359void waiting_buffer_scan_tap(void)
340{ 360{
341 // tapping already is settled 361 // tapping already is settled
@@ -359,14 +379,19 @@ void waiting_buffer_scan_tap(void)
359} 379}
360 380
361 381
362/* 382/** \brief Tapping key debug print
363 * debug print 383 *
384 * FIXME: Needs docs
364 */ 385 */
365static void debug_tapping_key(void) 386static void debug_tapping_key(void)
366{ 387{
367 debug("TAPPING_KEY="); debug_record(tapping_key); debug("\n"); 388 debug("TAPPING_KEY="); debug_record(tapping_key); debug("\n");
368} 389}
369 390
391/** \brief Waiting buffer debug print
392 *
393 * FIXME: Needs docs
394 */
370static void debug_waiting_buffer(void) 395static void debug_waiting_buffer(void)
371{ 396{
372 debug("{ "); 397 debug("{ ");
diff --git a/tmk_core/common/action_util.c b/tmk_core/common/action_util.c
index 148162a51..afd4ae8b2 100644
--- a/tmk_core/common/action_util.c
+++ b/tmk_core/common/action_util.c
@@ -67,12 +67,12 @@ bool has_oneshot_mods_timed_out(void) {
67 67
68/* oneshot layer */ 68/* oneshot layer */
69#ifndef NO_ACTION_ONESHOT 69#ifndef NO_ACTION_ONESHOT
70/* oneshot_layer_data bits 70/** \brief oneshot_layer_data bits
71* LLLL LSSS 71 * LLLL LSSS
72* where: 72 * where:
73* L => are layer bits 73 * L => are layer bits
74* S => oneshot state bits 74 * S => oneshot state bits
75*/ 75 */
76static int8_t oneshot_layer_data = 0; 76static int8_t oneshot_layer_data = 0;
77 77
78inline uint8_t get_oneshot_layer(void) { return oneshot_layer_data >> 3; } 78inline uint8_t get_oneshot_layer(void) { return oneshot_layer_data >> 3; }
@@ -86,7 +86,10 @@ inline bool has_oneshot_layer_timed_out() {
86} 86}
87#endif 87#endif
88 88
89/* Oneshot layer */ 89/** \brief Set oneshot layer
90 *
91 * FIXME: needs doc
92 */
90void set_oneshot_layer(uint8_t layer, uint8_t state) 93void set_oneshot_layer(uint8_t layer, uint8_t state)
91{ 94{
92 oneshot_layer_data = layer << 3 | state; 95 oneshot_layer_data = layer << 3 | state;
@@ -95,12 +98,20 @@ void set_oneshot_layer(uint8_t layer, uint8_t state)
95 oneshot_layer_time = timer_read(); 98 oneshot_layer_time = timer_read();
96#endif 99#endif
97} 100}
101/** \brief Reset oneshot layer
102 *
103 * FIXME: needs doc
104 */
98void reset_oneshot_layer(void) { 105void reset_oneshot_layer(void) {
99 oneshot_layer_data = 0; 106 oneshot_layer_data = 0;
100#if (defined(ONESHOT_TIMEOUT) && (ONESHOT_TIMEOUT > 0)) 107#if (defined(ONESHOT_TIMEOUT) && (ONESHOT_TIMEOUT > 0))
101 oneshot_layer_time = 0; 108 oneshot_layer_time = 0;
102#endif 109#endif
103} 110}
111/** \brief Clear oneshot layer
112 *
113 * FIXME: needs doc
114 */
104void clear_oneshot_layer_state(oneshot_fullfillment_t state) 115void clear_oneshot_layer_state(oneshot_fullfillment_t state)
105{ 116{
106 uint8_t start_state = oneshot_layer_data; 117 uint8_t start_state = oneshot_layer_data;
@@ -112,12 +123,20 @@ void clear_oneshot_layer_state(oneshot_fullfillment_t state)
112#endif 123#endif
113 } 124 }
114} 125}
126/** \brief Is oneshot layer active
127 *
128 * FIXME: needs doc
129 */
115bool is_oneshot_layer_active(void) 130bool is_oneshot_layer_active(void)
116{ 131{
117 return get_oneshot_layer_state(); 132 return get_oneshot_layer_state();
118} 133}
119#endif 134#endif
120 135
136/** \brief Send keyboard report
137 *
138 * FIXME: needs doc
139 */
121void send_keyboard_report(void) { 140void send_keyboard_report(void) {
122 keyboard_report->mods = real_mods; 141 keyboard_report->mods = real_mods;
123 keyboard_report->mods |= weak_mods; 142 keyboard_report->mods |= weak_mods;
@@ -140,29 +159,90 @@ void send_keyboard_report(void) {
140 host_keyboard_send(keyboard_report); 159 host_keyboard_send(keyboard_report);
141} 160}
142 161
143/* modifier */ 162/** \brief Get mods
163 *
164 * FIXME: needs doc
165 */
144uint8_t get_mods(void) { return real_mods; } 166uint8_t get_mods(void) { return real_mods; }
167/** \brief add mods
168 *
169 * FIXME: needs doc
170 */
145void add_mods(uint8_t mods) { real_mods |= mods; } 171void add_mods(uint8_t mods) { real_mods |= mods; }
172/** \brief del mods
173 *
174 * FIXME: needs doc
175 */
146void del_mods(uint8_t mods) { real_mods &= ~mods; } 176void del_mods(uint8_t mods) { real_mods &= ~mods; }
177/** \brief set mods
178 *
179 * FIXME: needs doc
180 */
147void set_mods(uint8_t mods) { real_mods = mods; } 181void set_mods(uint8_t mods) { real_mods = mods; }
182/** \brief clear mods
183 *
184 * FIXME: needs doc
185 */
148void clear_mods(void) { real_mods = 0; } 186void clear_mods(void) { real_mods = 0; }
149 187
150/* weak modifier */ 188/** \brief get weak mods
189 *
190 * FIXME: needs doc
191 */
151uint8_t get_weak_mods(void) { return weak_mods; } 192uint8_t get_weak_mods(void) { return weak_mods; }
193/** \brief add weak mods
194 *
195 * FIXME: needs doc
196 */
152void add_weak_mods(uint8_t mods) { weak_mods |= mods; } 197void add_weak_mods(uint8_t mods) { weak_mods |= mods; }
198/** \brief del weak mods
199 *
200 * FIXME: needs doc
201 */
153void del_weak_mods(uint8_t mods) { weak_mods &= ~mods; } 202void del_weak_mods(uint8_t mods) { weak_mods &= ~mods; }
203/** \brief set weak mods
204 *
205 * FIXME: needs doc
206 */
154void set_weak_mods(uint8_t mods) { weak_mods = mods; } 207void set_weak_mods(uint8_t mods) { weak_mods = mods; }
208/** \brief clear weak mods
209 *
210 * FIXME: needs doc
211 */
155void clear_weak_mods(void) { weak_mods = 0; } 212void clear_weak_mods(void) { weak_mods = 0; }
156 213
157/* macro modifier */ 214/* macro modifier */
215/** \brief get macro mods
216 *
217 * FIXME: needs doc
218 */
158uint8_t get_macro_mods(void) { return macro_mods; } 219uint8_t get_macro_mods(void) { return macro_mods; }
220/** \brief add macro mods
221 *
222 * FIXME: needs doc
223 */
159void add_macro_mods(uint8_t mods) { macro_mods |= mods; } 224void add_macro_mods(uint8_t mods) { macro_mods |= mods; }
225/** \brief del macro mods
226 *
227 * FIXME: needs doc
228 */
160void del_macro_mods(uint8_t mods) { macro_mods &= ~mods; } 229void del_macro_mods(uint8_t mods) { macro_mods &= ~mods; }
230/** \brief set macro mods
231 *
232 * FIXME: needs doc
233 */
161void set_macro_mods(uint8_t mods) { macro_mods = mods; } 234void set_macro_mods(uint8_t mods) { macro_mods = mods; }
235/** \brief clear macro mods
236 *
237 * FIXME: needs doc
238 */
162void clear_macro_mods(void) { macro_mods = 0; } 239void clear_macro_mods(void) { macro_mods = 0; }
163 240
164/* Oneshot modifier */
165#ifndef NO_ACTION_ONESHOT 241#ifndef NO_ACTION_ONESHOT
242/** \brief set oneshot mods
243 *
244 * FIXME: needs doc
245 */
166void set_oneshot_mods(uint8_t mods) 246void set_oneshot_mods(uint8_t mods)
167{ 247{
168 oneshot_mods = mods; 248 oneshot_mods = mods;
@@ -170,6 +250,10 @@ void set_oneshot_mods(uint8_t mods)
170 oneshot_time = timer_read(); 250 oneshot_time = timer_read();
171#endif 251#endif
172} 252}
253/** \brief clear oneshot mods
254 *
255 * FIXME: needs doc
256 */
173void clear_oneshot_mods(void) 257void clear_oneshot_mods(void)
174{ 258{
175 oneshot_mods = 0; 259 oneshot_mods = 0;
@@ -177,14 +261,19 @@ void clear_oneshot_mods(void)
177 oneshot_time = 0; 261 oneshot_time = 0;
178#endif 262#endif
179} 263}
264/** \brief get oneshot mods
265 *
266 * FIXME: needs doc
267 */
180uint8_t get_oneshot_mods(void) 268uint8_t get_oneshot_mods(void)
181{ 269{
182 return oneshot_mods; 270 return oneshot_mods;
183} 271}
184#endif 272#endif
185 273
186/* 274/** \brief inspect keyboard state
187 * inspect keyboard state 275 *
276 * FIXME: needs doc
188 */ 277 */
189uint8_t has_anymod(void) 278uint8_t has_anymod(void)
190{ 279{
diff --git a/tmk_core/common/avr/bootloader.c b/tmk_core/common/avr/bootloader.c
index ee150817c..d89c8d768 100644
--- a/tmk_core/common/avr/bootloader.c
+++ b/tmk_core/common/avr/bootloader.c
@@ -13,12 +13,11 @@
13#endif 13#endif
14 14
15 15
16/* Bootloader Size in *bytes* 16/** \brief Bootloader Size in *bytes*
17 * 17 *
18 * AVR Boot section size are defined by setting BOOTSZ fuse in fact. Consult with your MCU datasheet. 18 * AVR Boot section size are defined by setting BOOTSZ fuse in fact. Consult with your MCU datasheet.
19 * Note that 'Word'(2 bytes) size and address are used in datasheet while TMK uses 'Byte'. 19 * Note that 'Word'(2 bytes) size and address are used in datasheet while TMK uses 'Byte'.
20 * 20 *
21 *
22 * Size of Bootloaders in bytes: 21 * Size of Bootloaders in bytes:
23 * Atmel DFU loader(ATmega32U4) 4096 22 * Atmel DFU loader(ATmega32U4) 4096
24 * Atmel DFU loader(AT90USB128) 8192 23 * Atmel DFU loader(AT90USB128) 8192
@@ -28,10 +27,8 @@
28 * Teensy halfKay(ATmega32U4) 512 27 * Teensy halfKay(ATmega32U4) 512
29 * Teensy++ halfKay(AT90USB128) 1024 28 * Teensy++ halfKay(AT90USB128) 1024
30 * 29 *
31 *
32 * AVR Boot section is located at the end of Flash memory like the followings. 30 * AVR Boot section is located at the end of Flash memory like the followings.
33 * 31 *
34 *
35 * byte Atmel/LUFA(ATMega32u4) byte Atmel(AT90SUB128) 32 * byte Atmel/LUFA(ATMega32u4) byte Atmel(AT90SUB128)
36 * 0x0000 +---------------+ 0x00000 +---------------+ 33 * 0x0000 +---------------+ 0x00000 +---------------+
37 * | | | | 34 * | | | |
@@ -57,7 +54,6 @@
57 * | Bootloader | 512B | Bootloader | 1KB 54 * | Bootloader | 512B | Bootloader | 1KB
58 * 0x7FFF +---------------+ 0x1FFFF +---------------+ 55 * 0x7FFF +---------------+ 0x1FFFF +---------------+
59 */ 56 */
60
61#define FLASH_SIZE (FLASHEND + 1L) 57#define FLASH_SIZE (FLASHEND + 1L)
62 58
63#if !defined(BOOTLOADER_SIZE) 59#if !defined(BOOTLOADER_SIZE)
@@ -69,14 +65,17 @@
69#define BOOT_SIZE_1024 0b010 65#define BOOT_SIZE_1024 0b010
70#define BOOT_SIZE_2048 0b000 66#define BOOT_SIZE_2048 0b000
71 67
72/* 68/** \brief Entering the Bootloader via Software
73 * Entering the Bootloader via Software 69 *
74 * http://www.fourwalledcubicle.com/files/LUFA/Doc/120730/html/_page__software_bootloader_start.html 70 * http://www.fourwalledcubicle.com/files/LUFA/Doc/120730/html/_page__software_bootloader_start.html
75 */ 71 */
76#define BOOTLOADER_RESET_KEY 0xB007B007 72#define BOOTLOADER_RESET_KEY 0xB007B007
77uint32_t reset_key __attribute__ ((section (".noinit"))); 73uint32_t reset_key __attribute__ ((section (".noinit")));
78 74
79/* initialize MCU status by watchdog reset */ 75/** \brief initialize MCU status by watchdog reset
76 *
77 * FIXME: needs doc
78 */
80void bootloader_jump(void) { 79void bootloader_jump(void) {
81 80
82 #if !defined(BOOTLOADER_SIZE) 81 #if !defined(BOOTLOADER_SIZE)
diff --git a/tmk_core/common/avr/sleep_led.c b/tmk_core/common/avr/sleep_led.c
index dab3eb0f3..0cb774c81 100644
--- a/tmk_core/common/avr/sleep_led.c
+++ b/tmk_core/common/avr/sleep_led.c
@@ -18,6 +18,10 @@
18 */ 18 */
19#define SLEEP_LED_TIMER_TOP F_CPU/(256*64) 19#define SLEEP_LED_TIMER_TOP F_CPU/(256*64)
20 20
21/** \brief Sleep LED initialization
22 *
23 * FIXME: needs doc
24 */
21void sleep_led_init(void) 25void sleep_led_init(void)
22{ 26{
23 /* Timer1 setup */ 27 /* Timer1 setup */
@@ -33,18 +37,30 @@ void sleep_led_init(void)
33 SREG = sreg; 37 SREG = sreg;
34} 38}
35 39
40/** \brief Sleep LED enable
41 *
42 * FIXME: needs doc
43 */
36void sleep_led_enable(void) 44void sleep_led_enable(void)
37{ 45{
38 /* Enable Compare Match Interrupt */ 46 /* Enable Compare Match Interrupt */
39 TIMSK1 |= _BV(OCIE1A); 47 TIMSK1 |= _BV(OCIE1A);
40} 48}
41 49
50/** \brief Sleep LED disable
51 *
52 * FIXME: needs doc
53 */
42void sleep_led_disable(void) 54void sleep_led_disable(void)
43{ 55{
44 /* Disable Compare Match Interrupt */ 56 /* Disable Compare Match Interrupt */
45 TIMSK1 &= ~_BV(OCIE1A); 57 TIMSK1 &= ~_BV(OCIE1A);
46} 58}
47 59
60/** \brief Sleep LED toggle
61 *
62 * FIXME: needs doc
63 */
48void sleep_led_toggle(void) 64void sleep_led_toggle(void)
49{ 65{
50 /* Disable Compare Match Interrupt */ 66 /* Disable Compare Match Interrupt */
@@ -52,7 +68,8 @@ void sleep_led_toggle(void)
52} 68}
53 69
54 70
55/* Breathing Sleep LED brighness(PWM On period) table 71/** \brief Breathing Sleep LED brighness(PWM On period) table
72 *
56 * (64[steps] * 4[duration]) / 64[PWM periods/s] = 4 second breath cycle 73 * (64[steps] * 4[duration]) / 64[PWM periods/s] = 4 second breath cycle
57 * 74 *
58 * http://www.wolframalpha.com/input/?i=%28sin%28+x%2F64*pi%29**8+*+255%2C+x%3D0+to+63 75 * http://www.wolframalpha.com/input/?i=%28sin%28+x%2F64*pi%29**8+*+255%2C+x%3D0+to+63
diff --git a/tmk_core/common/avr/suspend.c b/tmk_core/common/avr/suspend.c
index 213f03f6f..4cdd6a420 100644
--- a/tmk_core/common/avr/suspend.c
+++ b/tmk_core/common/avr/suspend.c
@@ -41,6 +41,10 @@ __asm__ __volatile__ ( \
41) 41)
42 42
43 43
44/** \brief Suspend idle
45 *
46 * FIXME: needs doc
47 */
44void suspend_idle(uint8_t time) 48void suspend_idle(uint8_t time)
45{ 49{
46 cli(); 50 cli();
@@ -52,7 +56,8 @@ void suspend_idle(uint8_t time)
52} 56}
53 57
54#ifndef NO_SUSPEND_POWER_DOWN 58#ifndef NO_SUSPEND_POWER_DOWN
55/* Power down MCU with watchdog timer 59/** \brief Power down MCU with watchdog timer
60 *
56 * wdto: watchdog timer timeout defined in <avr/wdt.h> 61 * wdto: watchdog timer timeout defined in <avr/wdt.h>
57 * WDTO_15MS 62 * WDTO_15MS
58 * WDTO_30MS 63 * WDTO_30MS
@@ -67,6 +72,10 @@ void suspend_idle(uint8_t time)
67 */ 72 */
68static uint8_t wdt_timeout = 0; 73static uint8_t wdt_timeout = 0;
69 74
75/** \brief Power down
76 *
77 * FIXME: needs doc
78 */
70static void power_down(uint8_t wdto) 79static void power_down(uint8_t wdto)
71{ 80{
72#ifdef PROTOCOL_LUFA 81#ifdef PROTOCOL_LUFA
@@ -111,6 +120,10 @@ static void power_down(uint8_t wdto)
111} 120}
112#endif 121#endif
113 122
123/** \brief Suspend power down
124 *
125 * FIXME: needs doc
126 */
114void suspend_power_down(void) 127void suspend_power_down(void)
115{ 128{
116#ifndef NO_SUSPEND_POWER_DOWN 129#ifndef NO_SUSPEND_POWER_DOWN
@@ -131,7 +144,10 @@ bool suspend_wakeup_condition(void)
131 return false; 144 return false;
132} 145}
133 146
134// run immediately after wakeup 147/** \brief run immediately after wakeup
148 *
149 * FIXME: needs doc
150 */
135void suspend_wakeup_init(void) 151void suspend_wakeup_init(void)
136{ 152{
137 // clear keyboard state 153 // clear keyboard state
diff --git a/tmk_core/common/avr/timer.c b/tmk_core/common/avr/timer.c
index 369015200..b7d4f060e 100644
--- a/tmk_core/common/avr/timer.c
+++ b/tmk_core/common/avr/timer.c
@@ -27,6 +27,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
27// NOTE: union { uint32_t timer32; struct { uint16_t dummy; uint16_t timer16; }} 27// NOTE: union { uint32_t timer32; struct { uint16_t dummy; uint16_t timer16; }}
28volatile uint32_t timer_count; 28volatile uint32_t timer_count;
29 29
30/** \brief timer initialization
31 *
32 * FIXME: needs doc
33 */
30void timer_init(void) 34void timer_init(void)
31{ 35{
32#if TIMER_PRESCALER == 1 36#if TIMER_PRESCALER == 1
@@ -60,6 +64,10 @@ void timer_init(void)
60#endif 64#endif
61} 65}
62 66
67/** \brief timer clear
68 *
69 * FIXME: needs doc
70 */
63inline 71inline
64void timer_clear(void) 72void timer_clear(void)
65{ 73{
@@ -68,6 +76,10 @@ void timer_clear(void)
68 } 76 }
69} 77}
70 78
79/** \brief timer read
80 *
81 * FIXME: needs doc
82 */
71inline 83inline
72uint16_t timer_read(void) 84uint16_t timer_read(void)
73{ 85{
@@ -80,6 +92,10 @@ uint16_t timer_read(void)
80 return (t & 0xFFFF); 92 return (t & 0xFFFF);
81} 93}
82 94
95/** \brief timer read32
96 *
97 * FIXME: needs doc
98 */
83inline 99inline
84uint32_t timer_read32(void) 100uint32_t timer_read32(void)
85{ 101{
@@ -92,6 +108,10 @@ uint32_t timer_read32(void)
92 return t; 108 return t;
93} 109}
94 110
111/** \brief timer elapsed
112 *
113 * FIXME: needs doc
114 */
95inline 115inline
96uint16_t timer_elapsed(uint16_t last) 116uint16_t timer_elapsed(uint16_t last)
97{ 117{
@@ -104,6 +124,10 @@ uint16_t timer_elapsed(uint16_t last)
104 return TIMER_DIFF_16((t & 0xFFFF), last); 124 return TIMER_DIFF_16((t & 0xFFFF), last);
105} 125}
106 126
127/** \brief timer elapsed32
128 *
129 * FIXME: needs doc
130 */
107inline 131inline
108uint32_t timer_elapsed32(uint32_t last) 132uint32_t timer_elapsed32(uint32_t last)
109{ 133{
diff --git a/tmk_core/common/backlight.c b/tmk_core/common/backlight.c
index 12f75b38a..3e29aacc4 100644
--- a/tmk_core/common/backlight.c
+++ b/tmk_core/common/backlight.c
@@ -21,6 +21,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
21 21
22backlight_config_t backlight_config; 22backlight_config_t backlight_config;
23 23
24/** \brief Backlight initialization
25 *
26 * FIXME: needs doc
27 */
24void backlight_init(void) 28void backlight_init(void)
25{ 29{
26 /* check signature */ 30 /* check signature */
@@ -34,6 +38,10 @@ void backlight_init(void)
34 backlight_set(backlight_config.enable ? backlight_config.level : 0); 38 backlight_set(backlight_config.enable ? backlight_config.level : 0);
35} 39}
36 40
41/** \brief Backlight increase
42 *
43 * FIXME: needs doc
44 */
37void backlight_increase(void) 45void backlight_increase(void)
38{ 46{
39 if(backlight_config.level < BACKLIGHT_LEVELS) 47 if(backlight_config.level < BACKLIGHT_LEVELS)
@@ -46,6 +54,10 @@ void backlight_increase(void)
46 backlight_set(backlight_config.level); 54 backlight_set(backlight_config.level);
47} 55}
48 56
57/** \brief Backlight decrease
58 *
59 * FIXME: needs doc
60 */
49void backlight_decrease(void) 61void backlight_decrease(void)
50{ 62{
51 if(backlight_config.level > 0) 63 if(backlight_config.level > 0)
@@ -58,6 +70,10 @@ void backlight_decrease(void)
58 backlight_set(backlight_config.level); 70 backlight_set(backlight_config.level);
59} 71}
60 72
73/** \brief Backlight toggle
74 *
75 * FIXME: needs doc
76 */
61void backlight_toggle(void) 77void backlight_toggle(void)
62{ 78{
63 backlight_config.enable ^= 1; 79 backlight_config.enable ^= 1;
@@ -68,6 +84,10 @@ void backlight_toggle(void)
68 backlight_set(backlight_config.enable ? backlight_config.level : 0); 84 backlight_set(backlight_config.enable ? backlight_config.level : 0);
69} 85}
70 86
87/** \brief Backlight step through levels
88 *
89 * FIXME: needs doc
90 */
71void backlight_step(void) 91void backlight_step(void)
72{ 92{
73 backlight_config.level++; 93 backlight_config.level++;
@@ -81,6 +101,10 @@ void backlight_step(void)
81 backlight_set(backlight_config.level); 101 backlight_set(backlight_config.level);
82} 102}
83 103
104/** \brief Backlight set level
105 *
106 * FIXME: needs doc
107 */
84void backlight_level(uint8_t level) 108void backlight_level(uint8_t level)
85{ 109{
86 if (level > BACKLIGHT_LEVELS) 110 if (level > BACKLIGHT_LEVELS)
@@ -91,6 +115,10 @@ void backlight_level(uint8_t level)
91 backlight_set(backlight_config.level); 115 backlight_set(backlight_config.level);
92} 116}
93 117
118/** \brief Get backlight level
119 *
120 * FIXME: needs doc
121 */
94uint8_t get_backlight_level(void) 122uint8_t get_backlight_level(void)
95{ 123{
96 return backlight_config.level; 124 return backlight_config.level;
diff --git a/tmk_core/common/bootmagic.c b/tmk_core/common/bootmagic.c
index 2c6bcbae5..9f79fb8ee 100644
--- a/tmk_core/common/bootmagic.c
+++ b/tmk_core/common/bootmagic.c
@@ -12,6 +12,10 @@
12 12
13keymap_config_t keymap_config; 13keymap_config_t keymap_config;
14 14
15/** \brief Bootmagic
16 *
17 * FIXME: needs doc
18 */
15void bootmagic(void) 19void bootmagic(void)
16{ 20{
17 /* check signature */ 21 /* check signature */
@@ -102,6 +106,10 @@ void bootmagic(void)
102 } 106 }
103} 107}
104 108
109/** \brief Scan Keycode
110 *
111 * FIXME: needs doc
112 */
105static bool scan_keycode(uint8_t keycode) 113static bool scan_keycode(uint8_t keycode)
106{ 114{
107 for (uint8_t r = 0; r < MATRIX_ROWS; r++) { 115 for (uint8_t r = 0; r < MATRIX_ROWS; r++) {
@@ -117,9 +125,13 @@ static bool scan_keycode(uint8_t keycode)
117 return false; 125 return false;
118} 126}
119 127
128/** \brief Bootmagic Scan Keycode
129 *
130 * FIXME: needs doc
131 */
120bool bootmagic_scan_keycode(uint8_t keycode) 132bool bootmagic_scan_keycode(uint8_t keycode)
121{ 133{
122 if (!scan_keycode(BOOTMAGIC_KEY_SALT)) return false; 134 if (!scan_keycode(BOOTMAGIC_KEY_SALT)) return false;
123 135
124 return scan_keycode(keycode); 136 return scan_keycode(keycode);
125} \ No newline at end of file 137}
diff --git a/tmk_core/common/bootmagic.h b/tmk_core/common/bootmagic.h
index 8f6618f4b..f3ea6a24d 100644
--- a/tmk_core/common/bootmagic.h
+++ b/tmk_core/common/bootmagic.h
@@ -2,6 +2,8 @@
2#define BOOTMAGIC_H 2#define BOOTMAGIC_H
3 3
4 4
5/* FIXME: Add special doxygen comments for defines here. */
6
5/* bootmagic salt key */ 7/* bootmagic salt key */
6#ifndef BOOTMAGIC_KEY_SALT 8#ifndef BOOTMAGIC_KEY_SALT
7#define BOOTMAGIC_KEY_SALT KC_SPACE 9#define BOOTMAGIC_KEY_SALT KC_SPACE
diff --git a/tmk_core/common/chibios/bootloader.c b/tmk_core/common/chibios/bootloader.c
index 2dd3ade34..f9895237b 100644
--- a/tmk_core/common/chibios/bootloader.c
+++ b/tmk_core/common/chibios/bootloader.c
@@ -13,11 +13,19 @@ extern uint32_t __ram0_end__;
13#define MAGIC_ADDR (unsigned long*)(SYMVAL(__ram0_end__) - 4) 13#define MAGIC_ADDR (unsigned long*)(SYMVAL(__ram0_end__) - 4)
14 14
15 15
16/** \brief Jump to the bootloader
17 *
18 * FIXME: needs doc
19 */
16void bootloader_jump(void) { 20void bootloader_jump(void) {
17 *MAGIC_ADDR = BOOTLOADER_MAGIC; // set magic flag => reset handler will jump into boot loader 21 *MAGIC_ADDR = BOOTLOADER_MAGIC; // set magic flag => reset handler will jump into boot loader
18 NVIC_SystemReset(); 22 NVIC_SystemReset();
19} 23}
20 24
25/** \brief Enter bootloader mode if requested
26 *
27 * FIXME: needs doc
28 */
21void enter_bootloader_mode_if_requested(void) { 29void enter_bootloader_mode_if_requested(void) {
22 unsigned long* check = MAGIC_ADDR; 30 unsigned long* check = MAGIC_ADDR;
23 if(*check == BOOTLOADER_MAGIC) { 31 if(*check == BOOTLOADER_MAGIC) {
diff --git a/tmk_core/common/chibios/eeprom.c b/tmk_core/common/chibios/eeprom.c
index 5ff8ee86f..9061b790c 100644
--- a/tmk_core/common/chibios/eeprom.c
+++ b/tmk_core/common/chibios/eeprom.c
@@ -79,6 +79,10 @@
79 #define EEESIZE 0x39 79 #define EEESIZE 0x39
80#endif 80#endif
81 81
82/** \brief eeprom initialization
83 *
84 * FIXME: needs doc
85 */
82void eeprom_initialize(void) 86void eeprom_initialize(void)
83{ 87{
84 uint32_t count=0; 88 uint32_t count=0;
@@ -111,6 +115,10 @@ void eeprom_initialize(void)
111 115
112#define FlexRAM ((uint8_t *)0x14000000) 116#define FlexRAM ((uint8_t *)0x14000000)
113 117
118/** \brief eeprom read byte
119 *
120 * FIXME: needs doc
121 */
114uint8_t eeprom_read_byte(const uint8_t *addr) 122uint8_t eeprom_read_byte(const uint8_t *addr)
115{ 123{
116 uint32_t offset = (uint32_t)addr; 124 uint32_t offset = (uint32_t)addr;
@@ -119,6 +127,10 @@ uint8_t eeprom_read_byte(const uint8_t *addr)
119 return FlexRAM[offset]; 127 return FlexRAM[offset];
120} 128}
121 129
130/** \brief eeprom read word
131 *
132 * FIXME: needs doc
133 */
122uint16_t eeprom_read_word(const uint16_t *addr) 134uint16_t eeprom_read_word(const uint16_t *addr)
123{ 135{
124 uint32_t offset = (uint32_t)addr; 136 uint32_t offset = (uint32_t)addr;
@@ -127,6 +139,10 @@ uint16_t eeprom_read_word(const uint16_t *addr)
127 return *(uint16_t *)(&FlexRAM[offset]); 139 return *(uint16_t *)(&FlexRAM[offset]);
128} 140}
129 141
142/** \brief eeprom read dword
143 *
144 * FIXME: needs doc
145 */
130uint32_t eeprom_read_dword(const uint32_t *addr) 146uint32_t eeprom_read_dword(const uint32_t *addr)
131{ 147{
132 uint32_t offset = (uint32_t)addr; 148 uint32_t offset = (uint32_t)addr;
@@ -135,6 +151,10 @@ uint32_t eeprom_read_dword(const uint32_t *addr)
135 return *(uint32_t *)(&FlexRAM[offset]); 151 return *(uint32_t *)(&FlexRAM[offset]);
136} 152}
137 153
154/** \brief eeprom read block
155 *
156 * FIXME: needs doc
157 */
138void eeprom_read_block(void *buf, const void *addr, uint32_t len) 158void eeprom_read_block(void *buf, const void *addr, uint32_t len)
139{ 159{
140 uint32_t offset = (uint32_t)addr; 160 uint32_t offset = (uint32_t)addr;
@@ -148,11 +168,19 @@ void eeprom_read_block(void *buf, const void *addr, uint32_t len)
148 } 168 }
149} 169}
150 170
171/** \brief eeprom is ready
172 *
173 * FIXME: needs doc
174 */
151int eeprom_is_ready(void) 175int eeprom_is_ready(void)
152{ 176{
153 return (FTFL->FCNFG & FTFL_FCNFG_EEERDY) ? 1 : 0; 177 return (FTFL->FCNFG & FTFL_FCNFG_EEERDY) ? 1 : 0;
154} 178}
155 179
180/** \brief flexram wait
181 *
182 * FIXME: needs doc
183 */
156static void flexram_wait(void) 184static void flexram_wait(void)
157{ 185{
158 while (!(FTFL->FCNFG & FTFL_FCNFG_EEERDY)) { 186 while (!(FTFL->FCNFG & FTFL_FCNFG_EEERDY)) {
@@ -160,6 +188,10 @@ static void flexram_wait(void)
160 } 188 }
161} 189}
162 190
191/** \brief eeprom_write_byte
192 *
193 * FIXME: needs doc
194 */
163void eeprom_write_byte(uint8_t *addr, uint8_t value) 195void eeprom_write_byte(uint8_t *addr, uint8_t value)
164{ 196{
165 uint32_t offset = (uint32_t)addr; 197 uint32_t offset = (uint32_t)addr;
@@ -172,6 +204,10 @@ void eeprom_write_byte(uint8_t *addr, uint8_t value)
172 } 204 }
173} 205}
174 206
207/** \brief eeprom write word
208 *
209 * FIXME: needs doc
210 */
175void eeprom_write_word(uint16_t *addr, uint16_t value) 211void eeprom_write_word(uint16_t *addr, uint16_t value)
176{ 212{
177 uint32_t offset = (uint32_t)addr; 213 uint32_t offset = (uint32_t)addr;
@@ -199,6 +235,10 @@ void eeprom_write_word(uint16_t *addr, uint16_t value)
199#endif 235#endif
200} 236}
201 237
238/** \brief eeprom write dword
239 *
240 * FIXME: needs doc
241 */
202void eeprom_write_dword(uint32_t *addr, uint32_t value) 242void eeprom_write_dword(uint32_t *addr, uint32_t value)
203{ 243{
204 uint32_t offset = (uint32_t)addr; 244 uint32_t offset = (uint32_t)addr;
@@ -242,6 +282,10 @@ void eeprom_write_dword(uint32_t *addr, uint32_t value)
242#endif 282#endif
243} 283}
244 284
285/** \brief eeprom write block
286 *
287 * FIXME: needs doc
288 */
245void eeprom_write_block(const void *buf, void *addr, uint32_t len) 289void eeprom_write_block(const void *buf, void *addr, uint32_t len)
246{ 290{
247 uint32_t offset = (uint32_t)addr; 291 uint32_t offset = (uint32_t)addr;
diff --git a/tmk_core/common/chibios/suspend.c b/tmk_core/common/chibios/suspend.c
index 7c3c75387..32ef773e2 100644
--- a/tmk_core/common/chibios/suspend.c
+++ b/tmk_core/common/chibios/suspend.c
@@ -12,11 +12,19 @@
12#include "suspend.h" 12#include "suspend.h"
13#include "wait.h" 13#include "wait.h"
14 14
15/** \brief suspend idle
16 *
17 * FIXME: needs doc
18 */
15void suspend_idle(uint8_t time) { 19void suspend_idle(uint8_t time) {
16 // TODO: this is not used anywhere - what units is 'time' in? 20 // TODO: this is not used anywhere - what units is 'time' in?
17 wait_ms(time); 21 wait_ms(time);
18} 22}
19 23
24/** \brief suspend power down
25 *
26 * FIXME: needs doc
27 */
20void suspend_power_down(void) { 28void suspend_power_down(void) {
21 // TODO: figure out what to power down and how 29 // TODO: figure out what to power down and how
22 // shouldn't power down TPM/FTM if we want a breathing LED 30 // shouldn't power down TPM/FTM if we want a breathing LED
@@ -28,6 +36,10 @@ void suspend_power_down(void) {
28 wait_ms(17); 36 wait_ms(17);
29} 37}
30 38
39/** \brief suspend wakeup condition
40 *
41 * FIXME: needs doc
42 */
31__attribute__ ((weak)) void matrix_power_up(void) {} 43__attribute__ ((weak)) void matrix_power_up(void) {}
32__attribute__ ((weak)) void matrix_power_down(void) {} 44__attribute__ ((weak)) void matrix_power_down(void) {}
33bool suspend_wakeup_condition(void) 45bool suspend_wakeup_condition(void)
@@ -41,7 +53,11 @@ bool suspend_wakeup_condition(void)
41 return false; 53 return false;
42} 54}
43 55
44// run immediately after wakeup 56/** \brief suspend wakeup condition
57 *
58 * run immediately after wakeup
59 * FIXME: needs doc
60 */
45void suspend_wakeup_init(void) 61void suspend_wakeup_init(void)
46{ 62{
47 // clear keyboard state 63 // clear keyboard state
diff --git a/tmk_core/common/command.h b/tmk_core/common/command.h
index a729e4b1e..d9d89ba0f 100644
--- a/tmk_core/common/command.h
+++ b/tmk_core/common/command.h
@@ -18,6 +18,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
18#ifndef COMMAND_H 18#ifndef COMMAND_H
19#define COMMAND 19#define COMMAND
20 20
21/* FIXME: Add doxygen comments for the behavioral defines in here. */
22
21/* TODO: Refactoring */ 23/* TODO: Refactoring */
22typedef enum { ONESHOT, CONSOLE, MOUSEKEY } command_state_t; 24typedef enum { ONESHOT, CONSOLE, MOUSEKEY } command_state_t;
23extern command_state_t command_state; 25extern command_state_t command_state;
@@ -154,4 +156,4 @@ bool command_proc(uint8_t code);
154#define XMAGIC_KC(key) KC_##key 156#define XMAGIC_KC(key) KC_##key
155#define MAGIC_KC(key) XMAGIC_KC(key) 157#define MAGIC_KC(key) XMAGIC_KC(key)
156 158
157#endif \ No newline at end of file 159#endif
diff --git a/tmk_core/common/eeconfig.c b/tmk_core/common/eeconfig.c
index e2eb4a38e..91c18e2e6 100644
--- a/tmk_core/common/eeconfig.c
+++ b/tmk_core/common/eeconfig.c
@@ -3,6 +3,10 @@
3#include "eeprom.h" 3#include "eeprom.h"
4#include "eeconfig.h" 4#include "eeconfig.h"
5 5
6/** \brief eeconfig initialization
7 *
8 * FIXME: needs doc
9 */
6void eeconfig_init(void) 10void eeconfig_init(void)
7{ 11{
8 eeprom_update_word(EECONFIG_MAGIC, EECONFIG_MAGIC_NUMBER); 12 eeprom_update_word(EECONFIG_MAGIC, EECONFIG_MAGIC_NUMBER);
@@ -24,36 +28,88 @@ void eeconfig_init(void)
24#endif 28#endif
25} 29}
26 30
31/** \brief eeconfig enable
32 *
33 * FIXME: needs doc
34 */
27void eeconfig_enable(void) 35void eeconfig_enable(void)
28{ 36{
29 eeprom_update_word(EECONFIG_MAGIC, EECONFIG_MAGIC_NUMBER); 37 eeprom_update_word(EECONFIG_MAGIC, EECONFIG_MAGIC_NUMBER);
30} 38}
31 39
40/** \brief eeconfig disable
41 *
42 * FIXME: needs doc
43 */
32void eeconfig_disable(void) 44void eeconfig_disable(void)
33{ 45{
34 eeprom_update_word(EECONFIG_MAGIC, 0xFFFF); 46 eeprom_update_word(EECONFIG_MAGIC, 0xFFFF);
35} 47}
36 48
49/** \brief eeconfig is enabled
50 *
51 * FIXME: needs doc
52 */
37bool eeconfig_is_enabled(void) 53bool eeconfig_is_enabled(void)
38{ 54{
39 return (eeprom_read_word(EECONFIG_MAGIC) == EECONFIG_MAGIC_NUMBER); 55 return (eeprom_read_word(EECONFIG_MAGIC) == EECONFIG_MAGIC_NUMBER);
40} 56}
41 57
58/** \brief eeconfig read debug
59 *
60 * FIXME: needs doc
61 */
42uint8_t eeconfig_read_debug(void) { return eeprom_read_byte(EECONFIG_DEBUG); } 62uint8_t eeconfig_read_debug(void) { return eeprom_read_byte(EECONFIG_DEBUG); }
63/** \brief eeconfig update debug
64 *
65 * FIXME: needs doc
66 */
43void eeconfig_update_debug(uint8_t val) { eeprom_update_byte(EECONFIG_DEBUG, val); } 67void eeconfig_update_debug(uint8_t val) { eeprom_update_byte(EECONFIG_DEBUG, val); }
44 68
69/** \brief eeconfig read default layer
70 *
71 * FIXME: needs doc
72 */
45uint8_t eeconfig_read_default_layer(void) { return eeprom_read_byte(EECONFIG_DEFAULT_LAYER); } 73uint8_t eeconfig_read_default_layer(void) { return eeprom_read_byte(EECONFIG_DEFAULT_LAYER); }
74/** \brief eeconfig update default layer
75 *
76 * FIXME: needs doc
77 */
46void eeconfig_update_default_layer(uint8_t val) { eeprom_update_byte(EECONFIG_DEFAULT_LAYER, val); } 78void eeconfig_update_default_layer(uint8_t val) { eeprom_update_byte(EECONFIG_DEFAULT_LAYER, val); }
47 79
80/** \brief eeconfig read keymap
81 *
82 * FIXME: needs doc
83 */
48uint8_t eeconfig_read_keymap(void) { return eeprom_read_byte(EECONFIG_KEYMAP); } 84uint8_t eeconfig_read_keymap(void) { return eeprom_read_byte(EECONFIG_KEYMAP); }
85/** \brief eeconfig update keymap
86 *
87 * FIXME: needs doc
88 */
49void eeconfig_update_keymap(uint8_t val) { eeprom_update_byte(EECONFIG_KEYMAP, val); } 89void eeconfig_update_keymap(uint8_t val) { eeprom_update_byte(EECONFIG_KEYMAP, val); }
50 90
51#ifdef BACKLIGHT_ENABLE 91#ifdef BACKLIGHT_ENABLE
92/** \brief eeconfig read backlight
93 *
94 * FIXME: needs doc
95 */
52uint8_t eeconfig_read_backlight(void) { return eeprom_read_byte(EECONFIG_BACKLIGHT); } 96uint8_t eeconfig_read_backlight(void) { return eeprom_read_byte(EECONFIG_BACKLIGHT); }
97/** \brief eeconfig update backlight
98 *
99 * FIXME: needs doc
100 */
53void eeconfig_update_backlight(uint8_t val) { eeprom_update_byte(EECONFIG_BACKLIGHT, val); } 101void eeconfig_update_backlight(uint8_t val) { eeprom_update_byte(EECONFIG_BACKLIGHT, val); }
54#endif 102#endif
55 103
56#ifdef AUDIO_ENABLE 104#ifdef AUDIO_ENABLE
105/** \brief eeconfig read audio
106 *
107 * FIXME: needs doc
108 */
57uint8_t eeconfig_read_audio(void) { return eeprom_read_byte(EECONFIG_AUDIO); } 109uint8_t eeconfig_read_audio(void) { return eeprom_read_byte(EECONFIG_AUDIO); }
110/** \brief eeconfig update audio
111 *
112 * FIXME: needs doc
113 */
58void eeconfig_update_audio(uint8_t val) { eeprom_update_byte(EECONFIG_AUDIO, val); } 114void eeconfig_update_audio(uint8_t val) { eeprom_update_byte(EECONFIG_AUDIO, val); }
59#endif 115#endif
diff --git a/tmk_core/common/keyboard.c b/tmk_core/common/keyboard.c
index 001fb00ce..4eff764e2 100644
--- a/tmk_core/common/keyboard.c
+++ b/tmk_core/common/keyboard.c
@@ -117,19 +117,35 @@ static inline bool has_ghost_in_row(uint8_t row, matrix_row_t rowdata)
117 117
118#endif 118#endif
119 119
120/** \brief matrix_setup
121 *
122 * FIXME: needs doc
123 */
120__attribute__ ((weak)) 124__attribute__ ((weak))
121void matrix_setup(void) { 125void matrix_setup(void) {
122} 126}
123 127
128/** \brief keyboard_setup
129 *
130 * FIXME: needs doc
131 */
124void keyboard_setup(void) { 132void keyboard_setup(void) {
125 matrix_setup(); 133 matrix_setup();
126} 134}
127 135
136/** \brief is_keyboard_master
137 *
138 * FIXME: needs doc
139 */
128__attribute__((weak)) 140__attribute__((weak))
129bool is_keyboard_master(void) { 141bool is_keyboard_master(void) {
130 return true; 142 return true;
131} 143}
132 144
145/** \brief keyboard_init
146 *
147 * FIXME: needs doc
148 */
133void keyboard_init(void) { 149void keyboard_init(void) {
134 timer_init(); 150 timer_init();
135 matrix_init(); 151 matrix_init();
@@ -167,8 +183,16 @@ void keyboard_init(void) {
167#endif 183#endif
168} 184}
169 185
170/* 186/** \brief Keyboard task: Do keyboard routine jobs
171 * Do keyboard routine jobs: scan matrix, light LEDs, ... 187 *
188 * Do routine keyboard jobs:
189 *
190 * * scan matrix
191 * * handle mouse movements
192 * * run visualizer code
193 * * handle midi commands
194 * * light LEDs
195 *
172 * This is repeatedly called as fast as possible. 196 * This is repeatedly called as fast as possible.
173 */ 197 */
174void keyboard_task(void) 198void keyboard_task(void)
@@ -274,6 +298,10 @@ MATRIX_LOOP_END:
274 } 298 }
275} 299}
276 300
301/** \brief keyboard set leds
302 *
303 * FIXME: needs doc
304 */
277void keyboard_set_leds(uint8_t leds) 305void keyboard_set_leds(uint8_t leds)
278{ 306{
279 if (debug_keyboard) { debug("keyboard_set_led: "); debug_hex8(leds); debug("\n"); } 307 if (debug_keyboard) { debug("keyboard_set_led: "); debug_hex8(leds); debug("\n"); }
diff --git a/tmk_core/common/keycode.h b/tmk_core/common/keycode.h
index e7e09e098..734c9fbff 100644
--- a/tmk_core/common/keycode.h
+++ b/tmk_core/common/keycode.h
@@ -22,6 +22,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
22#ifndef KEYCODE_H 22#ifndef KEYCODE_H
23#define KEYCODE_H 23#define KEYCODE_H
24 24
25/* FIXME: Add doxygen comments here */
25 26
26#define IS_ERROR(code) (KC_ROLL_OVER <= (code) && (code) <= KC_UNDEFINED) 27#define IS_ERROR(code) (KC_ROLL_OVER <= (code) && (code) <= KC_UNDEFINED)
27#define IS_ANY(code) (KC_A <= (code) && (code) <= 0xFF) 28#define IS_ANY(code) (KC_A <= (code) && (code) <= 0xFF)
diff --git a/tmk_core/common/led.h b/tmk_core/common/led.h
index 61c971c10..c16305129 100644
--- a/tmk_core/common/led.h
+++ b/tmk_core/common/led.h
@@ -19,6 +19,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
19#define LED_H 19#define LED_H
20#include "stdint.h" 20#include "stdint.h"
21 21
22/* FIXME: Add doxygen comments here. */
22 23
23/* keyboard LEDs */ 24/* keyboard LEDs */
24#define USB_LED_NUM_LOCK 0 25#define USB_LED_NUM_LOCK 0
@@ -40,4 +41,4 @@ void led_init_ports(void);
40} 41}
41#endif 42#endif
42 43
43#endif \ No newline at end of file 44#endif
diff --git a/tmk_core/common/magic.c b/tmk_core/common/magic.c
index 49617a3d1..714acc0f5 100644
--- a/tmk_core/common/magic.c
+++ b/tmk_core/common/magic.c
@@ -14,6 +14,10 @@
14 14
15keymap_config_t keymap_config; 15keymap_config_t keymap_config;
16 16
17/** \brief Magic
18 *
19 * FIXME: Needs doc
20 */
17void magic(void) 21void magic(void)
18{ 22{
19 /* check signature */ 23 /* check signature */
diff --git a/tmk_core/common/report.c b/tmk_core/common/report.c
index 4b25f4428..eb3b44312 100644
--- a/tmk_core/common/report.c
+++ b/tmk_core/common/report.c
@@ -20,6 +20,10 @@
20#include "debug.h" 20#include "debug.h"
21#include "util.h" 21#include "util.h"
22 22
23/** \brief has_anykey
24 *
25 * FIXME: Needs doc
26 */
23uint8_t has_anykey(report_keyboard_t* keyboard_report) 27uint8_t has_anykey(report_keyboard_t* keyboard_report)
24{ 28{
25 uint8_t cnt = 0; 29 uint8_t cnt = 0;
@@ -30,6 +34,10 @@ uint8_t has_anykey(report_keyboard_t* keyboard_report)
30 return cnt; 34 return cnt;
31} 35}
32 36
37/** \brief get_first_key
38 *
39 * FIXME: Needs doc
40 */
33uint8_t get_first_key(report_keyboard_t* keyboard_report) 41uint8_t get_first_key(report_keyboard_t* keyboard_report)
34{ 42{
35#ifdef NKRO_ENABLE 43#ifdef NKRO_ENABLE
@@ -54,6 +62,10 @@ uint8_t get_first_key(report_keyboard_t* keyboard_report)
54#endif 62#endif
55} 63}
56 64
65/** \brief add key byte
66 *
67 * FIXME: Needs doc
68 */
57void add_key_byte(report_keyboard_t* keyboard_report, uint8_t code) 69void add_key_byte(report_keyboard_t* keyboard_report, uint8_t code)
58{ 70{
59#ifdef USB_6KRO_ENABLE 71#ifdef USB_6KRO_ENABLE
@@ -120,6 +132,10 @@ void add_key_byte(report_keyboard_t* keyboard_report, uint8_t code)
120#endif 132#endif
121} 133}
122 134
135/** \brief del key byte
136 *
137 * FIXME: Needs doc
138 */
123void del_key_byte(report_keyboard_t* keyboard_report, uint8_t code) 139void del_key_byte(report_keyboard_t* keyboard_report, uint8_t code)
124{ 140{
125#ifdef USB_6KRO_ENABLE 141#ifdef USB_6KRO_ENABLE
@@ -157,6 +173,10 @@ void del_key_byte(report_keyboard_t* keyboard_report, uint8_t code)
157} 173}
158 174
159#ifdef NKRO_ENABLE 175#ifdef NKRO_ENABLE
176/** \brief add key bit
177 *
178 * FIXME: Needs doc
179 */
160void add_key_bit(report_keyboard_t* keyboard_report, uint8_t code) 180void add_key_bit(report_keyboard_t* keyboard_report, uint8_t code)
161{ 181{
162 if ((code>>3) < KEYBOARD_REPORT_BITS) { 182 if ((code>>3) < KEYBOARD_REPORT_BITS) {
@@ -166,6 +186,10 @@ void add_key_bit(report_keyboard_t* keyboard_report, uint8_t code)
166 } 186 }
167} 187}
168 188
189/** \brief del key bit
190 *
191 * FIXME: Needs doc
192 */
169void del_key_bit(report_keyboard_t* keyboard_report, uint8_t code) 193void del_key_bit(report_keyboard_t* keyboard_report, uint8_t code)
170{ 194{
171 if ((code>>3) < KEYBOARD_REPORT_BITS) { 195 if ((code>>3) < KEYBOARD_REPORT_BITS) {
@@ -176,6 +200,10 @@ void del_key_bit(report_keyboard_t* keyboard_report, uint8_t code)
176} 200}
177#endif 201#endif
178 202
203/** \brief add key to report
204 *
205 * FIXME: Needs doc
206 */
179void add_key_to_report(report_keyboard_t* keyboard_report, uint8_t key) 207void add_key_to_report(report_keyboard_t* keyboard_report, uint8_t key)
180{ 208{
181#ifdef NKRO_ENABLE 209#ifdef NKRO_ENABLE
@@ -187,6 +215,10 @@ void add_key_to_report(report_keyboard_t* keyboard_report, uint8_t key)
187 add_key_byte(keyboard_report, key); 215 add_key_byte(keyboard_report, key);
188} 216}
189 217
218/** \brief del key from report
219 *
220 * FIXME: Needs doc
221 */
190void del_key_from_report(report_keyboard_t* keyboard_report, uint8_t key) 222void del_key_from_report(report_keyboard_t* keyboard_report, uint8_t key)
191{ 223{
192#ifdef NKRO_ENABLE 224#ifdef NKRO_ENABLE
@@ -198,6 +230,10 @@ void del_key_from_report(report_keyboard_t* keyboard_report, uint8_t key)
198 del_key_byte(keyboard_report, key); 230 del_key_byte(keyboard_report, key);
199} 231}
200 232
233/** \brief clear key from report
234 *
235 * FIXME: Needs doc
236 */
201void clear_keys_from_report(report_keyboard_t* keyboard_report) 237void clear_keys_from_report(report_keyboard_t* keyboard_report)
202{ 238{
203 // not clear mods 239 // not clear mods
diff --git a/tmk_core/protocol/lufa/lufa.c b/tmk_core/protocol/lufa/lufa.c
index a1cab98a6..cb918d3dc 100644
--- a/tmk_core/protocol/lufa/lufa.c
+++ b/tmk_core/protocol/lufa/lufa.c
@@ -141,6 +141,10 @@ USB_ClassInfo_CDC_Device_t cdc_device =
141 141
142#ifdef RAW_ENABLE 142#ifdef RAW_ENABLE
143 143
144/** \brief Raw HID Send
145 *
146 * FIXME: Needs doc
147 */
144void raw_hid_send( uint8_t *data, uint8_t length ) 148void raw_hid_send( uint8_t *data, uint8_t length )
145{ 149{
146 // TODO: implement variable size packet 150 // TODO: implement variable size packet
@@ -172,6 +176,10 @@ void raw_hid_send( uint8_t *data, uint8_t length )
172 Endpoint_SelectEndpoint(ep); 176 Endpoint_SelectEndpoint(ep);
173} 177}
174 178
179/** \brief Raw HID Receive
180 *
181 * FIXME: Needs doc
182 */
175__attribute__ ((weak)) 183__attribute__ ((weak))
176void raw_hid_receive( uint8_t *data, uint8_t length ) 184void raw_hid_receive( uint8_t *data, uint8_t length )
177{ 185{
@@ -180,6 +188,10 @@ void raw_hid_receive( uint8_t *data, uint8_t length )
180 // so users can opt to not handle data coming in. 188 // so users can opt to not handle data coming in.
181} 189}
182 190
191/** \brief Raw HID Task
192 *
193 * FIXME: Needs doc
194 */
183static void raw_hid_task(void) 195static void raw_hid_task(void)
184{ 196{
185 // Create a temporary buffer to hold the read in data from the host 197 // Create a temporary buffer to hold the read in data from the host
@@ -218,6 +230,10 @@ static void raw_hid_task(void)
218 * Console 230 * Console
219 ******************************************************************************/ 231 ******************************************************************************/
220#ifdef CONSOLE_ENABLE 232#ifdef CONSOLE_ENABLE
233/** \brief Console Task
234 *
235 * FIXME: Needs doc
236 */
221static void Console_Task(void) 237static void Console_Task(void)
222{ 238{
223 /* Device must be connected and configured for the task to run */ 239 /* Device must be connected and configured for the task to run */
@@ -282,6 +298,10 @@ static void Console_Task(void)
282 * 2) EVENT_USB_Device_Reset 298 * 2) EVENT_USB_Device_Reset
283 * 3) EVENT_USB_Device_Wake 299 * 3) EVENT_USB_Device_Wake
284*/ 300*/
301/** \brief Event USB Device Connect
302 *
303 * FIXME: Needs doc
304 */
285void EVENT_USB_Device_Connect(void) 305void EVENT_USB_Device_Connect(void)
286{ 306{
287 print("[C]"); 307 print("[C]");
@@ -293,6 +313,10 @@ void EVENT_USB_Device_Connect(void)
293 } 313 }
294} 314}
295 315
316/** \brief Event USB Device Connect
317 *
318 * FIXME: Needs doc
319 */
296void EVENT_USB_Device_Disconnect(void) 320void EVENT_USB_Device_Disconnect(void)
297{ 321{
298 print("[D]"); 322 print("[D]");
@@ -307,11 +331,19 @@ void EVENT_USB_Device_Disconnect(void)
307*/ 331*/
308} 332}
309 333
334/** \brief Event USB Device Connect
335 *
336 * FIXME: Needs doc
337 */
310void EVENT_USB_Device_Reset(void) 338void EVENT_USB_Device_Reset(void)
311{ 339{
312 print("[R]"); 340 print("[R]");
313} 341}
314 342
343/** \brief Event USB Device Connect
344 *
345 * FIXME: Needs doc
346 */
315void EVENT_USB_Device_Suspend() 347void EVENT_USB_Device_Suspend()
316{ 348{
317 print("[S]"); 349 print("[S]");
@@ -320,6 +352,10 @@ void EVENT_USB_Device_Suspend()
320#endif 352#endif
321} 353}
322 354
355/** \brief Event USB Device Connect
356 *
357 * FIXME: Needs doc
358 */
323void EVENT_USB_Device_WakeUp() 359void EVENT_USB_Device_WakeUp()
324{ 360{
325 print("[W]"); 361 print("[W]");
@@ -342,7 +378,11 @@ static bool console_flush = false;
342 } \ 378 } \
343} while (0) 379} while (0)
344 380
345// called every 1ms 381/** \brief Event USB Device Start Of Frame
382 *
383 * FIXME: Needs doc
384 * called every 1ms
385 */
346void EVENT_USB_Device_StartOfFrame(void) 386void EVENT_USB_Device_StartOfFrame(void)
347{ 387{
348 static uint8_t count; 388 static uint8_t count;
@@ -356,11 +396,12 @@ void EVENT_USB_Device_StartOfFrame(void)
356 396
357#endif 397#endif
358 398
359/** Event handler for the USB_ConfigurationChanged event. 399/** \brief Event handler for the USB_ConfigurationChanged event.
400 *
360 * This is fired when the host sets the current configuration of the USB device after enumeration. 401 * This is fired when the host sets the current configuration of the USB device after enumeration.
361 * 402 *
362 * ATMega32u2 supports dual bank(ping-pong mode) only on endpoint 3 and 4, 403 * ATMega32u2 supports dual bank(ping-pong mode) only on endpoint 3 and 4,
363 * it is safe to use singl bank for all endpoints. 404 * it is safe to use single bank for all endpoints.
364 */ 405 */
365void EVENT_USB_Device_ConfigurationChanged(void) 406void EVENT_USB_Device_ConfigurationChanged(void)
366{ 407{
@@ -418,7 +459,7 @@ void EVENT_USB_Device_ConfigurationChanged(void)
418#endif 459#endif
419} 460}
420 461
421/* 462/* FIXME: Expose this table in the docs somehow
422Appendix G: HID Request Support Requirements 463Appendix G: HID Request Support Requirements
423 464
424The following table enumerates the requests that need to be supported by various types of HID class devices. 465The following table enumerates the requests that need to be supported by various types of HID class devices.
@@ -431,7 +472,8 @@ Boot Keyboard Required Optional Required Required Required Requ
431Non-Boot Keybrd Required Optional Required Required Optional Optional 472Non-Boot Keybrd Required Optional Required Required Optional Optional
432Other Device Required Optional Optional Optional Optional Optional 473Other Device Required Optional Optional Optional Optional Optional
433*/ 474*/
434/** Event handler for the USB_ControlRequest event. 475/** \brief Event handler for the USB_ControlRequest event.
476 *
435 * This is fired before passing along unhandled control requests to the library for processing internally. 477 * This is fired before passing along unhandled control requests to the library for processing internally.
436 */ 478 */
437void EVENT_USB_Device_ControlRequest(void) 479void EVENT_USB_Device_ControlRequest(void)
@@ -546,11 +588,19 @@ void EVENT_USB_Device_ControlRequest(void)
546/******************************************************************************* 588/*******************************************************************************
547 * Host driver 589 * Host driver
548 ******************************************************************************/ 590 ******************************************************************************/
591/** \brief Keyboard LEDs
592 *
593 * FIXME: Needs doc
594 */
549static uint8_t keyboard_leds(void) 595static uint8_t keyboard_leds(void)
550{ 596{
551 return keyboard_led_stats; 597 return keyboard_led_stats;
552} 598}
553 599
600/** \brief Send Keyboard
601 *
602 * FIXME: Needs doc
603 */
554static void send_keyboard(report_keyboard_t *report) 604static void send_keyboard(report_keyboard_t *report)
555{ 605{
556 uint8_t timeout = 255; 606 uint8_t timeout = 255;
@@ -612,7 +662,11 @@ static void send_keyboard(report_keyboard_t *report)
612 662
613 keyboard_report_sent = *report; 663 keyboard_report_sent = *report;
614} 664}
615 665
666/** \brief Send Mouse
667 *
668 * FIXME: Needs doc
669 */
616static void send_mouse(report_mouse_t *report) 670static void send_mouse(report_mouse_t *report)
617{ 671{
618#ifdef MOUSE_ENABLE 672#ifdef MOUSE_ENABLE
@@ -657,6 +711,10 @@ static void send_mouse(report_mouse_t *report)
657#endif 711#endif
658} 712}
659 713
714/** \brief Send System
715 *
716 * FIXME: Needs doc
717 */
660static void send_system(uint16_t data) 718static void send_system(uint16_t data)
661{ 719{
662 uint8_t timeout = 255; 720 uint8_t timeout = 255;
@@ -678,6 +736,10 @@ static void send_system(uint16_t data)
678 Endpoint_ClearIN(); 736 Endpoint_ClearIN();
679} 737}
680 738
739/** \brief Send Consumer
740 *
741 * FIXME: Needs doc
742 */
681static void send_consumer(uint16_t data) 743static void send_consumer(uint16_t data)
682{ 744{
683 uint8_t timeout = 255; 745 uint8_t timeout = 255;
@@ -739,6 +801,10 @@ static void send_consumer(uint16_t data)
739 ******************************************************************************/ 801 ******************************************************************************/
740#ifdef CONSOLE_ENABLE 802#ifdef CONSOLE_ENABLE
741#define SEND_TIMEOUT 5 803#define SEND_TIMEOUT 5
804/** \brief Send Char
805 *
806 * FIXME: Needs doc
807 */
742int8_t sendchar(uint8_t c) 808int8_t sendchar(uint8_t c)
743{ 809{
744 // Not wait once timeouted. 810 // Not wait once timeouted.
@@ -842,18 +908,30 @@ bool recv_midi_packet(MIDI_EventPacket_t* const event) {
842 ******************************************************************************/ 908 ******************************************************************************/
843 909
844#ifdef VIRTSER_ENABLE 910#ifdef VIRTSER_ENABLE
911/** \brief Virtual Serial Init
912 *
913 * FIXME: Needs doc
914 */
845void virtser_init(void) 915void virtser_init(void)
846{ 916{
847 cdc_device.State.ControlLineStates.DeviceToHost = CDC_CONTROL_LINE_IN_DSR ; 917 cdc_device.State.ControlLineStates.DeviceToHost = CDC_CONTROL_LINE_IN_DSR ;
848 CDC_Device_SendControlLineStateChange(&cdc_device); 918 CDC_Device_SendControlLineStateChange(&cdc_device);
849} 919}
850 920
921/** \brief Virtual Serial Receive
922 *
923 * FIXME: Needs doc
924 */
851void virtser_recv(uint8_t c) __attribute__ ((weak)); 925void virtser_recv(uint8_t c) __attribute__ ((weak));
852void virtser_recv(uint8_t c) 926void virtser_recv(uint8_t c)
853{ 927{
854 // Ignore by default 928 // Ignore by default
855} 929}
856 930
931/** \brief Virtual Serial Task
932 *
933 * FIXME: Needs doc
934 */
857void virtser_task(void) 935void virtser_task(void)
858{ 936{
859 uint16_t count = CDC_Device_BytesReceived(&cdc_device); 937 uint16_t count = CDC_Device_BytesReceived(&cdc_device);
@@ -864,6 +942,10 @@ void virtser_task(void)
864 virtser_recv(ch); 942 virtser_recv(ch);
865 } 943 }
866} 944}
945/** \brief Virtual Serial Send
946 *
947 * FIXME: Needs doc
948 */
867void virtser_send(const uint8_t byte) 949void virtser_send(const uint8_t byte)
868{ 950{
869 uint8_t timeout = 255; 951 uint8_t timeout = 255;
@@ -896,6 +978,10 @@ void virtser_send(const uint8_t byte)
896/******************************************************************************* 978/*******************************************************************************
897 * main 979 * main
898 ******************************************************************************/ 980 ******************************************************************************/
981/** \brief Setup MCU
982 *
983 * FIXME: Needs doc
984 */
899static void setup_mcu(void) 985static void setup_mcu(void)
900{ 986{
901 /* Disable watchdog if enabled by bootloader/fuses */ 987 /* Disable watchdog if enabled by bootloader/fuses */
@@ -909,6 +995,10 @@ static void setup_mcu(void)
909 CLKPR = (0 << CLKPS3) | (0 << CLKPS2) | (0 << CLKPS1) | (0 << CLKPS0); 995 CLKPR = (0 << CLKPS3) | (0 << CLKPS2) | (0 << CLKPS1) | (0 << CLKPS0);
910} 996}
911 997
998/** \brief Setup USB
999 *
1000 * FIXME: Needs doc
1001 */
912static void setup_usb(void) 1002static void setup_usb(void)
913{ 1003{
914 // Leonardo needs. Without this USB device is not recognized. 1004 // Leonardo needs. Without this USB device is not recognized.
@@ -921,6 +1011,10 @@ static void setup_usb(void)
921 print_set_sendchar(sendchar); 1011 print_set_sendchar(sendchar);
922} 1012}
923 1013
1014/** \brief Main
1015 *
1016 * FIXME: Needs doc
1017 */
924int main(void) __attribute__ ((weak)); 1018int main(void) __attribute__ ((weak));
925int main(void) 1019int main(void)
926{ 1020{
diff --git a/tmk_core/protocol/lufa/outputselect.c b/tmk_core/protocol/lufa/outputselect.c
index 0df5d3b75..42de80612 100644
--- a/tmk_core/protocol/lufa/outputselect.c
+++ b/tmk_core/protocol/lufa/outputselect.c
@@ -20,15 +20,27 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
20 20
21uint8_t desired_output = OUTPUT_DEFAULT; 21uint8_t desired_output = OUTPUT_DEFAULT;
22 22
23/** \brief Set Output
24 *
25 * FIXME: Needs doc
26 */
23void set_output(uint8_t output) { 27void set_output(uint8_t output) {
24 set_output_user(output); 28 set_output_user(output);
25 desired_output = output; 29 desired_output = output;
26} 30}
27 31
32/** \brief Set Output User
33 *
34 * FIXME: Needs doc
35 */
28__attribute__((weak)) 36__attribute__((weak))
29void set_output_user(uint8_t output) { 37void set_output_user(uint8_t output) {
30} 38}
31 39
40/** \brief Auto Detect Output
41 *
42 * FIXME: Needs doc
43 */
32uint8_t auto_detect_output(void) { 44uint8_t auto_detect_output(void) {
33 if (USB_DeviceState == DEVICE_STATE_Configured) { 45 if (USB_DeviceState == DEVICE_STATE_Configured) {
34 return OUTPUT_USB; 46 return OUTPUT_USB;
@@ -47,6 +59,10 @@ uint8_t auto_detect_output(void) {
47 return OUTPUT_NONE; 59 return OUTPUT_NONE;
48} 60}
49 61
62/** \brief Where To Send
63 *
64 * FIXME: Needs doc
65 */
50uint8_t where_to_send(void) { 66uint8_t where_to_send(void) {
51 if (desired_output == OUTPUT_AUTO) { 67 if (desired_output == OUTPUT_AUTO) {
52 return auto_detect_output(); 68 return auto_detect_output();