aboutsummaryrefslogtreecommitdiff
path: root/quantum/quantum.h
diff options
context:
space:
mode:
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 221462567..2cb26d4f4 100644
--- a/quantum/quantum.h
+++ b/quantum/quantum.h
@@ -149,18 +149,17 @@ extern layer_state_t default_layer_state;
149#if defined(__AVR__) 149#if defined(__AVR__)
150 typedef uint8_t pin_t; 150 typedef uint8_t pin_t;
151 151
152 #define PIN_ADDRESS(p, offset) (_SFR_IO8(ADDRESS_BASE + ((p) >> PORT_SHIFTER) + (offset))) 152 #define setPinInput(pin) (DDRx_ADDRESS(pin) &= ~_BV((pin) & 0xF))
153 #define setPinInput(pin) (PIN_ADDRESS(pin, 1) &= ~_BV((pin) & 0xF)) 153 #define setPinInputHigh(pin) (DDRx_ADDRESS(pin) &= ~_BV((pin) & 0xF), \
154 #define setPinInputHigh(pin) (PIN_ADDRESS(pin, 1) &= ~_BV((pin) & 0xF), \ 154 PORTx_ADDRESS(pin) |= _BV((pin) & 0xF))
155 PIN_ADDRESS(pin, 2) |= _BV((pin) & 0xF))
156 #define setPinInputLow(pin) _Static_assert(0, "AVR processors cannot implement an input as pull low") 155 #define setPinInputLow(pin) _Static_assert(0, "AVR processors cannot implement an input as pull low")
157 #define setPinOutput(pin) (PIN_ADDRESS(pin, 1) |= _BV((pin) & 0xF)) 156 #define setPinOutput(pin) (DDRx_ADDRESS(pin) |= _BV((pin) & 0xF))
158 157
159 #define writePinHigh(pin) (PIN_ADDRESS(pin, 2) |= _BV((pin) & 0xF)) 158 #define writePinHigh(pin) (PORTx_ADDRESS(pin) |= _BV((pin) & 0xF))
160 #define writePinLow(pin) (PIN_ADDRESS(pin, 2) &= ~_BV((pin) & 0xF)) 159 #define writePinLow(pin) (PORTx_ADDRESS(pin) &= ~_BV((pin) & 0xF))
161 #define writePin(pin, level) ((level) ? writePinHigh(pin) : writePinLow(pin)) 160 #define writePin(pin, level) ((level) ? writePinHigh(pin) : writePinLow(pin))
162 161
163 #define readPin(pin) ((bool)(PIN_ADDRESS(pin, 0) & _BV((pin) & 0xF))) 162 #define readPin(pin) ((bool)(PINx_ADDRESS(pin) & _BV((pin) & 0xF)))
164#elif defined(PROTOCOL_CHIBIOS) 163#elif defined(PROTOCOL_CHIBIOS)
165 typedef ioline_t pin_t; 164 typedef ioline_t pin_t;
166 165