summaryrefslogtreecommitdiffstats
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 @@
-/* Copyright 2016-2017 Erez Zukerman, Jack Humbert
+/* Copyright 2016-2018 Erez Zukerman, Jack Humbert, Yiancar
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -17,9 +17,12 @@
#define QUANTUM_H
#if defined(__AVR__)
-#include <avr/pgmspace.h>
-#include <avr/io.h>
-#include <avr/interrupt.h>
+ #include <avr/pgmspace.h>
+ #include <avr/io.h>
+ #include <avr/interrupt.h>
+#endif
+#if defined(PROTOCOL_CHIBIOS)
+ #include "hal.h"
#endif
#include "wait.h"
#include "matrix.h"
@@ -28,10 +31,16 @@
#include "backlight.h"
#endif
#if !defined(RGBLIGHT_ENABLE) && !defined(RGB_MATRIX_ENABLE)
- #include "rgb.h"
+ #include "rgb.h"
#endif
#ifdef RGBLIGHT_ENABLE
#include "rgblight.h"
+#else
+ #ifdef RGB_MATRIX_ENABLE
+ /* dummy define RGBLIGHT_MODE_xxxx */
+ #define RGBLIGHT_H_DUMMY_DEFINE
+ #include "rgblight.h"
+ #endif
#endif
#ifdef SPLIT_KEYBOARD
@@ -70,9 +79,9 @@ extern uint32_t default_layer_state;
#ifdef AUDIO_ENABLE
#include "audio.h"
#include "process_audio.h"
- #ifdef AUDIO_CLICKY
- #include "process_clicky.h"
- #endif // AUDIO_CLICKY
+ #ifdef AUDIO_CLICKY
+ #include "process_clicky.h"
+ #endif // AUDIO_CLICKY
#endif
#ifdef STENO_ENABLE
@@ -83,15 +92,10 @@ extern uint32_t default_layer_state;
#include "process_music.h"
#endif
-#ifndef DISABLE_LEADER
+#ifdef LEADER_ENABLE
#include "process_leader.h"
#endif
-#define DISABLE_CHORDING
-#ifndef DISABLE_CHORDING
- #include "process_chording.h"
-#endif
-
#ifdef UNICODE_ENABLE
#include "process_unicode.h"
#endif
@@ -104,7 +108,9 @@ extern uint32_t default_layer_state;
#include "process_unicodemap.h"
#endif
-#include "process_tap_dance.h"
+#ifdef TAP_DANCE_ENABLE
+ #include "process_tap_dance.h"
+#endif
#ifdef PRINTING_ENABLE
#include "process_printer.h"
@@ -132,6 +138,50 @@ extern uint32_t default_layer_state;
#include "hd44780.h"
#endif
+//Function substitutions to ease GPIO manipulation
+#ifdef __AVR__
+ #define PIN_ADDRESS(p, offset) _SFR_IO8(ADDRESS_BASE + (p >> PORT_SHIFTER) + offset)
+
+ #define pin_t uint8_t
+ #define setPinInput(pin) PIN_ADDRESS(pin, 1) &= ~ _BV(pin & 0xF)
+ #define setPinInputHigh(pin) ({\
+ PIN_ADDRESS(pin, 1) &= ~ _BV(pin & 0xF);\
+ PIN_ADDRESS(pin, 2) |= _BV(pin & 0xF);\
+ })
+ #define setPinInputLow(pin) _Static_assert(0, "AVR Processors cannot impliment an input as pull low")
+ #define setPinOutput(pin) PIN_ADDRESS(pin, 1) |= _BV(pin & 0xF)
+
+ #define writePinHigh(pin) PIN_ADDRESS(pin, 2) |= _BV(pin & 0xF)
+ #define writePinLow(pin) PIN_ADDRESS(pin, 2) &= ~_BV(pin & 0xF)
+ static inline void writePin(pin_t pin, uint8_t level){
+ if (level){
+ PIN_ADDRESS(pin, 2) |= _BV(pin & 0xF);
+ } else {
+ PIN_ADDRESS(pin, 2) &= ~_BV(pin & 0xF);
+ }
+ }
+
+ #define readPin(pin) ((bool)(PIN_ADDRESS(pin, 0) & _BV(pin & 0xF)))
+#elif defined(PROTOCOL_CHIBIOS)
+ #define pin_t ioline_t
+ #define setPinInput(pin) palSetLineMode(pin, PAL_MODE_INPUT)
+ #define setPinInputHigh(pin) palSetLineMode(pin, PAL_MODE_INPUT_PULLUP)
+ #define setPinInputLow(pin) palSetLineMode(pin, PAL_MODE_INPUT_PULLDOWN)
+ #define setPinOutput(pin) palSetLineMode(pin, PAL_MODE_OUTPUT_PUSHPULL)
+
+ #define writePinHigh(pin) palSetLine(pin)
+ #define writePinLow(pin) palClearLine(pin)
+ static inline void writePin(pin_t pin, uint8_t level){
+ if (level){
+ palSetLine(pin);
+ } else {
+ palClearLine(pin);
+ }
+ }
+
+ #define readPin(pin) palReadLine(pin)
+#endif
+
#define STRINGIZE(z) #z
#define ADD_SLASH_X(y) STRINGIZE(\x ## y)
#define SYMBOL_STR(x) ADD_SLASH_X(x)
@@ -147,6 +197,7 @@ extern uint32_t default_layer_state;
#define SS_LALT(string) SS_DOWN(X_LALT) string SS_UP(X_LALT)
#define SS_LSFT(string) SS_DOWN(X_LSHIFT) string SS_UP(X_LSHIFT)
#define SS_RALT(string) SS_DOWN(X_RALT) string SS_UP(X_RALT)
+#define SS_ALGR(string) SS_RALT(string)
#define SEND_STRING(str) send_string_P(PSTR(str))
extern const bool ascii_to_shift_lut[0x80];
@@ -176,13 +227,23 @@ bool process_action_kb(keyrecord_t *record);
bool process_record_kb(uint16_t keycode, keyrecord_t *record);
bool process_record_user(uint16_t keycode, keyrecord_t *record);
+#ifndef BOOTMAGIC_LITE_COLUMN
+ #define BOOTMAGIC_LITE_COLUMN 0
+#endif
+#ifndef BOOTMAGIC_LITE_ROW
+ #define BOOTMAGIC_LITE_ROW 0
+#endif
+
+void bootmagic_lite(void);
+
void reset_keyboard(void);
void startup_user(void);
void shutdown_user(void);
-void register_code16 (uint16_t code);
-void unregister_code16 (uint16_t code);
+void register_code16(uint16_t code);
+void unregister_code16(uint16_t code);
+void tap_code16(uint16_t code);
#ifdef BACKLIGHT_ENABLE
void backlight_init_ports(void);