From 94c86d6c6ce85143d47b79f7cc2680c6b0ee6889 Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Wed, 26 Dec 2018 16:50:44 -0500 Subject: sam3: Merge sam4e8e support into sam3 code Most of the peripherals on the sam4e8e are similar to the ones on the sam3x8e mcu. Merge the code together and use just one code directory. Signed-off-by: Kevin O'Connor --- src/sam3/gpio.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'src/sam3/gpio.c') diff --git a/src/sam3/gpio.c b/src/sam3/gpio.c index f48c5f0d..a0dfa0a4 100644 --- a/src/sam3/gpio.c +++ b/src/sam3/gpio.c @@ -1,4 +1,4 @@ -// GPIO functions on sam3x8e +// GPIO functions on sam3/sam4 // // Copyright (C) 2016-2018 Kevin O'Connor // @@ -9,11 +9,14 @@ #include "compiler.h" // ARRAY_SIZE #include "gpio.h" // gpio_out_setup #include "internal.h" // gpio_peripheral -#include "sam3x8e.h" // Pio #include "sched.h" // sched_shutdown static Pio * const digital_regs[] = { +#if CONFIG_MACH_SAM3X8E PIOA, PIOB, PIOC, PIOD +#elif CONFIG_MACH_SAM4E8E + PIOA, PIOB, PIOC, PIOD, PIOE +#endif }; @@ -24,12 +27,16 @@ static Pio * const digital_regs[] = { void gpio_peripheral(uint32_t gpio, char ptype, int32_t pull_up) { - uint32_t bank = GPIO2PORT(gpio), bit = GPIO2BIT(gpio); + uint32_t bank = GPIO2PORT(gpio), bit = GPIO2BIT(gpio), pt = ptype - 'A'; Pio *regs = digital_regs[bank]; - if (ptype == 'A') - regs->PIO_ABSR &= ~bit; - else - regs->PIO_ABSR |= bit; + +#if CONFIG_MACH_SAM3X8E + regs->PIO_ABSR = (regs->PIO_ABSR & ~bit) | (pt & 0x01 ? bit : 0); +#else + regs->PIO_ABCDSR[0] = (regs->PIO_ABCDSR[0] & ~bit) | (pt & 0x01 ? bit : 0); + regs->PIO_ABCDSR[1] = (regs->PIO_ABCDSR[1] & ~bit) | (pt & 0x02 ? bit : 0); +#endif + if (pull_up > 0) regs->PIO_PUER = bit; else -- cgit v1.2.3-70-g09d2