summaryrefslogtreecommitdiff
path: root/quantum/quantum.h
diff options
context:
space:
mode:
authorTakeshi ISHII <2170248+mtei@users.noreply.github.com>2019-08-22 09:10:47 +0900
committerDrashna Jaelre <drashna@live.com>2019-08-21 17:10:47 -0700
commit1c5b0cbbeb049b1ce3fb2da6a81fbf83dd9a3ea7 (patch)
treedaeafd91c08b5631e6e4429fbbd8f895b2855a86 /quantum/quantum.h
parentb62e160a8950f451b08f1fee0109e60a58c5ddaa (diff)
AVR GPIO macro defines more readable (#5937)
* A little easier to read the definition of the GPIO control macro for AVR. No change in build result. * Changed to not use GNU statement expression extension. No change in build result. * Modified split_common/serial.c to use qmk_firmware standard GPIO control macro. No change in build result. * fix PE6 -> E6 * remove some space * add some comment to config_common.h * Changed split_common/serial.c to use a newer version of qmk_firmware standard GPIO control macro.
Diffstat (limited to 'quantum/quantum.h')
-rw-r--r--quantum/quantum.h15
1 files changed, 7 insertions, 8 deletions
diff --git a/quantum/quantum.h b/quantum/quantum.h
index 2214625670..2cb26d4f46 100644
--- a/quantum/quantum.h
+++ b/quantum/quantum.h
@@ -149,18 +149,17 @@ extern layer_state_t default_layer_state;
#if defined(__AVR__)
typedef uint8_t pin_t;
- #define PIN_ADDRESS(p, offset) (_SFR_IO8(ADDRESS_BASE + ((p) >> PORT_SHIFTER) + (offset)))
- #define setPinInput(pin) (PIN_ADDRESS(pin, 1) &= ~_BV((pin) & 0xF))
- #define setPinInputHigh(pin) (PIN_ADDRESS(pin, 1) &= ~_BV((pin) & 0xF), \
- PIN_ADDRESS(pin, 2) |= _BV((pin) & 0xF))
+ #define setPinInput(pin) (DDRx_ADDRESS(pin) &= ~_BV((pin) & 0xF))
+ #define setPinInputHigh(pin) (DDRx_ADDRESS(pin) &= ~_BV((pin) & 0xF), \
+ PORTx_ADDRESS(pin) |= _BV((pin) & 0xF))
#define setPinInputLow(pin) _Static_assert(0, "AVR processors cannot implement an input as pull low")
- #define setPinOutput(pin) (PIN_ADDRESS(pin, 1) |= _BV((pin) & 0xF))
+ #define setPinOutput(pin) (DDRx_ADDRESS(pin) |= _BV((pin) & 0xF))
- #define writePinHigh(pin) (PIN_ADDRESS(pin, 2) |= _BV((pin) & 0xF))
- #define writePinLow(pin) (PIN_ADDRESS(pin, 2) &= ~_BV((pin) & 0xF))
+ #define writePinHigh(pin) (PORTx_ADDRESS(pin) |= _BV((pin) & 0xF))
+ #define writePinLow(pin) (PORTx_ADDRESS(pin) &= ~_BV((pin) & 0xF))
#define writePin(pin, level) ((level) ? writePinHigh(pin) : writePinLow(pin))
- #define readPin(pin) ((bool)(PIN_ADDRESS(pin, 0) & _BV((pin) & 0xF)))
+ #define readPin(pin) ((bool)(PINx_ADDRESS(pin) & _BV((pin) & 0xF)))
#elif defined(PROTOCOL_CHIBIOS)
typedef ioline_t pin_t;