diff --git a/hardware/sam/cores/sam/build_gcc/Makefile b/hardware/sam/cores/sam/build_gcc/Makefile index c938789f1..0c1e0c0d7 100644 --- a/hardware/sam/cores/sam/build_gcc/Makefile +++ b/hardware/sam/cores/sam/build_gcc/Makefile @@ -1,5 +1,5 @@ #VARIANTS = sam3s_ek sam3u_ek arduino_due -VARIANTS = sam3u_ek +VARIANTS = arduino_due SUBMAKE_OPTIONS=--no-builtin-rules --no-builtin-variables diff --git a/hardware/sam/cores/sam/validation/build_gcc/Makefile b/hardware/sam/cores/sam/validation/build_gcc/Makefile index 7183fffa5..18cabf301 100644 --- a/hardware/sam/cores/sam/validation/build_gcc/Makefile +++ b/hardware/sam/cores/sam/validation/build_gcc/Makefile @@ -1,6 +1,3 @@ -# Makefile for compiling libboard -BOARD = - SUBMAKE_OPTIONS=--no-builtin-rules --no-builtin-variables #------------------------------------------------------------------------------- diff --git a/hardware/sam/cores/sam/validation/build_gcc/test.mk b/hardware/sam/cores/sam/validation/build_gcc/test.mk index 7d6fed01a..77ad4147d 100644 --- a/hardware/sam/cores/sam/validation/build_gcc/test.mk +++ b/hardware/sam/cores/sam/validation/build_gcc/test.mk @@ -1,11 +1,21 @@ # Makefile for compiling libArduino .SUFFIXES: .o .a .c .s -#CHIP=__SAM3S4C__ -CHIP=__SAM3U4E__ +# putting default variant +ifeq ("$(VARIANT)", "") #VARIANT=sam3s_ek -VARIANT=sam3u_ek -#VARIANT=arduino_due +#VARIANT=sam3u_ek +VARIANT=arduino_due +endif + +ifeq ("$(VARIANT)", "sam3s_ek") +CHIP=__SAM3S4C__ +else ifeq ("$(VARIANT)", "sam3u_ek") +CHIP=__SAM3U4E__ +else ifeq ("$(VARIANT)", "arduino_due") +CHIP=__SAM3U4E__ +endif + TOOLCHAIN=gcc #------------------------------------------------------------------------------- diff --git a/hardware/sam/cores/sam/validation/test.cpp b/hardware/sam/cores/sam/validation/test.cpp index 9590f6e4c..340b19d4e 100644 --- a/hardware/sam/cores/sam/validation/test.cpp +++ b/hardware/sam/cores/sam/validation/test.cpp @@ -11,9 +11,9 @@ void setup( void ) pinMode( PIN_LED, OUTPUT ) ; digitalWrite( PIN_LED, LOW ) ; - // Initialize the PIN_LED_GREEN digital pin as an output. - pinMode( PIN_LED_GREEN, OUTPUT ) ; - digitalWrite( PIN_LED_GREEN, HIGH ) ; + // Initialize the PIN_LED2 digital pin as an output. + pinMode( PIN_LED2, OUTPUT ) ; + digitalWrite( PIN_LED2, HIGH ) ; Serial.begin( 19200 ) ; } @@ -21,10 +21,10 @@ void setup( void ) void loop( void ) { digitalWrite( PIN_LED, HIGH ) ; // set the LED on - digitalWrite( PIN_LED_GREEN, LOW ) ; // set the red LED off + digitalWrite( PIN_LED2, LOW ) ; // set the red LED off delay( 1000 ) ; // wait for a second digitalWrite( PIN_LED, LOW ) ; // set the LED off - digitalWrite( PIN_LED_GREEN, HIGH ) ; // set the red LED on + digitalWrite( PIN_LED2, HIGH ) ; // set the red LED on delay( 1000 ) ; // wait for a second // Serial.write( '*' ) ; // send an initial char diff --git a/hardware/sam/system/libsam/cmsis/sam3u/include/component/pmc.h b/hardware/sam/system/libsam/cmsis/sam3u/include/component/pmc.h index be14b7828..a8b8ed77f 100644 --- a/hardware/sam/system/libsam/cmsis/sam3u/include/component/pmc.h +++ b/hardware/sam/system/libsam/cmsis/sam3u/include/component/pmc.h @@ -210,10 +210,20 @@ typedef struct { /* -------- PMC_PCK[3] : (PMC Offset: 0x0040) Programmable Clock 0 Register -------- */ #define PMC_PCK_CSS_Pos 0 #define PMC_PCK_CSS_Msk (0x7u << PMC_PCK_CSS_Pos) /**< \brief (PMC_PCK[3]) Master Clock Source Selection */ -#define PMC_PCK_CSS(value) ((PMC_PCK_CSS_Msk & ((value) << PMC_PCK_CSS_Pos))) +#define PMC_PCK_CSS_SLOW_CLK (0x0u << 0) /**< \brief (PMC_PCK[3]) Slow Clock is selected */ +#define PMC_PCK_CSS_MAIN_CLK (0x1u << 0) /**< \brief (PMC_PCK[3]) Main Clock is selected */ +#define PMC_PCK_CSS_PLLA_CLK (0x2u << 0) /**< \brief (PMC_PCK[3]) PLLA Clock is selected */ +#define PMC_PCK_CSS_PLLB_CLK (0x3u << 0) /**< \brief (PMC_PCK[3]) PLLB Clock is selected */ +#define PMC_PCK_CSS_MCK (0x4u << 0) /**< \brief (PMC_PCK[3]) Master Clock is selected */ #define PMC_PCK_PRES_Pos 4 -#define PMC_PCK_PRES_Msk (0x7u << PMC_PCK_PRES_Pos) /**< \brief (PMC_PCK[3]) Programmable Clock Prescaler */ -#define PMC_PCK_PRES(value) ((PMC_PCK_PRES_Msk & ((value) << PMC_PCK_PRES_Pos))) +#define PMC_PCK_PRES_Msk (0x7u << PMC_PCK_PRES_Pos) /**< \brief (PMC_PCK[3]) Processor Clock Prescaler */ +#define PMC_PCK_PRES_CLK (0x0u << 4) /**< \brief (PMC_PCK[3]) Selected clock */ +#define PMC_PCK_PRES_CLK_2 (0x1u << 4) /**< \brief (PMC_PCK[3]) Selected clock divided by 2 */ +#define PMC_PCK_PRES_CLK_4 (0x2u << 4) /**< \brief (PMC_PCK[3]) Selected clock divided by 4 */ +#define PMC_PCK_PRES_CLK_8 (0x3u << 4) /**< \brief (PMC_PCK[3]) Selected clock divided by 8 */ +#define PMC_PCK_PRES_CLK_16 (0x4u << 4) /**< \brief (PMC_PCK[3]) Selected clock divided by 16 */ +#define PMC_PCK_PRES_CLK_32 (0x5u << 4) /**< \brief (PMC_PCK[3]) Selected clock divided by 32 */ +#define PMC_PCK_PRES_CLK_64 (0x6u << 4) /**< \brief (PMC_PCK[3]) Selected clock divided by 64 */ /* -------- PMC_IER : (PMC Offset: 0x0060) Interrupt Enable Register -------- */ #define PMC_IER_MOSCXTS (0x1u << 0) /**< \brief (PMC_IER) Main Crystal Oscillator Status Interrupt Enable */ #define PMC_IER_LOCKA (0x1u << 1) /**< \brief (PMC_IER) PLL A Lock Interrupt Enable */ diff --git a/hardware/sam/system/libsam/cmsis/sam3u/source/templates/system_sam3u.c b/hardware/sam/system/libsam/cmsis/sam3u/source/templates/system_sam3u.c index c107e5ed1..90eb3fee5 100644 --- a/hardware/sam/system/libsam/cmsis/sam3u/source/templates/system_sam3u.c +++ b/hardware/sam/system/libsam/cmsis/sam3u/source/templates/system_sam3u.c @@ -25,13 +25,13 @@ extern "C" { /**INDENT-ON**/ /* @endcond */ -/* Clock settings (48MHz) */ +/* Clock settings (96MHz) */ #define BOARD_OSCOUNT (CKGR_MOR_MOSCXTST(0x8)) #define BOARD_PLLAR (CKGR_PLLAR_STUCKTO1 \ | CKGR_PLLAR_MULA(0x7) \ | CKGR_PLLAR_PLLACOUNT(0x3f) \ | CKGR_PLLAR_DIVA(0x1)) -#define BOARD_MCKR (PMC_MCKR_PRES_CLK_2 | PMC_MCKR_CSS_PLLA_CLK) +#define BOARD_MCKR (PMC_MCKR_PRES_CLK | PMC_MCKR_CSS_PLLA_CLK) /* Clock Definitions */ #define XTAL32 ( 32768UL) /* 32k crystal frequency */ diff --git a/hardware/sam/system/libsam/include/pio.h b/hardware/sam/system/libsam/include/pio.h index 7ffab84d5..cffb6a9bc 100644 --- a/hardware/sam/system/libsam/include/pio.h +++ b/hardware/sam/system/libsam/include/pio.h @@ -18,7 +18,7 @@ */ typedef enum _EPioType { - PIO_NOT_A_PIN, /* The pin is controlled by the associated signal of peripheral A. */ + PIO_NOT_A_PIN, /* Not under control of a peripheral. */ PIO_PERIPH_A, /* The pin is controlled by the associated signal of peripheral A. */ PIO_PERIPH_B, /* The pin is controlled by the associated signal of peripheral B. */ #if (defined _SAM3S_) || (defined _SAM3S8_) || (defined _SAM3N_) diff --git a/hardware/sam/variants/arduino_due/variant.cpp b/hardware/sam/variants/arduino_due/variant.cpp index 681ed2d21..1af9258ab 100644 --- a/hardware/sam/variants/arduino_due/variant.cpp +++ b/hardware/sam/variants/arduino_due/variant.cpp @@ -152,9 +152,12 @@ RingBuffer rx_buffer2 ; RingBuffer tx_buffer2 ; RingBuffer rx_buffer3 ; RingBuffer tx_buffer3 ; +RingBuffer rx_buffer4 ; +RingBuffer tx_buffer4 ; USARTClass Serial2( USART0, USART0_IRQn, ID_USART0, &rx_buffer2, &tx_buffer2 ) ; USARTClass Serial3( USART1, USART1_IRQn, ID_USART1, &rx_buffer3, &tx_buffer3 ) ; +USARTClass Serial4( USART2, USART2_IRQn, ID_USART2, &rx_buffer4, &tx_buffer4 ) ; #ifdef __cplusplus extern "C" { @@ -171,6 +174,11 @@ extern void USART1_IrqHandler( void ) Serial3.IrqHandler() ; } +extern void USART2_IrqHandler( void ) +{ + Serial4.IrqHandler() ; +} + #ifdef __cplusplus } #endif @@ -198,14 +206,9 @@ extern void init( void ) /* Disable watchdog, common to all SAM variants */ WDT_Disable( WDT ) ; - // Initialize Serial port UART0, common to all SAM3 variants + // 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].ulPinAttribute ) ; - - // Switch off Power LED - 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].ulPinAttribute ) ; - PIO_Clear( g_APinDescription[PIN_LED_RED].pPort, g_APinDescription[PIN_LED_RED].ulPin ) ; } #ifdef __cplusplus } diff --git a/hardware/sam/variants/arduino_due/variant.h b/hardware/sam/variants/arduino_due/variant.h index 2be14614a..b7546c6e1 100644 --- a/hardware/sam/variants/arduino_due/variant.h +++ b/hardware/sam/variants/arduino_due/variant.h @@ -48,17 +48,23 @@ * Pins *----------------------------------------------------------------------------*/ -#define PIN_LED_BLUE (0u) -#define PIN_LED_GREEN (1u) -#define PIN_LED_RED (2u) -#define PIN_LED PIN_LED_BLUE +#define PIN_LED_13 (0u) +#define PIN_LED_RXL (1u) +#define PIN_LED_TXL (2u) +#define PIN_LED PIN_LED_13 +#define PIN_LED2 PIN_LED_RXL +#define PIN_LED3 PIN_LED_TXL -static const uint8_t SS = 23 ; -static const uint8_t MOSI = 21 ; -static const uint8_t MISO = 20 ; -static const uint8_t SCK = 22 ; +static const uint8_t SS = 15 ; +static const uint8_t MOSI = 13 ; +static const uint8_t MISO = 12 ; +static const uint8_t SCK = 14 ; -#define PINS_UART (6u) +#define PINS_UART (5u) + +#define PINS_USART0 (5u) +#define PINS_USART1 (5u) +#define PINS_USART2 (5u) /*---------------------------------------------------------------------------- * Arduino objects - C++ only @@ -70,6 +76,7 @@ extern UARTClass Serial ; extern USARTClass Serial2 ; extern USARTClass Serial3 ; +extern USARTClass Serial4 ; #endif