summaryrefslogtreecommitdiffstats
path: root/platforms/arm_atsam/gpio.h
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/arm_atsam/gpio.h
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/arm_atsam/gpio.h')
-rw-r--r--platforms/arm_atsam/gpio.h12
1 files changed, 8 insertions, 4 deletions
diff --git a/platforms/arm_atsam/gpio.h b/platforms/arm_atsam/gpio.h
index 915ed0ef4f..a42aaff54d 100644
--- a/platforms/arm_atsam/gpio.h
+++ b/platforms/arm_atsam/gpio.h
@@ -22,9 +22,9 @@
typedef uint8_t pin_t;
-#define SAMD_PORT(pin) ((pin & 0x20) >> 5)
-#define SAMD_PIN(pin) (pin & 0x1f)
-#define SAMD_PIN_MASK(pin) (1 << (pin & 0x1f))
+#define SAMD_PORT(pin) (((pin)&0x20) >> 5)
+#define SAMD_PIN(pin) ((pin)&0x1f)
+#define SAMD_PIN_MASK(pin) (1 << ((pin)&0x1f))
#define setPinInput(pin) \
do { \
@@ -48,12 +48,16 @@ typedef uint8_t pin_t;
PORT->Group[SAMD_PORT(pin)].PINCFG[SAMD_PIN(pin)].bit.PULLEN = 1; \
} while (0)
-#define setPinOutput(pin) \
+#define setPinOutputPushPull(pin) \
do { \
PORT->Group[SAMD_PORT(pin)].DIRSET.reg = SAMD_PIN_MASK(pin); \
PORT->Group[SAMD_PORT(pin)].OUTCLR.reg = SAMD_PIN_MASK(pin); \
} while (0)
+#define setPinOutputOpenDrain(pin) _Static_assert(0, "arm_atsam platform does not implement an open-drain output")
+
+#define setPinOutput(pin) setPinOutputPushPull(pin)
+
#define writePinHigh(pin) \
do { \
PORT->Group[SAMD_PORT(pin)].OUTSET.reg = SAMD_PIN_MASK(pin); \