mirror of
https://github.com/arduino/Arduino.git
synced 2025-01-30 19:52:13 +01:00
[SAM] Added SAM3X_EK support for USB debug
This commit is contained in:
parent
9139b106ef
commit
e034de5ea9
@ -1,6 +1,6 @@
|
||||
ifeq ("$(VARIANTS)", "")
|
||||
VARIANTS = arduino_due_x arduino_due_u
|
||||
#VARIANTS = sam3u_ek sam3s_ek sam3x_ek
|
||||
VARIANTS = arduino_due_x arduino_due_u sam3x_ek
|
||||
#VARIANTS = sam3u_ek sam3s_ek
|
||||
endif
|
||||
|
||||
SUBMAKE_OPTIONS=--no-builtin-rules --no-builtin-variables
|
||||
@ -11,7 +11,7 @@ SUBMAKE_OPTIONS=--no-builtin-rules --no-builtin-variables
|
||||
|
||||
all: $(VARIANTS)
|
||||
|
||||
.PHONY: sam3s_ek
|
||||
.PHONY: sam3s_ek
|
||||
sam3s_ek:
|
||||
@echo --- Making sam3s_ek
|
||||
@$(MAKE) DEBUG=1 $(SUBMAKE_OPTIONS) -f libarduino_sam3s_ek.mk
|
||||
|
@ -39,7 +39,7 @@ CMSIS_ROOT_PATH = $(SYSTEM_PATH)/CMSIS
|
||||
CMSIS_ARM_PATH=$(CMSIS_ROOT_PATH)/CMSIS/Include
|
||||
CMSIS_ATMEL_PATH=$(CMSIS_ROOT_PATH)/Device/ATMEL
|
||||
CMSIS_CHIP_PATH=$(CMSIS_ROOT_PATH)/Device/ATMEL/$(CHIP_SERIE)
|
||||
VARIANT_PATH = ../../../variants/$(VARIANT)
|
||||
VARIANT_PATH = ../../../../../atmel/sam/variants/$(VARIANT)
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Files
|
||||
|
@ -8,7 +8,7 @@
|
||||
#
|
||||
# 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.
|
||||
# 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
|
||||
@ -23,18 +23,19 @@
|
||||
ifeq ("$(VARIANT)", "")
|
||||
#VARIANT=sam3s_ek
|
||||
#VARIANT=sam3u_ek
|
||||
VARIANT=arduino_due_x
|
||||
VARIANT=sam3x_ek
|
||||
#VARIANT=arduino_due_x
|
||||
endif
|
||||
|
||||
ifeq ("$(VARIANT)", "sam3s_ek")
|
||||
CHIP=__SAM3S4C__
|
||||
VARIANT_PATH = ../../../../atmel/sam/variants/$(VARIANT)
|
||||
VARIANT_PATH = ../../../../../../atmel/sam/variants/$(VARIANT)
|
||||
else ifeq ("$(VARIANT)", "sam3u_ek")
|
||||
CHIP=__SAM3U4E__
|
||||
VARIANT_PATH = ../../../../atmel/sam/variants/$(VARIANT)
|
||||
VARIANT_PATH = ../../../../../../atmel/sam/variants/$(VARIANT)
|
||||
else ifeq ("$(VARIANT)", "sam3x_ek")
|
||||
CHIP=__SAM3X8H__
|
||||
VARIANT_PATH = ../../../../atmel/sam/variants/$(VARIANT)
|
||||
VARIANT_PATH = ../../../../../../atmel/sam/variants/$(VARIANT)
|
||||
else ifeq ("$(VARIANT)", "arduino_due_u")
|
||||
CHIP=__SAM3U4E__
|
||||
VARIANT_PATH = ../../../../variants/$(VARIANT)
|
||||
@ -153,7 +154,7 @@ test: create_output libsam_$(CHIP_NAME)_$(TOOLCHAIN)_$(LIBS_POSTFIX).a libarduin
|
||||
|
||||
.PHONY: create_output
|
||||
create_output:
|
||||
@echo --- Preparing $(VARIANT) files in $(OUTPUT_PATH) $(OUTPUT_BIN)
|
||||
@echo --- Preparing $(VARIANT) files in $(OUTPUT_PATH) $(OUTPUT_BIN)
|
||||
# @echo -------------------------
|
||||
# @echo *$(INCLUDES)
|
||||
# @echo -------------------------
|
||||
@ -190,11 +191,11 @@ $(OUTPUT_BIN): $(addprefix $(OUTPUT_PATH)/, $(C_OBJ)) $(addprefix $(OUTPUT_PATH)
|
||||
clean:
|
||||
@echo --- Cleaning test files
|
||||
-@$(RM) $(OUTPUT_PATH) 1>NUL 2>&1
|
||||
|
||||
|
||||
# -$(RM) $(OUTPUT_PATH)/test.o
|
||||
# -$(RM) $(OUTPUT_PATH)/$(OUTPUT_BIN).elf
|
||||
# -$(RM) $(OUTPUT_PATH)/$(OUTPUT_BIN).elf
|
||||
# -$(RM) $(OUTPUT_PATH)/$(OUTPUT_BIN).elf.txt
|
||||
# -$(RM) $(OUTPUT_PATH)/$(OUTPUT_BIN).bin
|
||||
# -$(RM) $(OUTPUT_PATH)/$(OUTPUT_BIN).bin
|
||||
# -$(RM) $(OUTPUT_PATH)/$(OUTPUT_BIN).map
|
||||
|
||||
debug: test
|
||||
|
@ -8,7 +8,7 @@
|
||||
|
||||
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.
|
||||
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
|
||||
@ -18,6 +18,12 @@
|
||||
|
||||
#include "variant.h"
|
||||
|
||||
#ifdef _VARIANT_SAM3X_EK_
|
||||
#define MAX_ANALOG A0
|
||||
#elif _VARIANT_ARDUINO_DUE_X_
|
||||
#define MAX_ANALOG A10
|
||||
#endif
|
||||
|
||||
void setup( void )
|
||||
{
|
||||
// Initialize the digital pin as an output.
|
||||
@ -80,7 +86,7 @@ void loop( void )
|
||||
// Serial1.write( "test2" ) ; // send another string
|
||||
|
||||
Serial1.print("Analog ins: ");
|
||||
for (int i=A0; i<A11; i++) {
|
||||
for (int i=A0; i<=MAX_ANALOG; i++) {
|
||||
int a = analogRead(i);
|
||||
Serial1.print(a, DEC);
|
||||
Serial1.print(" ");
|
||||
|
@ -107,7 +107,7 @@ uint32_t analogRead(uint32_t ulPin)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined __SAM3X8E__
|
||||
#if defined __SAM3X8E__ || defined __SAM3X8H__
|
||||
switch ( g_APinDescription[ulPin].ulAnalogChannel )
|
||||
{
|
||||
// Handling ADC 10 bits channels
|
||||
|
@ -27,5 +27,7 @@ set *0x80004 = *0x80004 & 0xFFFFFFFE
|
||||
mon reg pc=(0x80004)
|
||||
info reg
|
||||
|
||||
break main
|
||||
|
||||
# end of 'reset' command
|
||||
end
|
||||
|
@ -16,8 +16,8 @@
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef _VARIANT_ARDUINO_DUE_
|
||||
#define _VARIANT_ARDUINO_DUE_
|
||||
#ifndef _VARIANT_ARDUINO_DUE_X_
|
||||
#define _VARIANT_ARDUINO_DUE_X_
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Headers
|
||||
@ -182,5 +182,5 @@ extern USARTClass Serial4 ;
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* _VARIANT_ARDUINO_DUE_ */
|
||||
#endif /* _VARIANT_ARDUINO_DUE_X_ */
|
||||
|
||||
|
@ -29,17 +29,17 @@ TOOLCHAIN=gcc
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
# Output directories
|
||||
OUTPUT_BIN = ../../../cores/sam
|
||||
OUTPUT_BIN = ../../../../../arduino/sam/cores/sam
|
||||
|
||||
# Libraries
|
||||
PROJECT_BASE_PATH = ..
|
||||
SYSTEM_PATH = ../../../system
|
||||
SYSTEM_PATH = ../../../../../arduino/sam/system
|
||||
CMSIS_ROOT_PATH = $(SYSTEM_PATH)/CMSIS
|
||||
CMSIS_ARM_PATH=$(CMSIS_ROOT_PATH)/CMSIS/Include
|
||||
CMSIS_ATMEL_PATH=$(CMSIS_ROOT_PATH)/Device/ATMEL
|
||||
#CMSIS_CHIP_PATH=$(CMSIS_ROOT_PATH)/Device/ATMEL/$(CHIP_SERIE)
|
||||
|
||||
ARDUINO_PATH = ../../../cores/sam
|
||||
ARDUINO_PATH = ../../../../../arduino/sam/cores/sam
|
||||
VARIANT_BASE_PATH = ../../../variants
|
||||
VARIANT_PATH = ../../../variants/$(VARIANT)
|
||||
|
||||
@ -166,8 +166,8 @@ $(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"
|
||||
"$(AR)" -v -r "$(OUTPUT_BIN)/$@" $^
|
||||
"$(NM)" "$(OUTPUT_BIN)/$@" > "$(OUTPUT_BIN)/$@.txt"
|
||||
|
||||
|
||||
.PHONY: clean
|
||||
|
@ -1,12 +1,12 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* ATMEL Microcontroller Software Support
|
||||
* SAM Software Package License
|
||||
* ----------------------------------------------------------------------------
|
||||
* Copyright (c) 2009, Atmel Corporation
|
||||
* Copyright (c) 2012, 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:
|
||||
* modification, are permitted provided that the following condition is met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the disclaimer below.
|
||||
@ -27,10 +27,6 @@
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Linker script for running in internal FLASH on the SAM3U4
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm")
|
||||
OUTPUT_ARCH(arm)
|
||||
SEARCH_DIR(.)
|
||||
@ -38,22 +34,20 @@ 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 */
|
||||
rom (rx) : ORIGIN = 0x00080000, LENGTH = 0x00080000 /* Flash, 512K */
|
||||
sram0 (rwx) : ORIGIN = 0x20000000, LENGTH = 0x00010000 /* sram0, 64K */
|
||||
sram1 (rwx) : ORIGIN = 0x20080000, LENGTH = 0x00008000 /* sram1, 32K */
|
||||
ram (rwx) : ORIGIN = 0x20070000, LENGTH = 0x00018000 /* sram, 96K */
|
||||
}
|
||||
|
||||
/* The stack size used by the application. NOTE: you need to adjust */
|
||||
STACK_SIZE = 0x2000;
|
||||
STACK_SIZE = DEFINED(STACK_SIZE) ? STACK_SIZE : 0x2000 ;
|
||||
|
||||
/* Section Definitions */
|
||||
SECTIONS
|
||||
{
|
||||
.text :
|
||||
{
|
||||
/* Section Definitions */
|
||||
SECTIONS
|
||||
{
|
||||
.text :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
_sfixed = .;
|
||||
KEEP(*(.vectors .vectors.*))
|
||||
@ -99,17 +93,17 @@ SECTIONS
|
||||
|
||||
. = ALIGN(4);
|
||||
_efixed = .; /* End of text section */
|
||||
} > flash0
|
||||
} > rom
|
||||
|
||||
/* .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
|
||||
} > rom
|
||||
PROVIDE_HIDDEN (__exidx_end = .);
|
||||
|
||||
. = ALIGN(4);
|
||||
. = ALIGN(4);
|
||||
_etext = .;
|
||||
|
||||
.relocate : AT (_etext)
|
||||
@ -120,11 +114,11 @@ SECTIONS
|
||||
*(.data .data.*);
|
||||
. = ALIGN(4);
|
||||
_erelocate = .;
|
||||
} > sram0
|
||||
} > ram
|
||||
|
||||
/* .bss section which is used for uninitialized data */
|
||||
/* .bss section which is used for uninitialized data */
|
||||
.bss (NOLOAD) :
|
||||
{
|
||||
{
|
||||
. = ALIGN(4);
|
||||
_sbss = . ;
|
||||
_szero = .;
|
||||
@ -133,18 +127,18 @@ SECTIONS
|
||||
. = ALIGN(4);
|
||||
_ebss = . ;
|
||||
_ezero = .;
|
||||
} > sram0
|
||||
} > ram
|
||||
|
||||
/* stack section */
|
||||
.stack (NOLOAD):
|
||||
{
|
||||
. = ALIGN(8);
|
||||
_sstack = .;
|
||||
_sstack = .;
|
||||
. = . + STACK_SIZE;
|
||||
. = ALIGN(8);
|
||||
_estack = .;
|
||||
} > sram1
|
||||
} > ram
|
||||
|
||||
. = ALIGN(4);
|
||||
_end = . ;
|
||||
. = ALIGN(4);
|
||||
_end = . ;
|
||||
}
|
||||
|
@ -51,22 +51,27 @@ extern const PinDescription g_APinDescription[]=
|
||||
// 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/5 - LEDS
|
||||
{ PIOB, PIO_PB13, ID_PIOB, PIO_OUTPUT_1, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NO_PWM, NO_TC }, // USER_LED1
|
||||
{ PIOB, PIO_PB12, ID_PIOB, PIO_OUTPUT_1, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NO_PWM, NO_TC }, // USER_LED2
|
||||
{ PIOA, PIO_PA12, ID_PIOA, PIO_OUTPUT_1, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NO_PWM, NO_TC }, // USER_LED3
|
||||
{ PIOA, PIO_PA13, ID_PIOA, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NO_PWM, NO_TC }, // POWER_LED
|
||||
|
||||
// USART0 (Serial2)
|
||||
// 6/7 - USART0 (Serial2)
|
||||
{ PIOA, PIO_PA10A_RXD0, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NO_PWM, NO_TC }, // URXD
|
||||
{ PIOA, PIO_PA11A_TXD0, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NO_PWM, NO_TC }, // UTXD
|
||||
|
||||
// x .. x - "All pins" masks
|
||||
// x - UART (Serial) all pins
|
||||
// 8 - 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 },
|
||||
// x - USART0 (Serial2) all pins
|
||||
|
||||
// 9 - 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 },
|
||||
|
||||
// 10 - Analog pins
|
||||
// ----------------------
|
||||
{ PIOA, PIO_PA3, ID_PIOA, PIO_INPUT, PIO_DEFAULT, PIN_ATTR_ANALOG, ADC0, ADC7, NO_PWM, NO_TC }, // AD0
|
||||
|
||||
{ NULL, 0, 0, PIO_NOT_A_PIN, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NO_PWM, NO_TC } // END
|
||||
} ;
|
||||
|
||||
@ -75,12 +80,12 @@ extern const PinDescription g_APinDescription[]=
|
||||
*/
|
||||
RingBuffer rx_buffer1 ;
|
||||
|
||||
UARTClass Serial( UART, UART_IRQn, ID_UART, &rx_buffer1 ) ;
|
||||
UARTClass Serial1( UART, UART_IRQn, ID_UART, &rx_buffer1 ) ;
|
||||
|
||||
// IT handlers
|
||||
void UART_Handler(void)
|
||||
{
|
||||
Serial.IrqHandler() ;
|
||||
Serial1.IrqHandler() ;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
@ -137,11 +142,11 @@ extern void init( void )
|
||||
g_APinDescription[PINS_USART0].ulPinConfiguration ) ;
|
||||
|
||||
// Switch off Power LED
|
||||
PIO_Configure( g_APinDescription[PIN_LED_RED].pPort,
|
||||
PIO_Configure( g_APinDescription[PIN_LED_RED].pPort,
|
||||
g_APinDescription[PIN_LED_RED].ulPinType,
|
||||
g_APinDescription[PIN_LED_RED].ulPin,
|
||||
g_APinDescription[PIN_LED_RED].ulPin,
|
||||
g_APinDescription[PIN_LED_RED].ulPinConfiguration ) ;
|
||||
|
||||
|
||||
PIO_Clear( g_APinDescription[PIN_LED_RED].pPort, g_APinDescription[PIN_LED_RED].ulPin ) ;
|
||||
}
|
||||
#ifdef __cplusplus
|
||||
|
@ -16,8 +16,8 @@
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef _VARIANT_SAM3U_EK_
|
||||
#define _VARIANT_SAM3U_EK_
|
||||
#ifndef _VARIANT_SAM3X_EK_
|
||||
#define _VARIANT_SAM3X_EK_
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Headers
|
||||
@ -86,18 +86,39 @@
|
||||
#define PINS_USART0 (9u)
|
||||
|
||||
|
||||
/*
|
||||
* Analog pins
|
||||
*/
|
||||
static const uint8_t A0 = 10;
|
||||
|
||||
/*
|
||||
* 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 UARTClass Serial1 ;
|
||||
|
||||
extern USARTClass Serial2 ;
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* _VARIANT_SAM3U_EK_ */
|
||||
#endif /* _VARIANT_SAM3X_EK_ */
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user