atsam: Add MACH_SAM3X, MACH_SAM4, MACH_SAM4E, MACH_SAM4S definitions
Add additional Kconfig definitions to make it easier to select the correct code. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
275df53b2e
commit
d4790356da
|
@ -19,12 +19,26 @@ choice
|
|||
prompt "Processor model"
|
||||
config MACH_SAM3X8E
|
||||
bool "SAM3x8e (Arduino Due)"
|
||||
select MACH_SAM3X
|
||||
config MACH_SAM4S8C
|
||||
bool "SAM4s8c (Duet Maestro)"
|
||||
select MACH_SAM4S
|
||||
config MACH_SAM4E8E
|
||||
bool "SAM4e8e (Duet Wifi/Eth)"
|
||||
select MACH_SAM4E
|
||||
endchoice
|
||||
|
||||
config MACH_SAM3X
|
||||
bool
|
||||
config MACH_SAM4
|
||||
bool
|
||||
config MACH_SAM4S
|
||||
bool
|
||||
select MACH_SAM4
|
||||
config MACH_SAM4E
|
||||
bool
|
||||
select MACH_SAM4
|
||||
|
||||
config MCU
|
||||
string
|
||||
default "sam3x8e" if MACH_SAM3X8E
|
||||
|
@ -33,12 +47,12 @@ config MCU
|
|||
|
||||
config CLOCK_FREQ
|
||||
int
|
||||
default 42000000 if MACH_SAM3X8E # 84000000/2
|
||||
default 15000000 if MACH_SAM4S8C # 120000000/8
|
||||
default 60000000 if MACH_SAM4E8E # 120000000/2
|
||||
default 42000000 if MACH_SAM3X # 84000000/2
|
||||
default 15000000 if MACH_SAM4S # 120000000/8
|
||||
default 60000000 if MACH_SAM4E # 120000000/2
|
||||
|
||||
config USBSERIAL
|
||||
depends on MACH_SAM4S8C || MACH_SAM4E8E
|
||||
depends on MACH_SAM4
|
||||
bool "Use USB for communication (instead of serial)"
|
||||
default y
|
||||
config SERIAL
|
||||
|
|
|
@ -4,24 +4,27 @@
|
|||
CROSS_PREFIX=arm-none-eabi-
|
||||
|
||||
dirs-y += src/atsam src/generic
|
||||
dirs-$(CONFIG_MACH_SAM3X8E) += lib/sam3x/gcc/gcc
|
||||
dirs-$(CONFIG_MACH_SAM4S8C) += lib/sam4s/gcc/gcc
|
||||
dirs-$(CONFIG_MACH_SAM4E8E) += lib/sam4e/gcc/gcc
|
||||
dirs-$(CONFIG_MACH_SAM3X) += lib/sam3x/gcc/gcc
|
||||
dirs-$(CONFIG_MACH_SAM4S) += lib/sam4s/gcc/gcc
|
||||
dirs-$(CONFIG_MACH_SAM4E) += lib/sam4e/gcc/gcc
|
||||
|
||||
CFLAGS-$(CONFIG_MACH_SAM3X8E) += -mcpu=cortex-m3 -falign-loops=16
|
||||
CFLAGS-$(CONFIG_MACH_SAM3X8E) += -Ilib/sam3x/include -D__SAM3X8E__
|
||||
CFLAGS-$(CONFIG_MACH_SAM4S8C) += -mcpu=cortex-m4
|
||||
CFLAGS-$(CONFIG_MACH_SAM4S8C) += -Ilib/sam4s/include -D__SAM4S8C__
|
||||
CFLAGS-$(CONFIG_MACH_SAM4E8E) += -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=hard
|
||||
CFLAGS-$(CONFIG_MACH_SAM4E8E) += -Ilib/sam4e/include -D__SAM4E8E__
|
||||
CFLAGS-$(CONFIG_MACH_SAM3X) += -mcpu=cortex-m3 -falign-loops=16
|
||||
CFLAGS-$(CONFIG_MACH_SAM4) += -mcpu=cortex-m4
|
||||
CFLAGS-$(CONFIG_MACH_SAM4E) += -mfpu=fpv4-sp-d16 -mfloat-abi=hard
|
||||
CFLAGS-$(CONFIG_MACH_SAM3X) += -Ilib/sam3x/include
|
||||
CFLAGS-$(CONFIG_MACH_SAM4S) += -Ilib/sam4s/include
|
||||
CFLAGS-$(CONFIG_MACH_SAM4E) += -Ilib/sam4e/include
|
||||
CFLAGS-$(CONFIG_MACH_SAM3X8E) += -D__SAM3X8E__
|
||||
CFLAGS-$(CONFIG_MACH_SAM4S8C) += -D__SAM4S8C__
|
||||
CFLAGS-$(CONFIG_MACH_SAM4E8E) += -D__SAM4E8E__
|
||||
CFLAGS += -mthumb $(CFLAGS-y) -Ilib/cmsis-core
|
||||
|
||||
eflags-$(CONFIG_MACH_SAM3X8E) += -Llib/sam3x/gcc/gcc
|
||||
eflags-$(CONFIG_MACH_SAM3X8E) += -T lib/sam3x/gcc/gcc/sam3x8e_flash.ld
|
||||
eflags-$(CONFIG_MACH_SAM4S8C) += -Llib/sam4s/gcc/gcc
|
||||
eflags-$(CONFIG_MACH_SAM4S8C) += -T lib/sam4s/gcc/gcc/sam4s8c_flash.ld
|
||||
eflags-$(CONFIG_MACH_SAM4E8E) += -Llib/sam4e/gcc/gcc
|
||||
eflags-$(CONFIG_MACH_SAM4E8E) += -T lib/sam4e/gcc/gcc/sam4e8e_flash.ld
|
||||
eflags-$(CONFIG_MACH_SAM3X) += -Llib/sam3x/gcc/gcc
|
||||
eflags-$(CONFIG_MACH_SAM3X) += -T lib/sam3x/gcc/gcc/sam3x8e_flash.ld
|
||||
eflags-$(CONFIG_MACH_SAM4S) += -Llib/sam4s/gcc/gcc
|
||||
eflags-$(CONFIG_MACH_SAM4S) += -T lib/sam4s/gcc/gcc/sam4s8c_flash.ld
|
||||
eflags-$(CONFIG_MACH_SAM4E) += -Llib/sam4e/gcc/gcc
|
||||
eflags-$(CONFIG_MACH_SAM4E) += -T lib/sam4e/gcc/gcc/sam4e8e_flash.ld
|
||||
CFLAGS_klipper.elf += $(eflags-y) --specs=nano.specs --specs=nosys.specs
|
||||
|
||||
# Add source files
|
||||
|
@ -30,14 +33,15 @@ src-y += generic/crc16_ccitt.c generic/alloc.c
|
|||
src-y += generic/armcm_irq.c generic/timer_irq.c
|
||||
src-$(CONFIG_USBSERIAL) += atsam/sam4_usb.c generic/usb_cdc.c
|
||||
src-$(CONFIG_SERIAL) += atsam/serial.c generic/serial_irq.c
|
||||
src-$(CONFIG_MACH_SAM3X8E) += atsam/adc.c atsam/timer.c
|
||||
src-$(CONFIG_MACH_SAM3X8E) += ../lib/sam3x/gcc/system_sam3xa.c
|
||||
src-$(CONFIG_MACH_SAM3X8E) += ../lib/sam3x/gcc/gcc/startup_sam3xa.c
|
||||
src-$(CONFIG_MACH_SAM4S8C) += atsam/adc.c atsam/sam4s_timer.c atsam/sam4s_sysinit.c
|
||||
src-$(CONFIG_MACH_SAM4S8C) += ../lib/sam4s/gcc/gcc/startup_sam4s.c
|
||||
src-$(CONFIG_MACH_SAM4E8E) += atsam/sam4e_afec.c atsam/timer.c atsam/sam4_cache.c
|
||||
src-$(CONFIG_MACH_SAM4E8E) += ../lib/sam4e/gcc/system_sam4e.c
|
||||
src-$(CONFIG_MACH_SAM4E8E) += ../lib/sam4e/gcc/gcc/startup_sam4e.c
|
||||
src-$(CONFIG_MACH_SAM3X) += atsam/adc.c atsam/timer.c
|
||||
src-$(CONFIG_MACH_SAM4S) += atsam/adc.c atsam/sam4s_timer.c
|
||||
src-$(CONFIG_MACH_SAM4E) += atsam/sam4e_afec.c atsam/timer.c atsam/sam4_cache.c
|
||||
src-$(CONFIG_MACH_SAM3X) += ../lib/sam3x/gcc/system_sam3xa.c
|
||||
src-$(CONFIG_MACH_SAM3X) += ../lib/sam3x/gcc/gcc/startup_sam3xa.c
|
||||
src-$(CONFIG_MACH_SAM4S) += atsam/sam4s_sysinit.c
|
||||
src-$(CONFIG_MACH_SAM4S) += ../lib/sam4s/gcc/gcc/startup_sam4s.c
|
||||
src-$(CONFIG_MACH_SAM4E) += ../lib/sam4e/gcc/system_sam4e.c
|
||||
src-$(CONFIG_MACH_SAM4E) += ../lib/sam4e/gcc/gcc/startup_sam4e.c
|
||||
|
||||
# Build the additional hex output file
|
||||
target-y += $(OUT)klipper.bin
|
||||
|
|
|
@ -13,12 +13,12 @@
|
|||
#include "sched.h" // sched_shutdown
|
||||
|
||||
static const uint8_t adc_pins[] = {
|
||||
#if CONFIG_MACH_SAM3X8E
|
||||
#if CONFIG_MACH_SAM3X
|
||||
GPIO('A', 2), GPIO('A', 3), GPIO('A', 4), GPIO('A', 6),
|
||||
GPIO('A', 22), GPIO('A', 23), GPIO('A', 24), GPIO('A', 16),
|
||||
GPIO('B', 12), GPIO('B', 13), GPIO('B', 17), GPIO('B', 18),
|
||||
GPIO('B', 19), GPIO('B', 20)
|
||||
#elif CONFIG_MACH_SAM4S8C
|
||||
#elif CONFIG_MACH_SAM4S
|
||||
GPIO('A', 17), GPIO('A', 18), GPIO('A', 19), GPIO('A', 20),
|
||||
GPIO('B', 0), GPIO('B', 1), GPIO('B', 2), GPIO('B', 3),
|
||||
GPIO('A', 21), GPIO('A', 22), GPIO('C', 13), GPIO('C', 15),
|
||||
|
|
|
@ -32,7 +32,7 @@ gpio_peripheral(uint32_t gpio, char ptype, int32_t pull_up)
|
|||
uint32_t bank = GPIO2PORT(gpio), bit = GPIO2BIT(gpio), pt = ptype - 'A';
|
||||
Pio *regs = digital_regs[bank];
|
||||
|
||||
#if CONFIG_MACH_SAM3X8E
|
||||
#if CONFIG_MACH_SAM3X
|
||||
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);
|
||||
|
|
|
@ -12,12 +12,12 @@
|
|||
#include "sched.h" // sched_shutdown
|
||||
|
||||
// I2C pin definitions
|
||||
#if CONFIG_MACH_SAM3X8E
|
||||
#if CONFIG_MACH_SAM3X
|
||||
#define TWI0_SCL_GPIO GPIO('A', 18)
|
||||
#define TWI0_SDA_GPIO GPIO('A', 17)
|
||||
#define TWI1_SCL_GPIO GPIO('B', 13)
|
||||
#define TWI1_SDA_GPIO GPIO('B', 12)
|
||||
#elif CONFIG_MACH_SAM4S8C || CONFIG_MACH_SAM4E8E
|
||||
#elif CONFIG_MACH_SAM4
|
||||
#define TWI0_SCL_GPIO GPIO('A', 4)
|
||||
#define TWI0_SDA_GPIO GPIO('A', 3)
|
||||
#define TWI1_SCL_GPIO GPIO('B', 5)
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
#ifndef __SAM3_INTERNAL_H
|
||||
#define __SAM3_INTERNAL_H
|
||||
#ifndef __ATSAM_INTERNAL_H
|
||||
#define __ATSAM_INTERNAL_H
|
||||
// Local definitions for sam3/sam4 code
|
||||
|
||||
#include <stdint.h> // uint32_t
|
||||
#include "autoconf.h" // CONFIG_MACH_SAM3X8E
|
||||
#include "autoconf.h" // CONFIG_MACH_SAM3X
|
||||
|
||||
#if CONFIG_MACH_SAM3X8E
|
||||
#include "sam3x8e.h"
|
||||
#elif CONFIG_MACH_SAM4S8C
|
||||
#if CONFIG_MACH_SAM3X
|
||||
#include "sam3xa.h"
|
||||
#elif CONFIG_MACH_SAM4S
|
||||
#include "sam4s.h"
|
||||
#elif CONFIG_MACH_SAM4E8E
|
||||
#elif CONFIG_MACH_SAM4E
|
||||
#include "sam4e.h"
|
||||
#endif
|
||||
|
||||
|
|
|
@ -10,19 +10,19 @@
|
|||
#include "sched.h" // DECL_INIT
|
||||
|
||||
// Serial port pins
|
||||
#if CONFIG_MACH_SAM3X8E
|
||||
#if CONFIG_MACH_SAM3X
|
||||
#define Serial_IRQ_Handler UART_Handler
|
||||
static Uart * const Port = UART;
|
||||
static const uint32_t Pmc_id = ID_UART, Irq_id = UART_IRQn;
|
||||
static const uint32_t rx_pin = GPIO('A', 8);
|
||||
static const uint32_t tx_pin = GPIO('A', 9);
|
||||
#elif CONFIG_MACH_SAM4S8C
|
||||
#elif CONFIG_MACH_SAM4S
|
||||
#define Serial_IRQ_Handler UART1_Handler
|
||||
static Uart * const Port = UART1;
|
||||
static const uint32_t Pmc_id = ID_UART1, Irq_id = UART1_IRQn;
|
||||
static const uint32_t rx_pin = GPIO('B', 2);
|
||||
static const uint32_t tx_pin = GPIO('B', 3);
|
||||
#elif CONFIG_MACH_SAM4E8E
|
||||
#elif CONFIG_MACH_SAM4E
|
||||
#define Serial_IRQ_Handler UART0_Handler
|
||||
static Uart * const Port = UART0;
|
||||
static const uint32_t Pmc_id = ID_UART0, Irq_id = UART0_IRQn;
|
||||
|
|
|
@ -23,16 +23,16 @@ struct spi_info {
|
|||
};
|
||||
|
||||
static const struct spi_info spi_bus[] = {
|
||||
#if CONFIG_MACH_SAM3X8E
|
||||
#if CONFIG_MACH_SAM3X
|
||||
{ SPI0, ID_SPI0, GPIO('A', 25), GPIO('A', 26), GPIO('A', 27), 'A', 'A' },
|
||||
{ USART0, ID_USART0, GPIO('A', 10), GPIO('A', 11), GPIO('A', 17), 'A', 'B'},
|
||||
{ USART1, ID_USART1, GPIO('A', 12), GPIO('A', 13), GPIO('A', 16), 'A', 'A'},
|
||||
{ USART2, ID_USART2, GPIO('B', 21), GPIO('B', 20), GPIO('B', 24), 'A', 'A'},
|
||||
#elif CONFIG_MACH_SAM4S8C
|
||||
#elif CONFIG_MACH_SAM4S
|
||||
{ SPI, ID_SPI, GPIO('A', 12), GPIO('A', 13), GPIO('A', 14), 'A', 'A' },
|
||||
{ USART0, ID_USART0, GPIO('A', 5), GPIO('A', 6), GPIO('A', 2), 'A', 'B' },
|
||||
{ USART1, ID_USART1, GPIO('A', 21), GPIO('A', 22), GPIO('A', 23), 'A', 'A'},
|
||||
#elif CONFIG_MACH_SAM4E8E
|
||||
#elif CONFIG_MACH_SAM4E
|
||||
{ USART0, ID_USART0, GPIO('B', 0), GPIO('B', 1), GPIO('B', 13), 'C', 'C' },
|
||||
{ USART1, ID_USART1, GPIO('A', 21), GPIO('A', 22), GPIO('A', 23), 'A', 'A'},
|
||||
{ SPI, ID_SPI, GPIO('A', 12), GPIO('A', 13), GPIO('A', 14), 'A', 'A' },
|
||||
|
@ -42,7 +42,7 @@ static const struct spi_info spi_bus[] = {
|
|||
static int
|
||||
is_spihw(void *dev)
|
||||
{
|
||||
#if CONFIG_MACH_SAM3X8E
|
||||
#if CONFIG_MACH_SAM3X
|
||||
return dev == SPI0;
|
||||
#else
|
||||
return dev == SPI;
|
||||
|
|
Loading…
Reference in New Issue