summaryrefslogtreecommitdiffstats
path: root/quantum
diff options
context:
space:
mode:
authorAlex Ong <the.onga@gmail.com>2019-01-04 19:43:45 +1100
committerAlex Ong <the.onga@gmail.com>2019-01-04 19:43:45 +1100
commit2bb2977c133646c4e056960e72029270d77cc1eb (patch)
tree235d491f992121ac1716c5bf2fafb80983748576 /quantum
parenta55c838961c89097ab849ed6cb1f261791e6b9b4 (diff)
parent47c91fc7f75ae0a477e55b687aa0fc30da0a283c (diff)
Merge branch 'master' into debounce_refactor
# Conflicts: # tmk_core/common/keyboard.c
Diffstat (limited to 'quantum')
-rw-r--r--quantum/api.h4
-rw-r--r--quantum/audio/audio.c8
-rw-r--r--quantum/audio/audio.h3
-rw-r--r--quantum/audio/audio_arm.c135
-rw-r--r--quantum/audio/song_list.h30
-rw-r--r--quantum/config_common.h257
-rw-r--r--quantum/dynamic_keymap.c230
-rw-r--r--quantum/dynamic_keymap.h63
-rw-r--r--quantum/encoder.c70
-rw-r--r--quantum/encoder.h (renamed from quantum/process_keycode/process_chording.h)21
-rw-r--r--quantum/keymap_common.c2
-rw-r--r--quantum/keymap_extras/keymap_belgian.h9
-rw-r--r--quantum/keymap_extras/keymap_bepo.h153
-rw-r--r--quantum/keymap_extras/keymap_canadian_multilingual.h49
-rw-r--r--quantum/keymap_extras/keymap_fr_ch.h4
-rw-r--r--quantum/keymap_extras/keymap_french.h6
-rw-r--r--quantum/keymap_extras/keymap_german.h4
-rw-r--r--quantum/keymap_extras/keymap_german_ch.h4
-rw-r--r--quantum/keymap_extras/keymap_hungarian.h4
-rw-r--r--quantum/keymap_extras/keymap_italian.h7
-rw-r--r--quantum/keymap_extras/keymap_jp.h3
-rw-r--r--quantum/keymap_extras/keymap_neo2.h2
-rw-r--r--quantum/keymap_extras/keymap_nordic.h4
-rw-r--r--quantum/keymap_extras/keymap_plover_dvorak.h47
-rw-r--r--quantum/keymap_extras/keymap_slovenian.h107
-rw-r--r--quantum/keymap_extras/keymap_spanish.h4
-rw-r--r--quantum/keymap_extras/keymap_swedish.h4
-rw-r--r--quantum/keymap_extras/keymap_uk.h4
-rw-r--r--quantum/keymap_extras/sendstring_german.h81
-rw-r--r--quantum/matrix.c49
-rw-r--r--quantum/process_keycode/process_auto_shift.c2
-rw-r--r--quantum/process_keycode/process_chording.c76
-rw-r--r--quantum/process_keycode/process_clicky.c72
-rw-r--r--quantum/process_keycode/process_clicky.h10
-rw-r--r--quantum/process_keycode/process_leader.c49
-rw-r--r--quantum/process_keycode/process_leader.h2
-rw-r--r--quantum/process_keycode/process_tap_dance.c6
-rw-r--r--quantum/process_keycode/process_tap_dance.h1
-rw-r--r--quantum/process_keycode/process_ucis.c8
-rw-r--r--quantum/process_keycode/process_ucis.h6
-rw-r--r--quantum/process_keycode/process_unicode.c7
-rw-r--r--quantum/process_keycode/process_unicode.h5
-rw-r--r--quantum/process_keycode/process_unicode_common.c223
-rw-r--r--quantum/process_keycode/process_unicode_common.h68
-rw-r--r--quantum/process_keycode/process_unicodemap.c4
-rw-r--r--quantum/process_keycode/process_unicodemap.h4
-rw-r--r--quantum/quantum.c149
-rw-r--r--quantum/quantum.h95
-rw-r--r--quantum/quantum_keycodes.h129
-rw-r--r--quantum/rgb_matrix.c446
-rw-r--r--quantum/rgb_matrix.h120
-rw-r--r--quantum/rgb_matrix_drivers.c82
-rw-r--r--quantum/rgblight.c343
-rw-r--r--quantum/rgblight.h147
-rw-r--r--quantum/rgblight_reconfig.h36
-rw-r--r--quantum/split_common/i2c.c3
-rw-r--r--quantum/split_common/matrix.c160
-rw-r--r--quantum/split_common/matrix.h31
-rw-r--r--quantum/split_common/serial.c548
-rw-r--r--quantum/split_common/serial.h78
-rw-r--r--quantum/split_common/split_util.c51
-rw-r--r--quantum/template/avr/config.h31
-rw-r--r--quantum/template/avr/readme.md2
-rw-r--r--quantum/template/avr/rules.mk25
-rw-r--r--quantum/template/avr/template.h14
-rw-r--r--quantum/template/base/keymaps/default/keymap.c54
-rw-r--r--quantum/template/ps2avrgb/config.h4
-rw-r--r--quantum/template/ps2avrgb/readme.md2
-rw-r--r--quantum/template/ps2avrgb/rules.mk4
-rw-r--r--quantum/template/ps2avrgb/template.h12
70 files changed, 3146 insertions, 1331 deletions
diff --git a/quantum/api.h b/quantum/api.h
index efc0ddca12..fc016391bc 100644
--- a/quantum/api.h
+++ b/quantum/api.h
@@ -17,7 +17,9 @@
#ifndef _API_H_
#define _API_H_
+#ifdef __AVR__
#include "lufa.h"
+#endif
enum MESSAGE_TYPE {
MT_GET_DATA = 0x10, // Get data from keyboard
@@ -28,7 +30,7 @@ enum MESSAGE_TYPE {
MT_SEND_DATA_ACK = 0x31, // returned data/action confirmation (ACK)
MT_EXE_ACTION = 0x40, // executing actions on keyboard
MT_EXE_ACTION_ACK =0x41, // return confirmation/value (ACK)
- MT_TYPE_ERROR = 0x80 // type not recofgnised (ACK)
+ MT_TYPE_ERROR = 0x80 // type not recognised (ACK)
};
enum DATA_TYPE {
diff --git a/quantum/audio/audio.c b/quantum/audio/audio.c
index c948a60d6c..6d6833ec11 100644
--- a/quantum/audio/audio.c
+++ b/quantum/audio/audio.c
@@ -223,7 +223,7 @@ void audio_init()
TCCR1B = (1 << WGM13) | (1 << WGM12) | (0 << CS12) | (1 << CS11) | (0 << CS10);
TIMER_1_PERIOD = (uint16_t)(((float)F_CPU) / (440 * CPU_PRESCALER));
TIMER_1_DUTY_CYCLE = (uint16_t)((((float)F_CPU) / (440 * CPU_PRESCALER)) * note_timbre);
- #endif
+ #endif
audio_initialized = true;
}
@@ -231,7 +231,7 @@ void audio_init()
if (audio_config.enable) {
PLAY_SONG(startup_song);
}
-
+
}
void stop_all_notes()
@@ -464,7 +464,7 @@ ISR(TIMER3_AUDIO_vect)
note_position++;
bool end_of_note = false;
if (TIMER_3_PERIOD > 0) {
- if (!note_resting)
+ if (!note_resting)
end_of_note = (note_position >= (note_length / TIMER_3_PERIOD * 0xFFFF - 1));
else
end_of_note = (note_position >= (note_length));
@@ -604,7 +604,7 @@ ISR(TIMER1_AUDIO_vect)
note_position++;
bool end_of_note = false;
if (TIMER_1_PERIOD > 0) {
- if (!note_resting)
+ if (!note_resting)
end_of_note = (note_position >= (note_length / TIMER_1_PERIOD * 0xFFFF - 1));
else
end_of_note = (note_position >= (note_length));
diff --git a/quantum/audio/audio.h b/quantum/audio/audio.h
index da09b2bcd2..8136c5b258 100644
--- a/quantum/audio/audio.h
+++ b/quantum/audio/audio.h
@@ -40,7 +40,8 @@ typedef union {
uint8_t raw;
struct {
bool enable :1;
- uint8_t level :7;
+ bool clicky_enable :1;
+ uint8_t level :6;
};
} audio_config_t;
diff --git a/quantum/audio/audio_arm.c b/quantum/audio/audio_arm.c
index d38184f323..989f7a64be 100644
--- a/quantum/audio/audio_arm.c
+++ b/quantum/audio/audio_arm.c
@@ -80,6 +80,9 @@ float startup_song[][2] = STARTUP_SONG;
static void gpt_cb8(GPTDriver *gptp);
#define DAC_BUFFER_SIZE 720
+#ifndef DAC_SAMPLE_MAX
+#define DAC_SAMPLE_MAX 65535U
+#endif
#define START_CHANNEL_1() gptStart(&GPTD6, &gpt6cfg1); \
gptStartContinuous(&GPTD6, 2U)
@@ -202,132 +205,16 @@ GPTConfig gpt8cfg1 = {
// squarewave
static const dacsample_t dac_buffer[DAC_BUFFER_SIZE] = {
- 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047,
- 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047,
- 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047,
- 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047,
- 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047,
- 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047,
- 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047,
- 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047,
- 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047,
- 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047,
- 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047,
- 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047,
- 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047,
- 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047,
- 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047,
- 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047,
- 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047,
- 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047,
- 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047,
- 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047,
- 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047,
- 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047,
- 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047,
- 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047,
- 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047,
- 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047,
- 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047,
- 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047,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 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047,
- 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047,
- 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047,
- 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047,
- 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047,
- 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047,
- 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047,
- 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047,
- 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047,
- 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047,
- 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047,
- 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047,
- 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047,
- 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047,
- 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047,
- 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047,
- 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047,
- 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047,
- 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047,
- 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047,
- 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047,
- 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047,
- 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047,
- 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047,
- 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047,
- 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047,
- 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047,
- 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047,
- 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047,
- 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047
+ // opposite of dac_buffer above
+ [0 ... DAC_BUFFER_SIZE/2-1] = 0,
+ [DAC_BUFFER_SIZE/2 ... DAC_BUFFER_SIZE -1] = DAC_SAMPLE_MAX,
};
/*
@@ -363,7 +250,7 @@ static void error_cb1(DACDriver *dacp, dacerror_t err) {
}
static const DACConfig dac1cfg1 = {
- .init = 2047U,
+ .init = DAC_SAMPLE_MAX,
.datamode = DAC_DHRM_12BIT_RIGHT
};
@@ -375,7 +262,7 @@ static const DACConversionGroup dacgrpcfg1 = {
};
static const DACConfig dac1cfg2 = {
- .init = 2047U,
+ .init = DAC_SAMPLE_MAX,
.datamode = DAC_DHRM_12BIT_RIGHT
};
diff --git a/quantum/audio/song_list.h b/quantum/audio/song_list.h
index e63616a994..9946084977 100644
--- a/quantum/audio/song_list.h
+++ b/quantum/audio/song_list.h
@@ -472,4 +472,34 @@
H__NOTE(_AS4), W__NOTE(_GS4), W__NOTE(_GS4), W__NOTE(_FS4), W__NOTE(_GS4), \
H__NOTE(_AS4), WD_NOTE(_DS4)
+#define RICK_ROLL \
+ Q__NOTE(_F4), \
+ Q__NOTE(_G4), \
+ Q__NOTE(_BF4), \
+ Q__NOTE(_G4), \
+ HD_NOTE(_D5), \
+ HD_NOTE(_D5), \
+ W__NOTE(_C5), \
+ S__NOTE(_REST), \
+ Q__NOTE(_F4), \
+ Q__NOTE(_G4), \
+ Q__NOTE(_BF4), \
+ Q__NOTE(_G4), \
+ HD_NOTE(_C5), \
+ HD_NOTE(_C5), \
+ W__NOTE(_BF4), \
+ S__NOTE(_REST), \
+ Q__NOTE(_F4), \
+ Q__NOTE(_G4), \
+ Q__NOTE(_BF4), \
+ Q__NOTE(_G4), \
+ W__NOTE(_BF4), \
+ H__NOTE(_C5), \
+ H__NOTE(_A4), \
+ H__NOTE(_A4), \
+ H__NOTE(_G4), \
+ H__NOTE(_F4), \
+ H__NOTE(_F4), \
+ W__NOTE(_C5), \
+ W__NOTE(_BF4),
#endif
diff --git a/quantum/config_common.h b/quantum/config_common.h
index f6f51b367d..cbff372eaf 100644
--- a/quantum/config_common.h
+++ b/quantum/config_common.h
@@ -1,4 +1,4 @@
-/* Copyright 2015-2017 Jack Humbert
+/* Copyright 2015-2018 Jack Humbert
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -14,8 +14,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef CONFIG_DEFINITIONS_H
-#define CONFIG_DEFINITIONS_H
+#pragma once
/* diode directions */
#define COL2ROW 0
@@ -23,57 +22,205 @@
#define CUSTOM_MATRIX 2 /* Disables built-in matrix scanning code */
#ifdef __AVR__
- /* I/O pins */
- #ifndef F0
- #define B0 0x30
- #define B1 0x31
- #define B2 0x32
- #define B3 0x33
- #define B4 0x34
- #define B5 0x35
- #define B6 0x36
- #define B7 0x37
- #define C0 0x60
- #define C1 0x61
- #define C2 0x62
- #define C3 0x63
- #define C4 0x64
- #define C5 0x65
- #define C6 0x66
- #define C7 0x67
- #define D0 0x90
- #define D1 0x91
- #define D2 0x92
- #define D3 0x93
- #define D4 0x94
- #define D5 0x95
- #define D6 0x96
- #define D7 0x97
- #define E0 0xC0
- #define E1 0xC1
- #define E2 0xC2
- #define E3 0xC3
- #define E4 0xC4
- #define E5 0xC5
- #define E6 0xC6
- #define E7 0xC7
- #define F0 0xF0
- #define F1 0xF1
- #define F2 0xF2
- #define F3 0xF3
- #define F4 0xF4
- #define F5 0xF5
- #define F6 0xF6
- #define F7 0xF7
- #define A0 0x00
- #define A1 0x01
- #define A2 0x02
- #define A3 0x03
- #define A4 0x04
- #define A5 0x05
- #define A6 0x06
- #define A7 0x07
- #endif
+ #ifndef __ASSEMBLER__
+ #include <avr/io.h>
+ #endif
+ #define PORT_SHIFTER 4 // this may be 4 for all AVR chips
+
+ // If you want to add more to this list, reference the PINx definitions in these header
+ // files: https://github.com/vancegroup-mirrors/avr-libc/tree/master/avr-libc/include/avr
+
+ #if defined(__AVR_ATmega32U4__) || defined(__AVR_ATmega16U4__)
+ #define ADDRESS_BASE 0x00
+ #define PINB_ADDRESS 0x3
+ #define PINC_ADDRESS 0x6
+ #define PIND_ADDRESS 0x9
+ #define PINE_ADDRESS 0xC
+ #define PINF_ADDRESS 0xF
+ #elif defined(__AVR_ATmega32U2__) || defined(__AVR_ATmega16U2__)
+ #define ADDRESS_BASE 0x00
+ #define PINB_ADDRESS 0x3
+ #define PINC_ADDRESS 0x6
+ #define PIND_ADDRESS 0x9
+ #elif defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB646__)
+ #define ADDRESS_BASE 0x00
+ #define PINA_ADDRESS 0x0
+ #define PINB_ADDRESS 0x3
+ #define PINC_ADDRESS 0x6
+ #define PIND_ADDRESS 0x9
+ #define PINE_ADDRESS 0xC
+ #define PINF_ADDRESS 0xF
+ #elif defined(__AVR_ATmega32A__)
+ #define ADDRESS_BASE 0x10
+ #define PIND_ADDRESS 0x0
+ #define PINC_ADDRESS 0x3
+ #define PINB_ADDRESS 0x6
+ #define PINA_ADDRESS 0x9
+ #else
+ #error "Pins are not defined"
+ #endif
+
+ /* I/O pins */
+ #define PINDEF(port, pin) ((PIN##port##_ADDRESS << PORT_SHIFTER) | pin)
+
+ #ifdef PORTA
+ #define A0 PINDEF(A, 0)
+ #define A1 PINDEF(A, 1)
+ #define A2 PINDEF(A, 2)
+ #define A3 PINDEF(A, 3)
+ #define A4 PINDEF(A, 4)
+ #define A5 PINDEF(A, 5)
+ #define A6 PINDEF(A, 6)
+ #define A7 PINDEF(A, 7)
+ #endif
+ #ifdef PORTB
+ #define B0 PINDEF(B, 0)
+ #define B1 PINDEF(B, 1)
+ #define B2 PINDEF(B, 2)
+ #define B3 PINDEF(B, 3)
+ #define B4 PINDEF(B, 4)
+ #define B5 PINDEF(B, 5)
+ #define B6 PINDEF(B, 6)
+ #define B7 PINDEF(B, 7)
+ #endif
+ #ifdef PORTC
+ #define C0 PINDEF(C, 0)
+ #define C1 PINDEF(C, 1)
+ #define C2 PINDEF(C, 2)
+ #define C3 PINDEF(C, 3)
+ #define C4 PINDEF(C, 4)
+ #define C5 PINDEF(C, 5)
+ #define C6 PINDEF(C, 6)
+ #define C7 PINDEF(C, 7)
+ #endif
+ #ifdef PORTD
+ #define D0 PINDEF(D, 0)
+ #define D1 PINDEF(D, 1)
+ #define D2 PINDEF(D, 2)
+ #define D3 PINDEF(D, 3)
+ #define D4 PINDEF(D, 4)
+ #define D5 PINDEF(D, 5)
+ #define D6 PINDEF(D, 6)
+ #define D7 PINDEF(D, 7)
+ #endif
+ #ifdef PORTE
+ #define E0 PINDEF(E, 0)
+ #define E1 PINDEF(E, 1)
+ #define E2 PINDEF(E, 2)
+ #define E3 PINDEF(E, 3)
+ #define E4 PINDEF(E, 4)
+ #define E5 PINDEF(E, 5)
+ #define E6 PINDEF(E, 6)
+ #define E7 PINDEF(E, 7)
+ #endif
+ #ifdef PORTF
+ #define F0 PINDEF(F, 0)
+ #define F1 PINDEF(F, 1)
+ #define F2 PINDEF(F, 2)
+ #define F3 PINDEF(F, 3)
+ #define F4 PINDEF(F, 4)
+ #define F5 PINDEF(F, 5)
+ #define F6 PINDEF(F, 6)
+ #define F7 PINDEF(F, 7)
+ #endif
+
+#elif defined(PROTOCOL_CHIBIOS)
+ #define A0 PAL_LINE(GPIOA, 0)
+ #define A1 PAL_LINE(GPIOA, 1)
+ #define A2 PAL_LINE(GPIOA, 2)
+ #define A3 PAL_LINE(GPIOA, 3)
+ #define A4 PAL_LINE(GPIOA, 4)
+ #define A5 PAL_LINE(GPIOA, 5)
+ #define A6 PAL_LINE(GPIOA, 6)
+ #define A7 PAL_LINE(GPIOA, 7)
+ #define A8 PAL_LINE(GPIOA, 8)
+ #define A9 PAL_LINE(GPIO