diff --git a/hardware/arduino/sam/variants/arduino_due_u/build_gcc/libvariant_arduino_due_u.mk b/hardware/arduino/sam/variants/arduino_due_u/build_gcc/libvariant_arduino_due_u.mk index 6b1d5e066..635def90a 100644 --- a/hardware/arduino/sam/variants/arduino_due_u/build_gcc/libvariant_arduino_due_u.mk +++ b/hardware/arduino/sam/variants/arduino_due_u/build_gcc/libvariant_arduino_due_u.mk @@ -42,15 +42,13 @@ CMSIS_ATMEL_PATH=$(CMSIS_ROOT_PATH)/Device/ATMEL 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 %.h $(PROJECT_BASE_PATH) $(SYSTEM_PATH) $(VARIANT_PATH) +vpath %.cpp $(PROJECT_BASE_PATH) $(PROJECT_BASE_PATH) VPATH+=$(PROJECT_BASE_PATH) @@ -105,7 +103,6 @@ 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))) @@ -138,20 +135,20 @@ 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 ------------------------- +# @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 diff --git a/hardware/arduino/sam/variants/arduino_due_u/variant.cpp b/hardware/arduino/sam/variants/arduino_due_u/variant.cpp index a836a4e38..c98a30f63 100644 --- a/hardware/arduino/sam/variants/arduino_due_u/variant.cpp +++ b/hardware/arduino/sam/variants/arduino_due_u/variant.cpp @@ -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 @@ -356,15 +356,15 @@ extern void init( void ) 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_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_configure_trigger( ADC12B, ADC_TRIG_SW ) ; adc12_disable_interrupt( ADC12B, 0xFFFFFFFF ) ; /* Disable all adc interrupt. */ adc12_disable_channel( ADC12B, ADC_ALL_CHANNEL ) ; diff --git a/hardware/arduino/sam/variants/sam3s_ek/build_gcc/gcc.mk b/hardware/arduino/sam/variants/sam3s_ek/build_gcc/gcc.mk index ebbf6d3c0..99d8969be 100644 --- a/hardware/arduino/sam/variants/sam3s_ek/build_gcc/gcc.mk +++ b/hardware/arduino/sam/variants/sam3s_ek/build_gcc/gcc.mk @@ -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 @@ -17,7 +17,6 @@ # # Tool suffix when cross-compiling -#CROSS_COMPILE = ../../../../tools/CodeSourcery_arm/bin/arm-none-eabi- CROSS_COMPILE = $(ARM_GCC_TOOLCHAIN)/arm-none-eabi- # Compilation tools @@ -25,11 +24,13 @@ 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 +ifeq ($(OS),Windows_NT) RM=cs-rm -Rf +else +RM=rm -Rf +endif + SEP=\\ # --------------------------------------------------------------------------------------- @@ -49,7 +50,7 @@ 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 += --param max-inline-insns-single=500 -mcpu=cortex-m3 -mthumb -mlong-calls -ffunction-sections -nostdlib -std=c99 CFLAGS += $(OPTIMIZATION) $(INCLUDES) -D$(CHIP) -D$(VARIANT) # To reduce application size use only integer printf function. @@ -69,7 +70,7 @@ 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 += --param max-inline-insns-single=500 -mcpu=cortex-m3 -mthumb -mlong-calls -ffunction-sections -fno-rtti -fno-exceptions -std=c++98 CPPFLAGS += $(OPTIMIZATION) $(INCLUDES) -D$(CHIP) # To reduce application size use only integer printf function. diff --git a/hardware/arduino/sam/variants/sam3s_ek/build_gcc/libvariant_sam3s_ek.mk b/hardware/arduino/sam/variants/sam3s_ek/build_gcc/libvariant_sam3s_ek.mk index 1af8f3d32..ea4115594 100644 --- a/hardware/arduino/sam/variants/sam3s_ek/build_gcc/libvariant_sam3s_ek.mk +++ b/hardware/arduino/sam/variants/sam3s_ek/build_gcc/libvariant_sam3s_ek.mk @@ -1,5 +1,5 @@ # -# Copyright (c) 2011 Arduino. All right reserved. +# Copyright (c) 2012 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 @@ -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 @@ -34,30 +34,33 @@ OUTPUT_BIN = ../../../cores/sam # Libraries PROJECT_BASE_PATH = .. SYSTEM_PATH = ../../../system -CMSIS_PATH = $(SYSTEM_PATH)/CMSIS/Include +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 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 %.h $(PROJECT_BASE_PATH) $(SYSTEM_PATH) $(VARIANT_PATH) +vpath %.cpp $(PROJECT_BASE_PATH) $(PROJECT_BASE_PATH) VPATH+=$(PROJECT_BASE_PATH) -INCLUDES = +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) +INCLUDES += -I$(CMSIS_ARM_PATH) +INCLUDES += -I$(CMSIS_ATMEL_PATH) #------------------------------------------------------------------------------- ifdef DEBUG @@ -92,7 +95,7 @@ C_SRC=$(wildcard $(PROJECT_BASE_PATH)/*.c) C_OBJ_TEMP = $(patsubst %.c, %.o, $(notdir $(C_SRC))) # during development, remove some files -C_OBJ_FILTER=wiring_analog.o wiring_pulse.o +C_OBJ_FILTER= C_OBJ=$(filter-out $(C_OBJ_FILTER), $(C_OBJ_TEMP)) @@ -100,12 +103,11 @@ 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=Tone.o +CPP_OBJ_FILTER= CPP_OBJ=$(filter-out $(CPP_OBJ_FILTER), $(CPP_OBJ_TEMP)) @@ -130,23 +132,23 @@ $(VARIANT): create_output $(OUTPUT_LIB) .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 ------------------------- - @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 ------------------------- +# @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 diff --git a/hardware/arduino/sam/variants/sam3s_ek/variant.h b/hardware/arduino/sam/variants/sam3s_ek/variant.h index b2cb9256e..427f411cd 100644 --- a/hardware/arduino/sam/variants/sam3s_ek/variant.h +++ b/hardware/arduino/sam/variants/sam3s_ek/variant.h @@ -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 @@ -24,8 +24,10 @@ *----------------------------------------------------------------------------*/ #include "Arduino.h" +#ifdef __cplusplus #include "UARTClass.h" #include "USARTClass.h" +#endif /** * Libc porting layers @@ -62,19 +64,48 @@ * Pins *----------------------------------------------------------------------------*/ +// Number of pins defined in PinDescription array +#define PINS_COUNT (84u) + +// LEDs #define PIN_LED_BLUE (0u) #define PIN_LED_GREEN (1u) #define PIN_LED_RED (2u) #define PIN_LED PIN_LED_BLUE -#define PIN_DAC0 (u) +/* + * SPI Interfaces + */ +#define SPI_INTERFACES_COUNT 1 + +#define SPI_INTERFACE SPI +#define SPI_INTERFACE_ID ID_SPI +#define PIN_SPI_SS (4u) +#define PIN_SPI_MOSI (76u) +#define PIN_SPI_MISO (75u) +#define PIN_SPI_SCK (77u) static const uint8_t SS = 34 ; static const uint8_t MOSI = 32 ; static const uint8_t MISO = 31 ; static const uint8_t SCK = 33 ; -#define PINS_UART (16u) +/* + * 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 (68u) +#define PIN_WIRE1_SCL (69u) +#define WIRE1_INTERFACE TWI0 +#define WIRE1_INTERFACE_ID ID_TWI0 +#define WIRE1_ISR_HANDLER TWI0_IrqHandler #if defined VARIANT_REV_A # define PIN_TSC_IRQ_WUP_ID (1UL << 3) @@ -88,6 +119,54 @@ static const uint8_t SCK = 33 ; #define BOARD_LCD_BASE 0x61000000 /** Define ILI9325 base address. */ #define BOARD_LCD_RS (1 << 1) /** Define ILI9325 register select signal. */ +/* + * UART/USART Interfaces + */ +#define PINS_UART (6u) + +#define PINS_USART0 (81u) +#define PINS_USART1 (82u) + +/* + * 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 = ; +static const uint8_t A15 = ; + +#define PIN_DAC0 (u) + +/* + * 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 *----------------------------------------------------------------------------*/ @@ -98,7 +177,6 @@ extern UARTClass Serial ; extern UARTClass Serial2 ; extern USARTClass Serial3 ; -extern USARTClass Serial4 ; #endif diff --git a/hardware/arduino/sam/variants/sam3u_ek/build_gcc/gcc.mk b/hardware/arduino/sam/variants/sam3u_ek/build_gcc/gcc.mk index 34ceef055..99d8969be 100644 --- a/hardware/arduino/sam/variants/sam3u_ek/build_gcc/gcc.mk +++ b/hardware/arduino/sam/variants/sam3u_ek/build_gcc/gcc.mk @@ -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 @@ -17,7 +17,6 @@ # # Tool suffix when cross-compiling -#CROSS_COMPILE = ../../../../tools/CodeSourcery_arm/bin/arm-none-eabi- CROSS_COMPILE = $(ARM_GCC_TOOLCHAIN)/arm-none-eabi- # Compilation tools @@ -25,11 +24,13 @@ 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 +ifeq ($(OS),Windows_NT) RM=cs-rm -Rf +else +RM=rm -Rf +endif + SEP=\\ # --------------------------------------------------------------------------------------- @@ -49,7 +50,7 @@ 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 += --param max-inline-insns-single=500 -mcpu=cortex-m3 -mthumb -mlong-calls -ffunction-sections -nostdlib -std=c99 CFLAGS += $(OPTIMIZATION) $(INCLUDES) -D$(CHIP) -D$(VARIANT) # To reduce application size use only integer printf function. @@ -69,8 +70,7 @@ CPPFLAGS += -Wpacked -Wredundant-decls -Winline -Wlong-long #CPPFLAGS += -Wmissing-noreturn #CPPFLAGS += -Wconversion -# -fno-rtti -fno-exceptions -CPPFLAGS += --param max-inline-insns-single=500 -mcpu=cortex-m3 -mthumb -mlong-calls -ffunction-sections +CPPFLAGS += --param max-inline-insns-single=500 -mcpu=cortex-m3 -mthumb -mlong-calls -ffunction-sections -fno-rtti -fno-exceptions -std=c++98 CPPFLAGS += $(OPTIMIZATION) $(INCLUDES) -D$(CHIP) # To reduce application size use only integer printf function. diff --git a/hardware/arduino/sam/variants/sam3u_ek/build_gcc/libvariant_sam3u_ek.mk b/hardware/arduino/sam/variants/sam3u_ek/build_gcc/libvariant_sam3u_ek.mk index 8254f3c52..455896909 100644 --- a/hardware/arduino/sam/variants/sam3u_ek/build_gcc/libvariant_sam3u_ek.mk +++ b/hardware/arduino/sam/variants/sam3u_ek/build_gcc/libvariant_sam3u_ek.mk @@ -1,5 +1,5 @@ # -# Copyright (c) 2011 Arduino. All right reserved. +# Copyright (c) 2012 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 @@ -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 @@ -34,32 +34,33 @@ OUTPUT_BIN = ../../../cores/sam # Libraries PROJECT_BASE_PATH = .. SYSTEM_PATH = ../../../system -CMSIS_PATH = $(SYSTEM_PATH)/CMSIS/Include +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 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 %.h $(PROJECT_BASE_PATH) $(SYSTEM_PATH) $(VARIANT_PATH) +vpath %.cpp $(PROJECT_BASE_PATH) $(PROJECT_BASE_PATH) VPATH+=$(PROJECT_BASE_PATH) -INCLUDES = +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) +INCLUDES += -I$(CMSIS_ARM_PATH) +INCLUDES += -I$(CMSIS_ATMEL_PATH) #------------------------------------------------------------------------------- ifdef DEBUG @@ -102,7 +103,6 @@ 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))) @@ -132,23 +132,23 @@ $(VARIANT): create_output $(OUTPUT_LIB) .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 ------------------------- - @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 ------------------------- +# @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 diff --git a/hardware/arduino/sam/variants/sam3u_ek/variant.cpp b/hardware/arduino/sam/variants/sam3u_ek/variant.cpp index 4c436e451..74e4683b4 100644 --- a/hardware/arduino/sam/variants/sam3u_ek/variant.cpp +++ b/hardware/arduino/sam/variants/sam3u_ek/variant.cpp @@ -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,6 +23,11 @@ */ 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 // LEDS, 0..2 { PIOB, PIO_PB0, ID_PIOB, PIO_OUTPUT_0, PIO_DEFAULT }, // LED BLUE { PIOB, PIO_PB1, ID_PIOB, PIO_OUTPUT_1, PIO_DEFAULT }, // LED GREEN @@ -77,6 +82,13 @@ extern const PinDescription g_APinDescription[]= { PIOB, PIO_PB8, ID_PIOB, PIO_OUTPUT_0, PIO_DEFAULT }, // LCD RS { PIOC, PIO_PC19, ID_PIOC, PIO_OUTPUT_0, PIO_DEFAULT }, // LCD BackLight + // 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 }, + // 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 }, { NULL, 0, 0, PIO_NOT_A_PIN, PIO_DEFAULT } // END } ; @@ -84,86 +96,104 @@ extern const PinDescription g_APinDescription[]= * UART objects */ RingBuffer rx_buffer1 ; -RingBuffer tx_buffer1 ; -UARTClass Serial( UART, UART_IRQn, ID_UART, &rx_buffer1, &tx_buffer1 ) ; - -#ifdef __cplusplus -extern "C" { -#endif +UARTClass Serial( UART, UART_IRQn, ID_UART, &rx_buffer1 ) ; // IT handlers -extern void UART_Handler( void ) +void UART_Handler(void) { Serial.IrqHandler() ; } -#ifdef __cplusplus -} -#endif - // ---------------------------------------------------------------------------- /* * USART objects */ RingBuffer rx_buffer2 ; -RingBuffer tx_buffer2 ; RingBuffer rx_buffer3 ; -RingBuffer tx_buffer3 ; -USARTClass Serial2( USART0, USART0_IRQn, ID_USART0, &rx_buffer2, &tx_buffer2 ) ; -USARTClass Serial3( USART1, USART1_IRQn, ID_USART1, &rx_buffer3, &tx_buffer3 ) ; - -#ifdef __cplusplus -extern "C" { -#endif +USARTClass Serial2( USART0, USART0_IRQn, ID_USART0, &rx_buffer2 ) ; +USARTClass Serial3( USART1, USART1_IRQn, ID_USART1, &rx_buffer3 ) ; // IT handlers -extern void USART0_Handler( void ) +void USART0_Handler( void ) { Serial2.IrqHandler() ; } -extern void USART1_Handler( void ) +void USART1_Handler( void ) { Serial3.IrqHandler() ; } -#ifdef __cplusplus -} -#endif - // ---------------------------------------------------------------------------- #ifdef __cplusplus extern "C" { #endif +// Should be made in a better way... +extern void analogOutputInit(void); + /** * */ extern void init( void ) { - SystemInit() ; + SystemInit() ; - /* Set Systick to 1ms interval, common to all SAM3 variants */ - if ( SysTick_Config( SystemCoreClock / 1000 ) ) + // Set Systick to 1ms interval, common to all SAM3 variants + if ( SysTick_Config( SystemCoreClock / 1000 ) ) { - /* Capture error */ + // Capture error while ( 1 ) ; - } + } - /* Disable watchdog, common to all SAM variants */ + // Disable watchdog, common to all SAM variants WDT_Disable( WDT ) ; - // Initialize UART Serial port - PIO_Configure( g_APinDescription[PINS_UART].pPort, g_APinDescription[PINS_UART].ulPinType, - g_APinDescription[PINS_UART].ulPin, g_APinDescription[PINS_UART].ulPinConfiguration ) ; + // 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); // 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].ulPinConfiguration ) ; PIO_Clear( g_APinDescription[PIN_LED_RED].pPort, g_APinDescription[PIN_LED_RED].ulPin ) ; + + // 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 } diff --git a/hardware/arduino/sam/variants/sam3u_ek/variant.h b/hardware/arduino/sam/variants/sam3u_ek/variant.h index 77b0fe305..d259ea6a0 100644 --- a/hardware/arduino/sam/variants/sam3u_ek/variant.h +++ b/hardware/arduino/sam/variants/sam3u_ek/variant.h @@ -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 @@ -24,8 +24,10 @@ *----------------------------------------------------------------------------*/ #include "Arduino.h" +#ifdef __cplusplus #include "UARTClass.h" #include "USARTClass.h" +#endif /** * Libc porting layers @@ -64,19 +66,96 @@ * Pins *----------------------------------------------------------------------------*/ +// Number of pins defined in PinDescription array +#define PINS_COUNT (84u) + +// LEDs #define PIN_LED_BLUE (0u) #define PIN_LED_GREEN (1u) #define PIN_LED_RED (2u) #define PIN_LED PIN_LED_BLUE #define PIN_LED2 PIN_LED_GREEN +/* + * SPI Interfaces + */ +#define SPI_INTERFACES_COUNT 1 + +#define SPI_INTERFACE SPI +#define SPI_INTERFACE_ID ID_SPI +#define PIN_SPI_SS (4u) +#define PIN_SPI_MOSI (76u) +#define PIN_SPI_MISO (75u) +#define PIN_SPI_SCK (77u) + static const uint8_t SS = 23 ; static const uint8_t MOSI = 21 ; static const uint8_t MISO = 20 ; static const uint8_t SCK = 22 ; +/* + * 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 (68u) +#define PIN_WIRE1_SCL (69u) +#define WIRE1_INTERFACE TWI0 +#define WIRE1_INTERFACE_ID ID_TWI0 +#define WIRE1_ISR_HANDLER TWI0_IrqHandler + +/* + * UART/USART Interfaces + */ #define PINS_UART (6u) +#define PINS_USART0 (81u) +#define PINS_USART1 (82u) + +/* + * 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 = ; +// static const uint8_t A15 = ; + +/* + * 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 *----------------------------------------------------------------------------*/