diff options
author | Kevin O'Connor <kevin@koconnor.net> | 2018-11-26 22:18:51 -0500 |
---|---|---|
committer | Kevin O'Connor <kevin@koconnor.net> | 2018-11-30 11:50:50 -0500 |
commit | 6d90ebe6f8c2aa9071ba524063e89ceb164037eb (patch) | |
tree | 35222216c94d61e7b7a8735285343b5deeb907f0 /src/samd21/gpio.c | |
parent | 0af0bc946e174e2726218aa2ec81a75331aa2644 (diff) | |
download | kutter-6d90ebe6f8c2aa9071ba524063e89ceb164037eb.tar.gz kutter-6d90ebe6f8c2aa9071ba524063e89ceb164037eb.tar.xz kutter-6d90ebe6f8c2aa9071ba524063e89ceb164037eb.zip |
samd21: Use GPIO() macro when calling gpio_peripheral()
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'src/samd21/gpio.c')
-rw-r--r-- | src/samd21/gpio.c | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/src/samd21/gpio.c b/src/samd21/gpio.c index 24fe59bc..a38dd63d 100644 --- a/src/samd21/gpio.c +++ b/src/samd21/gpio.c @@ -18,10 +18,10 @@ ****************************************************************/ void -gpio_peripheral(char bank, uint32_t bit, char ptype, uint32_t pull_up) +gpio_peripheral(uint32_t gpio, char ptype, uint32_t pull_up) { - int group = bank == 'A' ? 0 : 1; - PortGroup *pg = &PORT->Group[group]; + uint32_t bank = GPIO2PORT(gpio), bit = gpio % 32; + PortGroup *pg = &PORT->Group[bank]; if (ptype) { volatile uint8_t *pmux = &pg->PMUX[bit/2].reg; uint8_t shift = (bit & 1) ? 4 : 0, mask = ~(0xf << shift); @@ -36,9 +36,6 @@ gpio_peripheral(char bank, uint32_t bit, char ptype, uint32_t pull_up) * General Purpose Input Output (GPIO) pins ****************************************************************/ -#define GPIO(PORT, NUM) (((PORT)-'A') * 32 + (NUM)) -#define GPIO2PORT(PIN) ((PIN) / 32) -#define GPIO2BIT(PIN) (1<<((PIN) % 32)) #define NUM_PORT 2 struct gpio_out |