diff --git a/src/sam3x8e/gpio.c b/src/sam3x8e/gpio.c index 9b7cca65..2311d41f 100644 --- a/src/sam3x8e/gpio.c +++ b/src/sam3x8e/gpio.c @@ -10,25 +10,17 @@ #include "command.h" // shutdown #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 - -/**************************************************************** - * Pin mappings - ****************************************************************/ - -#define GPIO(PORT, NUM) (((PORT)-'A') * 32 + (NUM)) -#define GPIO2PORT(PIN) ((PIN) / 32) -#define GPIO2BIT(PIN) (1<<((PIN) % 32)) - static Pio * const digital_regs[] = { PIOA, PIOB, PIOC, PIOD }; /**************************************************************** - * General Purpose Input Output (GPIO) pins + * Pin multiplexing ****************************************************************/ void @@ -47,6 +39,10 @@ gpio_peripheral(char bank, uint32_t bit, char ptype, uint32_t pull_up) } +/**************************************************************** + * General Purpose Input Output (GPIO) pins + ****************************************************************/ + struct gpio_out gpio_out_setup(uint8_t pin, uint8_t val) { diff --git a/src/sam3x8e/gpio.h b/src/sam3x8e/gpio.h index ec3ea821..be9d41c0 100644 --- a/src/sam3x8e/gpio.h +++ b/src/sam3x8e/gpio.h @@ -1,9 +1,7 @@ #ifndef __SAM3X8E_GPIO_H #define __SAM3X8E_GPIO_H -#include - -void gpio_peripheral(char bank, uint32_t bit, char ptype, uint32_t pull_up); +#include // uint32_t struct gpio_out { void *regs; diff --git a/src/sam3x8e/internal.h b/src/sam3x8e/internal.h new file mode 100644 index 00000000..733ef694 --- /dev/null +++ b/src/sam3x8e/internal.h @@ -0,0 +1,13 @@ +#ifndef __SAM3_INTERNAL_H +#define __SAM3_INTERNAL_H +// Local definitions for sam3 code + +#include // uint32_t + +#define GPIO(PORT, NUM) (((PORT)-'A') * 32 + (NUM)) +#define GPIO2PORT(PIN) ((PIN) / 32) +#define GPIO2BIT(PIN) (1<<((PIN) % 32)) + +void gpio_peripheral(char bank, uint32_t bit, char ptype, uint32_t pull_up); + +#endif // internal.h diff --git a/src/sam3x8e/serial.c b/src/sam3x8e/serial.c index b10e8d8b..a118122d 100644 --- a/src/sam3x8e/serial.c +++ b/src/sam3x8e/serial.c @@ -5,8 +5,8 @@ // This file may be distributed under the terms of the GNU GPLv3 license. #include "autoconf.h" // CONFIG_SERIAL_BAUD -#include "board/gpio.h" // gpio_peripheral #include "board/serial_irq.h" // serial_rx_data +#include "internal.h" // gpio_peripheral #include "sam3x8e.h" // UART #include "sched.h" // DECL_INIT diff --git a/src/sam3x8e/spi.c b/src/sam3x8e/spi.c index 51799506..81e7b653 100644 --- a/src/sam3x8e/spi.c +++ b/src/sam3x8e/spi.c @@ -6,7 +6,8 @@ #include // REGPTR #include "command.h" // shutdown -#include "gpio.h" // gpio_peripheral +#include "gpio.h" // spi_setup +#include "internal.h" // gpio_peripheral #include "sched.h" // sched_shutdown #define REGPTR SPI0