diff --git a/hardware/arduino/sam/boards.txt b/hardware/arduino/sam/boards.txt index c0710c3f5..f550af5f4 100644 --- a/hardware/arduino/sam/boards.txt +++ b/hardware/arduino/sam/boards.txt @@ -26,7 +26,7 @@ sam3u_ek.build.pins=sam3u_ek ############################################################## -arduino_due.name=Arduino Due +arduino_due.name=Arduino DueU Dev. Ed. arduino_due.upload.tool=bossac arduino_due.upload.protocol=sam-ba arduino_due.upload.maximum_size=49152 @@ -35,4 +35,18 @@ arduino_due.build.f_cpu=96000000L arduino_due.build.core=sam arduino_due.build.extra_flags=-D__SAM3U4E__ arduino_due.build.ldscript=linker_scripts/gcc/flash.ld -arduino_due.build.variant=arduino_due +arduino_due.build.variant=arduino_due_u + +############################################################## + +arduino_due.name=Arduino DueX Dev. Ed. +arduino_due.upload.tool=bossac +arduino_due.upload.protocol=sam-ba +arduino_due.upload.maximum_size=49152 +arduino_due.build.mcu=cortex-m3 +arduino_due.build.f_cpu=96000000L +arduino_due.build.core=sam +arduino_due.build.extra_flags=-D__SAM3U4E__ +arduino_due.build.ldscript=linker_scripts/gcc/flash.ld +arduino_due.build.variant=arduino_due_x + diff --git a/hardware/arduino/sam/variants/arduino_due/1661fa.pdf b/hardware/arduino/sam/variants/arduino_due_u/1661fa.pdf similarity index 100% rename from hardware/arduino/sam/variants/arduino_due/1661fa.pdf rename to hardware/arduino/sam/variants/arduino_due_u/1661fa.pdf diff --git a/hardware/arduino/sam/variants/arduino_due/Arduino_ZZZ_U01.pdf b/hardware/arduino/sam/variants/arduino_due_u/Arduino_ZZZ_U01.pdf similarity index 100% rename from hardware/arduino/sam/variants/arduino_due/Arduino_ZZZ_U01.pdf rename to hardware/arduino/sam/variants/arduino_due_u/Arduino_ZZZ_U01.pdf diff --git a/hardware/arduino/sam/variants/arduino_due/build_gcc/Makefile b/hardware/arduino/sam/variants/arduino_due_u/build_gcc/Makefile similarity index 100% rename from hardware/arduino/sam/variants/arduino_due/build_gcc/Makefile rename to hardware/arduino/sam/variants/arduino_due_u/build_gcc/Makefile diff --git a/hardware/arduino/sam/variants/arduino_due/build_gcc/debug.mk b/hardware/arduino/sam/variants/arduino_due_u/build_gcc/debug.mk similarity index 100% rename from hardware/arduino/sam/variants/arduino_due/build_gcc/debug.mk rename to hardware/arduino/sam/variants/arduino_due_u/build_gcc/debug.mk diff --git a/hardware/arduino/sam/variants/arduino_due/build_gcc/gcc.mk b/hardware/arduino/sam/variants/arduino_due_u/build_gcc/gcc.mk similarity index 100% rename from hardware/arduino/sam/variants/arduino_due/build_gcc/gcc.mk rename to hardware/arduino/sam/variants/arduino_due_u/build_gcc/gcc.mk diff --git a/hardware/arduino/sam/variants/arduino_due/build_gcc/libvariant_arduino_due.mk b/hardware/arduino/sam/variants/arduino_due_u/build_gcc/libvariant_arduino_due.mk similarity index 100% rename from hardware/arduino/sam/variants/arduino_due/build_gcc/libvariant_arduino_due.mk rename to hardware/arduino/sam/variants/arduino_due_u/build_gcc/libvariant_arduino_due.mk diff --git a/hardware/arduino/sam/variants/arduino_due/build_gcc/release.mk b/hardware/arduino/sam/variants/arduino_due_u/build_gcc/release.mk similarity index 100% rename from hardware/arduino/sam/variants/arduino_due/build_gcc/release.mk rename to hardware/arduino/sam/variants/arduino_due_u/build_gcc/release.mk diff --git a/hardware/arduino/sam/variants/arduino_due/debug_scripts/gcc/arduino_due_flash.gdb b/hardware/arduino/sam/variants/arduino_due_u/debug_scripts/gcc/arduino_due_flash.gdb similarity index 100% rename from hardware/arduino/sam/variants/arduino_due/debug_scripts/gcc/arduino_due_flash.gdb rename to hardware/arduino/sam/variants/arduino_due_u/debug_scripts/gcc/arduino_due_flash.gdb diff --git a/hardware/arduino/sam/variants/arduino_due/debug_scripts/gcc/arduino_due_sram.gdb b/hardware/arduino/sam/variants/arduino_due_u/debug_scripts/gcc/arduino_due_sram.gdb similarity index 100% rename from hardware/arduino/sam/variants/arduino_due/debug_scripts/gcc/arduino_due_sram.gdb rename to hardware/arduino/sam/variants/arduino_due_u/debug_scripts/gcc/arduino_due_sram.gdb diff --git a/hardware/arduino/sam/variants/arduino_due/debug_scripts/iar/arduino_due_flash.mac b/hardware/arduino/sam/variants/arduino_due_u/debug_scripts/iar/arduino_due_flash.mac similarity index 100% rename from hardware/arduino/sam/variants/arduino_due/debug_scripts/iar/arduino_due_flash.mac rename to hardware/arduino/sam/variants/arduino_due_u/debug_scripts/iar/arduino_due_flash.mac diff --git a/hardware/arduino/sam/variants/arduino_due/debug_scripts/iar/arduino_due_sram.mac b/hardware/arduino/sam/variants/arduino_due_u/debug_scripts/iar/arduino_due_sram.mac similarity index 100% rename from hardware/arduino/sam/variants/arduino_due/debug_scripts/iar/arduino_due_sram.mac rename to hardware/arduino/sam/variants/arduino_due_u/debug_scripts/iar/arduino_due_sram.mac diff --git a/hardware/arduino/sam/variants/arduino_due/libsam_sam3u4e_gcc_rel.a b/hardware/arduino/sam/variants/arduino_due_u/libsam_sam3u4e_gcc_rel.a similarity index 100% rename from hardware/arduino/sam/variants/arduino_due/libsam_sam3u4e_gcc_rel.a rename to hardware/arduino/sam/variants/arduino_due_u/libsam_sam3u4e_gcc_rel.a diff --git a/hardware/arduino/sam/variants/arduino_due/libsam_sam3u4e_gcc_rel.a.txt b/hardware/arduino/sam/variants/arduino_due_u/libsam_sam3u4e_gcc_rel.a.txt similarity index 100% rename from hardware/arduino/sam/variants/arduino_due/libsam_sam3u4e_gcc_rel.a.txt rename to hardware/arduino/sam/variants/arduino_due_u/libsam_sam3u4e_gcc_rel.a.txt diff --git a/hardware/arduino/sam/variants/arduino_due/linker_scripts/gcc/flash.ld b/hardware/arduino/sam/variants/arduino_due_u/linker_scripts/gcc/flash.ld similarity index 100% rename from hardware/arduino/sam/variants/arduino_due/linker_scripts/gcc/flash.ld rename to hardware/arduino/sam/variants/arduino_due_u/linker_scripts/gcc/flash.ld diff --git a/hardware/arduino/sam/variants/arduino_due/linker_scripts/gcc/sram.ld b/hardware/arduino/sam/variants/arduino_due_u/linker_scripts/gcc/sram.ld similarity index 100% rename from hardware/arduino/sam/variants/arduino_due/linker_scripts/gcc/sram.ld rename to hardware/arduino/sam/variants/arduino_due_u/linker_scripts/gcc/sram.ld diff --git a/hardware/arduino/sam/variants/arduino_due/linker_scripts/iar/flash.icf b/hardware/arduino/sam/variants/arduino_due_u/linker_scripts/iar/flash.icf similarity index 100% rename from hardware/arduino/sam/variants/arduino_due/linker_scripts/iar/flash.icf rename to hardware/arduino/sam/variants/arduino_due_u/linker_scripts/iar/flash.icf diff --git a/hardware/arduino/sam/variants/arduino_due/linker_scripts/iar/sram.icf b/hardware/arduino/sam/variants/arduino_due_u/linker_scripts/iar/sram.icf similarity index 100% rename from hardware/arduino/sam/variants/arduino_due/linker_scripts/iar/sram.icf rename to hardware/arduino/sam/variants/arduino_due_u/linker_scripts/iar/sram.icf diff --git a/hardware/arduino/sam/variants/arduino_due/pins.xls b/hardware/arduino/sam/variants/arduino_due_u/pins.xls similarity index 100% rename from hardware/arduino/sam/variants/arduino_due/pins.xls rename to hardware/arduino/sam/variants/arduino_due_u/pins.xls diff --git a/hardware/arduino/sam/variants/arduino_due/variant.cpp b/hardware/arduino/sam/variants/arduino_due_u/variant.cpp similarity index 100% rename from hardware/arduino/sam/variants/arduino_due/variant.cpp rename to hardware/arduino/sam/variants/arduino_due_u/variant.cpp diff --git a/hardware/arduino/sam/variants/arduino_due/variant.h b/hardware/arduino/sam/variants/arduino_due_u/variant.h similarity index 100% rename from hardware/arduino/sam/variants/arduino_due/variant.h rename to hardware/arduino/sam/variants/arduino_due_u/variant.h diff --git a/hardware/arduino/sam/variants/arduino_due_x/1661fa.pdf b/hardware/arduino/sam/variants/arduino_due_x/1661fa.pdf new file mode 100644 index 000000000..bda8df4cb Binary files /dev/null and b/hardware/arduino/sam/variants/arduino_due_x/1661fa.pdf differ diff --git a/hardware/arduino/sam/variants/arduino_due_x/build_gcc/Makefile b/hardware/arduino/sam/variants/arduino_due_x/build_gcc/Makefile new file mode 100644 index 000000000..6851bdaa8 --- /dev/null +++ b/hardware/arduino/sam/variants/arduino_due_x/build_gcc/Makefile @@ -0,0 +1,42 @@ +# +# Copyright (c) 2011 Arduino. All right reserved. +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +# + +# Makefile for compiling libboard +BOARD = + +SUBMAKE_OPTIONS=--no-builtin-rules --no-builtin-variables + +#------------------------------------------------------------------------------- +# Rules +#------------------------------------------------------------------------------- + +all: arduino_due + +.PHONY: arduino_due +arduino_due: + @echo --- Making arduino_due + @$(MAKE) DEBUG=1 $(SUBMAKE_OPTIONS) -f libvariant_arduino_due.mk +# @$(MAKE) $(SUBMAKE_OPTIONS) -f libvariant_arduino_due.mk + +.PHONY: clean +clean: + @echo --- Cleaning arduino_due + @$(MAKE) DEBUG=1 $(SUBMAKE_OPTIONS) -f libvariant_arduino_due.mk $@ +# @$(MAKE) $(SUBMAKE_OPTIONS) -f libvariant_arduino_due.mk $@ + + diff --git a/hardware/arduino/sam/variants/arduino_due_x/build_gcc/debug.mk b/hardware/arduino/sam/variants/arduino_due_x/build_gcc/debug.mk new file mode 100644 index 000000000..d0716744a --- /dev/null +++ b/hardware/arduino/sam/variants/arduino_due_x/build_gcc/debug.mk @@ -0,0 +1,25 @@ +# +# Copyright (c) 2011 Arduino. All right reserved. +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +# + +# Optimization level +# -O1 Optimize +# -O2 Optimize even more +# -O3 Optimize yet more +# -O0 Reduce compilation time and make debugging produce the expected results +# -Os Optimize for size +OPTIMIZATION = -g -O0 -DDEBUG diff --git a/hardware/arduino/sam/variants/arduino_due_x/build_gcc/gcc.mk b/hardware/arduino/sam/variants/arduino_due_x/build_gcc/gcc.mk new file mode 100644 index 000000000..ebbf6d3c0 --- /dev/null +++ b/hardware/arduino/sam/variants/arduino_due_x/build_gcc/gcc.mk @@ -0,0 +1,81 @@ +# +# Copyright (c) 2011 Arduino. All right reserved. +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +# + +# Tool suffix when cross-compiling +#CROSS_COMPILE = ../../../../tools/CodeSourcery_arm/bin/arm-none-eabi- +CROSS_COMPILE = $(ARM_GCC_TOOLCHAIN)/arm-none-eabi- + +# Compilation tools +AR = $(CROSS_COMPILE)ar +CC = $(CROSS_COMPILE)gcc +CXX = $(CROSS_COMPILE)g++ +AS = $(CROSS_COMPILE)as +#LD = $(CROSS_COMPILE)ld +#SIZE = $(CROSS_COMPILE)size +NM = $(CROSS_COMPILE)nm +#OBJCOPY = $(CROSS_COMPILE)objcopy +RM=cs-rm -Rf +SEP=\\ + +# --------------------------------------------------------------------------------------- +# C Flags + +CFLAGS += -Wall -Wchar-subscripts -Wcomment -Wformat=2 -Wimplicit-int +CFLAGS += -Werror-implicit-function-declaration -Wmain -Wparentheses +CFLAGS += -Wsequence-point -Wreturn-type -Wswitch -Wtrigraphs -Wunused +CFLAGS += -Wuninitialized -Wunknown-pragmas -Wfloat-equal -Wundef +CFLAGS += -Wshadow -Wpointer-arith -Wbad-function-cast -Wwrite-strings +CFLAGS += -Wsign-compare -Waggregate-return -Wstrict-prototypes +CFLAGS += -Wmissing-prototypes -Wmissing-declarations +CFLAGS += -Wformat -Wmissing-format-attribute -Wno-deprecated-declarations +CFLAGS += -Wpacked -Wredundant-decls -Wnested-externs -Winline -Wlong-long +CFLAGS += -Wunreachable-code +CFLAGS += -Wcast-align +#CFLAGS += -Wmissing-noreturn +#CFLAGS += -Wconversion + +CFLAGS += --param max-inline-insns-single=500 -mcpu=cortex-m3 -mthumb -mlong-calls -ffunction-sections -nostdlib +CFLAGS += $(OPTIMIZATION) $(INCLUDES) -D$(CHIP) -D$(VARIANT) + +# To reduce application size use only integer printf function. +CFLAGS += -Dprintf=iprintf + +# --------------------------------------------------------------------------------------- +# CPP Flags + +CPPFLAGS += -Wall -Wchar-subscripts -Wcomment -Wformat=2 +CPPFLAGS += -Wmain -Wparentheses -Wcast-align -Wunreachable-code +CPPFLAGS += -Wsequence-point -Wreturn-type -Wswitch -Wtrigraphs -Wunused +CPPFLAGS += -Wuninitialized -Wunknown-pragmas -Wfloat-equal -Wundef +CPPFLAGS += -Wshadow -Wpointer-arith -Wwrite-strings +CPPFLAGS += -Wsign-compare -Waggregate-return -Wmissing-declarations +CPPFLAGS += -Wformat -Wmissing-format-attribute -Wno-deprecated-declarations +CPPFLAGS += -Wpacked -Wredundant-decls -Winline -Wlong-long +#CPPFLAGS += -Wmissing-noreturn +#CPPFLAGS += -Wconversion + +CPPFLAGS += --param max-inline-insns-single=500 -mcpu=cortex-m3 -mthumb -mlong-calls -ffunction-sections -fno-rtti -fno-exceptions +CPPFLAGS += $(OPTIMIZATION) $(INCLUDES) -D$(CHIP) + +# To reduce application size use only integer printf function. +CPPFLAGS += -Dprintf=iprintf + +# --------------------------------------------------------------------------------------- +# ASM Flags + +ASFLAGS = -mcpu=cortex-m3 -mthumb -Wall -g $(OPTIMIZATION) $(INCLUDES) diff --git a/hardware/arduino/sam/variants/arduino_due_x/build_gcc/libvariant_arduino_due.mk b/hardware/arduino/sam/variants/arduino_due_x/build_gcc/libvariant_arduino_due.mk new file mode 100644 index 000000000..f4d5965f3 --- /dev/null +++ b/hardware/arduino/sam/variants/arduino_due_x/build_gcc/libvariant_arduino_due.mk @@ -0,0 +1,174 @@ +# +# Copyright (c) 2011 Arduino. All right reserved. +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +# + +# Makefile for compiling libArduino +.SUFFIXES: .o .a .c .s + +CHIP=__SAM3U4E__ +VARIANT=arduino_due +LIBNAME=libvariant_$(VARIANT) +TOOLCHAIN=gcc + +#------------------------------------------------------------------------------- +# Path +#------------------------------------------------------------------------------- + +# Output directories +OUTPUT_BIN = ../../../cores/sam + +# Libraries +PROJECT_BASE_PATH = .. +SYSTEM_PATH = ../../../system +CMSIS_PATH = $(SYSTEM_PATH)/CMSIS/Include +ARDUINO_PATH = ../../../cores/sam +VARIANT_BASE_PATH = ../../../variants +VARIANT_PATH = ../../../variants/$(VARIANT) +VARIANT_COMMON_PATH = ../../common + +#------------------------------------------------------------------------------- +# Files +#------------------------------------------------------------------------------- + +vpath %.h $(PROJECT_BASE_PATH) $(SYSTEM_PATH) $(VARIANT_PATH) $(VARIANT_COMMON_PATH) +#vpath %.c $(PROJECT_BASE_PATH) $(VARIANT_PATH) +vpath %.cpp $(PROJECT_BASE_PATH) $(PROJECT_BASE_PATH) $(VARIANT_COMMON_PATH) + +VPATH+=$(PROJECT_BASE_PATH) + +INCLUDES = +#INCLUDES += -I$(PROJECT_BASE_PATH) +INCLUDES += -I$(ARDUINO_PATH) +INCLUDES += -I$(SYSTEM_PATH) +INCLUDES += -I$(SYSTEM_PATH)/libsam +INCLUDES += -I$(VARIANT_BASE_PATH) +INCLUDES += -I$(VARIANT_PATH) +INCLUDES += -I$(CMSIS_PATH) + +#------------------------------------------------------------------------------- +ifdef DEBUG +include debug.mk +else +include release.mk +endif + +#------------------------------------------------------------------------------- +# Tools +#------------------------------------------------------------------------------- + +include $(TOOLCHAIN).mk + +#------------------------------------------------------------------------------- +ifdef DEBUG +OUTPUT_OBJ=debug +OUTPUT_LIB_POSTFIX=dbg +else +OUTPUT_OBJ=release +OUTPUT_LIB_POSTFIX=rel +endif + +OUTPUT_LIB=$(LIBNAME)_$(TOOLCHAIN)_$(OUTPUT_LIB_POSTFIX).a +OUTPUT_PATH=$(OUTPUT_OBJ)_$(VARIANT) + +#------------------------------------------------------------------------------- +# C source files and objects +#------------------------------------------------------------------------------- +C_SRC=$(wildcard $(PROJECT_BASE_PATH)/*.c) + +C_OBJ_TEMP = $(patsubst %.c, %.o, $(notdir $(C_SRC))) + +# during development, remove some files +C_OBJ_FILTER= + +C_OBJ=$(filter-out $(C_OBJ_FILTER), $(C_OBJ_TEMP)) + +#------------------------------------------------------------------------------- +# CPP source files and objects +#------------------------------------------------------------------------------- +CPP_SRC=$(wildcard $(PROJECT_BASE_PATH)/*.cpp) +CPP_SRC+=$(wildcard $(VARIANT_COMMON_PATH)/*.cpp) + +CPP_OBJ_TEMP = $(patsubst %.cpp, %.o, $(notdir $(CPP_SRC))) + +# during development, remove some files +CPP_OBJ_FILTER= + +CPP_OBJ=$(filter-out $(CPP_OBJ_FILTER), $(CPP_OBJ_TEMP)) + +#------------------------------------------------------------------------------- +# Assembler source files and objects +#------------------------------------------------------------------------------- +A_SRC=$(wildcard $(PROJECT_BASE_PATH)/*.s) + +A_OBJ_TEMP=$(patsubst %.s, %.o, $(notdir $(A_SRC))) + +# during development, remove some files +A_OBJ_FILTER= + +A_OBJ=$(filter-out $(A_OBJ_FILTER), $(A_OBJ_TEMP)) + +#------------------------------------------------------------------------------- +# Rules +#------------------------------------------------------------------------------- +all: $(VARIANT) + +$(VARIANT): create_output $(OUTPUT_LIB) + +.PHONY: create_output +create_output: + @echo --- Preparing $(VARIANT) files in $(OUTPUT_PATH) $(OUTPUT_BIN) + @echo ------------------------- + @echo *$(INCLUDES) + @echo ------------------------- + @echo *$(C_SRC) + @echo ------------------------- + @echo *$(C_OBJ) + @echo ------------------------- + @echo *$(addprefix $(OUTPUT_PATH)/, $(C_OBJ)) + @echo ------------------------- + @echo *$(CPP_SRC) + @echo ------------------------- + @echo *$(CPP_OBJ) + @echo ------------------------- + @echo *$(addprefix $(OUTPUT_PATH)/, $(CPP_OBJ)) + @echo ------------------------- + @echo *$(A_SRC) + @echo ------------------------- + + -@mkdir $(OUTPUT_PATH) 1>NUL 2>&1 + +$(addprefix $(OUTPUT_PATH)/,$(C_OBJ)): $(OUTPUT_PATH)/%.o: %.c +# @$(CC) -v -c $(CFLAGS) $< -o $@ + @$(CC) -c $(CFLAGS) $< -o $@ + +$(addprefix $(OUTPUT_PATH)/,$(CPP_OBJ)): $(OUTPUT_PATH)/%.o: %.cpp +# @$(CC) -c $(CPPFLAGS) $< -o $@ + @$(CC) -xc++ -c $(CPPFLAGS) $< -o $@ + +$(addprefix $(OUTPUT_PATH)/,$(A_OBJ)): $(OUTPUT_PATH)/%.o: %.s + @$(AS) -c $(ASFLAGS) $< -o $@ + +$(OUTPUT_LIB): $(addprefix $(OUTPUT_PATH)/, $(C_OBJ)) $(addprefix $(OUTPUT_PATH)/, $(CPP_OBJ)) $(addprefix $(OUTPUT_PATH)/, $(A_OBJ)) + @$(AR) -v -r "$(OUTPUT_BIN)/$@" $^ + @$(NM) "$(OUTPUT_BIN)/$@" > "$(OUTPUT_BIN)/$@.txt" + + +.PHONY: clean +clean: + @echo --- Cleaning $(VARIANT) files [$(OUTPUT_PATH)$(SEP)*.o] + -@$(RM) $(OUTPUT_PATH) 1>NUL 2>&1 + -@$(RM) $(OUTPUT_BIN)/$(OUTPUT_LIB) 1>NUL 2>&1 diff --git a/hardware/arduino/sam/variants/arduino_due_x/build_gcc/release.mk b/hardware/arduino/sam/variants/arduino_due_x/build_gcc/release.mk new file mode 100644 index 000000000..0d15157f4 --- /dev/null +++ b/hardware/arduino/sam/variants/arduino_due_x/build_gcc/release.mk @@ -0,0 +1,25 @@ +# +# Copyright (c) 2011 Arduino. All right reserved. +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +# + +# Optimization level +# -O1 Optimize +# -O2 Optimize even more +# -O3 Optimize yet more +# -O0 Reduce compilation time and make debugging produce the expected results +# -Os Optimize for size +OPTIMIZATION = -Os diff --git a/hardware/arduino/sam/variants/arduino_due_x/debug_scripts/gcc/arduino_due_flash.gdb b/hardware/arduino/sam/variants/arduino_due_x/debug_scripts/gcc/arduino_due_flash.gdb new file mode 100644 index 000000000..c912752bc --- /dev/null +++ b/hardware/arduino/sam/variants/arduino_due_x/debug_scripts/gcc/arduino_due_flash.gdb @@ -0,0 +1,31 @@ +#******************************************************* +# +# Connect to J-Link and debug application in flash. +# + +# define 'reset' command +define reset + +# Connect to the J-Link gdb server +target remote localhost:2331 +# Reset the chip to get to a known state +monitor reset + +# Select flash device +monitor flash device = AT91SAM3U4E +# Enable flash download and flash breakpoints +monitor flash download = 1 +# Load the program +load + +# Reset peripheral (RSTC_CR) +set *0x400e1200 = 0xA5000004 + +# Initializing PC and stack pointer +mon reg sp=(0x80000) +set *0x80004 = *0x80004 & 0xFFFFFFFE +mon reg pc=(0x80004) +info reg + +# end of 'reset' command +end diff --git a/hardware/arduino/sam/variants/arduino_due_x/debug_scripts/gcc/arduino_due_sram.gdb b/hardware/arduino/sam/variants/arduino_due_x/debug_scripts/gcc/arduino_due_sram.gdb new file mode 100644 index 000000000..c7cc015ba --- /dev/null +++ b/hardware/arduino/sam/variants/arduino_due_x/debug_scripts/gcc/arduino_due_sram.gdb @@ -0,0 +1,23 @@ +#************************************************* +# +# Connect to J-Link and debug application in sram on SAM3U +# +# Note: +# First,users should do Step1 and Step2 according to your project, +# then do Step3. + +# Step1: Connect to the J-Link gdb server +#target remote localhost:2331 +#mon reset + +# Step2: Load file(eg. getting-started project) +#load bin/basic-dhrystone-project-at91sam3u-ek-at91sam3u4-sram.elf +#symbol-file bin/basic-dhrystone-project-at91sam3u-ek-at91sam3u4-sram.elf + +# Step3: Initializing PC and stack pointer +# Perpheral reset RSTC_CR +set *0x400e1200 = 0xA5000004 +# Modify pc value to even before writing pc register +mon reg sp=(0x20000000) +set *0x20000004 = *0x20000004 & 0xFFFFFFFE +mon reg pc=(0x20000004) diff --git a/hardware/arduino/sam/variants/arduino_due_x/debug_scripts/iar/arduino_due_flash.mac b/hardware/arduino/sam/variants/arduino_due_x/debug_scripts/iar/arduino_due_flash.mac new file mode 100644 index 000000000..959583582 --- /dev/null +++ b/hardware/arduino/sam/variants/arduino_due_x/debug_scripts/iar/arduino_due_flash.mac @@ -0,0 +1,44 @@ +// --------------------------------------------------------- +// ATMEL Microcontroller Software Support - ROUSSET - +// --------------------------------------------------------- +// The software is delivered "AS IS" without warranty or +// condition of any kind, either express, implied or +// statutory. This includes without limitation any warranty +// or condition with respect to merchantability or fitness +// for any particular purpose, or against the infringements of +// intellectual property rights of others. +// --------------------------------------------------------- +// File: at91sam3u-ek-flash.mac +// User setup file for CSPY debugger. +// --------------------------------------------------------- +__var __mac_i; +__var __mac_pt; + +/********************************************************************* +* +* execUserReset() +*/ +execUserReset() +{ + __message "------------------------------ execUserReset ---------------------------------"; + __message "-------------------------------Set PC Reset ----------------------------------"; + + __hwReset(0); + + // perpheral reset RSTC_CR + __writeMemory32(0xA5000004,0x400e1200,"Memory"); +} + +/********************************************************************* +* +* execUserPreload() +*/ +execUserPreload() +{ + __message "------------------------------ execUserPreload ---------------------------------"; + + __hwReset(0); //* Hardware Reset: CPU is automatically halted after the reset + + // perpheral reset RSTC_CR + __writeMemory32(0xA5000004,0x400e1200,"Memory"); +} diff --git a/hardware/arduino/sam/variants/arduino_due_x/debug_scripts/iar/arduino_due_sram.mac b/hardware/arduino/sam/variants/arduino_due_x/debug_scripts/iar/arduino_due_sram.mac new file mode 100644 index 000000000..ba86029d3 --- /dev/null +++ b/hardware/arduino/sam/variants/arduino_due_x/debug_scripts/iar/arduino_due_sram.mac @@ -0,0 +1,44 @@ +// --------------------------------------------------------- +// ATMEL Microcontroller Software Support - ROUSSET - +// --------------------------------------------------------- +// The software is delivered "AS IS" without warranty or +// condition of any kind, either express, implied or +// statutory. This includes without limitation any warranty +// or condition with respect to merchantability or fitness +// for any particular purpose, or against the infringements of +// intellectual property rights of others. +// --------------------------------------------------------- +// File: at91sam3u-ek-sram.mac +// User setup file for CSPY debugger. +// --------------------------------------------------------- +__var __mac_i; +__var __mac_pt; + +/********************************************************************* +* +* execUserReset() +*/ +execUserReset() +{ + __message "------------------------------ execUserReset ---------------------------------"; + __message "-------------------------------Set PC Reset ----------------------------------"; + + //__hwReset(50); + + // perpheral reset RSTC_CR + __writeMemory32(0xA5000004,0x400e1200,"Memory"); +} + +/********************************************************************* +* +* execUserPreload() +*/ +execUserPreload() +{ + __message "------------------------------ execUserPreload ---------------------------------"; + + __hwReset(0); //* Hardware Reset: CPU is automatically halted after the reset + + // perpheral reset RSTC_CR + __writeMemory32(0xA5000004,0x400e1200,"Memory"); +} diff --git a/hardware/arduino/sam/variants/arduino_due_x/linker_scripts/gcc/flash.ld b/hardware/arduino/sam/variants/arduino_due_x/linker_scripts/gcc/flash.ld new file mode 100644 index 000000000..c79e630a5 --- /dev/null +++ b/hardware/arduino/sam/variants/arduino_due_x/linker_scripts/gcc/flash.ld @@ -0,0 +1,150 @@ +/* ---------------------------------------------------------------------------- + * ATMEL Microcontroller Software Support + * ---------------------------------------------------------------------------- + * Copyright (c) 2009, Atmel Corporation + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the disclaimer below. + * + * Atmel's name may not be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE + * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * ---------------------------------------------------------------------------- + */ + +/*------------------------------------------------------------------------------ + * Linker script for running in internal FLASH on the SAM3U4 + *----------------------------------------------------------------------------*/ + +OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm") +OUTPUT_ARCH(arm) +SEARCH_DIR(.) + +/* Memory Spaces Definitions */ +MEMORY +{ + flash0 (W!RX) : ORIGIN = 0x00080000, LENGTH = 0x00020000 /* Flash0, 128K */ + flash1 (W!RX) : ORIGIN = 0x00100000, LENGTH = 0x00020000 /* Flash1, 128K */ + sram0 (W!RX) : ORIGIN = 0x20000000, LENGTH = 0x00008000 /* Sram0, 32K */ + sram1 (W!RX) : ORIGIN = 0x20080000, LENGTH = 0x00004000 /* Sram1, 16K */ + rom (rx) : ORIGIN = ORIGIN(flash1)-LENGTH(flash0), LENGTH = LENGTH(flash0)+LENGTH(flash1) /* Flash, 256K */ + ram (rwx) : ORIGIN = ORIGIN( sram1)-LENGTH( sram0), LENGTH = LENGTH( sram0)+LENGTH( sram1) /* sram, 48K */ +} + +/* The stack size used by the application. NOTE: you need to adjust */ +STACK_SIZE = 0x2000; + +/* Section Definitions */ +SECTIONS +{ + .text : + { + . = ALIGN(4); + _sfixed = .; + KEEP(*(.vectors .vectors.*)) + *(.text .text.* .gnu.linkonce.t.*) + *(.glue_7t) *(.glue_7) + *(.rodata .rodata* .gnu.linkonce.r.*) + *(.ARM.extab* .gnu.linkonce.armextab.*) + + /* Support C constructors, and C destructors in both user code + and the C library. This also provides support for C++ code. */ + . = ALIGN(4); + KEEP(*(.init)) + . = ALIGN(4); + __preinit_array_start = .; + KEEP (*(.preinit_array)) + __preinit_array_end = .; + + . = ALIGN(4); + __init_array_start = .; + KEEP (*(SORT(.init_array.*))) + KEEP (*(.init_array)) + __init_array_end = .; + + . = ALIGN(0x4); + KEEP (*crtbegin.o(.ctors)) + KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors)) + KEEP (*(SORT(.ctors.*))) + KEEP (*crtend.o(.ctors)) + + . = ALIGN(4); + KEEP(*(.fini)) + + . = ALIGN(4); + __fini_array_start = .; + KEEP (*(.fini_array)) + KEEP (*(SORT(.fini_array.*))) + __fini_array_end = .; + + KEEP (*crtbegin.o(.dtors)) + KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors)) + KEEP (*(SORT(.dtors.*))) + KEEP (*crtend.o(.dtors)) + + . = ALIGN(4); + _efixed = .; /* End of text section */ + } > flash0 + + /* .ARM.exidx is sorted, so has to go in its own output section. */ + PROVIDE_HIDDEN (__exidx_start = .); + .ARM.exidx : + { + *(.ARM.exidx* .gnu.linkonce.armexidx.*) + } > flash0 + PROVIDE_HIDDEN (__exidx_end = .); + + . = ALIGN(4); + _etext = .; + + .relocate : AT (_etext) + { + . = ALIGN(4); + _srelocate = .; + *(.ramfunc .ramfunc.*); + *(.data .data.*); + . = ALIGN(4); + _erelocate = .; + } > sram0 + + /* .bss section which is used for uninitialized data */ + .bss (NOLOAD) : + { + . = ALIGN(4); + _sbss = . ; + _szero = .; + *(.bss .bss.*) + *(COMMON) + . = ALIGN(4); + _ebss = . ; + _ezero = .; + } > sram0 + + /* stack section */ + .stack (NOLOAD): + { + . = ALIGN(8); + _sstack = .; + . = . + STACK_SIZE; + . = ALIGN(8); + _estack = .; + } > sram1 + + . = ALIGN(4); + _end = . ; +} diff --git a/hardware/arduino/sam/variants/arduino_due_x/linker_scripts/gcc/sram.ld b/hardware/arduino/sam/variants/arduino_due_x/linker_scripts/gcc/sram.ld new file mode 100644 index 000000000..c8e21ad30 --- /dev/null +++ b/hardware/arduino/sam/variants/arduino_due_x/linker_scripts/gcc/sram.ld @@ -0,0 +1,150 @@ +/* ---------------------------------------------------------------------------- + * ATMEL Microcontroller Software Support + * ---------------------------------------------------------------------------- + * Copyright (c) 2009, Atmel Corporation + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the disclaimer below. + * + * Atmel's name may not be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE + * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * ---------------------------------------------------------------------------- + */ + +/*------------------------------------------------------------------------------ + * Linker script for running in internal SRAM on the SAM3U4 + *----------------------------------------------------------------------------*/ + +OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm") +OUTPUT_ARCH(arm) +SEARCH_DIR(.) + +/* Memory Spaces Definitions */ +MEMORY +{ + flash0 (W!RX) : ORIGIN = 0x00080000, LENGTH = 0x00020000 /* Flash0, 128K */ + flash1 (W!RX) : ORIGIN = 0x00100000, LENGTH = 0x00020000 /* Flash1, 128K */ + sram0 (W!RX) : ORIGIN = 0x20000000, LENGTH = 0x00008000 /* Sram0, 32K */ + sram1 (W!RX) : ORIGIN = 0x20080000, LENGTH = 0x00004000 /* Sram1, 16K */ + rom (rx) : ORIGIN = ORIGIN(flash1)-LENGTH(flash0), LENGTH = LENGTH(flash0)+LENGTH(flash1) /* Flash, 256K */ + ram (rwx) : ORIGIN = ORIGIN( sram1)-LENGTH( sram0), LENGTH = LENGTH( sram0)+LENGTH( sram1) /* sram, 48K */ +} + +/* The stack size used by the application. NOTE: you need to adjust */ +STACK_SIZE = 0x800; + +/* Section Definitions */ +SECTIONS +{ + .text : + { + . = ALIGN(4); + _sfixed = .; + KEEP(*(.vectors .vectors.*)) + *(.text .text.* .gnu.linkonce.t.*) + *(.glue_7t) *(.glue_7) + *(.rodata .rodata* .gnu.linkonce.r.*) + *(.ARM.extab* .gnu.linkonce.armextab.*) + + /* Support C constructors, and C destructors in both user code + and the C library. This also provides support for C++ code. */ + . = ALIGN(4); + KEEP(*(.init)) + . = ALIGN(4); + __preinit_array_start = .; + KEEP (*(.preinit_array)) + __preinit_array_end = .; + + . = ALIGN(4); + __init_array_start = .; + KEEP (*(SORT(.init_array.*))) + KEEP (*(.init_array)) + __init_array_end = .; + + . = ALIGN(0x4); + KEEP (*crtbegin.o(.ctors)) + KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors)) + KEEP (*(SORT(.ctors.*))) + KEEP (*crtend.o(.ctors)) + + . = ALIGN(4); + KEEP(*(.fini)) + + . = ALIGN(4); + __fini_array_start = .; + KEEP (*(.fini_array)) + KEEP (*(SORT(.fini_array.*))) + __fini_array_end = .; + + KEEP (*crtbegin.o(.dtors)) + KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors)) + KEEP (*(SORT(.dtors.*))) + KEEP (*crtend.o(.dtors)) + + . = ALIGN(4); + _efixed = .; /* End of text section */ + } > sram0 + + . = ALIGN(4); + _etext = .; + + .relocate : AT (_etext) + { + . = ALIGN(4); + _srelocate = .; + *(.ramfunc .ramfunc.*); + *(.data .data.*); + . = ALIGN(4); + _erelocate = .; + } > sram1 + + /* .bss section which is used for uninitialized data */ + .bss (NOLOAD) : + { + . = ALIGN(4); + _sbss = . ; + _szero = .; + *(.bss .bss.*) + *(COMMON) + . = ALIGN(4); + _ebss = . ; + _ezero = .; + } > sram1 + + /* stack section */ + .stack (NOLOAD): + { + . = ALIGN(8); + _sstack = .; + . = . + STACK_SIZE; + . = ALIGN(8); + _estack = .; + } > sram1 + + /* .ARM.exidx is sorted, so has to go in its own output section. */ + PROVIDE_HIDDEN (__exidx_start = .); + .ARM.exidx : + { + *(.ARM.exidx* .gnu.linkonce.armexidx.*) + } > sram1 + PROVIDE_HIDDEN (__exidx_end = .); + + . = ALIGN(4); + _end = . ; +} diff --git a/hardware/arduino/sam/variants/arduino_due_x/linker_scripts/iar/flash.icf b/hardware/arduino/sam/variants/arduino_due_x/linker_scripts/iar/flash.icf new file mode 100644 index 000000000..956230fbd --- /dev/null +++ b/hardware/arduino/sam/variants/arduino_due_x/linker_scripts/iar/flash.icf @@ -0,0 +1,49 @@ +/*###ICF### Section handled by ICF editor, don't touch! ****/ +/*-Editor annotation file-*/ +/* IcfEditorFile="$TOOLKIT_DIR$\config\ide\IcfEditor\a_v1_0.xml" */ +/*-Vector table start*/ +define symbol __ICFEDIT_vector_start__ = 0x00080000; /*Add for CMSIS*/ +/*-Memory Regions-*/ +define symbol __ICFEDIT_region_RAM0_start__ = 0x20000000; +define symbol __ICFEDIT_region_RAM0_end__ = 0x20007FFF; +define symbol __ICFEDIT_region_RAM1_start__ = 0x20080000; +define symbol __ICFEDIT_region_RAM1_end__ = 0x20083FFF; +define symbol __ICFEDIT_region_ROM0_start__ = 0x00080000; +define symbol __ICFEDIT_region_ROM0_end__ = 0x0009FFFF; +define symbol __ICFEDIT_region_ROM1_start__ = 0x00100000; +define symbol __ICFEDIT_region_ROM1_end__ = 0x0011FFFF; +/*-Sizes-*/ +/*define symbol __ICFEDIT_size_cstack__ = 0x1000;*//*for nandflash*/ +define symbol __ICFEDIT_size_cstack__ = 0x2000; +define symbol __ICFEDIT_size_heap__ = 0x200; +/*-Specials-*/ +/*define symbol __ICFEDIT_region_RAM_VECT_start__ = __ICFEDIT_region_RAM0_start__;*/ /*Referenced for CMSIS*/ +/*define symbol __ICFEDIT_size_vectors__ = 0x100;*/ /*Referenced for CMSIS*/ +/*-Exports-*/ +/*export symbol __ICFEDIT_region_RAM_VECT_start__;*/ +export symbol __ICFEDIT_vector_start__; /*Add for CMSIS*/ +/**** End of ICF editor section. ###ICF###*/ + +define memory mem with size = 4G; +/*define region RAM_VECT_region = mem:[from __ICFEDIT_region_RAM_VECT_start__ size __ICFEDIT_size_vectors__];*/ /*Referenced for CMSIS*/ +/*define region RAM0_region = mem:[from __ICFEDIT_region_RAM0_start__+__ICFEDIT_size_vectors__ to __ICFEDIT_region_RAM0_end__];*/ /*Referenced for CMSIS*/ +define region RAM0_region = mem:[from __ICFEDIT_region_RAM0_start__ to __ICFEDIT_region_RAM0_end__]; +define region RAM1_region = mem:[from __ICFEDIT_region_RAM1_start__ to __ICFEDIT_region_RAM1_end__]; +/*define region RAM_region = mem:[from __ICFEDIT_region_RAM0_start__+__ICFEDIT_size_vectors__ to __ICFEDIT_region_RAM0_end__] | + mem:[from __ICFEDIT_region_RAM1_start__ to __ICFEDIT_region_RAM1_end__];*/ /*Referenced for CMSIS*/ +define region ROM0_region = mem:[from __ICFEDIT_region_ROM0_start__ to __ICFEDIT_region_ROM0_end__]; +define region ROM1_region = mem:[from __ICFEDIT_region_ROM1_start__ to __ICFEDIT_region_ROM1_end__]; + +/*define block RamVect with alignment = 8, size = __ICFEDIT_size_vectors__ { };*/ +define block CSTACK with alignment = 8, size = __ICFEDIT_size_cstack__ { }; +define block HEAP with alignment = 8, size = __ICFEDIT_size_heap__ { }; + +initialize by copy { readwrite }; +do not initialize { section .noinit }; + +/*place at start of ROM0_region { readonly section .vectors };*/ /*Referenced for CMSIS*/ +place at address mem:__ICFEDIT_vector_start__ { readonly section .intvec }; /*Add for CMSIS*/ +place in ROM0_region { readonly }; +place in RAM0_region { readwrite, block HEAP }; +place in RAM1_region { block CSTACK }; /* for nandflash*/ +/*place in RAM_VECT_region { block RamVect };*/ /*Referenced for CMSIS*/ \ No newline at end of file diff --git a/hardware/arduino/sam/variants/arduino_due_x/linker_scripts/iar/sram.icf b/hardware/arduino/sam/variants/arduino_due_x/linker_scripts/iar/sram.icf new file mode 100644 index 000000000..d7d33537a --- /dev/null +++ b/hardware/arduino/sam/variants/arduino_due_x/linker_scripts/iar/sram.icf @@ -0,0 +1,33 @@ +/*###ICF### Section handled by ICF editor, don't touch! ****/ +/*-Editor annotation file-*/ +/* IcfEditorFile="$TOOLKIT_DIR$\config\ide\IcfEditor\a_v1_0.xml" */ +/*-Vector table start*/ +define symbol __ICFEDIT_vector_start__ = 0x20000000; +/*-Memory Regions-*/ +define symbol __ICFEDIT_region_RAM0_start__ = 0x20000000; +define symbol __ICFEDIT_region_RAM0_end__ = 0x20007FFF; +define symbol __ICFEDIT_region_RAM1_start__ = 0x20080000; +define symbol __ICFEDIT_region_RAM1_end__ = 0x20083FFF; +/*-Sizes-*/ +define symbol __ICFEDIT_size_cstack__ = 0x900; +define symbol __ICFEDIT_size_heap__ = 0x200; +/*-Exports-*/ +export symbol __ICFEDIT_vector_start__; +/**** End of ICF editor section. ###ICF###*/ + +define memory mem with size = 4G; +define region RAM0_region = mem:[from __ICFEDIT_region_RAM0_start__ to __ICFEDIT_region_RAM0_end__]; +define region RAM1_region = mem:[from __ICFEDIT_region_RAM1_start__ to __ICFEDIT_region_RAM1_end__]; +/*define region RAM_region = mem:[from __ICFEDIT_region_RAM0_start__+__ICFEDIT_size_vectors__ to __ICFEDIT_region_RAM0_end__] | + mem:[from __ICFEDIT_region_RAM1_start__ to __ICFEDIT_region_RAM1_end__];*/ + +/* define block RamVect with alignment = 8, size = __ICFEDIT_size_vectors__ { }; */ +define block CSTACK with alignment = 8, size = __ICFEDIT_size_cstack__ { }; +define block HEAP with alignment = 8, size = __ICFEDIT_size_heap__ { }; + +initialize by copy { readwrite }; +do not initialize { section .noinit }; + +place at address mem:__ICFEDIT_vector_start__ { readonly section .intvec }; +place in RAM0_region { readonly }; +place in RAM1_region { readwrite, block CSTACK, block HEAP }; diff --git a/hardware/arduino/sam/variants/arduino_due_x/pins.xls b/hardware/arduino/sam/variants/arduino_due_x/pins.xls new file mode 100644 index 000000000..d105ee475 Binary files /dev/null and b/hardware/arduino/sam/variants/arduino_due_x/pins.xls differ diff --git a/hardware/arduino/sam/variants/arduino_due_x/variant.cpp b/hardware/arduino/sam/variants/arduino_due_x/variant.cpp new file mode 100644 index 000000000..40baa395d --- /dev/null +++ b/hardware/arduino/sam/variants/arduino_due_x/variant.cpp @@ -0,0 +1,383 @@ +/* + Copyright (c) 2011 Arduino. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include "variant.h" + +/* + * DUE Board pin | PORT + * ----------------+-------- + * 0 RX0 | PA8 + * 1 TX0 | PA9 + * 2 TIOA0 | PB25 + * 3 TIOA7 | PC28 + * 4 NPCS1 | PA29 + * 5 TIOA6 | PC25 + * 6 PWML7 | PC24 + * 7 PWML6 | PC23 + * 8 PWML5 | PC22 + * 9 PWML4 | PC21 + * 10 TIOA0 | PA28 PC29??? + * 11 TIOA8 | PD7 + * 12 TIOB8 | PD8 + * 13 TIOB0 | PB27 + * 14 TX3 TXD2 | PD4 + * 15 RX3 RXD2 | PD5 + * 16 TX2 TXD1 | PA13 + * 17 RX2 RXD1 | PA12 + * 18 TX1 | PA11 + * 19 RX1 | PA10 + * 20 SDA | PB12 (this pin is level adapted to 5V) + * 21 SCL | PB13 (this pin is level adapted to 5V) + * 22 | PB26 + * 23 | PA14 + * 24 | PA15 + * 25 | PD0 + * 26 | PD1 + * 27 | PD2 + * 28 | PD3 + * 29 | PD6 + * 30 | PD9 + * 31 | PA7 + * 32 | PD10 + * 33 | PC1 + * 34 | PC2 + * 35 | PC3 + * 36 | PC4 + * 37 | PC5 + * 38 | PC6 + * 39 | PC7 + * 40 | PC8 + * 41 | PC9 + * 42 | PA19 + * 43 | PA20 + * 44 | PC19 + * 45 | PC18 + * 46 | PC17 + * 47 | PC16 + * 48 | PC15 + * 49 | PC14 + * 50 | PC13 + * 51 | PC12 + * 52 | PB21 + * 53 | PB14 + * A0 | PA16 + * A1 | PA24 + * A2 | PA23 + * A3 | PA22 + * A4 | PA6 + * A5 | PA4 + * A6 | PA3 + * A7 | PA2 + * A8 | PB17 + * A9 | PB18 + * A10 | PB19 + * A11 | PB20 + * A12 | PB15 + * A13 | PB16 + * A14 | PA1 + * A15 | PA0 + * SDA1 | PA17 + * SCL1 | PA18 + * + * + * AT45DB021 pin | PORT + * ----------------+-------- + * SO | PA25 + * SI | PA26 + * SCK | PA27 + * #CS SS3 | PB23 + * + * + * LEDs | PORT + * ----------------+-------- + * "TX" | PA21 + * "RX" | PC30 + * "L" | PB27 + */ + + +/* + * Pins descriptions + */ +extern const PinDescription g_APinDescription[]= +{ + // 0 .. 53 - Digital pins + // ---------------------- + // 0/1 - UART (Serial) + { PIOA, PIO_PA8A_URXD, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NO_PWM, NO_TC }, // URXD + { PIOA, PIO_PA9A_UTXD, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NO_PWM, NO_TC }, // UTXD + + // 2 + { PIOB, PIO_PB25B_TIOA0, ID_PIOB, PIO_PERIPH_B, PIO_DEFAULT, (PIN_ATTR_DIGITAL|PIN_ATTR_TIMER), NO_ADC, NO_ADC, NO_PWM, TC0_CHA0 }, // TIOA0 + { PIOC, PIO_PC28B_TIOA7, ID_PIOC, PIO_PERIPH_B, PIO_DEFAULT, (PIN_ATTR_DIGITAL|PIN_ATTR_TIMER), NO_ADC, NO_ADC, NO_PWM, TC0_CHA7 }, // TIOA7 + { PIOA, PIO_PA29A_SPI0_NPCS1,ID_PIOA,PIO_PERIPH_A,PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NO_PWM, NO_TC }, // NPCS1 + + // 5 + { PIOC, PIO_PC25B_TIOA6, ID_PIOC, PIO_PERIPH_B, PIO_DEFAULT, (PIN_ATTR_DIGITAL|PIN_ATTR_TIMER), NO_ADC, NO_ADC, NO_PWM, TC0_CHA2 }, // TIOA6 + { PIOC, PIO_PC24B_PWML7, ID_PIOC, PIO_PERIPH_B, PIO_DEFAULT, (PIN_ATTR_DIGITAL|PIN_ATTR_PWM), NO_ADC, NO_ADC, PWM_CH7, NO_TC }, // PWML7 + { PIOC, PIO_PC23B_PWML6, ID_PIOC, PIO_PERIPH_B, PIO_DEFAULT, (PIN_ATTR_DIGITAL|PIN_ATTR_PWM), NO_ADC, NO_ADC, PWM_CH6, NO_TC }, // PWML6 + { PIOC, PIO_PC22B_PWML5, ID_PIOC, PIO_PERIPH_B, PIO_DEFAULT, (PIN_ATTR_DIGITAL|PIN_ATTR_PWM), NO_ADC, NO_ADC, PWM_CH5, NO_TC }, // PWML5 + { PIOC, PIO_PC21B_PWML4, ID_PIOC, PIO_PERIPH_B, PIO_DEFAULT, (PIN_ATTR_DIGITAL|PIN_ATTR_PWM), NO_ADC, NO_ADC, PWM_CH4, NO_TC }, // PWML4 + // 10 +// * 10 TIOA0 | PA28 PC29??? + { PIOA, PIO_PA1, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT, (PIN_ATTR_DIGITAL|PIN_ATTR_TIMER), NO_ADC, NO_ADC, NO_PWM, TC0_CHA0 }, // TIOA0 + { PIOD, PIO_PD7B_TIOA8, ID_PIOD, PIO_PERIPH_B, PIO_DEFAULT, (PIN_ATTR_DIGITAL|PIN_ATTR_TIMER), NO_ADC, NO_ADC, NO_PWM, TC0_CHA8 }, // TIOA8 + { PIOD, PIO_PD8B_TIOB8, ID_PIOD, PIO_PERIPH_B, PIO_DEFAULT, (PIN_ATTR_DIGITAL|PIN_ATTR_TIMER), NO_ADC, NO_ADC, NO_PWM, TC0_CHB8 }, // TIOB8 + + // 13 - AMBER LED + { PIOB, PIO_PB27B_TIOB0, ID_PIOB, PIO_OUTPUT_0, PIO_DEFAULT, (PIN_ATTR_DIGITAL|PIN_ATTR_TIMER), NO_ADC, NO_ADC, NO_PWM, TC0_CHB0 }, // TIOB0 + + // 14/15 - USART2 (Serial4) + { PIOA, PIO_PA22A_TXD2, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NO_PWM, NO_TC }, // TXD2 + { PIOA, PIO_PA23A_RXD2, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NO_PWM, NO_TC }, // RXD2 + + // 16/17 - USART1 (Serial3) + { PIOA, PIO_PA13A_TXD1, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NO_PWM, NO_TC }, // TXD1 + { PIOA, PIO_PA12A_RXD1, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NO_PWM, NO_TC }, // RXD1 + + // 18/19 - USART0 (Serial2) + { PIOA, PIO_PA11A_TXD0, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NO_PWM, NO_TC }, // TXD0 + { PIOA, PIO_PA10A_RXD0, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NO_PWM, NO_TC }, // RXD0 + + // 20/21 - TWI1 + { PIOB, PIO_PB12A_TWD1, ID_PIOB, PIO_PERIPH_A, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NO_PWM, NO_TC }, // TWD1 - SDA0 + { PIOB, PIO_PB13A_TWCK1, ID_PIOB, PIO_PERIPH_A, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NO_PWM, NO_TC }, // TWCK1 - SCL0 + + // 22 + { PIOB, PIO_PB26, ID_PIOB, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NO_PWM, NO_TC }, // PIN 22 + { PIOA, PIO_PA14, ID_PIOA, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NO_PWM, NO_TC }, // PIN 23 + { PIOA, PIO_PA15, ID_PIOA, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NO_PWM, NO_TC }, // PIN 24 + { PIOD, PIO_PD0, ID_PIOD, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NO_PWM, NO_TC }, // PIN 25 + + // 26 + { PIOD, PIO_PD1, ID_PIOD, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NO_PWM, NO_TC }, // PIN 26 + { PIOD, PIO_PD2, ID_PIOD, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NO_PWM, NO_TC }, // PIN 27 + { PIOD, PIO_PD3, ID_PIOD, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NO_PWM, NO_TC }, // PIN 28 + { PIOD, PIO_PD6, ID_PIOD, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NO_PWM, NO_TC }, // PIN 29 + + // 30 + { PIOD, PIO_PD9, ID_PIOD, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NO_PWM, NO_TC }, // PIN 30 + { PIOA, PIO_PA7, ID_PIOA, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NO_PWM, NO_TC }, // PIN 31 + { PIOD, PIO_PD10, ID_PIOD, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NO_PWM, NO_TC }, // PIN 32 + { PIOC, PIO_PC1, ID_PIOC, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NO_PWM, NO_TC }, // PIN 33 + + // 34 + { PIOC, PIO_PC2, ID_PIOC, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NO_PWM, NO_TC }, // PIN 34 + { PIOC, PIO_PC3, ID_PIOC, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NO_PWM, NO_TC }, // PIN 35 + { PIOC, PIO_PC4, ID_PIOC, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NO_PWM, NO_TC }, // PIN 36 + { PIOC, PIO_PC5, ID_PIOC, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NO_PWM, NO_TC }, // PIN 37 + + // 38 + { PIOC, PIO_PC6, ID_PIOC, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NO_PWM, NO_TC }, // PIN 38 + { PIOC, PIO_PC7, ID_PIOC, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NO_PWM, NO_TC }, // PIN 39 + { PIOC, PIO_PC8, ID_PIOC, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NO_PWM, NO_TC }, // PIN 40 + { PIOC, PIO_PC9, ID_PIOC, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NO_PWM, NO_TC }, // PIN 41 + + // 42 + { PIOA, PIO_PA19, ID_PIOA, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NO_PWM, NO_TC }, // PIN 42 + { PIOA, PIO_PA20, ID_PIOA, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NO_PWM, NO_TC }, // PIN 43 + { PIOC, PIO_PC19, ID_PIOC, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NO_PWM, NO_TC }, // PIN 44 + { PIOC, PIO_PC18, ID_PIOC, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NO_PWM, NO_TC }, // PIN 45 + + // 46 + { PIOC, PIO_PC17, ID_PIOC, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NO_PWM, NO_TC }, // PIN 46 + { PIOC, PIO_PC16, ID_PIOC, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NO_PWM, NO_TC }, // PIN 47 + { PIOC, PIO_PC15, ID_PIOC, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NO_PWM, NO_TC }, // PIN 48 + { PIOC, PIO_PC14, ID_PIOC, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NO_PWM, NO_TC }, // PIN 49 + + // 50 + { PIOC, PIO_PC13, ID_PIOC, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NO_PWM, NO_TC }, // PIN 50 + { PIOC, PIO_PC12, ID_PIOC, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NO_PWM, NO_TC }, // PIN 51 + { PIOB, PIO_PB21, ID_PIOB, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NO_PWM, NO_TC }, // PIN 52 + { PIOB, PIO_PB14, ID_PIOB, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NO_PWM, NO_TC }, // PIN 53 + + + // 54 .. 69 - Analog pins + // ---------------------- + { PIOA, PIO_PA16X1_AD7, ID_PIOA, PIO_INPUT, PIO_DEFAULT, PIN_ATTR_ANALOG, ADC0, ADC7, NO_PWM, NO_TC }, // AD0 + { PIOA, PIO_PA24X1_AD6, ID_PIOA, PIO_INPUT, PIO_DEFAULT, PIN_ATTR_ANALOG, ADC1, ADC6, NO_PWM, NO_TC }, // AD1 + { PIOA, PIO_PA23X1_AD5, ID_PIOA, PIO_INPUT, PIO_DEFAULT, PIN_ATTR_ANALOG, ADC2, ADC5, NO_PWM, NO_TC }, // AD2 + { PIOA, PIO_PA22X1_AD4, ID_PIOA, PIO_INPUT, PIO_DEFAULT, PIN_ATTR_ANALOG, ADC3, ADC4, NO_PWM, NO_TC }, // AD3 + // 58 + { PIOA, PIO_PA6X1_AD3, ID_PIOA, PIO_INPUT, PIO_DEFAULT, PIN_ATTR_ANALOG, ADC4, ADC3, NO_PWM, NO_TC }, // AD4 + { PIOA, PIO_PA4X1_AD2, ID_PIOA, PIO_INPUT, PIO_DEFAULT, PIN_ATTR_ANALOG, ADC5, ADC2, NO_PWM, NO_TC }, // AD5 + { PIOA, PIO_PA3X1_AD1, ID_PIOA, PIO_INPUT, PIO_DEFAULT, PIN_ATTR_ANALOG, ADC6, ADC1, NO_PWM, NO_TC }, // AD6 + { PIOA, PIO_PA2X1_AD0, ID_PIOA, PIO_INPUT, PIO_DEFAULT, PIN_ATTR_ANALOG, ADC7, ADC0, NO_PWM, NO_TC }, // AD7 + // 62 + { PIOB, PIO_PB17X1_AD10, ID_PIOB, PIO_INPUT, PIO_DEFAULT, PIN_ATTR_ANALOG, ADC8, ADC10, NO_PWM, NO_TC }, // AD8 + { PIOB, PIO_PB18X1_AD11, ID_PIOB, PIO_INPUT, PIO_DEFAULT, PIN_ATTR_ANALOG, ADC9, ADC11, NO_PWM, NO_TC }, // AD9 + { PIOB, PIO_PB19X1_AD12, ID_PIOB, PIO_INPUT, PIO_DEFAULT, PIN_ATTR_ANALOG, ADC10, ADC12, NO_PWM, NO_TC }, // AD10 + { PIOB, PIO_PB20X1_AD13, ID_PIOB, PIO_INPUT, PIO_DEFAULT, PIN_ATTR_ANALOG, ADC11, ADC13, NO_PWM, NO_TC }, // AD11 + // 66 + { PIOB, PIO_PB15X1_DAC0, ID_PIOB, PIO_INPUT, PIO_DEFAULT, PIN_ATTR_ANALOG, ADC12, DAC0, NO_PWM, NO_TC }, // AD12 + { PIOB, PIO_PB16X1_DAC1, ID_PIOB, PIO_INPUT, PIO_DEFAULT, PIN_ATTR_ANALOG, ADC13, DAC1, NO_PWM, NO_TC }, // AD13 + { PIOA, PIO_PA1A_CANRX0, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT, PIN_ATTR_DIGITAL, ADC14, NO_ADC, NO_PWM, NO_TC }, // AD14 + { PIOA, PIO_PA0A_CANTX0, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT, PIN_ATTR_DIGITAL, ADC15, NO_ADC, NO_PWM, NO_TC }, // AD15 + + // 70/71 - TWI0 + { PIOA, PIO_PA17A_TWD0, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NO_PWM, NO_TC }, // TWD0 - SDA1 + { PIOA, PIO_PA18A_TWCK0, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NO_PWM, NO_TC }, // TWCK0 - SCL1 + + // 72/73 - LEDs + { PIOC, PIO_PC30, ID_PIOC, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NO_PWM, NO_TC }, // LED AMBER RXL + { PIOA, PIO_PA21, ID_PIOA, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NO_PWM, NO_TC }, // LED AMBER TXL + + // 74/75/76 - SPI + { PIOA, PIO_PA25A_SPI0_MISO,ID_PIOA,PIO_PERIPH_A, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NO_PWM, NO_TC }, // MISO + { PIOA, PIO_PA26A_SPI0_MOSI,ID_PIOA,PIO_PERIPH_A, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NO_PWM, NO_TC }, // MOSI + { PIOA, PIO_PA27A_SPI0_SPCK,ID_PIOA,PIO_PERIPH_A, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NO_PWM, NO_TC }, // SPCK + + // 77 - SPI CS0 + { PIOA, PIO_PA28A_SPI0_NPCS0,ID_PIOA,PIO_PERIPH_A,PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NO_PWM, NO_TC }, // NPCS0 + + // 78 - SPI CS3 (chip select for onboard AT45DB021) + { PIOB, PIO_PB23B_SPI0_NPCS3,ID_PIOB,PIO_PERIPH_B,PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NO_PWM, NO_TC }, // NPCS3 + + // 79 .. 84 - "All pins" masks + + // 79 - TWI0 all pins + { PIOA, PIO_PA17A_TWD0|PIO_PA18A_TWCK0, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT, (PIN_ATTR_DIGITAL|PIN_ATTR_COMBO), NO_ADC, NO_ADC, NO_PWM, NO_TC }, + // 80 - TWI1 all pins + { PIOB, PIO_PB12A_TWD1|PIO_PB13A_TWCK1, ID_PIOB, PIO_PERIPH_A, PIO_DEFAULT, (PIN_ATTR_DIGITAL|PIN_ATTR_COMBO), NO_ADC, NO_ADC, NO_PWM, NO_TC }, + // 81 - UART (Serial) all pins + { PIOA, PIO_PA8A_URXD|PIO_PA9A_UTXD, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT, (PIN_ATTR_DIGITAL|PIN_ATTR_COMBO), NO_ADC, NO_ADC, NO_PWM, NO_TC }, + // 82 - USART0 (Serial2) all pins + { PIOA, PIO_PA11A_TXD0|PIO_PA10A_RXD0, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT, (PIN_ATTR_DIGITAL|PIN_ATTR_COMBO), NO_ADC, NO_ADC, NO_PWM, NO_TC }, + // 83 - USART1 (Serial3) all pins + { PIOA, PIO_PA13A_TXD1|PIO_PA12A_RXD1, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT, (PIN_ATTR_DIGITAL|PIN_ATTR_COMBO), NO_ADC, NO_ADC, NO_PWM, NO_TC }, + // 84 - USART2 (Serial4) all pins + { PIOA, PIO_PA22A_TXD2|PIO_PA23A_RXD2, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT, (PIN_ATTR_DIGITAL|PIN_ATTR_COMBO), NO_ADC, NO_ADC, NO_PWM, NO_TC }, + + // END + { NULL, 0, 0, PIO_NOT_A_PIN, PIO_DEFAULT, 0, NO_ADC, NO_ADC, NO_PWM, NO_TC } +} ; + +/* + * UART objects + */ +RingBuffer rx_buffer1 ; + +UARTClass Serial( UART, UART_IRQn, ID_UART, &rx_buffer1 ) ; + +// IT handlers +void UART_IrqHandler(void) +{ + Serial.IrqHandler() ; +} + +// ---------------------------------------------------------------------------- +/* + * USART objects + */ +RingBuffer rx_buffer2 ; +RingBuffer rx_buffer3 ; +RingBuffer rx_buffer4 ; + +USARTClass Serial2( USART0, USART0_IRQn, ID_USART0, &rx_buffer2 ) ; +USARTClass Serial3( USART1, USART1_IRQn, ID_USART1, &rx_buffer3 ) ; +USARTClass Serial4( USART2, USART2_IRQn, ID_USART2, &rx_buffer4 ) ; + +// IT handlers +void USART0_IrqHandler( void ) +{ + Serial2.IrqHandler() ; +} + +void USART1_IrqHandler( void ) +{ + Serial3.IrqHandler() ; +} + +void USART2_IrqHandler( void ) +{ + Serial4.IrqHandler() ; +} + +// ---------------------------------------------------------------------------- + +#ifdef __cplusplus +extern "C" { +#endif + +// Should be made in a better way... +extern void analogOutputInit(void); + +/** + * + */ +extern void init( void ) +{ + SystemInit() ; + + // Set Systick to 1ms interval, common to all SAM3 variants + if ( SysTick_Config( SystemCoreClock / 1000 ) ) + { + // Capture error + while ( 1 ) ; + } + + // Disable watchdog, common to all SAM variants + WDT_Disable( WDT ) ; + + // Initialize Serial port UART, common to all SAM3 variants + PIO_Configure( + g_APinDescription[PINS_UART].pPort, + g_APinDescription[PINS_UART].ulPinType, + g_APinDescription[PINS_UART].ulPin, + g_APinDescription[PINS_UART].ulPinConfiguration); + + // Initialize Serial ports USART + PIO_Configure( + g_APinDescription[PINS_USART0].pPort, + g_APinDescription[PINS_USART0].ulPinType, + g_APinDescription[PINS_USART0].ulPin, + g_APinDescription[PINS_USART0].ulPinConfiguration); + PIO_Configure( + g_APinDescription[PINS_USART1].pPort, + g_APinDescription[PINS_USART1].ulPinType, + g_APinDescription[PINS_USART1].ulPin, + g_APinDescription[PINS_USART1].ulPinConfiguration); + PIO_Configure( + g_APinDescription[PINS_USART2].pPort, + g_APinDescription[PINS_USART2].ulPinType, + g_APinDescription[PINS_USART2].ulPin, + g_APinDescription[PINS_USART2].ulPinConfiguration); + + // Initialize 10bit Analog Controller + PMC_EnablePeripheral( ID_ADC ) ; + adc_init( ADC, SystemCoreClock, ADC_FREQ_MAX, ADC_STARTUP ) ; + adc_configure_timing( ADC, 15 ) ; + adc_configure_trigger( ADC, ADC_TRIG_SW ) ; + adc_disable_interrupt( ADC, 0xFFFFFFFF ) ; /* Disable all adc interrupt. */ + adc_disable_channel( ADC, ADC_ALL_CHANNEL ) ; + + // Initialize 12bit Analog Controller + PMC_EnablePeripheral( ID_ADC12B ) ; + adc12_init( ADC12B, SystemCoreClock, ADC12_FREQ_MAX, ADC12_STARTUP_FAST, 1 ) ; + adc12_configure_timing( ADC12B, 15 ) ; + adc12_configure_trigger( ADC12B, ADC_TRIG_SW ) ; + adc12_disable_interrupt( ADC12B, 0xFFFFFFFF ) ; /* Disable all adc interrupt. */ + adc12_disable_channel( ADC12B, ADC_ALL_CHANNEL ) ; + + // Initialize analogOutput module + analogOutputInit(); +} +#ifdef __cplusplus +} +#endif + diff --git a/hardware/arduino/sam/variants/arduino_due_x/variant.h b/hardware/arduino/sam/variants/arduino_due_x/variant.h new file mode 100644 index 000000000..3a3e30e6f --- /dev/null +++ b/hardware/arduino/sam/variants/arduino_due_x/variant.h @@ -0,0 +1,174 @@ +/* + Copyright (c) 2011 Arduino. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#ifndef _VARIANT_ARDUINO_DUE_ +#define _VARIANT_ARDUINO_DUE_ + +/*---------------------------------------------------------------------------- + * Headers + *----------------------------------------------------------------------------*/ + +#include "Arduino.h" +#ifdef __cplusplus +#include "UARTClass.h" +#include "USARTClass.h" +#endif + +/** + * Libc porting layers + */ +#if defined ( __GNUC__ ) /* GCC CS3 */ +# include /** RedHat Newlib minimal stub */ +#endif + +/*---------------------------------------------------------------------------- + * Definitions + *----------------------------------------------------------------------------*/ + +/*----------------------------------------------------------------------------*/ + +#ifndef arduino_due +#define arduino_due +#endif + +/** Name of the board */ +#define VARIANT_NAME "ARDUINO_DUE" + +/* +#define VARIANT_REV_A +#define VARIANT_REV_B +*/ + +/** Frequency of the board main oscillator */ +#define VARIANT_MAINOSC 12000000 + +/** Master clock frequency */ +#define VARIANT_MCK 96000000 + +/*---------------------------------------------------------------------------- + * Pins + *----------------------------------------------------------------------------*/ + +// Number of pins defined in PinDescription array +#define PINS_COUNT (84u) + +// LEDs +#define PIN_LED_13 (13u) +#define PIN_LED_RXL (72u) +#define PIN_LED_TXL (73u) +#define PIN_LED PIN_LED_13 +#define PIN_LED2 PIN_LED_RXL +#define PIN_LED3 PIN_LED_TXL + +/* + * SPI Interfaces + */ +#define SPI_INTERFACES_COUNT 1 + +#define SPI_INTERFACE SPI +#define SPI_INTERFACE_ID ID_SPI +#define PIN_SPI_SS (77u) +#define PIN_SPI_MOSI (75u) +#define PIN_SPI_MISO (74u) +#define PIN_SPI_SCK (76u) + +static const uint8_t SS = PIN_SPI_SS ; +static const uint8_t MOSI = PIN_SPI_MOSI ; +static const uint8_t MISO = PIN_SPI_MISO ; +static const uint8_t SCK = PIN_SPI_SCK ; + +/* + * Wire Interfaces + */ +#define WIRE_INTERFACES_COUNT 2 + +#define PIN_WIRE_SDA (20u) +#define PIN_WIRE_SCL (21u) +#define WIRE_INTERFACE TWI1 +#define WIRE_INTERFACE_ID ID_TWI1 +#define WIRE_ISR_HANDLER TWI1_IrqHandler + +#define PIN_WIRE1_SDA (70u) +#define PIN_WIRE1_SCL (71u) +#define WIRE1_INTERFACE TWI0 +#define WIRE1_INTERFACE_ID ID_TWI0 +#define WIRE1_ISR_HANDLER TWI0_IrqHandler + +/* + * UART/USART Interfaces + */ +#define PINS_UART (81u) + +#define PINS_USART0 (82u) +#define PINS_USART1 (83u) +#define PINS_USART2 (84u) + +/* + * Analog pins + */ +static const uint8_t A0 = 54; +static const uint8_t A1 = 55; +static const uint8_t A2 = 56; +static const uint8_t A3 = 57; +static const uint8_t A4 = 58; +static const uint8_t A5 = 59; +static const uint8_t A6 = 60; +static const uint8_t A7 = 61; +static const uint8_t A8 = 62; +static const uint8_t A9 = 63; +static const uint8_t A10 = 64; +static const uint8_t A11 = 65; +static const uint8_t A12 = 66; +static const uint8_t A13 = 67; +static const uint8_t A14 = 68; +static const uint8_t A15 = 69; + +/* + * PWM + */ +#define PWM_INTERFACE PWM +#define PWM_INTERFACE_ID ID_PWM +#define PWM_FREQUENCY 1000 +#define PWM_MAX_DUTY_CYCLE 255 +#define PWM_MIN_DUTY_CYCLE 0 + +/* + * TC + */ +#define TC_INTERFACE TC0 +#define TC_INTERFACE_ID ID_TC0 +#define TC_FREQUENCY 1000 +#define TC_MAX_DUTY_CYCLE 255 +#define TC_MIN_DUTY_CYCLE 0 + +/*---------------------------------------------------------------------------- + * Arduino objects - C++ only + *----------------------------------------------------------------------------*/ + +#ifdef __cplusplus + +extern UARTClass Serial ; + +extern USARTClass Serial2 ; +extern USARTClass Serial3 ; +extern USARTClass Serial4 ; + +#endif + +#endif /* _VARIANT_ARDUINO_DUE_ */ +