diff options
| author | Alex Ong <the.onga@gmail.com> | 2019-01-26 12:13:19 +1100 |
|---|---|---|
| committer | Alex Ong <the.onga@gmail.com> | 2019-01-26 12:13:19 +1100 |
| commit | c9ba618654417ec115809a031d315f8327c79ad4 (patch) | |
| tree | cd5b907af5bebde7062897ff847e473232ed1214 /quantum | |
| parent | 2bb2977c133646c4e056960e72029270d77cc1eb (diff) | |
| parent | d977daa8dc9136746425f9e1414e1f93cb161877 (diff) | |
| download | qmk_firmware-c9ba618654417ec115809a031d315f8327c79ad4.tar.gz qmk_firmware-c9ba618654417ec115809a031d315f8327c79ad4.zip | |
DO NOT USE Merge branch 'master' into debounce_refactor
Merged, however now there are two debounce.h and debounce.c to mess around with and coalesce.
# Conflicts:
# quantum/matrix.c
Diffstat (limited to 'quantum')
37 files changed, 1987 insertions, 726 deletions
diff --git a/quantum/audio/musical_notes.h b/quantum/audio/musical_notes.h index 065608ccc..ce8d47d1c 100644 --- a/quantum/audio/musical_notes.h +++ b/quantum/audio/musical_notes.h | |||
| @@ -61,7 +61,11 @@ | |||
| 61 | 61 | ||
| 62 | // Notes - # = Octave | 62 | // Notes - # = Octave |
| 63 | 63 | ||
| 64 | #ifdef __arm__ | ||
| 65 | #define NOTE_REST 1.00f | ||
| 66 | #else | ||
| 64 | #define NOTE_REST 0.00f | 67 | #define NOTE_REST 0.00f |
| 68 | #endif | ||
| 65 | 69 | ||
| 66 | /* These notes are currently bugged | 70 | /* These notes are currently bugged |
| 67 | #define NOTE_C0 16.35f | 71 | #define NOTE_C0 16.35f |
diff --git a/quantum/config_common.h b/quantum/config_common.h index cbff372ea..0b2e408a4 100644 --- a/quantum/config_common.h +++ b/quantum/config_common.h | |||
| @@ -21,6 +21,9 @@ | |||
| 21 | #define ROW2COL 1 | 21 | #define ROW2COL 1 |
| 22 | #define CUSTOM_MATRIX 2 /* Disables built-in matrix scanning code */ | 22 | #define CUSTOM_MATRIX 2 /* Disables built-in matrix scanning code */ |
| 23 | 23 | ||
| 24 | // useful for direct pin mapping | ||
| 25 | #define NO_PIN (~0) | ||
| 26 | |||
| 24 | #ifdef __AVR__ | 27 | #ifdef __AVR__ |
| 25 | #ifndef __ASSEMBLER__ | 28 | #ifndef __ASSEMBLER__ |
| 26 | #include <avr/io.h> | 29 | #include <avr/io.h> |
| @@ -125,6 +128,45 @@ | |||
| 125 | #endif | 128 | #endif |
| 126 | 129 | ||
| 127 | #elif defined(PROTOCOL_CHIBIOS) | 130 | #elif defined(PROTOCOL_CHIBIOS) |
| 131 | // Defines mapping for Proton C replacement | ||
| 132 | #ifdef CONVERT_TO_PROTON_C | ||
| 133 | // Left side (front) | ||
| 134 | #define D3 PAL_LINE(GPIOA, 9) | ||
| 135 | #define D2 PAL_LINE(GPIOA, 10) | ||
| 136 | // GND | ||
| 137 | // GND | ||
| 138 | #define D1 PAL_LINE(GPIOB, 7) | ||
| 139 | #define D0 PAL_LINE(GPIOB, 6) | ||
| 140 | #define D4 PAL_LINE(GPIOB, 5) | ||
| 141 | #define C6 PAL_LINE(GPIOB, 4) | ||
| 142 | #define D7 PAL_LINE(GPIOB, 3) | ||
| 143 | #define E6 PAL_LINE(GPIOB, 2) | ||
| 144 | #define B4 PAL_LINE(GPIOB, 1) | ||
| 145 | #define B5 PAL_LINE(GPIOB, 0) | ||
| 146 | |||
| 147 | // Right side (front) | ||
| 148 | // RAW | ||
| 149 | // GND | ||
| 150 | // RESET | ||
| 151 | // VCC | ||
| 152 | #define F4 PAL_LINE(GPIOA, 2) | ||
| 153 | #define F5 PAL_LINE(GPIOA, 1) | ||
| 154 | #define F6 PAL_LINE(GPIOA, 0) | ||
| 155 | #define F7 PAL_LINE(GPIOB, 8) | ||
| 156 | #define B1 PAL_LINE(GPIOB, 13) | ||
| 157 | #define B3 PAL_LINE(GPIOB, 14) | ||
| 158 | #define B2 PAL_LINE(GPIOB, 15) | ||
| 159 | #define B6 PAL_LINE(GPIOB, 9) | ||
| 160 | |||
| 161 | // LEDs (only D5/C13 uses an actual LED) | ||
| 162 | #ifdef CONVERT_TO_PROTON_C_RXLED | ||
| 163 | #define D5 PAL_LINE(GPIOC, 13) | ||
| 164 | #define B0 PAL_LINE(GPIOC, 13) | ||
| 165 | #else | ||
| 166 | #define D5 PAL_LINE(GPIOC, 13) | ||
| 167 | #define B0 PAL_LINE(GPIOC, 14) | ||
| 168 | #endif | ||
| 169 | #else | ||
| 128 | #define A0 PAL_LINE(GPIOA, 0) | 170 | #define A0 PAL_LINE(GPIOA, 0) |
| 129 | #define A1 PAL_LINE(GPIOA, 1) | 171 | #define A1 PAL_LINE(GPIOA, 1) |
| 130 | #define A2 PAL_LINE(GPIOA, 2) | 172 | #define A2 PAL_LINE(GPIOA, 2) |
| @@ -221,6 +263,7 @@ | |||
| 221 | #define F13 PAL_LINE(GPIOF, 13) | 263 | #define F13 PAL_LINE(GPIOF, 13) |
| 222 | #define F14 PAL_LINE(GPIOF, 14) | 264 | #define F14 PAL_LINE(GPIOF, 14) |
| 223 | #define F15 PAL_LINE(GPIOF, 15) | 265 | #define F15 PAL_LINE(GPIOF, 15) |
| 266 | #endif | ||
| 224 | #endif | 267 | #endif |
| 225 | 268 | ||
| 226 | /* USART configuration */ | 269 | /* USART configuration */ |
diff --git a/quantum/debounce.c b/quantum/debounce.c new file mode 100644 index 000000000..929023ab2 --- /dev/null +++ b/quantum/debounce.c | |||
| @@ -0,0 +1,52 @@ | |||
| 1 | |||
| 2 | #include "matrix.h" | ||
| 3 | #include "timer.h" | ||
| 4 | #include "quantum.h" | ||
| 5 | |||
| 6 | #ifndef DEBOUNCING_DELAY | ||
| 7 | # define DEBOUNCING_DELAY 5 | ||
| 8 | #endif | ||
| 9 | |||
| 10 | void debounce_init(uint8_t num_rows) { | ||
| 11 | } | ||
| 12 | |||
| 13 | #if DEBOUNCING_DELAY > 0 | ||
| 14 | |||
| 15 | static bool debouncing = false; | ||
| 16 | |||
| 17 | void debounce(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, bool changed) { | ||
| 18 | static uint16_t debouncing_time; | ||
| 19 | |||
| 20 | if (changed) { | ||
| 21 | debouncing = true; | ||
| 22 | debouncing_time = timer_read(); | ||
| 23 | } | ||
| 24 | |||
| 25 | if (debouncing && (timer_elapsed(debouncing_time) > DEBOUNCING_DELAY)) { | ||
| 26 | for (uint8_t i = 0; i < num_rows; i++) { | ||
| 27 | cooked[i] = raw[i]; | ||
| 28 | } | ||
| 29 | debouncing = false; | ||
| 30 | } | ||
| 31 | } | ||
| 32 | |||
| 33 | bool debounce_active(void) { | ||
| 34 | return debouncing; | ||
| 35 | } | ||
| 36 | |||
| 37 | #else | ||
| 38 | |||
| 39 | // no debounce | ||
| 40 | void debounce(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, bool changed) { | ||
| 41 | if (changed) | ||
| 42 | { | ||
| 43 | for (uint8_t i = 0; i < num_rows; i++) { | ||
| 44 | cooked[i] = raw[i]; | ||
| 45 | } | ||
| 46 | } | ||
| 47 | } | ||
| 48 | |||
| 49 | bool debounce_active(void) { | ||
| 50 | return false; | ||
| 51 | } | ||
| 52 | #endif | ||
diff --git a/quantum/debounce.h b/quantum/debounce.h new file mode 100644 index 000000000..360af77e7 --- /dev/null +++ b/quantum/debounce.h | |||
| @@ -0,0 +1,11 @@ | |||
| 1 | #pragma once | ||
| 2 | |||
| 3 | // raw is the current key state | ||
| 4 | // on entry cooked is the previous debounced state | ||
| 5 | // on exit cooked is the current debounced state | ||
| 6 | // changed is true if raw has changed since the last call | ||
| 7 | void debounce(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, bool changed); | ||
| 8 | |||
| 9 | bool debounce_active(void); | ||
| 10 | |||
| 11 | void debounce_init(uint8_t num_rows); \ No newline at end of file | ||
diff --git a/quantum/keymap_common.c b/quantum/keymap_common.c index f6c8b70d2..1a6af9e08 100644 --- a/quantum/keymap_common.c +++ b/quantum/keymap_common.c | |||
| @@ -120,7 +120,7 @@ action_t action_for_key(uint8_t layer, keypos_t key) | |||
| 120 | break; | 120 | break; |
| 121 | case QK_ONE_SHOT_MOD ... QK_ONE_SHOT_MOD_MAX: ; | 121 | case QK_ONE_SHOT_MOD ... QK_ONE_SHOT_MOD_MAX: ; |
| 122 | // OSM(mod) - One-shot mod | 122 | // OSM(mod) - One-shot mod |
| 123 | mod = keycode & 0xFF; | 123 | mod = mod_config(keycode & 0xFF); |
| 124 | action.code = ACTION_MODS_ONESHOT(mod); | 124 | action.code = ACTION_MODS_ONESHOT(mod); |
| 125 | break; | 125 | break; |
| 126 | case QK_LAYER_TAP_TOGGLE ... QK_LAYER_TAP_TOGGLE_MAX: | 126 | case QK_LAYER_TAP_TOGGLE ... QK_LAYER_TAP_TOGGLE_MAX: |
diff --git a/quantum/matrix.c b/quantum/matrix.c index 292171490..71292db51 100644 --- a/quantum/matrix.c +++ b/quantum/matrix.c | |||
| @@ -21,10 +21,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 21 | #include "debug.h" | 21 | #include "debug.h" |
| 22 | #include "util.h" | 22 | #include "util.h" |
| 23 | #include "matrix.h" | 23 | #include "matrix.h" |
| 24 | #include "timer.h" | 24 | #include "debounce.h" |
| 25 | #include "quantum.h" | 25 | #include "quantum.h" |
| 26 | 26 | ||
| 27 | |||
| 28 | #if (MATRIX_COLS <= 8) | 27 | #if (MATRIX_COLS <= 8) |
| 29 | # define print_matrix_header() print("\nr/c 01234567\n") | 28 | # define print_matrix_header() print("\nr/c 01234567\n") |
| 30 | # define print_matrix_row(row) print_bin_reverse8(matrix_get_row(row)) | 29 | # define print_matrix_row(row) print_bin_reverse8(matrix_get_row(row)) |
| @@ -52,8 +51,9 @@ static const pin_t col_pins[MATRIX_COLS] = MATRIX_COL_PINS; | |||
| 52 | #endif | 51 | #endif |
| 53 | 52 | ||
| 54 | /* matrix state(1:on, 0:off) */ | 53 | /* matrix state(1:on, 0:off) */ |
| 55 | static matrix_row_t matrix[MATRIX_ROWS]; | 54 | static matrix_row_t raw_matrix[MATRIX_ROWS]; |
| 56 | 55 | ||
| 56 | static matrix_row_t matrix[MATRIX_ROWS]; | ||
| 57 | 57 | ||
| 58 | #if (DIODE_DIRECTION == COL2ROW) | 58 | #if (DIODE_DIRECTION == COL2ROW) |
| 59 | static void init_cols(void); | 59 | static void init_cols(void); |
| @@ -120,34 +120,40 @@ void matrix_init(void) { | |||
| 120 | 120 | ||
| 121 | // initialize matrix state: all keys off | 121 | // initialize matrix state: all keys off |
| 122 | for (uint8_t i=0; i < MATRIX_ROWS; i++) { | 122 | for (uint8_t i=0; i < MATRIX_ROWS; i++) { |
| 123 | raw_matrix[i] = 0; | ||
| 123 | matrix[i] = 0; | 124 | matrix[i] = 0; |
| 124 | } | 125 | } |
| 126 | debounce_init(MATRIX_ROWS); | ||
| 125 | 127 | ||
| 126 | matrix_init_quantum(); | 128 | matrix_init_quantum(); |
| 127 | } | 129 | } |
| 128 | 130 | ||
| 129 | uint8_t matrix_scan(void) | 131 | uint8_t matrix_scan(void) |
| 130 | { | 132 | { |
| 133 | bool changed = false; | ||
| 131 | 134 | ||
| 132 | #if (DIODE_DIRECTION == COL2ROW) | 135 | #if (DIODE_DIRECTION == COL2ROW) |
| 133 | // Set row, read cols | 136 | // Set row, read cols |
| 134 | for (uint8_t current_row = 0; current_row < MATRIX_ROWS; current_row++) { | 137 | for (uint8_t current_row = 0; current_row < MATRIX_ROWS; current_row++) { |
| 135 | read_cols_on_row(matrix, current_row); | 138 | changed |= read_cols_on_row(raw_matrix, current_row); |
| 136 | } | 139 | } |
| 137 | #elif (DIODE_DIRECTION == ROW2COL) | 140 | #elif (DIODE_DIRECTION == ROW2COL) |
| 138 | // Set col, read rows | 141 | // Set col, read rows |
| 139 | for (uint8_t current_col = 0; current_col < MATRIX_COLS; current_col++) { | 142 | for (uint8_t current_col = 0; current_col < MATRIX_COLS; current_col++) { |
| 140 | read_rows_on_col(matrix, current_col); | 143 | changed |= read_rows_on_col(raw_matrix, current_col); |
| 141 | } | 144 | } |
| 142 | #endif | 145 | #endif |
| 143 | 146 | ||
| 144 | matrix_scan_quantum(); | 147 | debounce(raw_matrix, matrix, MATRIX_ROWS, changed); |
| 145 | return 1; | 148 | |
| 149 | matrix_scan_quantum(); | ||
| 150 | return 1; | ||
| 146 | } | 151 | } |
| 147 | 152 | ||
| 148 | //Deprecated. | 153 | //Deprecated. |
| 149 | bool matrix_is_modified(void) | 154 | bool matrix_is_modified(void) |
| 150 | { | 155 | { |
| 156 | if (debounce_active()) return false; | ||
| 151 | return true; | 157 | return true; |
| 152 | } | 158 | } |
| 153 | 159 | ||
diff --git a/quantum/mcu_selection.mk b/quantum/mcu_selection.mk new file mode 100644 index 000000000..209b578ea --- /dev/null +++ b/quantum/mcu_selection.mk | |||
| @@ -0,0 +1,70 @@ | |||
| 1 | |||
| 2 | ifneq ($(findstring STM32F303, $(MCU)),) | ||
| 3 | ## chip/board settings | ||
| 4 | # - the next two should match the directories in | ||
| 5 | # <chibios>/os/hal/ports/$(MCU_FAMILY)/$(MCU_SERIES) | ||
| 6 | MCU_FAMILY ?= STM32 | ||
| 7 | MCU_SERIES ?= STM32F3xx | ||
| 8 | |||
| 9 | # Linker script to use | ||
| 10 | # - it should exist either in <chibios>/os/common/ports/ARMCMx/compilers/GCC/ld/ | ||
| 11 | # or <this_dir>/ld/ | ||
| 12 | MCU_LDSCRIPT ?= STM32F303xC | ||
| 13 | |||
| 14 | # Startup code to use | ||
| 15 | # - it should exist in <chibios>/os/common/startup/ARMCMx/compilers/GCC/mk/ | ||
| 16 | MCU_STARTUP ?= stm32f3xx | ||
| 17 | |||
| 18 | # Board: it should exist either in <chibios>/os/hal/boards/ | ||
| 19 | # or <this_dir>/boards | ||
| 20 | BOARD ?= GENERIC_STM32_F303XC | ||
| 21 | |||
| 22 | # Cortex version | ||
| 23 | MCU = cortex-m4 | ||
| 24 | |||
| 25 | # ARM version, CORTEX-M0/M1 are 6, CORTEX-M3/M4/M7 are 7 | ||
| 26 | ARMV ?= 7 | ||
| 27 | |||
| 28 | USE_FPU = yes | ||
| 29 | |||
| 30 | # Vector table for application | ||
| 31 | # 0x00000000-0x00001000 area is occupied by bootlaoder.*/ | ||
| 32 | # The CORTEX_VTOR... is needed only for MCHCK/Infinity KB | ||
| 33 | # OPT_DEFS = -DCORTEX_VTOR_INIT=0x08005000 | ||
| 34 | |||
| 35 | # Options to pass to dfu-util when flashing | ||
| 36 | DFU_ARGS ?= -d 0483:df11 -a 0 -s 0x08000000:leave | ||
| 37 | endif | ||
| 38 | |||
| 39 | ifneq (,$(filter $(MCU),atmega32u4 at90usb1286)) | ||
| 40 | # Processor frequency. | ||
| 41 | # This will define a symbol, F_CPU, in all source code files equal to the | ||
| 42 | # processor frequency in Hz. You can then use this symbol in your source code to | ||
| 43 | # calculate timings. Do NOT tack on a 'UL' at the end, this will be done | ||
| 44 | # automatically to create a 32-bit value in your source code. | ||
| 45 | # | ||
| 46 | # This will be an integer division of F_USB below, as it is sourced by | ||
| 47 | # F_USB after it has run through any CPU prescalers. Note that this value | ||
| 48 | # does not *change* the processor frequency - it should merely be updated to | ||
| 49 | # reflect the processor speed set externally so that the code can use accurate | ||
| 50 | # software delays. | ||
| 51 | F_CPU ?= 16000000 | ||
| 52 | |||
| 53 | # LUFA specific | ||
| 54 | # | ||
| 55 | # Target architecture (see library "Board Types" documentation). | ||
| 56 | ARCH ?= AVR8 | ||
| 57 | |||
| 58 | # Input clock frequency. | ||
| 59 | # This will define a symbol, F_USB, in all source code files equal to the | ||
| 60 | # input clock frequency (before any prescaling is performed) in Hz. This value may | ||
| 61 | # differ from F_CPU if prescaling is used on the latter, and is required as the | ||
| 62 | # raw input clock is fed directly to the PLL sections of the AVR for high speed | ||
| 63 | # clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL' | ||
| 64 | # at the end, this will be done automatically to create a 32-bit value in your | ||
| 65 | # source code. | ||
| 66 | # | ||
| 67 | # If no clock division is performed on the input clock inside the AVR (via the | ||
| 68 | # CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU. | ||
| 69 | F_USB ?= $(F_CPU) | ||
| 70 | endif | ||
diff --git a/quantum/process_keycode/process_combo.c b/quantum/process_keycode/process_combo.c index 6e9c28e4f..13f8bbb33 100644 --- a/quantum/process_keycode/process_combo.c +++ b/quantum/process_keycode/process_combo.c | |||
| @@ -18,9 +18,6 @@ | |||
| 18 | #include "print.h" | 18 | #include "print.h" |
| 19 | 19 | ||
| 20 | 20 | ||
| 21 | #define COMBO_TIMER_ELAPSED -1 | ||
| 22 | |||
| 23 | |||
| 24 | __attribute__ ((weak)) | 21 | __attribute__ ((weak)) |
| 25 | combo_t key_combos[COMBO_COUNT] = { | 22 | combo_t key_combos[COMBO_COUNT] = { |
| 26 | 23 | ||
| @@ -65,7 +62,7 @@ static bool process_single_combo(combo_t *combo, uint16_t keycode, keyrecord_t * | |||
| 65 | if (-1 == (int8_t)index) return false; | 62 | if (-1 == (int8_t)index) return false; |
| 66 | 63 | ||
| 67 | /* The combos timer is used to signal whether the combo is active */ | 64 | /* The combos timer is used to signal whether the combo is active */ |
| 68 | bool is_combo_active = COMBO_TIMER_ELAPSED == combo->timer ? false : true; | 65 | bool is_combo_active = combo->is_active; |
| 69 | 66 | ||
| 70 | if (record->event.pressed) { | 67 | if (record->event.pressed) { |
| 71 | KEY_STATE_DOWN(index); | 68 | KEY_STATE_DOWN(index); |
| @@ -73,9 +70,10 @@ static bool process_single_combo(combo_t *combo, uint16_t keycode, keyrecord_t * | |||
| 73 | if (is_combo_active) { | 70 | if (is_combo_active) { |
| 74 | if (ALL_COMBO_KEYS_ARE_DOWN) { /* Combo was pressed */ | 71 | if (ALL_COMBO_KEYS_ARE_DOWN) { /* Combo was pressed */ |
| 75 | send_combo(combo->keycode, true); | 72 | send_combo(combo->keycode, true); |
| 76 | combo->timer = COMBO_TIMER_ELAPSED; | 73 | combo->is_active = false; |
| 77 | } else { /* Combo key was pressed */ | 74 | } else { /* Combo key was pressed */ |
| 78 | combo->timer = timer_read(); | 75 | combo->timer = timer_read(); |
| 76 | combo->is_active = true; | ||
| 79 | #ifdef COMBO_ALLOW_ACTION_KEYS | 77 | #ifdef COMBO_ALLOW_ACTION_KEYS |
| 80 | combo->prev_record = *record; | 78 | combo->prev_record = *record; |
| 81 | #else | 79 | #else |
| @@ -99,6 +97,7 @@ static bool process_single_combo(combo_t *combo, uint16_t keycode, keyrecord_t * | |||
| 99 | send_keyboard_report(); | 97 | send_keyboard_report(); |
| 100 | unregister_code16(keycode); | 98 | unregister_code16(keycode); |
| 101 | #endif | 99 | #endif |
| 100 | combo->is_active = false; | ||
| 102 | combo->timer = 0; | 101 | combo->timer = 0; |
| 103 | } | 102 | } |
| 104 | 103 | ||
| @@ -106,6 +105,7 @@ static bool process_single_combo(combo_t *combo, uint16_t keycode, keyrecord_t * | |||
| 106 | } | 105 | } |
| 107 | 106 | ||
| 108 | if (NO_COMBO_KEYS_ARE_DOWN) { | 107 | if (NO_COMBO_KEYS_ARE_DOWN) { |
| 108 | combo->is_active = true; | ||
| 109 | combo->timer = 0; | 109 | combo->timer = 0; |
| 110 | } | 110 | } |
| 111 | 111 | ||
| @@ -132,14 +132,14 @@ void matrix_scan_combo(void) | |||
| 132 | #pragma GCC diagnostic ignored "-Warray-bounds" | 132 | #pragma GCC diagnostic ignored "-Warray-bounds" |
| 133 | combo_t *combo = &key_combos[i]; | 133 | combo_t *combo = &key_combos[i]; |
| 134 | #pragma GCC diagnostic pop | 134 | #pragma GCC diagnostic pop |
| 135 | if (combo->timer && | 135 | if (combo->is_active && |
| 136 | combo->timer != COMBO_TIMER_ELAPSED && | 136 | combo->timer && |
| 137 | timer_elapsed(combo->timer) > COMBO_TERM) { | 137 | timer_elapsed(combo->timer) > COMBO_TERM) { |
| 138 | 138 | ||
| 139 | /* This disables the combo, meaning key events for this | 139 | /* This disables the combo, meaning key events for this |
| 140 | * combo will be handled by the next processors in the chain | 140 | * combo will be handled by the next processors in the chain |
| 141 | */ | 141 | */ |
| 142 | combo->timer = COMBO_TIMER_ELAPSED; | 142 | combo->is_active = false; |
| 143 | 143 | ||
| 144 | #ifdef COMBO_ALLOW_ACTION_KEYS | 144 | #ifdef COMBO_ALLOW_ACTION_KEYS |
| 145 | process_action(&combo->prev_record, | 145 | process_action(&combo->prev_record, |
diff --git a/quantum/process_keycode/process_combo.h b/quantum/process_keycode/process_combo.h index a5dbd788a..a5787c9ed 100644 --- a/quantum/process_keycode/process_combo.h +++ b/quantum/process_keycode/process_combo.h | |||
| @@ -33,6 +33,7 @@ typedef struct | |||
| 33 | uint8_t state; | 33 | uint8_t state; |
| 34 | #endif | 34 | #endif |
| 35 | uint16_t timer; | 35 | uint16_t timer; |
| 36 | bool is_active; | ||
| 36 | #ifdef COMBO_ALLOW_ACTION_KEYS | 37 | #ifdef COMBO_ALLOW_ACTION_KEYS |
| 37 | keyrecord_t prev_record; | 38 | keyrecord_t prev_record; |
| 38 | #else | 39 | #else |
diff --git a/quantum/process_keycode/process_terminal.c b/quantum/process_keycode/process_terminal.c index 6998639f2..e791deffc 100644 --- a/quantum/process_keycode/process_terminal.c +++ b/quantum/process_keycode/process_terminal.c | |||
| @@ -273,11 +273,17 @@ bool process_terminal(uint16_t keycode, keyrecord_t *record) { | |||
| 273 | disable_terminal(); | 273 | disable_terminal(); |
| 274 | return false; | 274 | return false; |
| 275 | } | 275 | } |
| 276 | |||
| 277 | if ((keycode >= QK_MOD_TAP && keycode <= QK_MOD_TAP_MAX) || (keycode >= QK_LAYER_TAP && keycode <= QK_LAYER_TAP_MAX)) { | ||
| 278 | keycode = keycode & 0xFF; | ||
| 279 | } | ||
| 280 | |||
| 276 | if (keycode < 256) { | 281 | if (keycode < 256) { |
| 277 | uint8_t str_len; | 282 | uint8_t str_len; |
| 278 | char char_to_add; | 283 | char char_to_add; |
| 279 | switch (keycode) { | 284 | switch (keycode) { |
| 280 | case KC_ENTER: | 285 | case KC_ENTER: |
| 286 | case KC_KP_ENTER: | ||
| 281 | push_to_cmd_buffer(); | 287 | push_to_cmd_buffer(); |
| 282 | current_cmd_buffer_pos = 0; | 288 | current_cmd_buffer_pos = 0; |
| 283 | process_terminal_command(); | 289 | process_terminal_command(); |
diff --git a/quantum/process_keycode/process_unicode_common.c b/quantum/process_keycode/process_unicode_common.c index 3286f45b5..b64feb700 100644 --- a/quantum/process_keycode/process_unicode_common.c +++ b/quantum/process_keycode/process_unicode_common.c | |||
| @@ -216,7 +216,7 @@ bool process_unicode_common(uint16_t keycode, keyrecord_t *record) { | |||
| 216 | #if defined(UNICODE_ENABLE) | 216 | #if defined(UNICODE_ENABLE) |
| 217 | return process_unicode(keycode, record); | 217 | return process_unicode(keycode, record); |
| 218 | #elif defined(UNICODEMAP_ENABLE) | 218 | #elif defined(UNICODEMAP_ENABLE) |
| 219 | return process_unicode_map(keycode, record); | 219 | return process_unicodemap(keycode, record); |
| 220 | #elif defined(UCIS_ENABLE) | 220 | #elif defined(UCIS_ENABLE) |
| 221 | return process_ucis(keycode, record); | 221 | return process_ucis(keycode, record); |
| 222 | #else | 222 | #else |
diff --git a/quantum/process_keycode/process_unicodemap.c b/quantum/process_keycode/process_unicodemap.c index 75f35112b..cee9acb5f 100644 --- a/quantum/process_keycode/process_unicodemap.c +++ b/quantum/process_keycode/process_unicodemap.c | |||
| @@ -18,8 +18,7 @@ | |||
| 18 | #include "process_unicode_common.h" | 18 | #include "process_unicode_common.h" |
| 19 | 19 | ||
| 20 | __attribute__((weak)) | 20 | __attribute__((weak)) |
| 21 | const uint32_t PROGMEM unicode_map[] = { | 21 | const uint32_t PROGMEM unicode_map[] = {}; |
| 22 | }; | ||
| 23 | 22 | ||
| 24 | void register_hex32(uint32_t hex) { | 23 | void register_hex32(uint32_t hex) { |
| 25 | bool onzerostart = true; | 24 | bool onzerostart = true; |
| @@ -42,26 +41,26 @@ void register_hex32(uint32_t hex) { | |||
| 42 | } | 41 | } |
| 43 | 42 | ||
| 44 | __attribute__((weak)) | 43 | __attribute__((weak)) |
| 45 | void unicode_map_input_error() {} | 44 | void unicodemap_input_error() {} |
| 46 | 45 | ||
| 47 | bool process_unicode_map(uint16_t keycode, keyrecord_t *record) { | 46 | bool process_unicodemap(uint16_t keycode, keyrecord_t *record) { |
| 48 | uint8_t input_mode = get_unicode_input_mode(); | 47 | if ((keycode & QK_UNICODEMAP) == QK_UNICODEMAP && record->event.pressed) { |
| 49 | if ((keycode & QK_UNICODE_MAP) == QK_UNICODE_MAP && record->event.pressed) { | 48 | uint16_t index = keycode - QK_UNICODEMAP; |
| 50 | const uint32_t* map = unicode_map; | 49 | uint32_t code = pgm_read_dword(unicode_map + index); |
| 51 | uint16_t index = keycode - QK_UNICODE_MAP; | 50 | uint8_t input_mode = get_unicode_input_mode(); |
| 52 | uint32_t code = pgm_read_dword(&map[index]); | 51 | |
| 53 | if (code > 0xFFFF && code <= 0x10ffff && input_mode == UC_OSX) { | 52 | if (code > 0xFFFF && code <= 0x10FFFF && input_mode == UC_OSX) { |
| 54 | // Convert to UTF-16 surrogate pair | 53 | // Convert to UTF-16 surrogate pair |
| 55 | code -= 0x10000; | 54 | code -= 0x10000; |
| 56 | uint32_t lo = code & 0x3ff; | 55 | uint32_t lo = code & 0x3FF, hi = (code & 0xFFC00) >> 10; |
| 57 | uint32_t hi = (code & 0xffc00) >> 10; | 56 | |
| 58 | unicode_input_start(); | 57 | unicode_input_start(); |
| 59 | register_hex32(hi + 0xd800); | 58 | register_hex32(hi + 0xD800); |
| 60 | register_hex32(lo + 0xdc00); | 59 | register_hex32(lo + 0xDC00); |
| 61 | unicode_input_finish(); | 60 | unicode_input_finish(); |
| 62 | } else if ((code > 0x10ffff && input_mode == UC_OSX) || (code > 0xFFFFF && input_mode == UC_LNX)) { | 61 | } else if ((code > 0x10FFFF && input_mode == UC_OSX) || (code > 0xFFFFF && input_mode == UC_LNX)) { |
| 63 | // when character is out of range supported by the OS | 62 | // Character is out of range supported by the OS |
| 64 | unicode_map_input_error(); | 63 | unicodemap_input_error(); |
| 65 | } else { | 64 | } else { |
| 66 | unicode_input_start(); | 65 | unicode_input_start(); |
| 67 | register_hex32(code); | 66 | register_hex32(code); |
diff --git a/quantum/process_keycode/process_unicodemap.h b/quantum/process_keycode/process_unicodemap.h index f6d64bb86..5764697f8 100644 --- a/quantum/process_keycode/process_unicodemap.h +++ b/quantum/process_keycode/process_unicodemap.h | |||
| @@ -19,5 +19,5 @@ | |||
| 19 | #include "quantum.h" | 19 | #include "quantum.h" |
| 20 | #include "process_unicode_common.h" | 20 | #include "process_unicode_common.h" |
| 21 | 21 | ||
| 22 | void unicode_map_input_error(void); | 22 | void unicodemap_input_error(void); |
| 23 | bool process_unicode_map(uint16_t keycode, keyrecord_t *record); | 23 | bool process_unicodemap(uint16_t keycode, keyrecord_t *record); |
diff --git a/quantum/quantum.c b/quantum/quantum.c index 85db100ab..5d8ffe34e 100644 --- a/quantum/quantum.c +++ b/quantum/quantum.c | |||
| @@ -15,6 +15,11 @@ | |||
| 15 | */ | 15 | */ |
| 16 | 16 | ||
| 17 | #include "quantum.h" | 17 | #include "quantum.h" |
| 18 | |||
| 19 | #if !defined(RGBLIGHT_ENABLE) && !defined(RGB_MATRIX_ENABLE) | ||
| 20 | #include "rgb.h" | ||
| 21 | #endif | ||
| 22 | |||
| 18 | #ifdef PROTOCOL_LUFA | 23 | #ifdef PROTOCOL_LUFA |
| 19 | #include "outputselect.h" | 24 | #include "outputselect.h" |
| 20 | #endif | 25 | #endif |
diff --git a/quantum/quantum.h b/quantum/quantum.h index f78915fdf..56a6a1a99 100644 --- a/quantum/quantum.h +++ b/quantum/quantum.h | |||
| @@ -30,9 +30,6 @@ | |||
| 30 | #ifdef BACKLIGHT_ENABLE | 30 | #ifdef BACKLIGHT_ENABLE |
| 31 | #include "backlight.h" | 31 | #include "backlight.h" |
| 32 | #endif | 32 | #endif |
| 33 | #if !defined(RGBLIGHT_ENABLE) && !defined(RGB_MATRIX_ENABLE) | ||
| 34 | #include "rgb.h" | ||
| 35 | #endif | ||
| 36 | #ifdef RGBLIGHT_ENABLE | 33 | #ifdef RGBLIGHT_ENABLE |
| 37 | #include "rgblight.h" | 34 | #include "rgblight.h" |
| 38 | #else | 35 | #else |
diff --git a/quantum/quantum_keycodes.h b/quantum/quantum_keycodes.h index 2b309f4d5..0462291c2 100644 --- a/quantum/quantum_keycodes.h +++ b/quantum/quantum_keycodes.h | |||
| @@ -86,8 +86,8 @@ enum quantum_keycodes { | |||
| 86 | QK_UNICODE_MAX = 0xFFFF, | 86 | QK_UNICODE_MAX = 0xFFFF, |
| 87 | #endif | 87 | #endif |
| 88 | #ifdef UNICODEMAP_ENABLE | 88 | #ifdef UNICODEMAP_ENABLE |
| 89 | QK_UNICODE_MAP = 0x8000, | 89 | QK_UNICODEMAP = 0x8000, |
| 90 | QK_UNICODE_MAP_MAX = 0x83FF, | 90 | QK_UNICODEMAP_MAX = 0x83FF, |
| 91 | #endif | 91 | #endif |
| 92 | 92 | ||
| 93 | // Loose keycodes - to be used directly | 93 | // Loose keycodes - to be used directly |
| @@ -489,9 +489,8 @@ enum quantum_keycodes { | |||
| 489 | #define SWIN(kc) SGUI(kc) | 489 | #define SWIN(kc) SGUI(kc) |
| 490 | #define LCA(kc) (QK_LCTL | QK_LALT | (kc)) | 490 | #define LCA(kc) (QK_LCTL | QK_LALT | (kc)) |
| 491 | 491 | ||
| 492 | #define MOD_HYPR 0xf | 492 | #define MOD_HYPR 0xF |
| 493 | #define MOD_MEH 0x7 | 493 | #define MOD_MEH 0x7 |
| 494 | |||
| 495 | 494 | ||
| 496 | // Aliases for shifted symbols | 495 | // Aliases for shifted symbols |
| 497 | // Each key has a 4-letter code, and some have longer aliases too. | 496 | // Each key has a 4-letter code, and some have longer aliases too. |
| @@ -568,9 +567,12 @@ enum quantum_keycodes { | |||
| 568 | #define FUNC(kc) (QK_FUNCTION | (kc)) | 567 | #define FUNC(kc) (QK_FUNCTION | (kc)) |
| 569 | 568 | ||
| 570 | // Aliases | 569 | // Aliases |
| 570 | #define C(kc) LCTL(kc) | ||
| 571 | #define S(kc) LSFT(kc) | 571 | #define S(kc) LSFT(kc) |
| 572 | #define F(kc) FUNC(kc) | 572 | #define A(kc) LALT(kc) |
| 573 | #define G(kc) LGUI(kc) | ||
| 573 | 574 | ||
| 575 | #define F(kc) FUNC(kc) | ||
| 574 | #define M(kc) (QK_MACRO | (kc)) | 576 | #define M(kc) (QK_MACRO | (kc)) |
| 575 | 577 | ||
| 576 | #define MACROTAP(kc) (QK_MACRO | (FUNC_TAP << 8) | (kc)) | 578 | #define MACROTAP(kc) (QK_MACRO | (FUNC_TAP << 8) | (kc)) |
| @@ -601,7 +603,7 @@ enum quantum_keycodes { | |||
| 601 | #define RGB_M_T RGB_MODE_RGBTEST | 603 | #define RGB_M_T RGB_MODE_RGBTEST |
| 602 | 604 | ||
| 603 | // L-ayer, T-ap - 256 keycode max, 16 layer max | 605 | // L-ayer, T-ap - 256 keycode max, 16 layer max |
| 604 | #define LT(layer, kc) (QK_LAYER_TAP | ((layer & 0xF) << 8) | ((kc) & 0xFF)) | 606 | #define LT(layer, kc) (QK_LAYER_TAP | (((layer) & 0xF) << 8) | ((kc) & 0xFF)) |
| 605 | 607 | ||
| 606 | #define AG_SWAP MAGIC_SWAP_ALT_GUI | 608 | #define AG_SWAP MAGIC_SWAP_ALT_GUI |
| 607 | #define AG_NORM MAGIC_UNSWAP_ALT_GUI | 609 | #define AG_NORM MAGIC_UNSWAP_ALT_GUI |
| @@ -615,79 +617,77 @@ enum quantum_keycodes { | |||
| 615 | // In fact, we changed it to assume ON_PRESS for sanity/simplicity. If needed, you can add your own | 617 | // In fact, we changed it to assume ON_PRESS for sanity/simplicity. If needed, you can add your own |
| 616 | // keycode modeled after the old version, kept below for this. | 618 | // keycode modeled after the old version, kept below for this. |
| 617 | /* #define TO(layer, when) (QK_TO | (when << 0x4) | (layer & 0xFF)) */ | 619 | /* #define TO(layer, when) (QK_TO | (when << 0x4) | (layer & 0xFF)) */ |
| 618 | #define TO(layer) (QK_TO | (ON_PRESS << 0x4) | (layer & 0xFF)) | 620 | #define TO(layer) (QK_TO | (ON_PRESS << 0x4) | ((layer) & 0xFF)) |
| 619 | 621 | ||
| 620 | // Momentary switch layer - 256 layer max | 622 | // Momentary switch layer - 256 layer max |
| 621 | #define MO(layer) (QK_MOMENTARY | (layer & 0xFF)) | 623 | #define MO(layer) (QK_MOMENTARY | ((layer) & 0xFF)) |
| 622 | 624 | ||
| 623 | // Set default layer - 256 layer max | 625 | // Set default layer - 256 layer max |
| 624 | #define DF(layer) (QK_DEF_LAYER | (layer & 0xFF)) | 626 | #define DF(layer) (QK_DEF_LAYER | ((layer) & 0xFF)) |
| 625 | 627 | ||
| 626 | // Toggle to layer - 256 layer max | 628 | // Toggle to layer - 256 layer max |
| 627 | #define TG(layer) (QK_TOGGLE_LAYER | (layer & 0xFF)) | 629 | #define TG(layer) (QK_TOGGLE_LAYER | ((layer) & 0xFF)) |
| 628 | 630 | ||
| 629 | // One-shot layer - 256 layer max | 631 | // One-shot layer - 256 layer max |
| 630 | #define OSL(layer) (QK_ONE_SHOT_LAYER | (layer & 0xFF)) | 632 | #define OSL(layer) (QK_ONE_SHOT_LAYER | ((layer) & 0xFF)) |
| 631 | 633 | ||
| 632 | // L-ayer M-od: Momentary switch layer with modifiers active - 16 layer max, left mods only | 634 | // L-ayer M-od: Momentary switch layer with modifiers active - 16 layer max, left mods only |
| 633 | #define LM(layer, mod) (QK_LAYER_MOD | ((layer & 0xF) << 4) | ((mod) & 0xF)) | 635 | #define LM(layer, mod) (QK_LAYER_MOD | (((layer) & 0xF) << 4) | ((mod) & 0xF)) |
| 634 | 636 | ||
| 635 | // One-shot mod | 637 | // One-shot mod |
| 636 | #define OSM(mod) (QK_ONE_SHOT_MOD | ((mod) & 0xFF)) | 638 | #define OSM(mod) (QK_ONE_SHOT_MOD | ((mod) & 0xFF)) |
| 637 | 639 | ||
| 638 | // Layer tap-toggle | 640 | // Layer tap-toggle |
| 639 | #define TT(layer) (QK_LAYER_TAP_TOGGLE | (layer & 0xFF)) | 641 | #define TT(layer) (QK_LAYER_TAP_TOGGLE | ((layer) & 0xFF)) |
| 640 | 642 | ||
| 641 | // M-od, T-ap - 256 keycode max | 643 | // M-od, T-ap - 256 keycode max |
| 642 | #define MT(mod, kc) (QK_MOD_TAP | (((mod) & 0x1F) << 8) | ((kc) & 0xFF)) | 644 | #define MT(mod, kc) (QK_MOD_TAP | (((mod) & 0x1F) << 8) | ((kc) & 0xFF)) |
| 643 | 645 | ||
| 644 | #define CTL_T(kc) MT(MOD_LCTL, kc) | ||
| 645 | #define LCTL_T(kc) MT(MOD_LCTL, kc) | 646 | #define LCTL_T(kc) MT(MOD_LCTL, kc) |
| 646 | #define RCTL_T(kc) MT(MOD_RCTL, kc) | 647 | #define RCTL_T(kc) MT(MOD_RCTL, kc) |
| 648 | #define CTL_T(kc) LCTL_T(kc) | ||
| 647 | 649 | ||
| 648 | #define SFT_T(kc) MT(MOD_LSFT, kc) | ||
| 649 | #define LSFT_T(kc) MT(MOD_LSFT, kc) | 650 | #define LSFT_T(kc) MT(MOD_LSFT, kc) |
| 650 | #define RSFT_T(kc) MT(MOD_RSFT, kc) | 651 | #define RSFT_T(kc) MT(MOD_RSFT, kc) |
| 652 | #define SFT_T(kc) LSFT_T(kc) | ||
| 651 | 653 | ||
| 652 | #define ALT_T(kc) MT(MOD_LALT, kc) | ||
| 653 | #define LALT_T(kc) MT(MOD_LALT, kc) | 654 | #define LALT_T(kc) MT(MOD_LALT, kc) |
| 654 | #define RALT_T(kc) MT(MOD_RALT, kc) | 655 | #define RALT_T(kc) MT(MOD_RALT, kc) |
| 656 | #define ALT_T(kc) LALT_T(kc) | ||
| 655 | #define ALGR_T(kc) RALT_T(kc) | 657 | #define ALGR_T(kc) RALT_T(kc) |
| 656 | 658 | ||
| 657 | #define GUI_T(kc) MT(MOD_LGUI, kc) | ||
| 658 | #define CMD_T(kc) GUI_T(kc) | ||
| 659 | #define WIN_T(kc) GUI_T(kc) | ||
| 660 | #define LGUI_T(kc) MT(MOD_LGUI, kc) | 659 | #define LGUI_T(kc) MT(MOD_LGUI, kc) |
| 660 | #define RGUI_T(kc) MT(MOD_RGUI, kc) | ||
| 661 | #define LCMD_T(kc) LGUI_T(kc) | 661 | #define LCMD_T(kc) LGUI_T(kc) |
| 662 | #define LWIN_T(kc) LGUI_T(kc) | 662 | #define LWIN_T(kc) LGUI_T(kc) |
| 663 | #define RGUI_T(kc) MT(MOD_RGUI, kc) | ||
| 664 | #define RCMD_T(kc) RGUI_T(kc) | 663 | #define RCMD_T(kc) RGUI_T(kc) |
| 665 | #define RWIN_T(kc) RGUI_T(kc) | 664 | #define RWIN_T(kc) RGUI_T(kc) |
| 666 | 665 | #define GUI_T(kc) LGUI_T(kc) | |
| 667 | #define C_S_T(kc) MT(MOD_LCTL | MOD_LSFT, kc) // Control + Shift e.g. for gnome-terminal | 666 | #define CMD_T(kc) LCMD_T(kc) |
| 668 | #define MEH_T(kc) MT(MOD_LCTL | MOD_LSFT | MOD_LALT, kc) // Meh is a less hyper version of the Hyper key -- doesn't include Win or Cmd, so just alt+shift+ctrl | 667 | #define WIN_T(kc) LWIN_T(kc) |
| 669 | #define LCAG_T(kc) MT(MOD_LCTL | MOD_LALT | MOD_LGUI, kc) // Left control alt and gui | 668 | |
| 670 | #define RCAG_T(kc) MT(MOD_RCTL | MOD_RALT | MOD_RGUI, kc) // Right control alt and gui | 669 | #define C_S_T(kc) MT(MOD_LCTL | MOD_LSFT, kc) // Left Control + Shift e.g. for gnome-terminal |
| 671 | #define ALL_T(kc) MT(MOD_LCTL | MOD_LSFT | MOD_LALT | MOD_LGUI, kc) // see http://brettterpstra.com/2012/12/08/a-useful-caps-lock-key/ | 670 | #define MEH_T(kc) MT(MOD_LCTL | MOD_LSFT | MOD_LALT, kc) // Meh is a less hyper version of the Hyper key -- doesn't include GUI, so just Left Control + Shift + Alt |
| 672 | #define SGUI_T(kc) MT(MOD_LGUI | MOD_LSFT, kc) | 671 | #define LCAG_T(kc) MT(MOD_LCTL | MOD_LALT | MOD_LGUI, kc) // Left Control + Alt + GUI |
| 672 | #define RCAG_T(kc) MT(MOD_RCTL | MOD_RALT | MOD_RGUI, kc) // Right Control + Alt + GUI | ||
| 673 | #define HYPR_T(kc) MT(MOD_LCTL | MOD_LSFT | MOD_LALT | MOD_LGUI, kc) // see http://brettterpstra.com/2012/12/08/a-useful-caps-lock-key/ | ||
| 674 | #define SGUI_T(kc) MT(MOD_LGUI | MOD_LSFT, kc) // Left Shift + GUI | ||
| 673 | #define SCMD_T(kc) SGUI_T(kc) | 675 | #define SCMD_T(kc) SGUI_T(kc) |
| 674 | #define SWIN_T(kc) SGUI_T(kc) | 676 | #define SWIN_T(kc) SGUI_T(kc) |
| 675 | #define LCA_T(kc) MT(MOD_LCTL | MOD_LALT, kc) // Left control and left alt | 677 | #define LCA_T(kc) MT(MOD_LCTL | MOD_LALT, kc) // Left Control + Alt |
| 678 | #define ALL_T(kc) HYPR_T(kc) | ||
| 676 | 679 | ||
| 677 | // Dedicated keycode versions for Hyper and Meh, if you want to use them as standalone keys rather than mod-tap | 680 | // Dedicated keycode versions for Hyper and Meh, if you want to use them as standalone keys rather than mod-tap |
| 678 | #define KC_HYPR HYPR(KC_NO) | 681 | #define KC_HYPR HYPR(KC_NO) |
| 679 | #define KC_MEH MEH(KC_NO) | 682 | #define KC_MEH MEH(KC_NO) |
| 680 | 683 | ||
| 681 | #ifdef UNICODE_ENABLE | 684 | #ifdef UNICODE_ENABLE |
| 682 | // For sending unicode codes. | 685 | // Allows Unicode input up to 0x7FFF |
| 683 | // You may not send codes over 7FFF -- this supports most of UTF8. | 686 | #define UC(c) (QK_UNICODE | (c)) |
| 684 | // To have a key that sends out Å’, go UC(0x0152) | ||
| 685 | #define UNICODE(n) (QK_UNICODE | (n)) | ||
| 686 | #define UC(n) UNICODE(n) | ||
| 687 | #endif | 687 | #endif |
| 688 | |||
| 689 | #ifdef UNICODEMAP_ENABLE | 688 | #ifdef UNICODEMAP_ENABLE |
| 690 | #define X(n) (QK_UNICODE_MAP | (n)) | 689 | // Allows Unicode input up to 0x10FFFF, requires unicode_map |
| 690 | #define X(i) (QK_UNICODEMAP | (i)) | ||
| 691 | #endif | 691 | #endif |
| 692 | 692 | ||
| 693 | #define UC_MOD UNICODE_MODE_FORWARD | 693 | #define UC_MOD UNICODE_MODE_FORWARD |
diff --git a/quantum/split_common/i2c.h b/quantum/split_common/i2c.h index b3cbe8c82..91e8e96f4 100644 --- a/quantum/split_common/i2c.h +++ b/quantum/split_common/i2c.h | |||
| @@ -1,5 +1,4 @@ | |||
| 1 | #ifndef I2C_H | 1 | #pragma once |
| 2 | #define I2C_H | ||
| 3 | 2 | ||
| 4 | #include <stdint.h> | 3 | #include <stdint.h> |
| 5 | 4 | ||
| @@ -58,5 +57,3 @@ extern unsigned char i2c_readNak(void); | |||
| 58 | extern unsigned char i2c_read(unsigned char ack); | 57 | extern unsigned char i2c_read(unsigned char ack); |
| 59 | 58 | ||
| 60 | #define i2c_read(ack) (ack) ? i2c_readAck() : i2c_readNak(); | 59 | #define i2c_read(ack) (ack) ? i2c_readAck() : i2c_readNak(); |
| 61 | |||
| 62 | #endif | ||
diff --git a/quantum/split_common/matrix.c b/quantum/split_common/matrix.c index 2c37053f8..c3d2857ed 100644 --- a/quantum/split_common/matrix.c +++ b/quantum/split_common/matrix.c | |||
| @@ -25,529 +25,304 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 25 | #include "matrix.h" | 25 | #include "matrix.h" |
| 26 | #include "split_util.h" | 26 | #include "split_util.h" |
| 27 | #include "config.h" | 27 | #include "config.h" |
| 28 | #include "timer.h" | ||
| 29 | #include "split_flags.h" | 28 | #include "split_flags.h" |
| 30 | #include "quantum.h" | 29 | #include "quantum.h" |
| 31 | 30 | #include "debounce.h" | |
| 32 | #ifdef BACKLIGHT_ENABLE | 31 | #include "transport.h" |
| 33 | # include "backlight.h" | ||
| 34 | extern backlight_config_t backlight_config; | ||
| 35 | #endif | ||
| 36 | |||
| 37 | #if defined(USE_I2C) || defined(EH) | ||
| 38 | # include "i2c.h" | ||
| 39 | #else // USE_SERIAL | ||
| 40 | # include "serial.h" | ||
| 41 | #endif | ||
| 42 | |||
| 43 | #ifndef DEBOUNCING_DELAY | ||
| 44 | # define DEBOUNCING_DELAY 5 | ||
| 45 | #endif | ||
| 46 | |||
| 47 | #if (DEBOUNCING_DELAY > 0) | ||
| 48 | static uint16_t debouncing_time; | ||
| 49 | static bool debouncing = false; | ||
| 50 | #endif | ||
| 51 | |||
| 52 | #if defined(USE_I2C) || defined(EH) | ||
| 53 | |||
| 54 | #if (MATRIX_COLS <= 8) | ||
| 55 | # define print_matrix_header() print("\nr/c 01234567\n") | ||
| 56 | # define print_matrix_row(row) print_bin_reverse8(matrix_get_row(row)) | ||
| 57 | # define matrix_bitpop(i) bitpop(matrix[i]) | ||
| 58 | # define ROW_SHIFTER ((uint8_t)1) | ||
| 59 | #else | ||
| 60 | # error "Currently only supports 8 COLS" | ||
| 61 | #endif | ||
| 62 | |||
| 63 | #else // USE_SERIAL | ||
| 64 | 32 | ||
| 65 | #if (MATRIX_COLS <= 8) | 33 | #if (MATRIX_COLS <= 8) |
| 66 | # define print_matrix_header() print("\nr/c 01234567\n") | 34 | # define print_matrix_header() print("\nr/c 01234567\n") |
| 67 | # define print_matrix_row(row) print_bin_reverse8(matrix_get_row(row)) | 35 | # define print_matrix_row(row) print_bin_reverse8(matrix_get_row(row)) |
| 68 | # define matrix_bitpop(i) bitpop(matrix[i]) | 36 | # define matrix_bitpop(i) bitpop(matrix[i]) |
| 69 | # define ROW_SHIFTER ((uint8_t)1) | 37 | # define ROW_SHIFTER ((uint8_t)1) |
| 70 | #elif (MATRIX_COLS <= 16) | 38 | #elif (MATRIX_COLS <= 16) |
| 71 | # define print_matrix_header() print("\nr/c 0123456789ABCDEF\n") | 39 | # define print_matrix_header() print("\nr/c 0123456789ABCDEF\n") |
| 72 | # define print_matrix_row(row) print_bin_reverse16(matrix_get_row(row)) | 40 | # define print_matrix_row(row) print_bin_reverse16(matrix_get_row(row)) |
| 73 | # define matrix_bitpop(i) bitpop16(matrix[i]) | 41 | # define matrix_bitpop(i) bitpop16(matrix[i]) |
| 74 | # define ROW_SHIFTER ((uint16_t)1) | 42 | # define ROW_SHIFTER ((uint16_t)1) |
| 75 | #elif (MATRIX_COLS <= 32) | 43 | #elif (MATRIX_COLS <= 32) |
| 76 | # define print_matrix_header() print("\nr/c 0123456789ABCDEF0123456789ABCDEF\n") | 44 | # define print_matrix_header() print("\nr/c 0123456789ABCDEF0123456789ABCDEF\n") |
| 77 | # define print_matrix_row(row) print_bin_reverse32(matrix_get_row(row)) | 45 | # define print_matrix_row(row) print_bin_reverse32(matrix_get_row(row)) |
| 78 | # define matrix_bitpop(i) bitpop32(matrix[i]) | 46 | # define matrix_bitpop(i) bitpop32(matrix[i]) |
| 79 | # define ROW_SHIFTER ((uint32_t)1) | 47 | # define ROW_SHIFTER ((uint32_t)1) |
| 80 | #endif | ||
| 81 | |||
| 82 | #endif | 48 | #endif |
| 83 | static matrix_row_t matrix_debouncing[MATRIX_ROWS]; | ||
| 84 | 49 | ||
| 85 | #define ERROR_DISCONNECT_COUNT 5 | 50 | #define ERROR_DISCONNECT_COUNT 5 |
| 86 | 51 | ||
| 87 | #define ROWS_PER_HAND (MATRIX_ROWS/2) | 52 | #define ROWS_PER_HAND (MATRIX_ROWS / 2) |
| 88 | |||
| 89 | static uint8_t error_count = 0; | ||
| 90 | 53 | ||
| 54 | #ifdef DIRECT_PINS | ||
| 55 | static pin_t direct_pins[MATRIX_ROWS][MATRIX_COLS] = DIRECT_PINS; | ||
| 56 | #else | ||
| 91 | static pin_t row_pins[MATRIX_ROWS] = MATRIX_ROW_PINS; | 57 | static pin_t row_pins[MATRIX_ROWS] = MATRIX_ROW_PINS; |
| 92 | static pin_t col_pins[MATRIX_COLS] = MATRIX_COL_PINS; | 58 | static pin_t col_pins[MATRIX_COLS] = MATRIX_COL_PINS; |
| 59 | #endif | ||
| 93 | 60 | ||
| 94 | /* matrix state(1:on, 0:off) */ | 61 | /* matrix state(1:on, 0:off) */ |
| 95 | static matrix_row_t matrix[MATRIX_ROWS]; | 62 | static matrix_row_t matrix[MATRIX_ROWS]; |
| 96 | static matrix_row_t matrix_debouncing[MATRIX_ROWS]; | 63 | static matrix_row_t raw_matrix[ROWS_PER_HAND]; |
| 97 | |||
| 98 | #if (DIODE_DIRECTION == COL2ROW) | ||
| 99 | static void init_cols(void); | ||
| 100 | static bool read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row); | ||
| 101 | static void unselect_rows(void); | ||
| 102 | static void select_row(uint8_t row); | ||
| 103 | static void unselect_row(uint8_t row); | ||
| 104 | #elif (DIODE_DIRECTION == ROW2COL) | ||
| 105 | static void init_rows(void); | ||
| 106 | static bool read_rows_on_col(matrix_row_t current_matrix[], uint8_t current_col); | ||
| 107 | static void unselect_cols(void); | ||
| 108 | static void unselect_col(uint8_t col); | ||
| 109 | static void select_col(uint8_t col); | ||
| 110 | #endif | ||
| 111 | 64 | ||
| 112 | __attribute__ ((weak)) | 65 | // row offsets for each hand |
| 113 | void matrix_init_kb(void) { | 66 | uint8_t thisHand, thatHand; |
| 114 | matrix_init_user(); | ||
| 115 | } | ||
| 116 | 67 | ||
| 117 | __attribute__ ((weak)) | 68 | // user-defined overridable functions |
| 118 | void matrix_scan_kb(void) { | ||
| 119 | matrix_scan_user(); | ||
| 120 | } | ||
| 121 | 69 | ||
| 122 | __attribute__ ((weak)) | 70 | __attribute__((weak)) void matrix_init_kb(void) { matrix_init_user(); } |
| 123 | void matrix_init_user(void) { | ||
| 124 | } | ||
| 125 | 71 | ||
| 126 | __attribute__ ((weak)) | 72 | __attribute__((weak)) void matrix_scan_kb(void) { matrix_scan_user(); } |
| 127 | void matrix_scan_user(void) { | ||
| 128 | } | ||
| 129 | 73 | ||
| 130 | __attribute__ ((weak)) | 74 | __attribute__((weak)) void matrix_init_user(void) {} |
| 131 | void matrix_slave_scan_user(void) { | ||
| 132 | } | ||
| 133 | 75 | ||
| 134 | inline | 76 | __attribute__((weak)) void matrix_scan_user(void) {} |
| 135 | uint8_t matrix_rows(void) | ||
| 136 | { | ||
| 137 | return MATRIX_ROWS; | ||
| 138 | } | ||
| 139 | 77 | ||
| 140 | inline | 78 | __attribute__((weak)) void matrix_slave_scan_user(void) {} |
| 141 | uint8_t matrix_cols(void) | ||
| 142 | { | ||
| 143 | return MATRIX_COLS; | ||
| 144 | } | ||
| 145 | 79 | ||
| 146 | void matrix_init(void) | 80 | // helper functions |
| 147 | { | ||
| 148 | debug_enable = true; | ||
| 149 | debug_matrix = true; | ||
| 150 | debug_mouse = true; | ||
| 151 | 81 | ||
| 152 | // Set pinout for right half if pinout for that half is defined | 82 | inline uint8_t matrix_rows(void) { return MATRIX_ROWS; } |
| 153 | if (!isLeftHand) { | ||
| 154 | #ifdef MATRIX_ROW_PINS_RIGHT | ||
| 155 | const uint8_t row_pins_right[MATRIX_ROWS] = MATRIX_ROW_PINS_RIGHT; | ||
| 156 | for (uint8_t i = 0; i < MATRIX_ROWS; i++) | ||
| 157 | row_pins[i] = row_pins_right[i]; | ||
| 158 | #endif | ||
| 159 | #ifdef MATRIX_COL_PINS_RIGHT | ||
| 160 | const uint8_t col_pins_right[MATRIX_COLS] = MATRIX_COL_PINS_RIGHT; | ||
| 161 | for (uint8_t i = 0; i < MATRIX_COLS; i++) | ||
| 162 | col_pins[i] = col_pins_right[i]; | ||
| 163 | #endif | ||
| 164 | } | ||
| 165 | 83 | ||
| 166 | // initialize row and col | 84 | inline uint8_t matrix_cols(void) { return MATRIX_COLS; } |
| 167 | #if (DIODE_DIRECTION == COL2ROW) | ||
| 168 | unselect_rows(); | ||
| 169 | init_cols(); | ||
| 170 | #elif (DIODE_DIRECTION == ROW2COL) | ||
| 171 | unselect_cols(); | ||
| 172 | init_rows(); | ||
| 173 | #endif | ||
| 174 | 85 | ||
| 175 | // initialize matrix state: all keys off | 86 | bool matrix_is_modified(void) { |
| 176 | for (uint8_t i=0; i < MATRIX_ROWS; i++) { | 87 | if (debounce_active()) return false; |
| 177 | matrix[i] = 0; | 88 | return true; |
| 178 | matrix_debouncing[i] = 0; | ||
| 179 | } | ||
| 180 | |||
| 181 | matrix_init_quantum(); | ||
| 182 | |||
| 183 | } | 89 | } |
| 184 | 90 | ||
| 185 | uint8_t _matrix_scan(void) | 91 | inline bool matrix_is_on(uint8_t row, uint8_t col) { return (matrix[row] & ((matrix_row_t)1 << col)); } |
| 186 | { | ||
| 187 | int offset = isLeftHand ? 0 : (ROWS_PER_HAND); | ||
| 188 | #if (DIODE_DIRECTION == COL2ROW) | ||
| 189 | // Set row, read cols | ||
| 190 | for (uint8_t current_row = 0; current_row < ROWS_PER_HAND; current_row++) { | ||
| 191 | # if (DEBOUNCING_DELAY > 0) | ||
| 192 | bool matrix_changed = read_cols_on_row(matrix_debouncing+offset, current_row); | ||
| 193 | |||
| 194 | if (matrix_changed) { | ||
| 195 | debouncing = true; | ||
| 196 | debouncing_time = timer_read(); | ||
| 197 | } | ||
| 198 | |||
| 199 | # else | ||
| 200 | read_cols_on_row(matrix+offset, current_row); | ||
| 201 | # endif | ||
| 202 | |||
| 203 | } | ||
| 204 | 92 | ||
| 205 | #elif (DIODE_DIRECTION == ROW2COL) | 93 | inline matrix_row_t matrix_get_row(uint8_t row) { return matrix[row]; } |
| 206 | // Set col, read rows | ||
| 207 | for (uint8_t current_col = 0; current_col < MATRIX_COLS; current_col++) { | ||
| 208 | # if (DEBOUNCING_DELAY > 0) | ||
| 209 | bool matrix_changed = read_rows_on_col(matrix_debouncing+offset, current_col); | ||
| 210 | if (matrix_changed) { | ||
| 211 | debouncing = true; | ||
| 212 | debouncing_time = timer_read(); | ||
| 213 | } | ||
| 214 | # else | ||
| 215 | read_rows_on_col(matrix+offset, current_col); | ||
| 216 | # endif | ||
| 217 | 94 | ||
| 218 | } | 95 | void matrix_print(void) { |
| 219 | #endif | 96 | print_matrix_header(); |
| 220 | 97 | ||
| 221 | # if (DEBOUNCING_DELAY > 0) | 98 | for (uint8_t row = 0; row < MATRIX_ROWS; row++) { |
| 222 | if (debouncing && (timer_elapsed(debouncing_time) > DEBOUNCING_DELAY)) { | 99 | phex(row); |
| 223 | for (uint8_t i = 0; i < ROWS_PER_HAND; i++) { | 100 | print(": "); |
| 224 | matrix[i+offset] = matrix_debouncing[i+offset]; | 101 | print_matrix_row(row); |
| 225 | } | 102 | print("\n"); |
| 226 | debouncing = false; | 103 | } |
| 227 | } | 104 | } |
| 228 | # endif | ||
| 229 | 105 | ||
| 230 | return 1; | 106 | uint8_t matrix_key_count(void) { |
| 107 | uint8_t count = 0; | ||
| 108 | for (uint8_t i = 0; i < MATRIX_ROWS; i++) { | ||
| 109 | count += matrix_bitpop(i); | ||
| 110 | } | ||
| 111 | return count; | ||
| 231 | } | 112 | } |
| 232 | 113 | ||
| 233 | #if defined(USE_I2C) || defined(EH) | 114 | // matrix code |
| 234 | |||
| 235 | // Get rows from other half over i2c | ||
| 236 | int i2c_transaction(void) { | ||
| 237 | int slaveOffset = (isLeftHand) ? (ROWS_PER_HAND) : 0; | ||
| 238 | int err = 0; | ||
| 239 | |||
| 240 | // write backlight info | ||
| 241 | #ifdef BACKLIGHT_ENABLE | ||
| 242 | if (BACKLIT_DIRTY) { | ||
| 243 | err = i2c_master_start(SLAVE_I2C_ADDRESS + I2C_WRITE); | ||
| 244 | if (err) goto i2c_error; | ||
| 245 | |||
| 246 | // Backlight location | ||
| 247 | err = i2c_master_write(I2C_BACKLIT_START); | ||
| 248 | if (err) goto i2c_error; | ||
| 249 | |||
| 250 | // Write backlight | ||
| 251 | i2c_master_write(get_backlight_level()); | ||
| 252 | |||
| 253 | BACKLIT_DIRTY = false; | ||
| 254 | } | ||
| 255 | #endif | ||
| 256 | 115 | ||
| 257 | err = i2c_master_start(SLAVE_I2C_ADDRESS + I2C_WRITE); | 116 | #ifdef DIRECT_PINS |
| 258 | if (err) goto i2c_error; | ||
| 259 | 117 | ||
| 260 | // start of matrix stored at I2C_KEYMAP_START | 118 | static void init_pins(void) { |
| 261 | err = i2c_master_write(I2C_KEYMAP_START); | 119 | for (int row = 0; row < MATRIX_ROWS; row++) { |
| 262 | if (err) goto i2c_error; | 120 | for (int col = 0; col < MATRIX_COLS; col++) { |
| 121 | pin_t pin = direct_pins[row][col]; | ||
| 122 | if (pin != NO_PIN) { | ||
| 123 | setPinInputHigh(pin); | ||
| 124 | } | ||
| 125 | } | ||
| 126 | } | ||
| 127 | } | ||
| 263 | 128 | ||
| 264 | // Start read | 129 | static bool read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row) { |
| 265 | err = i2c_master_start(SLAVE_I2C_ADDRESS + I2C_READ); | 130 | matrix_row_t last_row_value = current_matrix[current_row]; |
| 266 | if (err) goto i2c_error; | 131 | current_matrix[current_row] = 0; |
| 267 | 132 | ||
| 268 | if (!err) { | 133 | for (uint8_t col_index = 0; col_index < MATRIX_COLS; col_index++) { |
| 269 | int i; | 134 | pin_t pin = direct_pins[current_row][col_index]; |
| 270 | for (i = 0; i < ROWS_PER_HAND-1; ++i) { | 135 | if (pin != NO_PIN) { |
| 271 | matrix[slaveOffset+i] = i2c_master_read(I2C_ACK); | 136 | current_matrix[current_row] |= readPin(pin) ? 0 : (ROW_SHIFTER << col_index); |
| 272 | } | ||
| 273 | matrix[slaveOffset+i] = i2c_master_read(I2C_NACK); | ||
| 274 | i2c_master_stop(); | ||
| 275 | } else { | ||
| 276 | i2c_error: // the cable is disconnceted, or something else went wrong | ||
| 277 | i2c_reset_state(); | ||
| 278 | return err; | ||
| 279 | } | 137 | } |
| 280 | 138 | } | |
| 281 | #ifdef RGBLIGHT_ENABLE | ||
| 282 | if (RGB_DIRTY) { | ||
| 283 | err = i2c_master_start(SLAVE_I2C_ADDRESS + I2C_WRITE); | ||
| 284 | if (err) goto i2c_error; | ||
| 285 | |||
| 286 | // RGB Location | ||
| 287 | err = i2c_master_write(I2C_RGB_START); | ||
| 288 | if (err) goto i2c_error; | ||
| 289 | |||
| 290 | uint32_t dword = eeconfig_read_rgblight(); | ||
| 291 | |||
| 292 | // Write RGB | ||
| 293 | err = i2c_master_write_data(&dword, 4); | ||
| 294 | if (err) goto i2c_error; | ||
| 295 | |||
| 296 | RGB_DIRTY = false; | ||
| 297 | i2c_master_stop(); | ||
| 298 | } | ||
| 299 | #endif | ||
| 300 | 139 | ||
| 301 | return 0; | 140 | return (last_row_value != current_matrix[current_row]); |
| 302 | } | 141 | } |
| 303 | 142 | ||
| 304 | #else // USE_SERIAL | 143 | #elif (DIODE_DIRECTION == COL2ROW) |
| 305 | |||
| 306 | 144 | ||
| 307 | typedef struct _Serial_s2m_buffer_t { | 145 | static void select_row(uint8_t row) { |
| 308 | // TODO: if MATRIX_COLS > 8 change to uint8_t packed_matrix[] for pack/unpack | 146 | writePinLow(row_pins[row]); |
| 309 | matrix_row_t smatrix[ROWS_PER_HAND]; | 147 | setPinOutput(row_pins[row]); |
| 310 | } Serial_s2m_buffer_t; | 148 | } |
| 311 | 149 | ||
| 312 | volatile Serial_s2m_buffer_t serial_s2m_buffer = {}; | 150 | static void unselect_row(uint8_t row) { setPinInputHigh(row_pins[row]); } |
| 313 | volatile Serial_m2s_buffer_t serial_m2s_buffer = {}; | ||
| 314 | uint8_t volatile status0 = 0; | ||
| 315 | 151 | ||
| 316 | SSTD_t transactions[] = { | 152 | static void unselect_rows(void) { |
| 317 | { (uint8_t *)&status0, | 153 | for (uint8_t x = 0; x < ROWS_PER_HAND; x++) { |
| 318 | sizeof(serial_m2s_buffer), (uint8_t *)&serial_m2s_buffer, | 154 | setPinInputHigh(row_pins[x]); |
| 319 | sizeof(serial_s2m_buffer), (uint8_t *)&serial_s2m_buffer | ||
| 320 | } | 155 | } |
| 321 | }; | 156 | } |
| 322 | 157 | ||
| 323 | void serial_master_init(void) | 158 | static void init_pins(void) { |
| 324 | { soft_serial_initiator_init(transactions, TID_LIMIT(transactions)); } | 159 | unselect_rows(); |
| 160 | for (uint8_t x = 0; x < MATRIX_COLS; x++) { | ||
| 161 | setPinInputHigh(col_pins[x]); | ||
| 162 | } | ||
| 163 | } | ||
| 325 | 164 | ||
| 326 | void serial_slave_init(void) | 165 | static bool read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row) { |
| 327 | { soft_serial_target_init(transactions, TID_LIMIT(transactions)); } | 166 | // Store last value of row prior to reading |
| 167 | matrix_row_t last_row_value = current_matrix[current_row]; | ||
| 328 | 168 | ||
| 329 | int serial_transaction(void) { | 169 | // Clear data in matrix row |
| 330 | int slaveOffset = (isLeftHand) ? (ROWS_PER_HAND) : 0; | 170 | current_matrix[current_row] = 0; |
| 331 | 171 | ||
| 332 | if (soft_serial_transaction()) { | 172 | // Select row and wait for row selecton to stabilize |
| 333 | return 1; | 173 | select_row(current_row); |
| 334 | } | 174 | wait_us(30); |
| 335 | 175 | ||
| 336 | // TODO: if MATRIX_COLS > 8 change to unpack() | 176 | // For each col... |
| 337 | for (int i = 0; i < ROWS_PER_HAND; ++i) { | 177 | for (uint8_t col_index = 0; col_index < MATRIX_COLS; col_index++) { |
| 338 | matrix[slaveOffset+i] = serial_s2m_buffer.smatrix[i]; | 178 | // Populate the matrix row with the state of the col pin |
| 339 | } | 179 | current_matrix[current_row] |= readPin(col_pins[col_index]) ? 0 : (ROW_SHIFTER << col_index); |
| 340 | 180 | } | |
| 341 | #if defined(RGBLIGHT_ENABLE) && defined(RGBLIGHT_SPLIT) | ||
| 342 | // Code to send RGB over serial goes here (not implemented yet) | ||
| 343 | #endif | ||
| 344 | |||
| 345 | #ifdef BACKLIGHT_ENABLE | ||
| 346 | // Write backlight level for slave to read | ||
| 347 | serial_m2s_buffer.backlight_level = backlight_config.enable ? backlight_config.level : 0; | ||
| 348 | #endif | ||
| 349 | |||
| 350 | return 0; | ||
| 351 | } | ||
| 352 | #endif | ||
| 353 | 181 | ||
| 354 | uint8_t matrix_scan(void) | 182 | // Unselect row |
| 355 | { | 183 | unselect_row(current_row); |
| 356 | uint8_t ret = _matrix_scan(); | ||
| 357 | 184 | ||
| 358 | #if defined(USE_I2C) || defined(EH) | 185 | return (last_row_value != current_matrix[current_row]); |
| 359 | if( i2c_transaction() ) { | 186 | } |
| 360 | #else // USE_SERIAL | ||
| 361 | if( serial_transaction() ) { | ||
| 362 | #endif | ||
| 363 | 187 | ||
| 364 | error_count++; | 188 | #elif (DIODE_DIRECTION == ROW2COL) |
| 365 | 189 | ||
| 366 | if (error_count > ERROR_DISCONNECT_COUNT) { | 190 | static void select_col(uint8_t col) { |
| 367 | // reset other half if disconnected | 191 | writePinLow(col_pins[col]); |
| 368 | int slaveOffset = (isLeftHand) ? (ROWS_PER_HAND) : 0; | 192 | setPinOutput(col_pins[col]); |
| 369 | for (int i = 0; i < ROWS_PER_HAND; ++i) { | ||
| 370 | matrix[slaveOffset+i] = 0; | ||
| 371 | } | ||
| 372 | } | ||
| 373 | } else { | ||
| 374 | error_count = 0; | ||
| 375 | } | ||
| 376 | matrix_scan_quantum(); | ||
| 377 | return ret; | ||
| 378 | } | 193 | } |
| 379 | 194 | ||
| 380 | void matrix_slave_scan(void) { | 195 | static void unselect_col(uint8_t col) { setPinInputHigh(col_pins[col]); } |
| 381 | _matrix_scan(); | ||
| 382 | |||
| 383 | int offset = (isLeftHand) ? 0 : ROWS_PER_HAND; | ||
| 384 | 196 | ||
| 385 | #if defined(USE_I2C) || defined(EH) | 197 | static void unselect_cols(void) { |
| 386 | for (int i = 0; i < ROWS_PER_HAND; ++i) { | 198 | for (uint8_t x = 0; x < MATRIX_COLS; x++) { |
| 387 | i2c_slave_buffer[I2C_KEYMAP_START+i] = matrix[offset+i]; | 199 | setPinInputHigh(col_pins[x]); |
| 388 | } | 200 | } |
| 389 | #else // USE_SERIAL | ||
| 390 | // TODO: if MATRIX_COLS > 8 change to pack() | ||
| 391 | for (int i = 0; i < ROWS_PER_HAND; ++i) { | ||
| 392 | serial_s2m_buffer.smatrix[i] = matrix[offset+i]; | ||
| 393 | } | ||
| 394 | #endif | ||
| 395 | matrix_slave_scan_user(); | ||
| 396 | } | 201 | } |
| 397 | 202 | ||
| 398 | bool matrix_is_modified(void) | 203 | static void init_pins(void) { |
| 399 | { | 204 | unselect_cols(); |
| 400 | if (debouncing) return false; | 205 | for (uint8_t x = 0; x < ROWS_PER_HAND; x++) { |
| 401 | return true; | 206 | setPinInputHigh(row_pins[x]); |
| 207 | } | ||
| 402 | } | 208 | } |
| 403 | 209 | ||
| 404 | inline | 210 | static bool read_rows_on_col(matrix_row_t current_matrix[], uint8_t current_col) { |
| 405 | bool matrix_is_on(uint8_t row, uint8_t col) | 211 | bool matrix_changed = false; |
| 406 | { | ||
| 407 | return (matrix[row] & ((matrix_row_t)1<<col)); | ||
| 408 | } | ||
| 409 | 212 | ||
| 410 | inline | 213 | // Select col and wait for col selecton to stabilize |
| 411 | matrix_row_t matrix_get_row(uint8_t row) | 214 | select_col(current_col); |
| 412 | { | 215 | wait_us(30); |
| 413 | return matrix[row]; | 216 | |
| 414 | } | 217 | // For each row... |
| 218 | for (uint8_t row_index = 0; row_index < ROWS_PER_HAND; row_index++) { | ||
| 219 | // Store last value of row prior to reading | ||
| 220 | matrix_row_t last_row_value = current_matrix[row_index]; | ||
| 415 | 221 | ||
| 416 | void matrix_print(void) | 222 | // Check row pin state |
| 417 | { | 223 | if (readPin(row_pins[row_index])) { |
| 418 | print("\nr/c 0123456789ABCDEF\n"); | 224 | // Pin HI, clear col bit |
| 419 | for (uint8_t row = 0; row < MATRIX_ROWS; row++) { | 225 | current_matrix[row_index] &= ~(ROW_SHIFTER << current_col); |
| 420 | phex(row); print(": "); | 226 | } else { |
| 421 | pbin_reverse16(matrix_get_row(row)); | 227 | // Pin LO, set col bit |
| 422 | print("\n"); | 228 | current_matrix[row_index] |= (ROW_SHIFTER << current_col); |
| 423 | } | 229 | } |
| 424 | } | ||
| 425 | 230 | ||
| 426 | uint8_t matrix_key_count(void) | 231 | // Determine if the matrix changed state |
| 427 | { | 232 | if ((last_row_value != current_matrix[row_index]) && !(matrix_changed)) { |
| 428 | uint8_t count = 0; | 233 | matrix_changed = true; |
| 429 | for (uint8_t i = 0; i < MATRIX_ROWS; i++) { | ||
| 430 | count += bitpop16(matrix[i]); | ||
| 431 | } | 234 | } |
| 432 | return count; | 235 | } |
| 433 | } | ||
| 434 | 236 | ||
| 435 | #if (DIODE_DIRECTION == COL2ROW) | 237 | // Unselect col |
| 238 | unselect_col(current_col); | ||
| 436 | 239 | ||
| 437 | static void init_cols(void) | 240 | return matrix_changed; |
| 438 | { | ||
| 439 | for(uint8_t x = 0; x < MATRIX_COLS; x++) { | ||
| 440 | setPinInputHigh(col_pins[x]); | ||
| 441 | } | ||
| 442 | } | 241 | } |
| 443 | 242 | ||
| 444 | static bool read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row) | 243 | #endif |
| 445 | { | ||
| 446 | // Store last value of row prior to reading | ||
| 447 | matrix_row_t last_row_value = current_matrix[current_row]; | ||
| 448 | |||
| 449 | // Clear data in matrix row | ||
| 450 | current_matrix[current_row] = 0; | ||
| 451 | 244 | ||
| 452 | // Select row and wait for row selecton to stabilize | 245 | void matrix_init(void) { |
| 453 | select_row(current_row); | 246 | debug_enable = true; |
| 454 | wait_us(30); | 247 | debug_matrix = true; |
| 248 | debug_mouse = true; | ||
| 455 | 249 | ||
| 456 | // For each col... | 250 | // Set pinout for right half if pinout for that half is defined |
| 457 | for(uint8_t col_index = 0; col_index < MATRIX_COLS; col_index++) { | 251 | if (!isLeftHand) { |
| 458 | // Populate the matrix row with the state of the col pin | 252 | #ifdef MATRIX_ROW_PINS_RIGHT |
| 459 | current_matrix[current_row] |= readPin(col_pins[col_index]) ? 0 : (ROW_SHIFTER << col_index); | 253 | const uint8_t row_pins_right[MATRIX_ROWS] = MATRIX_ROW_PINS_RIGHT; |
| 254 | for (uint8_t i = 0; i < MATRIX_ROWS; i++) { | ||
| 255 | row_pins[i] = row_pins_right[i]; | ||
| 460 | } | 256 | } |
| 257 | #endif | ||
| 258 | #ifdef MATRIX_COL_PINS_RIGHT | ||
| 259 | const uint8_t col_pins_right[MATRIX_COLS] = MATRIX_COL_PINS_RIGHT; | ||
| 260 | for (uint8_t i = 0; i < MATRIX_COLS; i++) { | ||
| 261 | col_pins[i] = col_pins_right[i]; | ||
| 262 | } | ||
| 263 | #endif | ||
| 264 | } | ||
| 461 | 265 | ||
| 462 | // Unselect row | 266 | thisHand = isLeftHand ? 0 : (ROWS_PER_HAND); |
| 463 | unselect_row(current_row); | 267 | thatHand = ROWS_PER_HAND - thisHand; |
| 464 | 268 | ||
| 465 | return (last_row_value != current_matrix[current_row]); | 269 | // initialize key pins |
| 466 | } | 270 | init_pins(); |
| 467 | 271 | ||
| 468 | static void select_row(uint8_t row) | 272 | // initialize matrix state: all keys off |
| 469 | { | 273 | for (uint8_t i = 0; i < MATRIX_ROWS; i++) { |
| 470 | writePinLow(row_pins[row]); | 274 | matrix[i] = 0; |
| 471 | setPinOutput(row_pins[row]); | 275 | } |
| 472 | } | ||
| 473 | 276 | ||
| 474 | static void unselect_row(uint8_t row) | 277 | debounce_init(ROWS_PER_HAND); |
| 475 | { | ||
| 476 | setPinInputHigh(row_pins[row]); | ||
| 477 | } | ||
| 478 | 278 | ||
| 479 | static void unselect_rows(void) | 279 | matrix_init_quantum(); |
| 480 | { | ||
| 481 | for(uint8_t x = 0; x < ROWS_PER_HAND; x++) { | ||
| 482 | setPinInputHigh(row_pins[x]); | ||
| 483 | } | ||
| 484 | } | 280 | } |
| 485 | 281 | ||
| 282 | uint8_t _matrix_scan(void) { | ||
| 283 | bool changed = false; | ||
| 284 | |||
| 285 | #if defined(DIRECT_PINS) || (DIODE_DIRECTION == COL2ROW) | ||
| 286 | // Set row, read cols | ||
| 287 | for (uint8_t current_row = 0; current_row < ROWS_PER_HAND; current_row++) { | ||
| 288 | changed |= read_cols_on_row(raw_matrix, current_row); | ||
| 289 | } | ||
| 486 | #elif (DIODE_DIRECTION == ROW2COL) | 290 | #elif (DIODE_DIRECTION == ROW2COL) |
| 291 | // Set col, read rows | ||
| 292 | for (uint8_t current_col = 0; current_col < MATRIX_COLS; current_col++) { | ||
| 293 | changed |= read_rows_on_col(raw_matrix, current_col); | ||
| 294 | } | ||
| 295 | #endif | ||
| 487 | 296 | ||
| 488 | static void init_rows(void) | 297 | debounce(raw_matrix, matrix + thisHand, ROWS_PER_HAND, changed); |
| 489 | { | ||
| 490 | for(uint8_t x = 0; x < ROWS_PER_HAND; x++) { | ||
| 491 | setPinInputHigh(row_pins[x]); | ||
| 492 | } | ||
| 493 | } | ||
| 494 | 298 | ||
| 495 | static bool read_rows_on_col(matrix_row_t current_matrix[], uint8_t current_col) | 299 | return 1; |
| 496 | { | 300 | } |
| 497 | bool matrix_changed = false; | ||
| 498 | 301 | ||
| 499 | // Select col and wait for col selecton to stabilize | 302 | uint8_t matrix_scan(void) { |
| 500 | select_col(current_col); | 303 | uint8_t ret = _matrix_scan(); |
| 501 | wait_us(30); | ||
| 502 | 304 | ||
| 503 | // For each row... | 305 | if (is_keyboard_master()) { |
| 504 | for(uint8_t row_index = 0; row_index < ROWS_PER_HAND; row_index++) | 306 | static uint8_t error_count; |
| 505 | { | ||
| 506 | 307 | ||
| 507 | // Store last value of row prior to reading | 308 | if (!transport_master(matrix + thatHand)) { |
| 508 | matrix_row_t last_row_value = current_matrix[row_index]; | 309 | error_count++; |
| 509 | 310 | ||
| 510 | // Check row pin state | 311 | if (error_count > ERROR_DISCONNECT_COUNT) { |
| 511 | if (readPin(row_pins[row_index])) | 312 | // reset other half if disconnected |
| 512 | { | 313 | for (int i = 0; i < ROWS_PER_HAND; ++i) { |
| 513 | // Pin HI, clear col bit | 314 | matrix[thatHand + i] = 0; |
| 514 | current_matrix[row_index] &= ~(ROW_SHIFTER << current_col); | ||
| 515 | } | ||
| 516 | else | ||
| 517 | { | ||
| 518 | // Pin LO, set col bit | ||
| 519 | current_matrix[row_index] |= (ROW_SHIFTER << current_col); | ||
| 520 | } | ||
| 521 | |||
| 522 | // Determine if the matrix changed state | ||
| 523 | if ((last_row_value != current_matrix[row_index]) && !(matrix_changed)) | ||
| 524 | { | ||
| 525 | matrix_changed = true; | ||
| 526 | } | 315 | } |
| 316 | } | ||
| 317 | } else { | ||
| 318 | error_count = 0; | ||
| 527 | } | 319 | } |
| 528 | 320 | ||
| 529 | // Unselect col | 321 | matrix_scan_quantum(); |
| 530 | unselect_col(current_col); | 322 | } else { |
| 531 | 323 | transport_slave(matrix + thisHand); | |
| 532 | return matrix_changed; | 324 | matrix_slave_scan_user(); |
| 533 | } | 325 | } |
| 534 | |||
| 535 | static void select_col(uint8_t col) | ||
| 536 | { | ||
| 537 | writePinLow(col_pins[col]); | ||
| 538 | setPinOutput(col_pins[col]); | ||
| 539 | } | ||
| 540 | |||
| 541 | static void unselect_col(uint8_t col) | ||
| 542 | { | ||
| 543 | setPinInputHigh(col_pins[col]); | ||
| 544 | } | ||
| 545 | 326 | ||
| 546 | static void unselect_cols(void) | 327 | return ret; |
| 547 | { | ||
| 548 | for(uint8_t x = 0; x < MATRIX_COLS; x++) { | ||
| 549 | setPinInputHigh(col_pins[x]); | ||
| 550 | } | ||
| 551 | } | 328 | } |
| 552 | |||
| 553 | #endif | ||
diff --git a/quantum/split_common/matrix.h b/quantum/split_common/matrix.h index b5cb45bae..c2bdd3098 100644 --- a/quantum/split_common/matrix.h +++ b/quantum/split_common/matrix.h | |||
| @@ -1,31 +1,3 @@ | |||
| 1 | #ifndef SPLIT_COMMON_MATRIX_H | 1 | #pragma once |
| 2 | #define SPLIT_COMMON_MATRIX_H | ||
| 3 | 2 | ||
| 4 | #include <common/matrix.h> | 3 | #include <common/matrix.h> |
| 5 | |||
| 6 | #ifdef RGBLIGHT_ENABLE | ||
| 7 | # include "rgblight.h" | ||
| 8 | #endif | ||
| 9 | |||
| 10 | typedef struct _Serial_m2s_buffer_t { | ||
| 11 | #ifdef BACKLIGHT_ENABLE | ||
| 12 | uint8_t backlight_level; | ||
| 13 | #endif | ||
| 14 | #if defined(RGBLIGHT_ENABLE) && defined(RGBLIGHT_SPLIT) | ||
| 15 | rgblight_config_t rgblight_config; //not yet use | ||
| 16 | // | ||
| 17 | // When MCUs on both sides drive their respective RGB LED chains, | ||
| 18 | // it is necessary to synchronize, so it is necessary to communicate RGB information. | ||
| 19 | // In that case, define the RGBLIGHT_SPLIT macro. | ||
| 20 | // | ||
| 21 | // Otherwise, if the master side MCU drives both sides RGB LED chains, | ||
| 22 | // there is no need to communicate. | ||
| 23 | #endif | ||
| 24 | } Serial_m2s_buffer_t; | ||
| 25 | |||
| 26 | extern volatile Serial_m2s_buffer_t serial_m2s_buffer; | ||
| 27 | |||
| 28 | void serial_master_init(void); | ||
| 29 | void serial_slave_init(void); | ||
| 30 | |||
| 31 | #endif | ||
diff --git a/quantum/split_common/serial.h b/quantum/split_common/serial.h index b6638b3bd..1c1e64006 100644 --- a/quantum/split_common/serial.h +++ b/quantum/split_common/serial.h | |||
| @@ -1,5 +1,4 @@ | |||
| 1 | #ifndef SOFT_SERIAL_H | 1 | #pragma once |
| 2 | #define SOFT_SERIAL_H | ||
| 3 | 2 | ||
| 4 | #include <stdbool.h> | 3 | #include <stdbool.h> |
| 5 | 4 | ||
| @@ -61,5 +60,3 @@ int soft_serial_transaction(int sstd_index); | |||
| 61 | #ifdef SERIAL_USE_MULTI_TRANSACTION | 60 | #ifdef SERIAL_USE_MULTI_TRANSACTION |
| 62 | int soft_serial_get_and_clean_status(int sstd_index); | 61 | int soft_serial_get_and_clean_status(int sstd_index); |
| 63 | #endif | 62 | #endif |
| 64 | |||
| 65 | #endif /* SOFT_SERIAL_H */ | ||
diff --git a/quantum/split_common/split_flags.h b/quantum/split_common/split_flags.h index f101fff5b..aaac474a7 100644 --- a/quantum/split_common/split_flags.h +++ b/quantum/split_common/split_flags.h | |||
| @@ -1,10 +1,9 @@ | |||
| 1 | #ifndef SPLIT_FLAGS_H | 1 | #pragma once |
| 2 | #define SPLIT_FLAGS_H | ||
| 3 | 2 | ||
| 4 | #include <stdbool.h> | 3 | #include <stdbool.h> |
| 5 | #include <stdint.h> | 4 | #include <stdint.h> |
| 6 | 5 | ||
| 7 | /** | 6 | /** |
| 8 | * Global Flags | 7 | * Global Flags |
| 9 | **/ | 8 | **/ |
| 10 | 9 | ||
| @@ -14,7 +13,3 @@ extern volatile bool RGB_DIRTY; | |||
| 14 | 13 | ||
| 15 | //Backlight Stuff | 14 | //Backlight Stuff |
| 16 | extern volatile bool BACKLIT_DIRTY; | 15 | extern volatile bool BACKLIT_DIRTY; |
| 17 | |||
| 18 | |||
| 19 | |||
| 20 | #endif \ No newline at end of file | ||
diff --git a/quantum/split_common/split_util.c b/quantum/split_common/split_util.c index e41b6f638..5095cb8fd 100644 --- a/quantum/split_common/split_util.c +++ b/quantum/split_common/split_util.c | |||
| @@ -4,142 +4,84 @@ | |||
| 4 | #include "config.h" | 4 | #include "config.h" |
| 5 | #include "timer.h" | 5 | #include "timer.h" |
| 6 | #include "split_flags.h" | 6 | #include "split_flags.h" |
| 7 | #include "transport.h" | ||
| 7 | #include "quantum.h" | 8 | #include "quantum.h" |
| 8 | 9 | ||
| 9 | #ifdef EE_HANDS | 10 | #ifdef EE_HANDS |
| 10 | # include "tmk_core/common/eeprom.h" | 11 | # include "tmk_core/common/eeprom.h" |
| 11 | #endif | 12 | # include "eeconfig.h" |
| 12 | |||
| 13 | #ifdef BACKLIGHT_ENABLE | ||
| 14 | # include "backlight.h" | ||
| 15 | #endif | ||
| 16 | |||
| 17 | #if defined(USE_I2C) || defined(EH) | ||
| 18 | # include "i2c.h" | ||
| 19 | #endif | 13 | #endif |
| 20 | 14 | ||
| 21 | volatile bool isLeftHand = true; | 15 | volatile bool isLeftHand = true; |
| 22 | 16 | ||
| 23 | volatile uint8_t setTries = 0; | 17 | __attribute__((weak)) |
| 24 | 18 | bool is_keyboard_left(void) { | |
| 25 | static void setup_handedness(void) { | ||
| 26 | #ifdef SPLIT_HAND_PIN | 19 | #ifdef SPLIT_HAND_PIN |
| 27 | // Test pin SPLIT_HAND_PIN for High/Low, if low it's right hand | 20 | // Test pin SPLIT_HAND_PIN for High/Low, if low it's right hand |
| 28 | setPinInput(SPLIT_HAND_PIN); | 21 | setPinInput(SPLIT_HAND_PIN); |
| 29 | isLeftHand = readPin(SPLIT_HAND_PIN); | 22 | return readPin(SPLIT_HAND_PIN); |
| 30 | #else | 23 | #else |
| 31 | #ifdef EE_HANDS | 24 | #ifdef EE_HANDS |
| 32 | isLeftHand = eeprom_read_byte(EECONFIG_HANDEDNESS); | 25 | return eeprom_read_byte(EECONFIG_HANDEDNESS); |
| 33 | #else | 26 | #else |
| 34 | #ifdef MASTER_RIGHT | 27 | #ifdef MASTER_RIGHT |
| 35 | isLeftHand = !has_usb(); | 28 | return !is_keyboard_master(); |
| 36 | #else | 29 | #else |
| 37 | isLeftHand = has_usb(); | 30 | return is_keyboard_master(); |
| 38 | #endif | 31 | #endif |
| 39 | #endif | 32 | #endif |
| 40 | #endif | 33 | #endif |
| 41 | } | 34 | } |
| 42 | 35 | ||
| 43 | static void keyboard_master_setup(void) { | 36 | bool is_keyboard_master(void) |
| 44 | #if defined(USE_I2C) || defined(EH) | 37 | { |
| 45 | i2c_master_init(); | 38 | #ifdef __AVR__ |
| 46 | #ifdef SSD1306OLED | 39 | static enum { UNKNOWN, MASTER, SLAVE } usbstate = UNKNOWN; |
| 47 | matrix_master_OLED_init (); | ||
| 48 | #endif | ||
| 49 | #else | ||
| 50 | serial_master_init(); | ||
| 51 | #endif | ||
| 52 | 40 | ||
| 53 | // For master the Backlight info needs to be sent on startup | 41 | // only check once, as this is called often |
| 54 | // Otherwise the salve won't start with the proper info until an update | 42 | if (usbstate == UNKNOWN) |
| 55 | BACKLIT_DIRTY = true; | 43 | { |
| 56 | } | 44 | USBCON |= (1 << OTGPADE); // enables VBUS pad |
| 45 | wait_us(5); | ||
| 57 | 46 | ||
| 58 | static void keyboard_slave_setup(void) { | 47 | usbstate = (USBSTA & (1 << VBUS)) ? MASTER : SLAVE; // checks state of VBUS |
| 59 | timer_init(); | 48 | } |
| 60 | #if defined(USE_I2C) || defined(EH) | 49 | |
| 61 | i2c_slave_init(SLAVE_I2C_ADDRESS); | 50 | return (usbstate == MASTER); |
| 62 | #else | 51 | #else |
| 63 | serial_slave_init(); | 52 | return true; |
| 64 | #endif | 53 | #endif |
| 65 | } | 54 | } |
| 66 | 55 | ||
| 67 | bool has_usb(void) { | 56 | static void keyboard_master_setup(void) { |
| 68 | USBCON |= (1 << OTGPADE); //enables VBUS pad | 57 | #if defined(USE_I2C) || defined(EH) |
| 69 | _delay_us(5); | 58 | #ifdef SSD1306OLED |
| 70 | return (USBSTA & (1<<VBUS)); //checks state of VBUS | 59 | matrix_master_OLED_init (); |
| 71 | } | 60 | #endif |
| 72 | 61 | #endif | |
| 73 | void split_keyboard_setup(void) { | 62 | transport_master_init(); |
| 74 | setup_handedness(); | ||
| 75 | 63 | ||
| 76 | if (has_usb()) { | 64 | // For master the Backlight info needs to be sent on startup |
| 77 | keyboard_master_setup(); | 65 | // Otherwise the salve won't start with the proper info until an update |
| 78 | } else { | 66 | BACKLIT_DIRTY = true; |
| 79 | keyboard_slave_setup(); | ||
| 80 | } | ||
| 81 | sei(); | ||
| 82 | } | 67 | } |
| 83 | 68 | ||
| 84 | void keyboard_slave_loop(void) { | 69 | static void keyboard_slave_setup(void) |
| 85 | matrix_init(); | 70 | { |
| 86 | 71 | transport_slave_init(); | |
| 87 | //Init RGB | ||
| 88 | #ifdef RGBLIGHT_ENABLE | ||
| 89 | rgblight_init(); | ||
| 90 | #endif | ||
| 91 | |||
| 92 | while (1) { | ||
| 93 | // Matrix Slave Scan | ||
| 94 | matrix_slave_scan(); | ||
| 95 | |||
| 96 | // Read Backlight Info | ||
| 97 | #ifdef BACKLIGHT_ENABLE | ||
| 98 | #ifdef USE_I2C | ||
| 99 | if (BACKLIT_DIRTY) { | ||
| 100 | backlight_set(i2c_slave_buffer[I2C_BACKLIT_START]); | ||
| 101 | BACKLIT_DIRTY = false; | ||
| 102 | } | ||
| 103 | #else // USE_SERIAL | ||
| 104 | backlight_set(serial_m2s_buffer.backlight_level); | ||
| 105 | #endif | ||
| 106 | #endif | ||
| 107 | // Read RGB Info | ||
| 108 | #ifdef RGBLIGHT_ENABLE | ||
| 109 | #ifdef USE_I2C | ||
| 110 | if (RGB_DIRTY) { | ||
| 111 | // Disable interupts (RGB data is big) | ||
| 112 | cli(); | ||
| 113 | // Create new DWORD for RGB data | ||
| 114 | uint32_t dword; | ||
| 115 | |||
| 116 | // Fill the new DWORD with the data that was sent over | ||
| 117 | uint8_t *dword_dat = (uint8_t *)(&dword); | ||
| 118 | for (int i = 0; i < 4; i++) { | ||
| 119 | dword_dat[i] = i2c_slave_buffer[I2C_RGB_START+i]; | ||
| 120 | } | ||
| 121 | |||
| 122 | // Update the RGB now with the new data and set RGB_DIRTY to false | ||
| 123 | rgblight_update_dword(dword); | ||
| 124 | RGB_DIRTY = false; | ||
| 125 | // Re-enable interupts now that RGB is set | ||
| 126 | sei(); | ||
| 127 | } | ||
| 128 | #else // USE_SERIAL | ||
| 129 | #ifdef RGBLIGHT_SPLIT | ||
| 130 | // Add serial implementation for RGB here | ||
| 131 | #endif | ||
| 132 | #endif | ||
| 133 | #endif | ||
| 134 | } | ||
| 135 | } | 72 | } |
| 136 | 73 | ||
| 137 | // this code runs before the usb and keyboard is initialized | 74 | // this code runs before the usb and keyboard is initialized |
| 138 | void matrix_setup(void) { | 75 | void matrix_setup(void) |
| 139 | split_keyboard_setup(); | 76 | { |
| 140 | 77 | isLeftHand = is_keyboard_left(); | |
| 141 | if (!has_usb()) { | 78 | |
| 142 | //rgblight_init(); | 79 | if (is_keyboard_master()) |
| 143 | keyboard_slave_loop(); | 80 | { |
| 144 | } | 81 | keyboard_master_setup(); |
| 82 | } | ||
| 83 | else | ||
| 84 | { | ||
| 85 | keyboard_slave_setup(); | ||
| 86 | } | ||
| 145 | } | 87 | } |
diff --git a/quantum/split_common/split_util.h b/quantum/split_common/split_util.h index d6cf3e72a..20f7535bf 100644 --- a/quantum/split_common/split_util.h +++ b/quantum/split_common/split_util.h | |||
| @@ -1,23 +1,10 @@ | |||
| 1 | #ifndef SPLIT_KEYBOARD_UTIL_H | 1 | #pragma once |
| 2 | #define SPLIT_KEYBOARD_UTIL_H | ||
| 3 | 2 | ||
| 4 | #include <stdbool.h> | 3 | #include <stdbool.h> |
| 5 | #include <stdint.h> | 4 | #include <stdint.h> |
| 6 | #include <stdio.h> | 5 | #include <stdio.h> |
| 7 | #include <stdlib.h> | 6 | #include <stdlib.h> |
| 8 | #include "eeconfig.h" | ||
| 9 | |||
| 10 | #define SLAVE_I2C_ADDRESS 0x32 | ||
| 11 | 7 | ||
| 12 | extern volatile bool isLeftHand; | 8 | extern volatile bool isLeftHand; |
| 13 | 9 | ||
| 14 | // slave version of matix scan, defined in matrix.c | ||
| 15 | void matrix_slave_scan(void); | ||
| 16 | |||
| 17 | void split_keyboard_setup(void); | ||
| 18 | bool has_usb(void); | ||
| 19 | void keyboard_slave_loop(void); | ||
| 20 | |||
| 21 | void matrix_master_OLED_init (void); | 10 | void matrix_master_OLED_init (void); |
| 22 | |||
| 23 | #endif | ||
diff --git a/quantum/split_common/transport.c b/quantum/split_common/transport.c new file mode 100644 index 000000000..95738530e --- /dev/null +++ b/quantum/split_common/transport.c | |||
| @@ -0,0 +1,224 @@ | |||
| 1 | |||
| 2 | #include "config.h" | ||
| 3 | #include "matrix.h" | ||
| 4 | #include "quantum.h" | ||
| 5 | |||
| 6 | #define ROWS_PER_HAND (MATRIX_ROWS/2) | ||
| 7 | |||
| 8 | #ifdef RGBLIGHT_ENABLE | ||
| 9 | # include "rgblight.h" | ||
| 10 | #endif | ||
| 11 | |||
| 12 | #ifdef BACKLIGHT_ENABLE | ||
| 13 | # include "backlight.h" | ||
| 14 | extern backlight_config_t backlight_config; | ||
| 15 | #endif | ||
| 16 | |||
| 17 | #if defined(USE_I2C) || defined(EH) | ||
| 18 | |||
| 19 | #include "i2c.h" | ||
| 20 | |||
| 21 | #ifndef SLAVE_I2C_ADDRESS | ||
| 22 | # define SLAVE_I2C_ADDRESS 0x32 | ||
| 23 | #endif | ||
| 24 | |||
| 25 | #if (MATRIX_COLS > 8) | ||
| 26 | # error "Currently only supports 8 COLS" | ||
| 27 | #endif | ||
| 28 | |||
| 29 | // Get rows from other half over i2c | ||
| 30 | bool transport_master(matrix_row_t matrix[]) { | ||
| 31 | int err = 0; | ||
| 32 | |||
| 33 | // write backlight info | ||
| 34 | #ifdef BACKLIGHT_ENABLE | ||
| 35 | if (BACKLIT_DIRTY) { | ||
| 36 | err = i2c_master_start(SLAVE_I2C_ADDRESS + I2C_WRITE); | ||
| 37 | if (err) { goto i2c_error; } | ||
| 38 | |||
| 39 | // Backlight location | ||
| 40 | err = i2c_master_write(I2C_BACKLIT_START); | ||
| 41 | if (err) { goto i2c_error; } | ||
| 42 | |||
| 43 | // Write backlight | ||
| 44 | i2c_master_write(get_backlight_level()); | ||
| 45 | |||
| 46 | BACKLIT_DIRTY = false; | ||
| 47 | } | ||
| 48 | #endif | ||
| 49 | |||
| 50 | err = i2c_master_start(SLAVE_I2C_ADDRESS + I2C_WRITE); | ||
| 51 | if (err) { goto i2c_error; } | ||
| 52 | |||
| 53 | // start of matrix stored at I2C_KEYMAP_START | ||
| 54 | err = i2c_master_write(I2C_KEYMAP_START); | ||
| 55 | if (err) { goto i2c_error; } | ||
| 56 | |||
| 57 | // Start read | ||
| 58 | err = i2c_master_start(SLAVE_I2C_ADDRESS + I2C_READ); | ||
| 59 | if (err) { goto i2c_error; } | ||
| 60 | |||
| 61 | if (!err) { | ||
| 62 | int i; | ||
| 63 | for (i = 0; i < ROWS_PER_HAND-1; ++i) { | ||
| 64 | matrix[i] = i2c_master_read(I2C_ACK); | ||
| 65 | } | ||
| 66 | matrix[i] = i2c_master_read(I2C_NACK); | ||
| 67 | i2c_master_stop(); | ||
| 68 | } else { | ||
| 69 | i2c_error: // the cable is disconnceted, or something else went wrong | ||
| 70 | i2c_reset_state(); | ||
| 71 | return false; | ||
| 72 | } | ||
| 73 | |||
| 74 | #ifdef RGBLIGHT_ENABLE | ||
| 75 | if (RGB_DIRTY) { | ||
| 76 | err = i2c_master_start(SLAVE_I2C_ADDRESS + I2C_WRITE); | ||
| 77 | if (err) { goto i2c_error; } | ||
| 78 | |||
| 79 | // RGB Location | ||
| 80 | err = i2c_master_write(I2C_RGB_START); | ||
| 81 | if (err) { goto i2c_error; } | ||
| 82 | |||
| 83 | uint32_t dword = eeconfig_read_rgblight(); | ||
| 84 | |||
| 85 | // Write RGB | ||
| 86 | err = i2c_master_write_data(&dword, 4); | ||
| 87 | if (err) { goto i2c_error; } | ||
| 88 | |||
| 89 | RGB_DIRTY = false; | ||
| 90 | i2c_master_stop(); | ||
| 91 | } | ||
| 92 | #endif | ||
| 93 | |||
| 94 | return true; | ||
| 95 | } | ||
| 96 | |||
| 97 | void transport_slave(matrix_row_t matrix[]) { | ||
| 98 | |||
| 99 | for (int i = 0; i < ROWS_PER_HAND; ++i) | ||
| 100 | { | ||
| 101 | i2c_slave_buffer[I2C_KEYMAP_START + i] = matrix[i]; | ||
| 102 | } | ||
| 103 | // Read Backlight Info | ||
| 104 | #ifdef BACKLIGHT_ENABLE | ||
| 105 | if (BACKLIT_DIRTY) | ||
| 106 | { | ||
| 107 | backlight_set(i2c_slave_buffer[I2C_BACKLIT_START]); | ||
| 108 | BACKLIT_DIRTY = false; | ||
| 109 | } | ||
| 110 | #endif | ||
| 111 | #ifdef RGBLIGHT_ENABLE | ||
| 112 | if (RGB_DIRTY) | ||
| 113 | { | ||
| 114 | // Disable interupts (RGB data is big) | ||
| 115 | cli(); | ||
| 116 | // Create new DWORD for RGB data | ||
| 117 | uint32_t dword; | ||
| 118 | |||
| 119 | // Fill the new DWORD with the data that was sent over | ||
| 120 | uint8_t * dword_dat = (uint8_t *)(&dword); | ||
| 121 | for (int i = 0; i < 4; i++) | ||
| 122 | { | ||
| 123 | dword_dat[i] = i2c_slave_buffer[I2C_RGB_START + i]; | ||
| 124 | } | ||
| 125 | |||
| 126 | // Update the RGB now with the new data and set RGB_DIRTY to false | ||
| 127 | rgblight_update_dword(dword); | ||
| 128 | RGB_DIRTY = false; | ||
| 129 | // Re-enable interupts now that RGB is set | ||
| 130 | sei(); | ||
| 131 | } | ||
| 132 | #endif | ||
| 133 | } | ||
| 134 | |||
| 135 | void transport_master_init(void) { | ||
| 136 | i2c_master_init(); | ||
| 137 | } | ||
| 138 | |||
| 139 | void transport_slave_init(void) { | ||
| 140 | i2c_slave_init(SLAVE_I2C_ADDRESS); | ||
| 141 | } | ||
| 142 | |||
| 143 | #else // USE_SERIAL | ||
| 144 | |||
| 145 | #include "serial.h" | ||
| 146 | |||
| 147 | typedef struct _Serial_s2m_buffer_t { | ||
| 148 | // TODO: if MATRIX_COLS > 8 change to uint8_t packed_matrix[] for pack/unpack | ||
| 149 | matrix_row_t smatrix[ROWS_PER_HAND]; | ||
| 150 | } Serial_s2m_buffer_t; | ||
| 151 | |||
| 152 | typedef struct _Serial_m2s_buffer_t { | ||
| 153 | #ifdef BACKLIGHT_ENABLE | ||
| 154 | uint8_t backlight_level; | ||
| 155 | #endif | ||
| 156 | #if defined(RGBLIGHT_ENABLE) && defined(RGBLIGHT_SPLIT) | ||
| 157 | rgblight_config_t rgblight_config; //not yet use | ||
| 158 | // | ||
| 159 | // When MCUs on both sides drive their respective RGB LED chains, | ||
| 160 | // it is necessary to synchronize, so it is necessary to communicate RGB information. | ||
| 161 | // In that case, define the RGBLIGHT_SPLIT macro. | ||
| 162 | // | ||
| 163 | // Otherwise, if the master side MCU drives both sides RGB LED chains, | ||
| 164 | // there is no need to communicate. | ||
| 165 | #endif | ||
| 166 | } Serial_m2s_buffer_t; | ||
| 167 | |||
| 168 | volatile Serial_s2m_buffer_t serial_s2m_buffer = {}; | ||
| 169 | volatile Serial_m2s_buffer_t serial_m2s_buffer = {}; | ||
| 170 | uint8_t volatile status0 = 0; | ||
| 171 | |||
| 172 | SSTD_t transactions[] = { | ||
| 173 | { (uint8_t *)&status0, | ||
| 174 | sizeof(serial_m2s_buffer), (uint8_t *)&serial_m2s_buffer, | ||
| 175 | sizeof(serial_s2m_buffer), (uint8_t *)&serial_s2m_buffer | ||
| 176 | } | ||
| 177 | }; | ||
| 178 | |||
| 179 | void transport_master_init(void) | ||
| 180 | { soft_serial_initiator_init(transactions, TID_LIMIT(transactions)); } | ||
| 181 | |||
| 182 | void transport_slave_init(void) | ||
| 183 | { soft_serial_target_init(transactions, TID_LIMIT(transactions)); } | ||
| 184 | |||
| 185 | bool transport_master(matrix_row_t matrix[]) { | ||
| 186 | |||
| 187 | if (soft_serial_transaction()) { | ||
| 188 | return false; | ||
| 189 | } | ||
| 190 | |||
| 191 | // TODO: if MATRIX_COLS > 8 change to unpack() | ||
| 192 | for (int i = 0; i < ROWS_PER_HAND; ++i) { | ||
| 193 | matrix[i] = serial_s2m_buffer.smatrix[i]; | ||
| 194 | } | ||
| 195 | |||
| 196 | #if defined(RGBLIGHT_ENABLE) && defined(RGBLIGHT_SPLIT) | ||
| 197 | // Code to send RGB over serial goes here (not implemented yet) | ||
| 198 | #endif | ||
| 199 | |||
| 200 | #ifdef BACKLIGHT_ENABLE | ||
| 201 | // Write backlight level for slave to read | ||
| 202 | serial_m2s_buffer.backlight_level = backlight_config.enable ? backlight_config.level : 0; | ||
| 203 | #endif | ||
| 204 | |||
| 205 | return true; | ||
| 206 | } | ||
| 207 | |||
| 208 | void transport_slave(matrix_row_t matrix[]) { | ||
| 209 | |||
| 210 | // TODO: if MATRIX_COLS > 8 change to pack() | ||
| 211 | for (int i = 0; i < ROWS_PER_HAND; ++i) | ||
| 212 | { | ||
| 213 | serial_s2m_buffer.smatrix[i] = matrix[i]; | ||
| 214 | } | ||
| 215 | #ifdef BACKLIGHT_ENABLE | ||
| 216 | backlight_set(serial_m2s_buffer.backlight_level); | ||
| 217 | #endif | ||
| 218 | #if defined(RGBLIGHT_ENABLE) && defined(RGBLIGHT_SPLIT) | ||
| 219 | // Add serial implementation for RGB here | ||
| 220 | #endif | ||
| 221 | |||
| 222 | } | ||
| 223 | |||
| 224 | #endif | ||
diff --git a/quantum/split_common/transport.h b/quantum/split_common/transport.h new file mode 100644 index 000000000..ccce57e44 --- /dev/null +++ b/quantum/split_common/transport.h | |||
| @@ -0,0 +1,10 @@ | |||
| 1 | #pragma once | ||
| 2 | |||
| 3 | #include <common/matrix.h> | ||
| 4 | |||
| 5 | void transport_master_init(void); | ||
| 6 | void transport_slave_init(void); | ||
| 7 | |||
| 8 | // returns false if valid data not received from slave | ||
| 9 | bool transport_master(matrix_row_t matrix[]); | ||
| 10 | void transport_slave(matrix_row_t matrix[]); | ||
diff --git a/quantum/stm32/chconf.h b/quantum/stm32/chconf.h new file mode 100644 index 000000000..1d9f12ff1 --- /dev/null +++ b/quantum/stm32/chconf.h | |||
| @@ -0,0 +1,520 @@ | |||
| 1 | /* | ||
| 2 | ChibiOS - Copyright (C) 2006..2016 Giovanni Di Sirio | ||
| 3 | |||
| 4 | Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 5 | you may not use this file except in compliance with the License. | ||
| 6 | You may obtain a copy of the License at | ||
| 7 | |||
| 8 | http://www.apache.org/licenses/LICENSE-2.0 | ||
| 9 | |||
| 10 | Unless required by applicable law or agreed to in writing, software | ||
| 11 | distributed under the License is distributed on an "AS IS" BASIS, | ||
| 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 13 | See the License for the specific language governing permissions and | ||
| 14 | limitations under the License. | ||
| 15 | */ | ||
| 16 | |||
| 17 | /** | ||
| 18 | * @file templates/chconf.h | ||
| 19 | * @brief Configuration file template. | ||
| 20 | * @details A copy of this file must be placed in each project directory, it | ||
| 21 | * contains the application specific kernel settings. | ||
| 22 | * | ||
| 23 | * @addtogroup config | ||
| 24 | * @details Kernel related settings and hooks. | ||
| 25 | * @{ | ||
| 26 | */ | ||
| 27 | |||
| 28 | #ifndef CHCONF_H | ||
| 29 | #define CHCONF_H | ||
| 30 | |||
| 31 | #define _CHIBIOS_RT_CONF_ | ||
| 32 | |||
| 33 | /*===========================================================================*/ | ||
| 34 | /** | ||
| 35 | * @name System timers settings | ||
| 36 | * @{ | ||
| 37 | */ | ||
| 38 | /*===========================================================================*/ | ||
| 39 | |||
| 40 | /** | ||
| 41 | * @brief System time counter resolution. | ||
| 42 | * @note Allowed values are 16 or 32 bits. | ||
| 43 | */ | ||
| 44 | #define CH_CFG_ST_RESOLUTION 32 | ||
| 45 | |||
| 46 | /** | ||
| 47 | * @brief System tick frequency. | ||
| 48 | * @details Frequency of the system timer that drives the system ticks. This | ||
| 49 | * setting also defines the system tick time unit. | ||
| 50 | */ | ||
| 51 | #define CH_CFG_ST_FREQUENCY 100000 | ||
| 52 | |||
| 53 | /** | ||
| 54 | * @brief Time delta constant for the tick-less mode. | ||
| 55 | * @note If this value is zero then the system uses the classic | ||
| 56 | * periodic tick. This value represents the minimum number | ||
| 57 | * of ticks that is safe to specify in a timeout directive. | ||
| 58 | * The value one is not valid, timeouts are rounded up to | ||
| 59 | * this value. | ||
| 60 | */ | ||
| 61 | #define CH_CFG_ST_TIMEDELTA 2 | ||
| 62 | |||
| 63 | /** @} */ | ||
| 64 | |||
| 65 | /*===========================================================================*/ | ||
| 66 | /** | ||
| 67 | * @name Kernel parameters and options | ||
| 68 | * @{ | ||
| 69 | */ | ||
| 70 | /*===========================================================================*/ | ||
| 71 | |||
| 72 | /** | ||
| 73 | * @brief Round robin interval. | ||
| 74 | * @details This constant is the number of system ticks allowed for the | ||
| 75 | * threads before preemption occurs. Setting this value to zero | ||
| 76 | * disables the preemption for threads with equal priority and the | ||
| 77 | * round robin becomes cooperative. Note that higher priority | ||
| 78 | * threads can still preempt, the kernel is always preemptive. | ||
| 79 | * @note Disabling the round robin preemption makes the kernel more compact | ||
| 80 | * and generally faster. | ||
| 81 | * @note The round robin preemption is not supported in tickless mode and | ||
| 82 | * must be set to zero in that case. | ||
| 83 | */ | ||
| 84 | #define CH_CFG_TIME_QUANTUM 0 | ||
| 85 | |||
| 86 | /** | ||
| 87 | * @brief Managed RAM size. | ||
| 88 | * @details Size of the RAM area to be managed by the OS. If set to zero | ||
| 89 | * then the whole available RAM is used. The core memory is made | ||
| 90 | * available to the heap allocator and/or can be used directly through | ||
| 91 | * the simplified core memory allocator. | ||
| 92 | * | ||
| 93 | * @note In order to let the OS manage the whole RAM the linker script must | ||
| 94 | * provide the @p __heap_base__ and @p __heap_end__ symbols. | ||
| 95 | * @note Requires @p CH_CFG_USE_MEMCORE. | ||
| 96 | */ | ||
| 97 | #define CH_CFG_MEMCORE_SIZE 0 | ||
| 98 | |||
| 99 | /** | ||
| 100 | * @brief Idle thread automatic spawn suppression. | ||
| 101 | * @details When this option is activated the function @p chSysInit() | ||
| 102 | * does not spawn the idle thread. The application @p main() | ||
| 103 | * function becomes the idle thread and must implement an | ||
| 104 | * infinite loop. | ||
| 105 | */ | ||
| 106 | #define CH_CFG_NO_IDLE_THREAD FALSE | ||
| 107 | |||
| 108 | /** @} */ | ||
| 109 | |||
| 110 | /*===========================================================================*/ | ||
| 111 | /** | ||
| 112 | * @name Performance options | ||
| 113 | * @{ | ||
| 114 | */ | ||
| 115 | /*===========================================================================*/ | ||
| 116 | |||
| 117 | /** | ||
| 118 | * @brief OS optimization. | ||
| 119 | * @details If enabled then time efficient rather than space efficient code | ||
| 120 | * is used when two possible implementations exist. | ||
| 121 | * | ||
| 122 | * @note This is not related to the compiler optimization options. | ||
| 123 | * @note The default is @p TRUE. | ||
| 124 | */ | ||
| 125 | #define CH_CFG_OPTIMIZE_SPEED TRUE | ||
| 126 | |||
| 127 | /** @} */ | ||
| 128 | |||
| 129 | /*===========================================================================*/ | ||
| 130 | /** | ||
| 131 | * @name Subsystem options | ||
| 132 | * @{ | ||
| 133 | */ | ||
| 134 | /*===========================================================================*/ | ||
| 135 | |||
| 136 | /** | ||
| 137 | * @brief Time Measurement APIs. | ||
| 138 | * @details If enabled then the time measurement APIs are included in | ||
| 139 | * the kernel. | ||
| 140 | * | ||
| 141 | * @note The default is @p TRUE. | ||
| 142 | */ | ||
| 143 | #define CH_CFG_USE_TM TRUE | ||
| 144 | |||
| 145 | /** | ||
| 146 | * @brief Threads registry APIs. | ||
| 147 | * @details If enabled then the registry APIs are included in the kernel. | ||
| 148 | * | ||
| 149 | * @note The default is @p TRUE. | ||
| 150 | */ | ||
| 151 | #define CH_CFG_USE_REGISTRY TRUE | ||
| 152 | |||
| 153 | /** | ||
| 154 | * @brief Threads synchronization APIs. | ||
| 155 | * @details If enabled then the @p chThdWait() function is included in | ||
| 156 | * the kernel. | ||
| 157 | * | ||
| 158 | * @note The default is @p TRUE. | ||
| 159 | */ | ||
| 160 | #define CH_CFG_USE_WAITEXIT TRUE | ||
| 161 | |||
| 162 | /** | ||
| 163 | * @brief Semaphores APIs. | ||
| 164 | * @details If enabled then the Semaphores APIs are included in the kernel. | ||
| 165 | * | ||
| 166 | * @note The default is @p TRUE. | ||
| 167 | */ | ||
| 168 | #define CH_CFG_USE_SEMAPHORES TRUE | ||
| 169 | |||
| 170 | /** | ||
| 171 | * @brief Semaphores queuing mode. | ||
| 172 | * @details If enabled then the threads are enqueued on semaphores by | ||
| 173 | * priority rather than in FIFO order. | ||
| 174 | * | ||
| 175 | * @note The default is @p FALSE. Enable this if you have special | ||
| 176 | * requirements. | ||
| 177 | * @note Requires @p CH_CFG_USE_SEMAPHORES. | ||
| 178 | */ | ||
| 179 | #define CH_CFG_USE_SEMAPHORES_PRIORITY FALSE | ||
| 180 | |||
| 181 | /** | ||
| 182 | * @brief Mutexes APIs. | ||
| 183 | * @details If enabled then the mutexes APIs are included in the kernel. | ||
| 184 | * | ||
| 185 | * @note The default is @p TRUE. | ||
| 186 | */ | ||
| 187 | #define CH_CFG_USE_MUTEXES TRUE | ||
| 188 | |||
| 189 | /** | ||
| 190 | * @brief Enables recursive behavior on mutexes. | ||
| 191 | * @note Recursive mutexes are heavier and have an increased | ||
| 192 | * memory footprint. | ||
| 193 | * | ||
| 194 | * @note The default is @p FALSE. | ||
| 195 | * @note Requires @p CH_CFG_USE_MUTEXES. | ||
| 196 | */ | ||
| 197 | #define CH_CFG_USE_MUTEXES_RECURSIVE FALSE | ||
| 198 | |||
| 199 | /** | ||
| 200 | * @brief Conditional Variables APIs. | ||
| 201 | * @details If enabled then the conditional variables APIs are included | ||
| 202 | * in the kernel. | ||
| 203 | * | ||
| 204 | * @note The default is @p TRUE. | ||
| 205 | * @note Requires @p CH_CFG_USE_MUTEXES. | ||
| 206 | */ | ||
| 207 | #define CH_CFG_USE_CONDVARS TRUE | ||
| 208 | |||
| 209 | /** | ||
| 210 | * @brief Conditional Variables APIs with timeout. | ||
| 211 | * @details If enabled then the conditional variables APIs with timeout | ||
| 212 | * specification are included in the kernel. | ||
| 213 | * | ||
| 214 | * @note The default is @p TRUE. | ||
| 215 | * @note Requires @p CH_CFG_USE_CONDVARS. | ||
| 216 | */ | ||
| 217 | #define CH_CFG_USE_CONDVARS_TIMEOUT TRUE | ||
| 218 | |||
| 219 | /** | ||
| 220 | * @brief Events Flags APIs. | ||
| 221 | * @details If enabled then the event flags APIs are included in the kernel. | ||
| 222 | * | ||
| 223 | * @note The default is @p TRUE. | ||
| 224 | */ | ||
| 225 | #define CH_CFG_USE_EVENTS TRUE | ||
| 226 | |||
| 227 | /** | ||
| 228 | * @brief Events Flags APIs with timeout. | ||
| 229 | * @details If enabled then the events APIs with timeout specification | ||
| 230 | * are included in the kernel. | ||
| 231 | * | ||
| 232 | * @note The default is @p TRUE. | ||
| 233 | * @note Requires @p CH_CFG_USE_EVENTS. | ||
| 234 | */ | ||
| 235 | #define CH_CFG_USE_EVENTS_TIMEOUT TRUE | ||
| 236 | |||
| 237 | /** | ||
| 238 | * @brief Synchronous Messages APIs. | ||
| 239 | * @details If enabled then the synchronous messages APIs are included | ||
| 240 | * in the kernel. | ||
| 241 | * | ||
| 242 | * @note The default is @p TRUE. | ||
| 243 | */ | ||
| 244 | #define CH_CFG_USE_MESSAGES TRUE | ||
| 245 | |||
| 246 | /** | ||
| 247 | * @brief Synchronous Messages queuing mode. | ||
| 248 | * @details If enabled then messages are served by priority rather than in | ||
| 249 | * FIFO order. | ||
| 250 | * | ||
| 251 | * @note The default is @p FALSE. Enable this if you have special | ||
| 252 | * requirements. | ||
| 253 | * @note Requires @p CH_CFG_USE_MESSAGES. | ||
| 254 | */ | ||
| 255 | #define CH_CFG_USE_MESSAGES_PRIORITY TRUE | ||
| 256 | |||
| 257 | /** | ||
| 258 | * @brief Mailboxes APIs. | ||
| 259 | * @details If enabled then the asynchronous messages (mailboxes) APIs are | ||
| 260 | * included in the kernel. | ||
| 261 | * | ||
| 262 | * @note The default is @p TRUE. | ||
| 263 | * @note Requires @p CH_CFG_USE_SEMAPHORES. | ||
| 264 | */ | ||
| 265 | #define CH_CFG_USE_MAILBOXES TRUE | ||
| 266 | |||
| 267 | /** | ||
| 268 | * @brief Core Memory Manager APIs. | ||
| 269 | * @details If enabled then the core memory manager APIs are included | ||
| 270 | * in the kernel. | ||
| 271 | * | ||
| 272 | * @note The default is @p TRUE. | ||
| 273 | */ | ||
| 274 | #define CH_CFG_USE_MEMCORE TRUE | ||
| 275 | |||
| 276 | /** | ||
| 277 | * @brief Heap Allocator APIs. | ||
| 278 | * @details If enabled then the memory heap allocator APIs are included | ||
| 279 | * in the kernel. | ||
| 280 | * | ||
| 281 | * @note The default is @p TRUE. | ||
| 282 | * @note Requires @p CH_CFG_USE_MEMCORE and either @p CH_CFG_USE_MUTEXES or | ||
| 283 | * @p CH_CFG_USE_SEMAPHORES. | ||
| 284 | * @note Mutexes are recommended. | ||
| 285 | */ | ||
| 286 | #define CH_CFG_USE_HEAP TRUE | ||
| 287 | |||
| 288 | /** | ||
| 289 | * @brief Memory Pools Allocator APIs. | ||
| 290 | * @details If enabled then the memory pools allocator APIs are included | ||
| 291 | * in the kernel. | ||
| 292 | * | ||
| 293 | * @note The default is @p TRUE. | ||
| 294 | */ | ||
| 295 | #define CH_CFG_USE_MEMPOOLS TRUE | ||
| 296 | |||
| 297 | /** | ||
| 298 | * @brief Dynamic Threads APIs. | ||
| 299 | * @details If enabled then the dynamic threads creation APIs are included | ||
| 300 | * in the kernel. | ||
| 301 | * | ||
| 302 | * @note The default is @p TRUE. | ||
| 303 | * @note Requires @p CH_CFG_USE_WAITEXIT. | ||
| 304 | * @note Requires @p CH_CFG_USE_HEAP and/or @p CH_CFG_USE_MEMPOOLS. | ||
| 305 | */ | ||
| 306 | #define CH_CFG_USE_DYNAMIC TRUE | ||
| 307 | |||
| 308 | /** @} */ | ||
| 309 | |||
| 310 | /*===========================================================================*/ | ||
| 311 | /** | ||
| 312 | * @name Debug options | ||
| 313 | * @{ | ||
| 314 | */ | ||
| 315 | /*===========================================================================*/ | ||
| 316 | |||
| 317 | /** | ||
| 318 | * @brief Debug option, kernel statistics. | ||
| 319 | * | ||
| 320 | * @note The default is @p FALSE. | ||
| 321 | */ | ||
| 322 | #define CH_DBG_STATISTICS FALSE | ||
| 323 | |||
| 324 | /** | ||
| 325 | * @brief Debug option, system state check. | ||
| 326 | * @details If enabled the correct call protocol for system APIs is checked | ||
| 327 | * at runtime. | ||
| 328 | * | ||
| 329 | * @note The default is @p FALSE. | ||
| 330 | */ | ||
| 331 | #define CH_DBG_SYSTEM_STATE_CHECK FALSE | ||
| 332 | |||
| 333 | /** | ||
| 334 | * @brief Debug option, parameters checks. | ||
| 335 | * @details If enabled then the checks on the API functions input | ||
| 336 | * parameters are activated. | ||
| 337 | * | ||
| 338 | * @note The default is @p FALSE. | ||
| 339 | */ | ||
| 340 | #define CH_DBG_ENABLE_CHECKS FALSE | ||
| 341 | |||
| 342 | /** | ||
| 343 | * @brief Debug option, consistency checks. | ||
| 344 | * @details If enabled then all the assertions in the kernel code are | ||
| 345 | * activated. This includes consistency checks inside the kernel, | ||
| 346 | * runtime anomalies and port-defined checks. | ||
| 347 | * | ||
| 348 | * @note The default is @p FALSE. | ||
| 349 | */ | ||
| 350 | #define CH_DBG_ENABLE_ASSERTS FALSE | ||
| 351 | |||
| 352 | /** | ||
| 353 | * @brief Debug option, trace buffer. | ||
| 354 | * @details If enabled then the trace buffer is activated. | ||
| 355 | * | ||
| 356 | * @note The default is @p CH_DBG_TRACE_MASK_DISABLED. | ||
| 357 | */ | ||
| 358 | #define CH_DBG_TRACE_MASK CH_DBG_TRACE_MASK_DISABLED | ||
| 359 | |||
| 360 | /** | ||
| 361 | * @brief Trace buffer entries. | ||
| 362 | * @note The trace buffer is only allocated if @p CH_DBG_TRACE_MASK is | ||
| 363 | * different from @p CH_DBG_TRACE_MASK_DISABLED. | ||
| 364 | */ | ||
| 365 | #define CH_DBG_TRACE_BUFFER_SIZE 128 | ||
| 366 | |||
| 367 | /** | ||
| 368 | * @brief Debug option, stack checks. | ||
| 369 | * @details If enabled then a runtime stack check is performed. | ||
| 370 | * | ||
| 371 | * @note The default is @p FALSE. | ||
| 372 | * @note The stack check is performed in a architecture/port dependent way. | ||
| 373 | * It may not be implemented or some ports. | ||
| 374 | * @note The default failure mode is to halt the system with the global | ||
| 375 | * @p panic_msg variable set to @p NULL. | ||
| 376 | */ | ||
| 377 | #define CH_DBG_ENABLE_STACK_CHECK TRUE | ||
| 378 | |||
| 379 | /** | ||
| 380 | * @brief Debug option, stacks initialization. | ||
| 381 | * @details If enabled then the threads working area is filled with a byte | ||
| 382 | * value when a thread is created. This can be useful for the | ||
| 383 | * runtime measurement of the used stack. | ||
| 384 | * | ||
| 385 | * @note The default is @p FALSE. | ||
| 386 | */ | ||
| 387 | #define CH_DBG_FILL_THREADS FALSE | ||
| 388 | |||
| 389 | /** | ||
| 390 | * @brief Debug option, threads profiling. | ||
| 391 | * @details If enabled then a field is added to the @p thread_t structure that | ||
| 392 | * counts the system ticks occurred while executing the thread. | ||
| 393 | * | ||
| 394 | * @note The default is @p FALSE. | ||
| 395 | * @note This debug option is not currently compatible with the | ||
| 396 | * tickless mode. | ||
| 397 | */ | ||
| 398 | #define CH_DBG_THREADS_PROFILING FALSE | ||
| 399 | |||
| 400 | /** @} */ | ||
| 401 | |||
| 402 | /*===========================================================================*/ | ||
| 403 | /** | ||
| 404 | * @name Kernel hooks | ||
| 405 | * @{ | ||
| 406 | */ | ||
| 407 | /*===========================================================================*/ | ||
| 408 | |||
| 409 | /** | ||
| 410 | * @brief Threads descriptor structure extension. | ||
| 411 | * @details User fields added to the end of the @p thread_t structure. | ||
| 412 | */ | ||
| 413 | #define CH_CFG_THREAD_EXTRA_FIELDS \ | ||
| 414 | /* Add threads custom fields here.*/ | ||
| 415 | |||
| 416 | /** | ||
| 417 | * @brief Threads initialization hook. | ||
| 418 | * @details User initialization code added to the @p chThdInit() API. | ||
| 419 | * | ||
| 420 | * @note It is invoked from within @p chThdInit() and implicitly from all | ||
| 421 | * the threads creation APIs. | ||
| 422 | */ | ||
| 423 | #define CH_CFG_THREAD_INIT_HOOK(tp) { \ | ||
| 424 | /* Add threads initialization code here.*/ \ | ||
| 425 | } | ||
| 426 | |||
| 427 | /** | ||
| 428 | * @brief Threads finalization hook. | ||
| 429 | * @details User finalization code added to the @p chThdExit() API. | ||
| 430 | */ | ||
| 431 | #define CH_CFG_THREAD_EXIT_HOOK(tp) { \ | ||
| 432 | /* Add threads finalization code here.*/ \ | ||
| 433 | } | ||
| 434 | |||
| 435 | /** | ||
| 436 | * @brief Context switch hook. | ||
| 437 | * @details This hook is invoked just before switching between threads. | ||
| 438 | */ | ||
| 439 | #define CH_CFG_CONTEXT_SWITCH_HOOK(ntp, otp) { \ | ||
| 440 | /* Context switch code here.*/ \ | ||
| 441 | } | ||
| 442 | |||
| 443 | /** | ||
| 444 | * @brief ISR enter hook. | ||
| 445 | */ | ||
| 446 | #define CH_CFG_IRQ_PROLOGUE_HOOK() { \ | ||
| 447 | /* IRQ prologue code here.*/ \ | ||
| 448 | } | ||
| 449 | |||
| 450 | /** | ||
| 451 | * @brief ISR exit hook. | ||
| 452 | */ | ||
| 453 | #define CH_CFG_IRQ_EPILOGUE_HOOK() { \ | ||
| 454 | /* IRQ epilogue code here.*/ \ | ||
| 455 | } | ||
| 456 | |||
| 457 | /** | ||
| 458 | * @brief Idle thread enter hook. | ||
| 459 | * @note This hook is invoked within a critical zone, no OS functions | ||
| 460 | * should be invoked from here. | ||
| 461 | * @note This macro can be used to activate a power saving mode. | ||
| 462 | */ | ||
| 463 | #define CH_CFG_IDLE_ENTER_HOOK() { \ | ||
| 464 | /* Idle-enter code here.*/ \ | ||
| 465 | } | ||
| 466 | |||
| 467 | /** | ||
| 468 | * @brief Idle thread leave hook. | ||
| 469 | * @note This hook is invoked within a critical zone, no OS functions | ||
| 470 | * should be invoked from here. | ||
| 471 | * @note This macro can be used to deactivate a power saving mode. | ||
| 472 | */ | ||
| 473 | #define CH_CFG_IDLE_LEAVE_HOOK() { \ | ||
| 474 | /* Idle-leave code here.*/ \ | ||
| 475 | } | ||
| 476 | |||
| 477 | /** | ||
| 478 | * @brief Idle Loop hook. | ||
| 479 | * @details This hook is continuously invoked by the idle thread loop. | ||
| 480 | */ | ||
| 481 | #define CH_CFG_IDLE_LOOP_HOOK() { \ | ||
| 482 | /* Idle loop code here.*/ \ | ||
| 483 | } | ||
| 484 | |||
| 485 | /** | ||
| 486 | * @brief System tick event hook. | ||
| 487 | * @details This hook is invoked in the system tick handler immediately | ||
| 488 | * after processing the virtual timers queue. | ||
| 489 | */ | ||
| 490 | #define CH_CFG_SYSTEM_TICK_HOOK() { \ | ||
| 491 | /* System tick event code here.*/ \ | ||
| 492 | } | ||
| 493 | |||
| 494 | /** | ||
| 495 | * @brief System halt hook. | ||
| 496 | * @details This hook is invoked in case to a system halting error before | ||
| 497 | * the system is halted. | ||
| 498 | */ | ||
| 499 | #define CH_CFG_SYSTEM_HALT_HOOK(reason) { \ | ||
| 500 | /* System halt code here.*/ \ | ||
| 501 | } | ||
| 502 | |||
| 503 | /** | ||
| 504 | * @brief Trace hook. | ||
| 505 | * @details This hook is invoked each time a new record is written in the | ||
| 506 | * trace buffer. | ||
| 507 | */ | ||
| 508 | #define CH_CFG_TRACE_HOOK(tep) { \ | ||
| 509 | /* Trace code here.*/ \ | ||
| 510 | } | ||
| 511 | |||
| 512 | /** @} */ | ||
| 513 | |||
| 514 | /*===========================================================================*/ | ||
| 515 | /* Port-specific settings (override port settings defaulted in chcore.h). */ | ||
| 516 | /*===========================================================================*/ | ||
| 517 | |||
| 518 | #endif /* CHCONF_H */ | ||
| 519 | |||
| 520 | /** @} */ | ||
diff --git a/quantum/stm32/halconf.h b/quantum/stm32/halconf.h new file mode 100644 index 000000000..8fe8e0c6f --- /dev/null +++ b/quantum/stm32/halconf.h | |||
| @@ -0,0 +1,388 @@ | |||
| 1 | /* | ||
| 2 | ChibiOS - Copyright (C) 2006..2016 Giovanni Di Sirio | ||
| 3 | |||
| 4 | Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 5 | you may not use this file except in compliance with the License. | ||
| 6 | You may obtain a copy of the License at | ||
| 7 | |||
| 8 | http://www.apache.org/licenses/LICENSE-2.0 | ||
| 9 | |||
| 10 | Unless required by applicable law or agreed to in writing, software | ||
| 11 | distributed under the License is distributed on an "AS IS" BASIS, | ||
| 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 13 | See the License for the specific language governing permissions and | ||
| 14 | limitations under the License. | ||
| 15 | */ | ||
| 16 | |||
| 17 | /** | ||
| 18 | * @file templates/halconf.h | ||
| 19 | * @brief HAL configuration header. | ||
| 20 | * @details HAL configuration file, this file allows to enable or disable the | ||
| 21 | * various device drivers from your application. You may also use | ||
| 22 | * this file in order to override the device drivers default settings. | ||
| 23 | * | ||
| 24 | * @addtogroup HAL_CONF | ||
| 25 | * @{ | ||
| 26 | */ | ||
| 27 | |||
| 28 | #ifndef HALCONF_H | ||
| 29 | #define HALCONF_H | ||
| 30 | |||
| 31 | #include "mcuconf.h" | ||
| 32 | |||
| 33 | /** | ||
| 34 | * @brief Enables the PAL subsystem. | ||
| 35 | */ | ||
| 36 | #if !defined(HAL_USE_PAL) || defined(__DOXYGEN__) | ||
| 37 | #define HAL_USE_PAL TRUE | ||
| 38 | #endif | ||
| 39 | |||
| 40 | /** | ||
| 41 | * @brief Enables the ADC subsystem. | ||
| 42 | */ | ||
| 43 | #if !defined(HAL_USE_ADC) || defined(__DOXYGEN__) | ||
| 44 | #define HAL_USE_ADC FALSE | ||
| 45 | #endif | ||
| 46 | |||
| 47 | /** | ||
| 48 | * @brief Enables the CAN subsystem. | ||
| 49 | */ | ||
| 50 | #if !defined(HAL_USE_CAN) || defined(__DOXYGEN__) | ||
| 51 | #define HAL_USE_CAN FALSE | ||
| 52 | #endif | ||
| 53 | |||
| 54 | /** | ||
| 55 | * @brief Enables the DAC subsystem. | ||
| 56 | */ | ||
| 57 | #if !defined(HAL_USE_DAC) || defined(__DOXYGEN__) | ||
| 58 | #define HAL_USE_DAC TRUE | ||
| 59 | #endif | ||
| 60 | |||
| 61 | /** | ||
| 62 | * @brief Enables the EXT subsystem. | ||
| 63 | */ | ||
| 64 | #if !defined(HAL_USE_EXT) || defined(__DOXYGEN__) | ||
| 65 | #define HAL_USE_EXT FALSE | ||
| 66 | #endif | ||
| 67 | |||
| 68 | /** | ||
| 69 | * @brief Enables the GPT subsystem. | ||
| 70 | */ | ||
| 71 | #if !defined(HAL_USE_GPT) || defined(__DOXYGEN__) | ||
| 72 | #define HAL_USE_GPT TRUE | ||
| 73 | #endif | ||
| 74 | |||
| 75 | /** | ||
| 76 | * @brief Enables the I2C subsystem. | ||
| 77 | */ | ||
| 78 | #if !defined(HAL_USE_I2C) || defined(__DOXYGEN__) | ||
| 79 | #define HAL_USE_I2C FALSE | ||
| 80 | #endif | ||
| 81 | |||
| 82 | /** | ||
| 83 | * @brief Enables the I2S subsystem. | ||
| 84 | */ | ||
| 85 | #if !defined(HAL_USE_I2S) || defined(__DOXYGEN__) | ||
| 86 | #define HAL_USE_I2S FALSE | ||
| 87 | #endif | ||
| 88 | |||
| 89 | /** | ||
| 90 | * @brief Enables the ICU subsystem. | ||
| 91 | */ | ||
| 92 | #if !defined(HAL_USE_ICU) || defined(__DOXYGEN__) | ||
| 93 | #define HAL_USE_ICU FALSE | ||
| 94 | #endif | ||
| 95 | |||
| 96 | /** | ||
| 97 | * @brief Enables the MAC subsystem. | ||
| 98 | */ | ||
| 99 | #if !defined(HAL_USE_MAC) || defined(__DOXYGEN__) | ||
| 100 | #define HAL_USE_MAC FALSE | ||
| 101 | #endif | ||
| 102 | |||
| 103 | /** | ||
| 104 | * @brief Enables the MMC_SPI subsystem. | ||
| 105 | */ | ||
| 106 | #if !defined(HAL_USE_MMC_SPI) || defined(__DOXYGEN__) | ||
| 107 | #define HAL_USE_MMC_SPI FALSE | ||
| 108 | #endif | ||
| 109 | |||
| 110 | /** | ||
| 111 | * @brief Enables the PWM subsystem. | ||
| 112 | */ | ||
| 113 | #if !defined(HAL_USE_PWM) || defined(__DOXYGEN__) | ||
| 114 | #define HAL_USE_PWM FALSE | ||
| 115 | #endif | ||
| 116 | |||
| 117 | /** | ||
| 118 | * @brief Enables the QSPI subsystem. | ||
| 119 | */ | ||
| 120 | #if !defined(HAL_USE_QSPI) || defined(__DOXYGEN__) | ||
| 121 | #define HAL_USE_QSPI FALSE | ||
| 122 | #endif | ||
| 123 | |||
| 124 | /** | ||
| 125 | * @brief Enables the RTC subsystem. | ||
| 126 | */ | ||
| 127 | #if !defined(HAL_USE_RTC) || defined(__DOXYGEN__) | ||
| 128 | #define HAL_USE_RTC FALSE | ||
| 129 | #endif | ||
| 130 | |||
| 131 | /** | ||
| 132 | * @brief Enables the SDC subsystem. | ||
| 133 | */ | ||
| 134 | #if !defined(HAL_USE_SDC) || defined(__DOXYGEN__) | ||
| 135 | #define HAL_USE_SDC FALSE | ||
| 136 | #endif | ||
| 137 | |||
| 138 | /** | ||
| 139 | * @brief Enables the SERIAL subsystem. | ||
| 140 | */ | ||
| 141 | #if !defined(HAL_USE_SERIAL) || defined(__DOXYGEN__) | ||
| 142 | #define HAL_USE_SERIAL FALSE | ||
| 143 | #endif | ||
| 144 | |||
| 145 | /** | ||
| 146 | * @brief Enables the SERIAL over USB subsystem. | ||
| 147 | */ | ||
| 148 | #if !defined(HAL_USE_SERIAL_USB) || defined(__DOXYGEN__) | ||
| 149 | #define HAL_USE_SERIAL_USB TRUE | ||
| 150 | #endif | ||
| 151 | |||
| 152 | /** | ||
| 153 | * @brief Enables the SPI subsystem. | ||
| 154 | */ | ||
| 155 | #if !defined(HAL_USE_SPI) || defined(__DOXYGEN__) | ||
| 156 | #define HAL_USE_SPI FALSE | ||
| 157 | #endif | ||
| 158 | |||
| 159 | /** | ||
| 160 | * @brief Enables the UART subsystem. | ||
| 161 | */ | ||
| 162 | #if !defined(HAL_USE_UART) || defined(__DOXYGEN__) | ||
| 163 | #define HAL_USE_UART FALSE | ||
| 164 | #endif | ||
| 165 | |||
| 166 | /** | ||
| 167 | * @brief Enables the USB subsystem. | ||
| 168 | */ | ||
| 169 | #if !defined(HAL_USE_USB) || defined(__DOXYGEN__) | ||
| 170 | #define HAL_USE_USB TRUE | ||
| 171 | #endif | ||
| 172 | |||
| 173 | /** | ||
| 174 | * @brief Enables the WDG subsystem. | ||
| 175 | */ | ||
| 176 | #if !defined(HAL_USE_WDG) || defined(__DOXYGEN__) | ||
| 177 | #define HAL_USE_WDG FALSE | ||
| 178 | #endif | ||
| 179 | |||
| 180 | /*===========================================================================*/ | ||
| 181 | /* ADC driver related settings. */ | ||
| 182 | /*===========================================================================*/ | ||
| 183 | |||
| 184 | /** | ||
| 185 | * @brief Enables synchronous APIs. | ||
| 186 | * @note Disabling this option saves both code and data space. | ||
| 187 | */ | ||
| 188 | #if !defined(ADC_USE_WAIT) || defined(__DOXYGEN__) | ||
| 189 | #define ADC_USE_WAIT TRUE | ||
| 190 | #endif | ||
| 191 | |||
| 192 | /** | ||
| 193 | * @brief Enables the @p adcAcquireBus() and @p adcReleaseBus() APIs. | ||
| 194 | * @note Disabling this option saves both code and data space. | ||
| 195 | */ | ||
| 196 | #if !defined(ADC_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__) | ||
| 197 | #define ADC_USE_MUTUAL_EXCLUSION TRUE | ||
| 198 | #endif | ||
| 199 | |||
| 200 | /*===========================================================================*/ | ||
| 201 | /* CAN driver related settings. */ | ||
| 202 | /*===========================================================================*/ | ||
| 203 | |||
| 204 | /** | ||
| 205 | * @brief Sleep mode related APIs inclusion switch. | ||
| 206 | */ | ||
| 207 | #if !defined(CAN_USE_SLEEP_MODE) || defined(__DOXYGEN__) | ||
| 208 | #define CAN_USE_SLEEP_MODE TRUE | ||
| 209 | #endif | ||
| 210 | |||
| 211 | /*===========================================================================*/ | ||
| 212 | /* I2C driver related settings. */ | ||
| 213 | /*===========================================================================*/ | ||
| 214 | |||
| 215 | /** | ||
| 216 | * @brief Enables the mutual exclusion APIs on the I2C bus. | ||
| 217 | */ | ||
| 218 | #if !defined(I2C_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__) | ||
| 219 | #define I2C_USE_MUTUAL_EXCLUSION TRUE | ||
| 220 | #endif | ||
| 221 | |||
| 222 | /*===========================================================================*/ | ||
| 223 | /* MAC driver related settings. */ | ||
| 224 | /*===========================================================================*/ | ||
| 225 | |||
| 226 | /** | ||
| 227 | * @brief Enables an event sources for incoming packets. | ||
| 228 | */ | ||
| 229 | #if !defined(MAC_USE_ZERO_COPY) || defined(__DOXYGEN__) | ||
| 230 | #define MAC_USE_ZERO_COPY FALSE | ||
| 231 | #endif | ||
| 232 | |||
| 233 | /** | ||
| 234 | * @brief Enables an event sources for incoming packets. | ||
| 235 | */ | ||
| 236 | #if !defined(MAC_USE_EVENTS) || defined(__DOXYGEN__) | ||
| 237 | #define MAC_USE_EVENTS TRUE | ||
| 238 | #endif | ||
| 239 | |||
| 240 | /*===========================================================================*/ | ||
| 241 | /* MMC_SPI driver related settings. */ | ||
| 242 | /*===========================================================================*/ | ||
| 243 | |||
| 244 | /** | ||
| 245 | * @brief Delays insertions. | ||
| 246 | * @details If enabled this options inserts delays into the MMC waiting | ||
| 247 | * routines releasing some extra CPU time for the threads with | ||
| 248 | * lower priority, this may slow down the driver a bit however. | ||
| 249 | * This option is recommended also if the SPI driver does not | ||
| 250 | * use a DMA channel and heavily loads the CPU. | ||
| 251 | */ | ||
| 252 | #if !defined(MMC_NICE_WAITING) || defined(__DOXYGEN__) | ||
| 253 | #define MMC_NICE_WAITING TRUE | ||
| 254 | #endif | ||
| 255 | |||
| 256 | /*===========================================================================*/ | ||
| 257 | /* SDC driver related settings. */ | ||
| 258 | /*===========================================================================*/ | ||
| 259 | |||
| 260 | /** | ||
| 261 | * @brief Number of initialization attempts before rejecting the card. | ||
| 262 | * @note Attempts are performed at 10mS intervals. | ||
| 263 | */ | ||
| 264 | #if !defined(SDC_INIT_RETRY) || defined(__DOXYGEN__) | ||
| 265 | #define SDC_INIT_RETRY 100 | ||
| 266 | #endif | ||
| 267 | |||
| 268 | /** | ||
| 269 | * @brief Include support for MMC cards. | ||
| 270 | * @note MMC support is not yet implemented so this option must be kept | ||
| 271 | * at @p FALSE. | ||
| 272 | */ | ||
| 273 | #if !defined(SDC_MMC_SUPPORT) || defined(__DOXYGEN__) | ||
| 274 | #define SDC_MMC_SUPPORT FALSE | ||
| 275 | #endif | ||
| 276 | |||
| 277 | /** | ||
| 278 | * @brief Delays insertions. | ||
| 279 | * @details If enabled this options inserts delays into the MMC waiting | ||
| 280 | * routines releasing some extra CPU time for the threads with | ||
| 281 | * lower priority, this may slow down the driver a bit however. | ||
| 282 | */ | ||
| 283 | #if !defined(SDC_NICE_WAITING) || defined(__DOXYGEN__) | ||
| 284 | #define SDC_NICE_WAITING TRUE | ||
| 285 | #endif | ||
| 286 | |||
| 287 | /*===========================================================================*/ | ||
| 288 | /* SERIAL driver related settings. */ | ||
| 289 | /*===========================================================================*/ | ||
| 290 | |||
| 291 | /** | ||
| 292 | * @brief Default bit rate. | ||
| 293 | * @details Configuration parameter, this is the baud rate selected for the | ||
| 294 | * default configuration. | ||
| 295 | */ | ||
| 296 | #if !defined(SERIAL_DEFAULT_BITRATE) || defined(__DOXYGEN__) | ||
| 297 | #define SERIAL_DEFAULT_BITRATE 38400 | ||
| 298 | #endif | ||
| 299 | |||
| 300 | /** | ||
| 301 | * @brief Serial buffers size. | ||
| 302 | * @details Configuration parameter, you can change the depth of the queue | ||
| 303 | * buffers depending on the requirements of your application. | ||
| 304 | * @note The default is 16 bytes for both the transmission and receive | ||
| 305 | * buffers. | ||
| 306 | */ | ||
| 307 | #if !defined(SERIAL_BUFFERS_SIZE) || defined(__DOXYGEN__) | ||
| 308 | #define SERIAL_BUFFERS_SIZE 16 | ||
| 309 | #endif | ||
| 310 | |||
| 311 | /*===========================================================================*/ | ||
| 312 | /* SERIAL_USB driver related setting. */ | ||
| 313 | /*===========================================================================*/ | ||
| 314 | |||
| 315 | /** | ||
| 316 | * @brief Serial over USB buffers size. | ||
| 317 | * @details Configuration parameter, the buffer size must be a multiple of | ||
| 318 | * the USB data endpoint maximum packet size. | ||
| 319 | * @note The default is 256 bytes for both the transmission and receive | ||
| 320 | * buffers. | ||
| 321 | */ | ||
| 322 | #if !defined(SERIAL_USB_BUFFERS_SIZE) || defined(__DOXYGEN__) | ||
| 323 | #define SERIAL_USB_BUFFERS_SIZE 1 | ||
| 324 | #endif | ||
| 325 | |||
| 326 | /** | ||
| 327 | * @brief Serial over USB number of buffers. | ||
| 328 | * @note The default is 2 buffers. | ||
| 329 | */ | ||
| 330 | #if !defined(SERIAL_USB_BUFFERS_NUMBER) || defined(__DOXYGEN__) | ||
| 331 | #define SERIAL_USB_BUFFERS_NUMBER 2 | ||
| 332 | #endif | ||
| 333 | |||
| 334 | /*===========================================================================*/ | ||
| 335 | /* SPI driver related settings. */ | ||
| 336 | /*===========================================================================*/ | ||
| 337 | |||
| 338 | /** | ||
| 339 | * @brief Enables synchronous APIs. | ||
| 340 | * @note Disabling this option saves both code and data space. | ||
| 341 | */ | ||
| 342 | #if !defined(SPI_USE_WAIT) || defined(__DOXYGEN__) | ||
| 343 | #define SPI_USE_WAIT TRUE | ||
| 344 | #endif | ||
| 345 | |||
| 346 | /** | ||
| 347 | * @brief Enables the @p spiAcquireBus() and @p spiReleaseBus() APIs. | ||
| 348 | * @note Disabling this option saves both code and data space. | ||
| 349 | */ | ||
| 350 | #if !defined(SPI_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__) | ||
| 351 | #define SPI_USE_MUTUAL_EXCLUSION TRUE | ||
| 352 | #endif | ||
| 353 | |||
| 354 | /*===========================================================================*/ | ||
| 355 | /* UART driver related settings. */ | ||
| 356 | /*===========================================================================*/ | ||
| 357 | |||
| 358 | /** | ||
| 359 | * @brief Enables synchronous APIs. | ||
| 360 | * @note Disabling this option saves both code and data space. | ||
| 361 | */ | ||
| 362 | #if !defined(UART_USE_WAIT) || defined(__DOXYGEN__) | ||
| 363 | #define UART_USE_WAIT FALSE | ||
| 364 | #endif | ||
| 365 | |||
| 366 | /** | ||
| 367 | * @brief Enables the @p uartAcquireBus() and @p uartReleaseBus() APIs. | ||
| 368 | * @note Disabling this option saves both code and data space. | ||
| 369 | */ | ||
| 370 | #if !defined(UART_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__) | ||
| 371 | #define UART_USE_MUTUAL_EXCLUSION FALSE | ||
| 372 | #endif | ||
| 373 | |||
| 374 | /*===========================================================================*/ | ||
| 375 | /* USB driver related settings. */ | ||
| 376 | /*===========================================================================*/ | ||
| 377 | |||
| 378 | /** | ||
| 379 | * @brief Enables synchronous APIs. | ||
| 380 | * @note Disabling this option saves both code and data space. | ||
| 381 | */ | ||
| 382 | #if !defined(USB_USE_WAIT) || defined(__DOXYGEN__) | ||
| 383 | #define USB_USE_WAIT TRUE | ||
| 384 | #endif | ||
| 385 | |||
| 386 | #endif /* HALCONF_H */ | ||
| 387 | |||
| 388 | /** @} */ | ||
diff --git a/quantum/stm32/mcuconf.h b/quantum/stm32/mcuconf.h new file mode 100644 index 000000000..7c3c6e570 --- /dev/null +++ b/quantum/stm32/mcuconf.h | |||
| @@ -0,0 +1,257 @@ | |||
| 1 | /* | ||
| 2 | ChibiOS - Copyright (C) 2006..2016 Giovanni Di Sirio | ||
| 3 | |||
| 4 | Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 5 | you may not use this file except in compliance with the License. | ||
| 6 | You may obtain a copy of the License at | ||
| 7 | |||
| 8 | http://www.apache.org/licenses/LICENSE-2.0 | ||
| 9 | |||
| 10 | Unless required by applicable law or agreed to in writing, software | ||
| 11 | distributed under the License is distributed on an "AS IS" BASIS, | ||
| 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 13 | See the License for the specific language governing permissions and | ||
| 14 | limitations under the License. | ||
| 15 | */ | ||
| 16 | |||
| 17 | #ifndef MCUCONF_H | ||
| 18 | #define MCUCONF_H | ||
| 19 | |||
| 20 | /* | ||
| 21 | * STM32F3xx drivers configuration. | ||
| 22 | * The following settings override the default settings present in | ||
| 23 | * the various device driver implementation headers. | ||
| 24 | * Note that the settings for each driver only have effect if the whole | ||
| 25 | * driver is enabled in halconf.h. | ||
| 26 | * | ||
| 27 | * IRQ priorities: | ||
| 28 | * 15...0 Lowest...Highest. | ||
| 29 | * | ||
| 30 | * DMA priorities: | ||
| 31 | * 0...3 Lowest...Highest. | ||
| 32 | */ | ||
| 33 | |||
| 34 | #define STM32F3xx_MCUCONF | ||
| 35 | |||
| 36 | /* | ||
| 37 | * HAL driver system settings. | ||
| 38 | */ | ||
| 39 | #define STM32_NO_INIT FALSE | ||
| 40 | #define STM32_PVD_ENABLE FALSE | ||
| 41 | #define STM32_PLS STM32_PLS_LEV0 | ||
| 42 | #define STM32_HSI_ENABLED TRUE | ||
| 43 | #define STM32_LSI_ENABLED TRUE | ||
| 44 | #define STM32_HSE_ENABLED TRUE | ||
| 45 | #define STM32_LSE_ENABLED FALSE | ||
| 46 | #define STM32_SW STM32_SW_PLL | ||
| 47 | #define STM32_PLLSRC STM32_PLLSRC_HSE | ||
| 48 | #define STM32_PREDIV_VALUE 1 | ||
| 49 | #define STM32_PLLMUL_VALUE 9 | ||
| 50 | #define STM32_HPRE STM32_HPRE_DIV1 | ||
| 51 | #define STM32_PPRE1 STM32_PPRE1_DIV2 | ||
| 52 | #define STM32_PPRE2 STM32_PPRE2_DIV2 | ||
| 53 | #define STM32_MCOSEL STM32_MCOSEL_NOCLOCK | ||
| 54 | #define STM32_ADC12PRES STM32_ADC12PRES_DIV1 | ||
| 55 | #define STM32_ADC34PRES STM32_ADC34PRES_DIV1 | ||
| 56 | #define STM32_USART1SW STM32_USART1SW_PCLK | ||
| 57 | #define STM32_USART2SW STM32_USART2SW_PCLK | ||
| 58 | #define STM32_USART3SW STM32_USART3SW_PCLK | ||
| 59 | #define STM32_UART4SW STM32_UART4SW_PCLK | ||
| 60 | #define STM32_UART5SW STM32_UART5SW_PCLK | ||
| 61 | #define STM32_I2C1SW STM32_I2C1SW_SYSCLK | ||
| 62 | #define STM32_I2C2SW STM32_I2C2SW_SYSCLK | ||
| 63 | #define STM32_TIM1SW STM32_TIM1SW_PCLK2 | ||
| 64 | #define STM32_TIM8SW STM32_TIM8SW_PCLK2 | ||
| 65 | #define STM32_RTCSEL STM32_RTCSEL_LSI | ||
| 66 | #define STM32_USB_CLOCK_REQUIRED TRUE | ||
| 67 | #define STM32_USBPRE STM32_USBPRE_DIV1P5 | ||
| 68 | |||
| 69 | #undef STM32_HSE_BYPASS | ||
| 70 | // #error "oh no" | ||
| 71 | // #endif | ||
| 72 | |||
| 73 | /* | ||
| 74 | * ADC driver system settings. | ||
| 75 | */ | ||
| 76 | #define STM32_ADC_DUAL_MODE FALSE | ||
| 77 | #define STM32_ADC_COMPACT_SAMPLES FALSE | ||
| 78 | #define STM32_ADC_USE_ADC1 FALSE | ||
| 79 | #define STM32_ADC_USE_ADC2 FALSE | ||
| 80 | #define STM32_ADC_USE_ADC3 FALSE | ||
| 81 | #define STM32_ADC_USE_ADC4 FALSE | ||
| 82 | #define STM32_ADC_ADC1_DMA_STREAM STM32_DMA_STREAM_ID(1, 1) | ||
| 83 | #define STM32_ADC_ADC2_DMA_STREAM STM32_DMA_STREAM_ID(2, 1) | ||
| 84 | #define STM32_ADC_ADC3_DMA_STREAM STM32_DMA_STREAM_ID(2, 5) | ||
| 85 | #define STM32_ADC_ADC4_DMA_STREAM STM32_DMA_STREAM_ID(2, 2) | ||
| 86 | #define STM32_ADC_ADC1_DMA_PRIORITY 2 | ||
| 87 | #define STM32_ADC_ADC2_DMA_PRIORITY 2 | ||
| 88 | #define STM32_ADC_ADC3_DMA_PRIORITY 2 | ||
| 89 | #define STM32_ADC_ADC4_DMA_PRIORITY 2 | ||
| 90 | #define STM32_ADC_ADC12_IRQ_PRIORITY 5 | ||
| 91 | #define STM32_ADC_ADC3_IRQ_PRIORITY 5 | ||
| 92 | #define STM32_ADC_ADC4_IRQ_PRIORITY 5 | ||
| 93 | #define STM32_ADC_ADC1_DMA_IRQ_PRIORITY 5 | ||
| 94 | #define STM32_ADC_ADC2_DMA_IRQ_PRIORITY 5 | ||
| 95 | #define STM32_ADC_ADC3_DMA_IRQ_PRIORITY 5 | ||
| 96 | #define STM32_ADC_ADC4_DMA_IRQ_PRIORITY 5 | ||
| 97 | #define STM32_ADC_ADC12_CLOCK_MODE ADC_CCR_CKMODE_AHB_DIV1 | ||
| 98 | #define STM32_ADC_ADC34_CLOCK_MODE ADC_CCR_CKMODE_AHB_DIV1 | ||
| 99 | |||
| 100 | /* | ||
| 101 | * CAN driver system settings. | ||
| 102 | */ | ||
| 103 | #define STM32_CAN_USE_CAN1 FALSE | ||
| 104 | #define STM32_CAN_CAN1_IRQ_PRIORITY 11 | ||
| 105 | |||
| 106 | /* | ||
| 107 | * DAC driver system settings. | ||
| 108 | */ | ||
| 109 | #define STM32_DAC_DUAL_MODE FALSE | ||
| 110 | #define STM32_DAC_USE_DAC1_CH1 TRUE | ||
| 111 | #define STM32_DAC_USE_DAC1_CH2 TRUE | ||
| 112 | #define STM32_DAC_DAC1_CH1_IRQ_PRIORITY 10 | ||
| 113 | #define STM32_DAC_DAC1_CH2_IRQ_PRIORITY 10 | ||
| 114 | #define STM32_DAC_DAC1_CH1_DMA_PRIORITY 2 | ||
| 115 | #define STM32_DAC_DAC1_CH2_DMA_PRIORITY 2 | ||
| 116 | |||
| 117 | /* | ||
| 118 | * EXT driver system settings. | ||
| 119 | */ | ||
| 120 | #define STM32_EXT_EXTI0_IRQ_PRIORITY 6 | ||
| 121 | #define STM32_EXT_EXTI1_IRQ_PRIORITY 6 | ||
| 122 | #define STM32_EXT_EXTI2_IRQ_PRIORITY 6 | ||
| 123 | #define STM32_EXT_EXTI3_IRQ_PRIORITY 6 | ||
| 124 | #define STM32_EXT_EXTI4_IRQ_PRIORITY 6 | ||
| 125 | #define STM32_EXT_EXTI5_9_IRQ_PRIORITY 6 | ||
| 126 | #define STM32_EXT_EXTI10_15_IRQ_PRIORITY 6 | ||
| 127 | #define STM32_EXT_EXTI16_IRQ_PRIORITY 6 | ||
| 128 | #define STM32_EXT_EXTI17_IRQ_PRIORITY 6 | ||
| 129 | #define STM32_EXT_EXTI18_IRQ_PRIORITY 6 | ||
| 130 | #define STM32_EXT_EXTI19_IRQ_PRIORITY 6 | ||
| 131 | #define STM32_EXT_EXTI20_IRQ_PRIORITY 6 | ||
| 132 | #define STM32_EXT_EXTI21_22_29_IRQ_PRIORITY 6 | ||
| 133 | #define STM32_EXT_EXTI30_32_IRQ_PRIORITY 6 | ||
| 134 | #define STM32_EXT_EXTI33_IRQ_PRIORITY 6 | ||
| 135 | |||
| 136 | /* | ||
| 137 | * GPT driver system settings. | ||
| 138 | */ | ||
| 139 | #define STM32_GPT_USE_TIM1 FALSE | ||
| 140 | #define STM32_GPT_USE_TIM2 FALSE | ||
| 141 | #define STM32_GPT_USE_TIM3 FALSE | ||
| 142 | #define STM32_GPT_USE_TIM4 FALSE | ||
| 143 | #define STM32_GPT_USE_TIM6 TRUE | ||
| 144 | #define STM32_GPT_USE_TIM7 TRUE | ||
| 145 | #define STM32_GPT_USE_TIM8 TRUE | ||
| 146 | #define STM32_GPT_TIM1_IRQ_PRIORITY 7 | ||
| 147 | #define STM32_GPT_TIM2_IRQ_PRIORITY 7 | ||
| 148 | #define STM32_GPT_TIM3_IRQ_PRIORITY 7 | ||
| 149 | #define STM32_GPT_TIM4_IRQ_PRIORITY 7 | ||
| 150 | #define STM32_GPT_TIM6_IRQ_PRIORITY 7 | ||
| 151 | #define STM32_GPT_TIM7_IRQ_PRIORITY 7 | ||
| 152 | #define STM32_GPT_TIM8_IRQ_PRIORITY 7 | ||
| 153 | |||
| 154 | /* | ||
| 155 | * I2C driver system settings. | ||
| 156 | */ | ||
| 157 | #define STM32_I2C_USE_I2C1 FALSE | ||
| 158 | #define STM32_I2C_USE_I2C2 FALSE | ||
| 159 | #define STM32_I2C_BUSY_TIMEOUT 50 | ||
| 160 | #define STM32_I2C_I2C1_IRQ_PRIORITY 10 | ||
| 161 | #define STM32_I2C_I2C2_IRQ_PRIORITY 10 | ||
| 162 | #define STM32_I2C_USE_DMA TRUE | ||
| 163 | #define STM32_I2C_I2C1_DMA_PRIORITY 1 | ||
| 164 | #define STM32_I2C_I2C2_DMA_PRIORITY 1 | ||
| 165 | #define STM32_I2C_DMA_ERROR_HOOK(i2cp) osalSysHalt("DMA failure") | ||
| 166 | |||
| 167 | /* | ||
| 168 | * ICU driver system settings. | ||
| 169 | */ | ||
| 170 | #define STM32_ICU_USE_TIM1 FALSE | ||
| 171 | #define STM32_ICU_USE_TIM2 FALSE | ||
| 172 | #define STM32_ICU_USE_TIM3 FALSE | ||
| 173 | #define STM32_ICU_USE_TIM4 FALSE | ||
| 174 | #define STM32_ICU_USE_TIM8 FALSE | ||
| 175 | #define STM32_ICU_TIM1_IRQ_PRIORITY 7 | ||
| 176 | #define STM32_ICU_TIM2_IRQ_PRIORITY 7 | ||
| 177 | #define STM32_ICU_TIM3_IRQ_PRIORITY 7 | ||
| 178 | #define STM32_ICU_TIM4_IRQ_PRIORITY 7 | ||
| 179 | #define STM32_ICU_TIM8_IRQ_PRIORITY 7 | ||
| 180 | |||
| 181 | /* | ||
| 182 | * PWM driver system settings. | ||
| 183 | */ | ||
| 184 | #define STM32_PWM_USE_ADVANCED FALSE | ||
| 185 | #define STM32_PWM_USE_TIM1 FALSE | ||
| 186 | #define STM32_PWM_USE_TIM2 TRUE | ||
| 187 | #define STM32_PWM_USE_TIM3 TRUE | ||
| 188 | #define STM32_PWM_USE_TIM4 FALSE | ||
| 189 | #define STM32_PWM_USE_TIM8 FALSE | ||
| 190 | #define STM32_PWM_TIM1_IRQ_PRIORITY 7 | ||
| 191 | #define STM32_PWM_TIM2_IRQ_PRIORITY 7 | ||
| 192 | #define STM32_PWM_TIM3_IRQ_PRIORITY 7 | ||
| 193 | #define STM32_PWM_TIM4_IRQ_PRIORITY 7 | ||
| 194 | #define STM32_PWM_TIM8_IRQ_PRIORITY 7 | ||
| 195 | |||
| 196 | /* | ||
| 197 | * SERIAL driver system settings. | ||
| 198 | */ | ||
| 199 | #define STM32_SERIAL_USE_USART1 FALSE | ||
| 200 | #define STM32_SERIAL_USE_USART2 TRUE | ||
| 201 | #define STM32_SERIAL_USE_USART3 FALSE | ||
| 202 | #define STM32_SERIAL_USE_UART4 FALSE | ||
| 203 | #define STM32_SERIAL_USE_UART5 FALSE | ||
| 204 | #define STM32_SERIAL_USART1_PRIORITY 12 | ||
| 205 | #define STM32_SERIAL_USART2_PRIORITY 12 | ||
| 206 | #define STM32_SERIAL_USART3_PRIORITY 12 | ||
| 207 | #define STM32_SERIAL_UART4_PRIORITY 12 | ||
| 208 | #define STM32_SERIAL_UART5_PRIORITY 12 | ||
| 209 | |||
| 210 | /* | ||
| 211 | * SPI driver system settings. | ||
| 212 | */ | ||
| 213 | #define STM32_SPI_USE_SPI1 FALSE | ||
| 214 | #define STM32_SPI_USE_SPI2 FALSE | ||
| 215 | #define STM32_SPI_USE_SPI3 FALSE | ||
| 216 | #define STM32_SPI_SPI1_DMA_PRIORITY 1 | ||
| 217 | #define STM32_SPI_SPI2_DMA_PRIORITY 1 | ||
| 218 | #define STM32_SPI_SPI3_DMA_PRIORITY 1 | ||
| 219 | #define STM32_SPI_SPI1_IRQ_PRIORITY 10 | ||
| 220 | #define STM32_SPI_SPI2_IRQ_PRIORITY 10 | ||
| 221 | #define STM32_SPI_SPI3_IRQ_PRIORITY 10 | ||
| 222 | #define STM32_SPI_DMA_ERROR_HOOK(spip) osalSysHalt("DMA failure") | ||
| 223 | |||
| 224 | /* | ||
| 225 | * ST driver system settings. | ||
| 226 | */ | ||
| 227 | #define STM32_ST_IRQ_PRIORITY 8 | ||
| 228 | #define STM32_ST_USE_TIMER 2 | ||
| 229 | |||
| 230 | /* | ||
| 231 | * UART driver system settings. | ||
| 232 | */ | ||
| 233 | #define STM32_UART_USE_USART1 FALSE | ||
| 234 | #define STM32_UART_USE_USART2 FALSE | ||
| 235 | #define STM32_UART_USE_USART3 FALSE | ||
| 236 | #define STM32_UART_USART1_IRQ_PRIORITY 12 | ||
| 237 | #define STM32_UART_USART2_IRQ_PRIORITY 12 | ||
| 238 | #define STM32_UART_USART3_IRQ_PRIORITY 12 | ||
| 239 | #define STM32_UART_USART1_DMA_PRIORITY 0 | ||
| 240 | #define STM32_UART_USART2_DMA_PRIORITY 0 | ||
| 241 | #define STM32_UART_USART3_DMA_PRIORITY 0 | ||
| 242 | #define STM32_UART_DMA_ERROR_HOOK(uartp) osalSysHalt("DMA failure") | ||
| 243 | |||
| 244 | /* | ||
| 245 | * USB driver system settings. | ||
| 246 | */ | ||
| 247 | #define STM32_USB_USE_USB1 TRUE | ||
| 248 | #define STM32_USB_LOW_POWER_ON_SUSPEND FALSE | ||
| 249 | #define STM32_USB_USB1_HP_IRQ_PRIORITY 13 | ||
| 250 | #define STM32_USB_USB1_LP_IRQ_PRIORITY 14 | ||
| 251 | |||
| 252 | /* | ||
| 253 | * WDG driver system settings. | ||
| 254 | */ | ||
| 255 | #define STM32_WDG_USE_IWDG FALSE | ||
| 256 | |||
| 257 | #endif /* MCUCONF_H */ | ||
diff --git a/quantum/stm32/proton_c.mk b/quantum/stm32/proton_c.mk new file mode 100644 index 000000000..a0fa01373 --- /dev/null +++ b/quantum/stm32/proton_c.mk | |||
| @@ -0,0 +1,44 @@ | |||
| 1 | # Proton C MCU settings for converting AVR projects | ||
| 2 | |||
| 3 | # These are defaults based on what has been implemented for ARM boards | ||
| 4 | AUDIO_ENABLE = yes | ||
| 5 | RGBLIGHT_ENABLE = no | ||
| 6 | BACKLIGHT_ENABLE = no | ||
| 7 | |||
| 8 | # The rest of these settings shouldn't change | ||
| 9 | |||
| 10 | ## chip/board settings | ||
| 11 | # - the next two should match the directories in | ||
| 12 | # <chibios>/os/hal/ports/$(MCU_FAMILY)/$(MCU_SERIES) | ||
| 13 | MCU_FAMILY = STM32 | ||
| 14 | MCU_SERIES = STM32F3xx | ||
| 15 | |||
| 16 | # Linker script to use | ||
| 17 | # - it should exist either in <chibios>/os/common/ports/ARMCMx/compilers/GCC/ld/ | ||
| 18 | # or <this_dir>/ld/ | ||
| 19 | MCU_LDSCRIPT = STM32F303xC | ||
| 20 | |||
| 21 | # Startup code to use | ||
| 22 | # - it should exist in <chibios>/os/common/startup/ARMCMx/compilers/GCC/mk/ | ||
| 23 | MCU_STARTUP = stm32f3xx | ||
| 24 | |||
| 25 | # Board: it should exist either in <chibios>/os/hal/boards/ | ||
| 26 | # or <this_dir>/boards | ||
| 27 | BOARD = GENERIC_STM32_F303XC | ||
| 28 | |||
| 29 | # Cortex version | ||
| 30 | MCU = cortex-m4 | ||
| 31 | |||
| 32 | # ARM version, CORTEX-M0/M1 are 6, CORTEX-M3/M4/M7 are 7 | ||
| 33 | ARMV = 7 | ||
| 34 | |||
| 35 | USE_FPU = yes | ||
| 36 | |||
| 37 | # Vector table for application | ||
| 38 | # 0x00000000-0x00001000 area is occupied by bootlaoder.*/ | ||
| 39 | # The CORTEX_VTOR... is needed only for MCHCK/Infinity KB | ||
| 40 | # OPT_DEFS = -DCORTEX_VTOR_INIT=0x08005000 | ||
| 41 | OPT_DEFS = | ||
| 42 | |||
| 43 | # Options to pass to dfu-util when flashing | ||
| 44 | DFU_ARGS = -d 0483:df11 -a 0 -s 0x08000000:leave | ||
diff --git a/quantum/template/avr/config.h b/quantum/template/avr/config.h index eed50e5c0..d05b2cb98 100644 --- a/quantum/template/avr/config.h +++ b/quantum/template/avr/config.h | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | Copyright 2018 REPLACE_WITH_YOUR_NAME | 2 | Copyright 2019 REPLACE_WITH_YOUR_NAME |
| 3 | 3 | ||
| 4 | This program is free software: you can redistribute it and/or modify | 4 | This program is free software: you can redistribute it and/or modify |
| 5 | it under the terms of the GNU General Public License as published by | 5 | it under the terms of the GNU General Public License as published by |
diff --git a/quantum/template/avr/template.c b/quantum/template/avr/template.c index b6366fd9a..3deeae88b 100644 --- a/quantum/template/avr/template.c +++ b/quantum/template/avr/template.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* Copyright 2018 REPLACE_WITH_YOUR_NAME | 1 | /* Copyright 2019 REPLACE_WITH_YOUR_NAME |
| 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 |
diff --git a/quantum/template/avr/template.h b/quantum/template/avr/template.h deleted file mode 100644 index 0d626ed50..000000000 --- a/quantum/template/avr/template.h +++ /dev/null | |||
| @@ -1,38 +0,0 @@ | |||
| 1 | /* Copyright 2018 REPLACE_WITH_YOUR_NAME | ||
| 2 | * | ||
| 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 | ||
| 5 | * the Free Software Foundation, either version 2 of the License, or | ||
| 6 | * (at your option) any later version. | ||
| 7 | * | ||
| 8 | * This program is distributed in the hope that it will be useful, | ||
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 11 | * GNU General Public License for more details. | ||
| 12 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 16 | #ifndef %KEYBOARD_UPPERCASE%_H | ||
| 17 | #define %KEYBOARD_UPPERCASE%_H | ||
| 18 | |||
| 19 | #include "quantum.h" | ||
| 20 | |||
| 21 | /* This a shortcut to help you visually see your layout. | ||
| 22 | * | ||
| 23 | * The first section contains all of the arguments representing the physical | ||
| 24 | * layout of the board and position of the keys. | ||
| 25 | * | ||
| 26 | * The second converts the arguments into a two-dimensional array which | ||
| 27 | * represents the switch matrix. | ||
| 28 | */ | ||
| 29 | #define LAYOUT( \ | ||
| 30 | K00, K01, K02, \ | ||
| 31 | K10, K11 \ | ||
| 32 | ) \ | ||
| 33 | { \ | ||
| 34 | { K00, K01, K02 }, \ | ||
| 35 | { K10, KC_NO, K11 }, \ | ||
| 36 | } | ||
| 37 | |||
| 38 | #endif | ||
diff --git a/quantum/template/base/keymaps/default/config.h b/quantum/template/base/keymaps/default/config.h index 4496c5910..c8e433412 100644 --- a/quantum/template/base/keymaps/default/config.h +++ b/quantum/template/base/keymaps/default/config.h | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* Copyright 2018 REPLACE_WITH_YOUR_NAME | 1 | /* Copyright 2019 REPLACE_WITH_YOUR_NAME |
| 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 |
diff --git a/quantum/template/base/keymaps/default/keymap.c b/quantum/template/base/keymaps/default/keymap.c index 5f0730c8a..11cd134a0 100644 --- a/quantum/template/base/keymaps/default/keymap.c +++ b/quantum/template/base/keymaps/default/keymap.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* Copyright 2018 REPLACE_WITH_YOUR_NAME | 1 | /* Copyright 2019 REPLACE_WITH_YOUR_NAME |
| 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 |
diff --git a/quantum/template/ps2avrgb/template.h b/quantum/template/base/template.h index b4d6f4662..caf2abb4c 100644 --- a/quantum/template/ps2avrgb/template.h +++ b/quantum/template/base/template.h | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* Copyright 2018 REPLACE_WITH_YOUR_NAME | 1 | /* Copyright 2019 REPLACE_WITH_YOUR_NAME |
| 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 |
| @@ -13,8 +13,7 @@ | |||
| 13 | * You should have received a copy of the GNU General Public License | 13 | * You should have received a copy of the GNU General Public License |
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 15 | */ | 15 | */ |
| 16 | #ifndef %KEYBOARD_UPPERCASE%_H | 16 | #pragma once |
| 17 | #define %KEYBOARD_UPPERCASE%_H | ||
| 18 | 17 | ||
| 19 | #include "quantum.h" | 18 | #include "quantum.h" |
| 20 | 19 | ||
| @@ -34,5 +33,3 @@ | |||
| 34 | { k00, k01, k02 }, \ | 33 | { k00, k01, k02 }, \ |
| 35 | { k10, KC_NO, k11 }, \ | 34 | { k10, KC_NO, k11 }, \ |
| 36 | } | 35 | } |
| 37 | |||
| 38 | #endif | ||
diff --git a/quantum/template/ps2avrgb/rules.mk b/quantum/template/ps2avrgb/rules.mk index 85603f955..bcd7dff99 100644 --- a/quantum/template/ps2avrgb/rules.mk +++ b/quantum/template/ps2avrgb/rules.mk | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | # Copyright 2017 Luiz Ribeiro <luizribeiro@gmail.com> | 1 | # Copyright 2019 Luiz Ribeiro <luizribeiro@gmail.com> |
| 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 |
diff --git a/quantum/template/ps2avrgb/template.c b/quantum/template/ps2avrgb/template.c index 8bbf9ebda..4e35a2c12 100644 --- a/quantum/template/ps2avrgb/template.c +++ b/quantum/template/ps2avrgb/template.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* Copyright 2018 REPLACE_WITH_YOUR_NAME | 1 | /* Copyright 2019 REPLACE_WITH_YOUR_NAME |
| 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 |
