From 1c5b0cbbeb049b1ce3fb2da6a81fbf83dd9a3ea7 Mon Sep 17 00:00:00 2001 From: Takeshi ISHII <2170248+mtei@users.noreply.github.com> Date: Thu, 22 Aug 2019 09:10:47 +0900 Subject: 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. --- quantum/quantum.h | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'quantum/quantum.h') 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; -- cgit v1.2.3