aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2018-12-25 10:28:21 -0500
committerKevin O'Connor <kevin@koconnor.net>2019-01-07 19:30:17 -0500
commitecba3e9a19236c04e93ff102bc5cde55fdc906ad (patch)
treeedbbb473ed077a7b38a493ab250708e0effaad28
parentc3a2fc981d29202821e8a375005813fec76b32a7 (diff)
downloadkutter-ecba3e9a19236c04e93ff102bc5cde55fdc906ad.tar.gz
kutter-ecba3e9a19236c04e93ff102bc5cde55fdc906ad.tar.xz
kutter-ecba3e9a19236c04e93ff102bc5cde55fdc906ad.zip
sam3x8e: Add an internal.h header file with local definitions
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
-rw-r--r--src/sam3x8e/gpio.c16
-rw-r--r--src/sam3x8e/gpio.h4
-rw-r--r--src/sam3x8e/internal.h13
-rw-r--r--src/sam3x8e/serial.c2
-rw-r--r--src/sam3x8e/spi.c3
5 files changed, 23 insertions, 15 deletions
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 <stdint.h>
-
-void gpio_peripheral(char bank, uint32_t bit, char ptype, uint32_t pull_up);
+#include <stdint.h> // 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 <stdint.h> // 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 <sam3x8e.h> // 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