summaryrefslogtreecommitdiff
path: root/platforms/avr
diff options
context:
space:
mode:
authorNick Brassel <nick@tzarc.org>2021-12-27 11:52:10 +1100
committerGitHub <noreply@github.com>2021-12-27 11:52:10 +1100
commit6e40dfa0220e68a6628d9e7d18788df6bcae5473 (patch)
tree743f0ad2504bad030b846477690fe6ceb228f580 /platforms/avr
parentf491e6b138c690263487bb791a1277b86da3a2e4 (diff)
Add open-drain GPIO support. (#15282)
* Add open-drain GPIO support. * `qmk format-c` * Wording. * Remove port GPIO implementations as the only board that uses it has its own internal defs anyway. Will wait for first-class handling of ports in core before reimplementing.
Diffstat (limited to 'platforms/avr')
-rw-r--r--platforms/avr/gpio.h17
1 files changed, 3 insertions, 14 deletions
diff --git a/platforms/avr/gpio.h b/platforms/avr/gpio.h
index e9be68491d..95f15c28dc 100644
--- a/platforms/avr/gpio.h
+++ b/platforms/avr/gpio.h
@@ -25,7 +25,9 @@ typedef uint8_t pin_t;
#define setPinInput(pin) (DDRx_ADDRESS(pin) &= ~_BV((pin)&0xF), PORTx_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) (DDRx_ADDRESS(pin) |= _BV((pin)&0xF))
+#define setPinOutputPushPull(pin) (DDRx_ADDRESS(pin) |= _BV((pin)&0xF))
+#define setPinOutputOpenDrain(pin) _Static_assert(0, "AVR platform does not implement an open-drain output")
+#define setPinOutput(pin) setPinOutputPushPull(pin)
#define writePinHigh(pin) (PORTx_ADDRESS(pin) |= _BV((pin)&0xF))
#define writePinLow(pin) (PORTx_ADDRESS(pin) &= ~_BV((pin)&0xF))
@@ -34,16 +36,3 @@ typedef uint8_t pin_t;
#define readPin(pin) ((bool)(PINx_ADDRESS(pin) & _BV((pin)&0xF)))
#define togglePin(pin) (PORTx_ADDRESS(pin) ^= _BV((pin)&0xF))
-
-/* Operation of GPIO by port. */
-
-typedef uint8_t port_data_t;
-
-#define readPort(port) PINx_ADDRESS(port)
-
-#define setPortBitInput(port, bit) (DDRx_ADDRESS(port) &= ~_BV((bit)&0xF), PORTx_ADDRESS(port) &= ~_BV((bit)&0xF))
-#define setPortBitInputHigh(port, bit) (DDRx_ADDRESS(port) &= ~_BV((bit)&0xF), PORTx_ADDRESS(port) |= _BV((bit)&0xF))
-#define setPortBitOutput(port, bit) (DDRx_ADDRESS(port) |= _BV((bit)&0xF))
-
-#define writePortBitLow(port, bit) (PORTx_ADDRESS(port) &= ~_BV((bit)&0xF))
-#define writePortBitHigh(port, bit) (PORTx_ADDRESS(port) |= _BV((bit)&0xF))