aboutsummaryrefslogtreecommitdiff
path: root/quantum/quantum.h
diff options
context:
space:
mode:
Diffstat (limited to 'quantum/quantum.h')
-rw-r--r--quantum/quantum.h95
1 files changed, 78 insertions, 17 deletions
diff --git a/quantum/quantum.h b/quantum/quantum.h
index b4e4de174..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"
@@ -28,10 +31,16 @@
28 #include "backlight.h" 31 #include "backlight.h"
29#endif 32#endif
30#if !defined(RGBLIGHT_ENABLE) && !defined(RGB_MATRIX_ENABLE) 33#if !defined(RGBLIGHT_ENABLE) && !defined(RGB_MATRIX_ENABLE)
31 #include "rgb.h" 34 #include "rgb.h"
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
@@ -70,9 +79,9 @@ extern uint32_t default_layer_state;
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
@@ -83,15 +92,10 @@ extern uint32_t default_layer_state;
83 #include "process_music.h" 92 #include "process_music.h"
84#endif 93#endif
85 94
86#ifndef DISABLE_LEADER 95#ifdef LEADER_ENABLE
87 #include "process_leader.h" 96 #include "process_leader.h"
88#endif 97#endif
89 98
90#define DISABLE_CHORDING
91#ifndef DISABLE_CHORDING
92 #include "process_chording.h"
93#endif
94
95#ifdef UNICODE_ENABLE 99#ifdef UNICODE_ENABLE
96 #include "process_unicode.h" 100 #include "process_unicode.h"
97#endif 101#endif
@@ -104,7 +108,9 @@ extern uint32_t default_layer_state;
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"
@@ -132,6 +138,50 @@ extern uint32_t default_layer_state;
132 #include "hd44780.h" 138 #include "hd44780.h"
133#endif 139#endif
134 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)
183#endif
184
135#define STRINGIZE(z) #z 185#define STRINGIZE(z) #z
136#define ADD_SLASH_X(y) STRINGIZE(\x ## y) 186#define ADD_SLASH_X(y) STRINGIZE(\x ## y)
137#define SYMBOL_STR(x) ADD_SLASH_X(x) 187#define SYMBOL_STR(x) ADD_SLASH_X(x)
@@ -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);