aboutsummaryrefslogtreecommitdiff
path: root/quantum/quantum.h
diff options
context:
space:
mode:
Diffstat (limited to 'quantum/quantum.h')
-rw-r--r--quantum/quantum.h129
1 files changed, 95 insertions, 34 deletions
diff --git a/quantum/quantum.h b/quantum/quantum.h
index 1db9846f0..f78915fdf 100644
--- a/quantum/quantum.h
+++ b/quantum/quantum.h
@@ -1,4 +1,4 @@
1/* Copyright 2016-2017 Erez Zukerman, Jack Humbert 1/* Copyright 2016-2018 Erez Zukerman, Jack Humbert, Yiancar
2 * 2 *
3 * This program is free software: you can redistribute it and/or modify 3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by 4 * it under the terms of the GNU General Public License as published by
@@ -17,9 +17,12 @@
17#define QUANTUM_H 17#define QUANTUM_H
18 18
19#if defined(__AVR__) 19#if defined(__AVR__)
20#include <avr/pgmspace.h> 20 #include <avr/pgmspace.h>
21#include <avr/io.h> 21 #include <avr/io.h>
22#include <avr/interrupt.h> 22 #include <avr/interrupt.h>
23#endif
24#if defined(PROTOCOL_CHIBIOS)
25 #include "hal.h"
23#endif 26#endif
24#include "wait.h" 27#include "wait.h"
25#include "matrix.h" 28#include "matrix.h"
@@ -32,6 +35,12 @@
32#endif 35#endif
33#ifdef RGBLIGHT_ENABLE 36#ifdef RGBLIGHT_ENABLE
34 #include "rgblight.h" 37 #include "rgblight.h"
38#else
39 #ifdef RGB_MATRIX_ENABLE
40 /* dummy define RGBLIGHT_MODE_xxxx */
41 #define RGBLIGHT_H_DUMMY_DEFINE
42 #include "rgblight.h"
43 #endif
35#endif 44#endif
36 45
37#ifdef SPLIT_KEYBOARD 46#ifdef SPLIT_KEYBOARD
@@ -39,7 +48,7 @@
39#endif 48#endif
40 49
41#ifdef RGB_MATRIX_ENABLE 50#ifdef RGB_MATRIX_ENABLE
42 #include "rgb_matrix.h" 51 #include "rgb_matrix.h"
43#endif 52#endif
44 53
45#include "action_layer.h" 54#include "action_layer.h"
@@ -58,78 +67,119 @@
58extern uint32_t default_layer_state; 67extern uint32_t default_layer_state;
59 68
60#ifndef NO_ACTION_LAYER 69#ifndef NO_ACTION_LAYER
61 extern uint32_t layer_state; 70 extern uint32_t layer_state;
62#endif 71#endif
63 72
64#ifdef MIDI_ENABLE 73#ifdef MIDI_ENABLE
65#ifdef MIDI_ADVANCED 74#ifdef MIDI_ADVANCED
66 #include "process_midi.h" 75 #include "process_midi.h"
67#endif 76#endif
68#endif // MIDI_ENABLE 77#endif // MIDI_ENABLE
69 78
70#ifdef AUDIO_ENABLE 79#ifdef AUDIO_ENABLE
71 #include "audio.h" 80 #include "audio.h"
72 #include "process_audio.h" 81 #include "process_audio.h"
73 #ifdef AUDIO_CLICKY 82 #ifdef AUDIO_CLICKY
74 #include "process_clicky.h" 83 #include "process_clicky.h"
75 #endif // AUDIO_CLICKY 84 #endif // AUDIO_CLICKY
76#endif 85#endif
77 86
78#ifdef STENO_ENABLE 87#ifdef STENO_ENABLE
79 #include "process_steno.h" 88 #include "process_steno.h"
80#endif 89#endif
81 90
82#if defined(AUDIO_ENABLE) || (defined(MIDI_ENABLE) && defined(MIDI_BASIC)) 91#if defined(AUDIO_ENABLE) || (defined(MIDI_ENABLE) && defined(MIDI_BASIC))
83 #include "process_music.h" 92 #include "process_music.h"
84#endif
85
86#ifndef DISABLE_LEADER
87 #include "process_leader.h"
88#endif 93#endif
89 94
90#define DISABLE_CHORDING 95#ifdef LEADER_ENABLE
91#ifndef DISABLE_CHORDING 96 #include "process_leader.h"
92 #include "process_chording.h"
93#endif 97#endif
94 98
95#ifdef UNICODE_ENABLE 99#ifdef UNICODE_ENABLE
96 #include "process_unicode.h" 100 #include "process_unicode.h"
97#endif 101#endif
98 102
99#ifdef UCIS_ENABLE 103#ifdef UCIS_ENABLE
100 #include "process_ucis.h" 104 #include "process_ucis.h"
101#endif 105#endif
102 106
103#ifdef UNICODEMAP_ENABLE 107#ifdef UNICODEMAP_ENABLE
104 #include "process_unicodemap.h" 108 #include "process_unicodemap.h"
105#endif 109#endif
106 110
107#include "process_tap_dance.h" 111#ifdef TAP_DANCE_ENABLE
112 #include "process_tap_dance.h"
113#endif
108 114
109#ifdef PRINTING_ENABLE 115#ifdef PRINTING_ENABLE
110 #include "process_printer.h" 116 #include "process_printer.h"
111#endif 117#endif
112 118
113#ifdef AUTO_SHIFT_ENABLE 119#ifdef AUTO_SHIFT_ENABLE
114 #include "process_auto_shift.h" 120 #include "process_auto_shift.h"
115#endif 121#endif
116 122
117#ifdef COMBO_ENABLE 123#ifdef COMBO_ENABLE
118 #include "process_combo.h" 124 #include "process_combo.h"
119#endif 125#endif
120 126
121#ifdef KEY_LOCK_ENABLE 127#ifdef KEY_LOCK_ENABLE
122 #include "process_key_lock.h" 128 #include "process_key_lock.h"
123#endif 129#endif
124 130
125#ifdef TERMINAL_ENABLE 131#ifdef TERMINAL_ENABLE
126 #include "process_terminal.h" 132 #include "process_terminal.h"
127#else 133#else
128 #include "process_terminal_nop.h" 134 #include "process_terminal_nop.h"
129#endif 135#endif
130 136
131#ifdef HD44780_ENABLE 137#ifdef HD44780_ENABLE
132 #include "hd44780.h" 138 #include "hd44780.h"
139#endif
140
141//Function substitutions to ease GPIO manipulation
142#ifdef __AVR__
143 #define PIN_ADDRESS(p, offset) _SFR_IO8(ADDRESS_BASE + (p >> PORT_SHIFTER) + offset)
144
145 #define pin_t uint8_t
146 #define setPinInput(pin) PIN_ADDRESS(pin, 1) &= ~ _BV(pin & 0xF)
147 #define setPinInputHigh(pin) ({\
148 PIN_ADDRESS(pin, 1) &= ~ _BV(pin & 0xF);\
149 PIN_ADDRESS(pin, 2) |= _BV(pin & 0xF);\
150 })
151 #define setPinInputLow(pin) _Static_assert(0, "AVR Processors cannot impliment an input as pull low")
152 #define setPinOutput(pin) PIN_ADDRESS(pin, 1) |= _BV(pin & 0xF)
153
154 #define writePinHigh(pin) PIN_ADDRESS(pin, 2) |= _BV(pin & 0xF)
155 #define writePinLow(pin) PIN_ADDRESS(pin, 2) &= ~_BV(pin & 0xF)
156 static inline void writePin(pin_t pin, uint8_t level){
157 if (level){
158 PIN_ADDRESS(pin, 2) |= _BV(pin & 0xF);
159 } else {
160 PIN_ADDRESS(pin, 2) &= ~_BV(pin & 0xF);
161 }
162 }
163
164 #define readPin(pin) ((bool)(PIN_ADDRESS(pin, 0) & _BV(pin & 0xF)))
165#elif defined(PROTOCOL_CHIBIOS)
166 #define pin_t ioline_t
167 #define setPinInput(pin) palSetLineMode(pin, PAL_MODE_INPUT)
168 #define setPinInputHigh(pin) palSetLineMode(pin, PAL_MODE_INPUT_PULLUP)
169 #define setPinInputLow(pin) palSetLineMode(pin, PAL_MODE_INPUT_PULLDOWN)
170 #define setPinOutput(pin) palSetLineMode(pin, PAL_MODE_OUTPUT_PUSHPULL)
171
172 #define writePinHigh(pin) palSetLine(pin)
173 #define writePinLow(pin) palClearLine(pin)
174 static inline void writePin(pin_t pin, uint8_t level){
175 if (level){
176 palSetLine(pin);
177 } else {
178 palClearLine(pin);
179 }
180 }
181
182 #define readPin(pin) palReadLine(pin)
133#endif 183#endif
134 184
135#define STRINGIZE(z) #z 185#define STRINGIZE(z) #z
@@ -147,6 +197,7 @@ extern uint32_t default_layer_state;
147#define SS_LALT(string) SS_DOWN(X_LALT) string SS_UP(X_LALT) 197#define SS_LALT(string) SS_DOWN(X_LALT) string SS_UP(X_LALT)
148#define SS_LSFT(string) SS_DOWN(X_LSHIFT) string SS_UP(X_LSHIFT) 198#define SS_LSFT(string) SS_DOWN(X_LSHIFT) string SS_UP(X_LSHIFT)
149#define SS_RALT(string) SS_DOWN(X_RALT) string SS_UP(X_RALT) 199#define SS_RALT(string) SS_DOWN(X_RALT) string SS_UP(X_RALT)
200#define SS_ALGR(string) SS_RALT(string)
150 201
151#define SEND_STRING(str) send_string_P(PSTR(str)) 202#define SEND_STRING(str) send_string_P(PSTR(str))
152extern const bool ascii_to_shift_lut[0x80]; 203extern const bool ascii_to_shift_lut[0x80];
@@ -176,13 +227,23 @@ bool process_action_kb(keyrecord_t *record);
176bool process_record_kb(uint16_t keycode, keyrecord_t *record); 227bool process_record_kb(uint16_t keycode, keyrecord_t *record);
177bool process_record_user(uint16_t keycode, keyrecord_t *record); 228bool process_record_user(uint16_t keycode, keyrecord_t *record);
178 229
230#ifndef BOOTMAGIC_LITE_COLUMN
231 #define BOOTMAGIC_LITE_COLUMN 0
232#endif
233#ifndef BOOTMAGIC_LITE_ROW
234 #define BOOTMAGIC_LITE_ROW 0
235#endif
236
237void bootmagic_lite(void);
238
179void reset_keyboard(void); 239void reset_keyboard(void);
180 240
181void startup_user(void); 241void startup_user(void);
182void shutdown_user(void); 242void shutdown_user(void);
183 243
184void register_code16 (uint16_t code); 244void register_code16(uint16_t code);
185void unregister_code16 (uint16_t code); 245void unregister_code16(uint16_t code);
246void tap_code16(uint16_t code);
186 247
187#ifdef BACKLIGHT_ENABLE 248#ifdef BACKLIGHT_ENABLE
188void backlight_init_ports(void); 249void backlight_init_ports(void);