From a6afb16c90169827bd350723a2d530e75de94052 Mon Sep 17 00:00:00 2001 From: Jack Humbert Date: Mon, 4 Jun 2018 00:50:09 -0400 Subject: [PATCH] fix assembly errors with hal --- keyboards/planck/light/rev2/matrix.c | 1 + quantum/config_common.h | 20 +----------------- quantum/encoder.c | 2 +- quantum/quantum.h | 31 +++++++++++++++++++++++++--- 4 files changed, 31 insertions(+), 23 deletions(-) diff --git a/keyboards/planck/light/rev2/matrix.c b/keyboards/planck/light/rev2/matrix.c index 0de8b20285..5982741b66 100644 --- a/keyboards/planck/light/rev2/matrix.c +++ b/keyboards/planck/light/rev2/matrix.c @@ -10,6 +10,7 @@ #include "action.h" #include "keycode.h" #include +#include "quantum.h" /* * col: { A10, B2, A15, A0, A1, A2, B0, B1, C13, A6, A7, A3 } diff --git a/quantum/config_common.h b/quantum/config_common.h index 5de2d13993..7c02e9e5f3 100644 --- a/quantum/config_common.h +++ b/quantum/config_common.h @@ -23,8 +23,6 @@ #define CUSTOM_MATRIX 2 /* Disables built-in matrix scanning code */ #ifdef __AVR__ - #include - #define LINE_TYPE uint8_t /* I/O pins */ #ifndef F0 @@ -78,18 +76,8 @@ #define A7 0x07 #endif - #define setPadMode(line, mode) _SFR_IO8((line >> 4) + 1) mode _BV(line & 0xF) - #define setPad(line) _SFR_IO8((line >> 4) + 2) |= _BV(line & 0xF) - #define clearPad(line) _SFR_IO8((line >> 4) + 2) &= ~_BV(line & 0xF) - #define readPad(line) (_SFR_IO8(line >> 4) & _BV(line & 0xF)) - #define PAD_MODE_INPUT &= ~ - #define PAD_MODE_OUTPUT |= - -#else - #include "hal.h" - - #define LINE_TYPE ioline_t +#elif defined(__arm__) #define A0 PAL_LINE(GPIOA, 0) #define A1 PAL_LINE(GPIOA, 1) @@ -188,12 +176,6 @@ #define F14 PAL_LINE(GPIOF, 14) #define F15 PAL_LINE(GPIOF, 15) - #define setPadMode(line, mode) palSetPadMode(PAL_PORT(line), PAL_PAD(line), mode) - #define setPad(line) palSetPad(PAL_PORT(line), PAL_PAD(line)) - #define clearPad(line) palClearPad(PAL_PORT(line), PAL_PAD(line)) - #define readPad(line) palReadPad(PAL_PORT(line), PAL_PAD(line)) - - #define PAD_MODE_INPUT PAL_MODE_INPUT_PULLUP #endif diff --git a/quantum/encoder.c b/quantum/encoder.c index 103ff8289b..265e0ec206 100644 --- a/quantum/encoder.c +++ b/quantum/encoder.c @@ -16,7 +16,7 @@ */ #include "encoder.h" -#include +#include "quantum.h" #ifndef ENCODER_RESOLUTION #define ENCODER_RESOLUTION 4 diff --git a/quantum/quantum.h b/quantum/quantum.h index 55ea4a5010..b634ab7418 100644 --- a/quantum/quantum.h +++ b/quantum/quantum.h @@ -17,10 +17,11 @@ #define QUANTUM_H #if defined(__AVR__) -#include -#include -#include + #include + #include + #include #endif + #include "wait.h" #include "matrix.h" #include "keymap.h" @@ -130,6 +131,30 @@ extern uint32_t default_layer_state; #define MIN(x, y) (((x) < (y)) ? (x) : (y)) #endif + +#ifdef __AVR__ + #include + #define LINE_TYPE uint8_t + + #define setPadMode(line, mode) _SFR_IO8((line >> 4) + 1) mode _BV(line & 0xF) + #define setPad(line) _SFR_IO8((line >> 4) + 2) |= _BV(line & 0xF) + #define clearPad(line) _SFR_IO8((line >> 4) + 2) &= ~_BV(line & 0xF) + #define readPad(line) (_SFR_IO8(line >> 4) & _BV(line & 0xF)) + + #define PAD_MODE_INPUT &= ~ + #define PAD_MODE_OUTPUT |= +#elif defined(__arm__) + #include "hal.h" + #define LINE_TYPE ioline_t + + #define setPadMode(line, mode) palSetPadMode(PAL_PORT(line), PAL_PAD(line), mode) + #define setPad(line) palSetPad(PAL_PORT(line), PAL_PAD(line)) + #define clearPad(line) palClearPad(PAL_PORT(line), PAL_PAD(line)) + #define readPad(line) palReadPad(PAL_PORT(line), PAL_PAD(line)) + + #define PAD_MODE_INPUT PAL_MODE_INPUT_PULLUP +#endif + #define STRINGIZE(z) #z #define ADD_SLASH_X(y) STRINGIZE(\x ## y) #define SYMBOL_STR(x) ADD_SLASH_X(x)