sam3x8e: Add an internal.h header file with local definitions

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor 2018-12-25 10:28:21 -05:00
parent c3a2fc981d
commit ecba3e9a19
5 changed files with 23 additions and 15 deletions

View File

@ -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)
{

View File

@ -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;

13
src/sam3x8e/internal.h Normal file
View File

@ -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

View File

@ -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

View File

@ -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