1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-07-30 16:24:09 +03:00

[sam] daily commit: EWARM project working, GCC compiling but fail due to missing match for Reset_Handler

This commit is contained in:
Thibaut VIARD
2011-09-09 19:15:21 +02:00
parent 3916472a36
commit 79ee7a1f6a
61 changed files with 4493 additions and 857 deletions

View File

@ -0,0 +1,140 @@
/*
%atmel_license%
*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "UART.h"
// Constructors ////////////////////////////////////////////////////////////////
UARTClass::UARTClass( Uart* pUart, IRQn_Type dwIrq, uint32_t dwId, RingBuffer* pRx_buffer, RingBuffer* pTx_buffer )
{
_rx_buffer = pRx_buffer ;
_tx_buffer = pTx_buffer ;
_pUart=pUart ;
_dwIrq=dwIrq ;
_dwId=dwId ;
}
// Public Methods //////////////////////////////////////////////////////////////
void UARTClass::begin( const uint32_t dwBaudRate )
{
/* Configure PMC */
PMC_EnablePeripheral( _dwId ) ;
/* Reset and disable receiver & transmitter */
_pUart->UART_CR = UART_CR_RSTRX | UART_CR_RSTTX | UART_CR_RXDIS | UART_CR_TXDIS ;
/* Configure mode */
_pUart->UART_MR = UART_MR_PAR_NO ;
/* Configure baudrate */
/* Asynchronous, no oversampling */
_pUart->UART_BRGR = (SystemCoreClock / dwBaudRate) / 16 ;
/* Disable PDC channel */
_pUart->UART_PTCR = UART_PTCR_RXTDIS | UART_PTCR_TXTDIS ;
/* Enable receiver and transmitter */
_pUart->UART_CR = UART_CR_RXEN | UART_CR_TXEN ;
}
void UARTClass::end( void )
{
// wait for transmission of outgoing data
while ( _tx_buffer->_iHead != _tx_buffer->_iTail )
{
}
// clear any received data
_rx_buffer->_iHead = _rx_buffer->_iTail ;
PMC_DisablePeripheral( _dwId ) ;
}
int UARTClass::available( void )
{
return (uint32_t)(SERIAL_BUFFER_SIZE + _rx_buffer->_iHead - _rx_buffer->_iTail) % SERIAL_BUFFER_SIZE ;
}
int UARTClass::peek( void )
{
if ( _rx_buffer->_iHead == _rx_buffer->_iTail )
{
return -1 ;
}
else
{
return _rx_buffer->_aucBuffer[_rx_buffer->_iTail] ;
}
}
int UARTClass::read( void )
{
// if the head isn't ahead of the _iTail, we don't have any characters
if ( _rx_buffer->_iHead == _rx_buffer->_iTail )
{
return -1 ;
}
else
{
unsigned char c = _rx_buffer->_aucBuffer[_rx_buffer->_iTail] ;
_rx_buffer->_iTail = (unsigned int)(_rx_buffer->_iTail + 1) % SERIAL_BUFFER_SIZE ;
return c ;
}
}
void UARTClass::flush( void )
{
while ( _tx_buffer->_iHead != _tx_buffer->_iTail )
{
}
}
void UARTClass::write( const uint8_t uc )
{
int i = (_tx_buffer->_iHead + 1) % SERIAL_BUFFER_SIZE ;
// If the output buffer is full, there's nothing for it other than to
// wait for the interrupt handler to empty it a bit
while ( i == _tx_buffer->_iTail )
{
}
_tx_buffer->_aucBuffer[_tx_buffer->_iHead] = uc ;
_tx_buffer->_iHead = i ;
/* Wait for the transmitter to be ready */
while ( (_pUart->UART_SR & UART_SR_TXEMPTY) == 0 ) ;
/* Send character */
_pUart->UART_THR=uc ;
}
void UARTClass::IrqHandler( void )
{
// RX char IT
uint8_t uc = _pUart->UART_RHR ;
_rx_buffer->store_char( uc ) ;
// TX FIFO empty IT
if ( _tx_buffer->_iHead == _tx_buffer->_iTail )
{
// Buffer empty, so disable interrupts
}
else
{
// There is more data in the output buffer. Send the next byte
uc = _tx_buffer->_aucBuffer[_tx_buffer->_iTail] ;
_tx_buffer->_iTail = (_tx_buffer->_iTail + 1) % SERIAL_BUFFER_SIZE ;
_pUart->UART_THR = uc ;
}
}

View File

@ -0,0 +1,34 @@
#ifndef _UART_CLASS_
#define _UART_CLASS_
// UART.cpp need this class to be predefined
//class UARTClass ;
#include "Arduino.h"
class UARTClass : public HardwareSerial
{
protected:
Uart* _pUart ;
IRQn_Type _dwIrq ;
uint32_t _dwId ;
public:
UARTClass( Uart* pUart, IRQn_Type dwIrq, uint32_t dwId, RingBuffer* pRx_buffer, RingBuffer* pTx_buffer ) ;
void begin( const uint32_t dwBaudRate ) ;
void end( void ) ;
int available( void ) ;
int peek( void ) ;
int read( void ) ;
void flush( void ) ;
void write( const uint8_t c ) ;
void IrqHandler( void ) ;
virtual void write( const char *str ) ;
virtual void write( const uint8_t *buffer, size_t size ) ;
// using Print::write ; // pull in write(str) and write(buf, size) from Print
};
#endif // _UART_CLASS_

View File

@ -0,0 +1,138 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "USART.h"
// Constructors ////////////////////////////////////////////////////////////////
USARTClass::USARTClass( Usart* pUsart, IRQn_Type dwIrq, uint32_t dwId, RingBuffer* pRx_buffer, RingBuffer* pTx_buffer )
{
_rx_buffer = pRx_buffer ;
_tx_buffer = pTx_buffer ;
_pUsart=pUsart ;
_dwIrq=dwIrq ;
_dwId=dwId ;
}
// Public Methods //////////////////////////////////////////////////////////////
void USARTClass::begin( const uint32_t dwBaudRate )
{
/* Configure PMC */
PMC_EnablePeripheral( _dwId ) ;
/* Reset and disable receiver & transmitter */
_pUsart->US_CR = US_CR_RSTRX | US_CR_RSTTX | US_CR_RXDIS | US_CR_TXDIS ;
/* Configure mode */
_pUsart->US_MR = US_MR_USART_MODE_NORMAL | US_MR_USCLKS_MCK | US_MR_CHRL_8_BIT | US_MR_PAR_NO |
US_MR_NBSTOP_1_BIT | US_MR_CHMODE_NORMAL;
/* Configure baudrate */
/* Asynchronous, no oversampling */
_pUsart->US_BRGR = (SystemCoreClock / dwBaudRate) / 16 ;
/* Disable PDC channel */
_pUsart->US_PTCR = US_PTCR_RXTDIS | US_PTCR_TXTDIS ;
/* Enable receiver and transmitter */
_pUsart->US_CR = US_CR_RXEN | US_CR_TXEN ;
}
void USARTClass::end()
{
// wait for transmission of outgoing data
while ( _tx_buffer->_iHead != _tx_buffer->_iTail )
{
}
// clear any received data
_rx_buffer->_iHead = _rx_buffer->_iTail ;
PMC_DisablePeripheral( _dwId ) ;
}
int USARTClass::available( void )
{
return (unsigned int)(SERIAL_BUFFER_SIZE + _rx_buffer->_iHead - _rx_buffer->_iTail) % SERIAL_BUFFER_SIZE ;
}
int USARTClass::peek( void )
{
if ( _rx_buffer->_iHead == _rx_buffer->_iTail )
{
return -1 ;
}
else
{
return _rx_buffer->_aucBuffer[_rx_buffer->_iTail] ;
}
}
int USARTClass::read( void )
{
// if the _iHead isn't ahead of the _iTail, we don't have any characters
if ( _rx_buffer->_iHead == _rx_buffer->_iTail )
{
return -1 ;
}
else
{
unsigned char c = _rx_buffer->_aucBuffer[_rx_buffer->_iTail] ;
_rx_buffer->_iTail = (unsigned int)(_rx_buffer->_iTail + 1) % SERIAL_BUFFER_SIZE ;
return c ;
}
}
void USARTClass::flush( void )
{
while ( _tx_buffer->_iHead != _tx_buffer->_iTail )
{
}
}
void USARTClass::write( uint8_t uc )
{
int i = (_tx_buffer->_iHead + 1) % SERIAL_BUFFER_SIZE ;
// If the output buffer is full, there's nothing for it other than to
// wait for the interrupt handler to empty it a bit
while ( i == _tx_buffer->_iTail )
{
}
_tx_buffer->_aucBuffer[_tx_buffer->_iHead] = uc ;
_tx_buffer->_iHead = i ;
/* Wait for the transmitter to be ready */
while ( (_pUsart->US_CSR & US_CSR_TXEMPTY) == 0 ) ;
/* Send character */
_pUsart->US_THR=uc ;
}
void USARTClass::IrqHandler( void )
{
// RX char IT
uint8_t uc = _pUsart->US_RHR ;
_rx_buffer->store_char( uc ) ;
// TX FIFO empty IT
if ( _tx_buffer->_iHead == _tx_buffer->_iTail )
{
// Buffer empty, so disable interrupts
}
else
{
// There is more data in the output buffer. Send the next byte
uc = _tx_buffer->_aucBuffer[_tx_buffer->_iTail] ;
_tx_buffer->_iTail = (_tx_buffer->_iTail + 1) % SERIAL_BUFFER_SIZE ;
_pUsart->US_THR = uc ;
}
}

View File

@ -0,0 +1,34 @@
#ifndef _USART_CLASS_
#define _USART_CLASS_
// USART.cpp need this class to be predefined
//class USARTClass ;
#include "Arduino.h"
class USARTClass : public HardwareSerial
{
protected:
Usart* _pUsart ;
IRQn_Type _dwIrq ;
uint32_t _dwId ;
public:
USARTClass( Usart* pUsart, IRQn_Type dwIrq, uint32_t dwId, RingBuffer* pRx_buffer, RingBuffer* pTx_buffer ) ;
void begin( const uint32_t dwBaudRate ) ;
void end( void ) ;
int available( void ) ;
int peek( void ) ;
int read( void ) ;
void flush( void ) ;
void write( const uint8_t c ) ;
void IrqHandler( void ) ;
virtual void write( const char *str ) ;
virtual void write( const uint8_t *buffer, size_t size ) ;
// using Print::write ; // pull in write(str) and write(buf, size) from Print
};
#endif // _USART_CLASS_

View File

@ -0,0 +1,50 @@
#include "Arduino.h"
#ifdef __cplusplus
extern "C" {
#endif
extern void NMI_Handler( void )
{
for ( ;; ) ;
}
extern void HardFault_Handler( void )
{
for ( ;; ) ;
}
extern void MemManage_Handler( void )
{
for ( ;; ) ;
}
extern void BusFault_Handler( void )
{
for ( ;; ) ;
}
extern void UsageFault_Handler( void )
{
for ( ;; ) ;
}
extern void SVC_Handler( void )
{
for ( ;; ) ;
}
extern void DebugMon_Handler( void )
{
for ( ;; ) ;
}
extern void PendSV_Handler( void )
{
for ( ;; ) ;
}
#ifdef __cplusplus
}
#endif

View File

@ -0,0 +1,24 @@
# Makefile for compiling libboard
BOARD =
SUBMAKE_OPTIONS=--no-builtin-rules --no-builtin-variables
#-------------------------------------------------------------------------------
# Rules
#-------------------------------------------------------------------------------
all: sam3s_ek
.PHONY: sam3s_ek
sam3s_ek:
@echo --- Making sam3s_ek
@$(MAKE) DEBUG=1 $(SUBMAKE_OPTIONS) -f libvariant_sam3s_ek.mk
# @$(MAKE) $(SUBMAKE_OPTIONS) -f libvariant_sam3s_ek.mk
.PHONY: clean
clean:
@echo --- Cleaning sam3s_ek
@$(MAKE) DEBUG=1 $(SUBMAKE_OPTIONS) -f libvariant_sam3s_ek.mk $@
# @$(MAKE) $(SUBMAKE_OPTIONS) -f libvariant_sam3s_ek.mk $@

View File

@ -0,0 +1,7 @@
# 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

View File

@ -0,0 +1,64 @@
# 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)

View File

@ -0,0 +1,156 @@
# Makefile for compiling libArduino
.SUFFIXES: .o .a .c .s
CHIP=__SAM3S4C__
VARIANT=sam3s_ek
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=wiring_analog.o wiring_pulse.o
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-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

View File

@ -0,0 +1,8 @@
# 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

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,33 +1,12 @@
/*
%atmel_license%
*/
#ifndef Pins_Arduino_h
#define Pins_Arduino_h
//#ifdef ARDUINO_MAIN
#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)
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)
#if defined VARIANT_REV_A
# define PIN_TSC_IRQ_WUP_ID (1UL << 3)
#elif defined VARIANT_REV_B
# define PIN_TSC_IRQ_WUP_ID (1UL << 15)
#else
#error "No board revision defined"
#endif
#define BOARD_LCD_PINS PIN_EBI_DATA_BUS, PIN_EBI_NRD, PIN_EBI_NWE, PIN_EBI_NCS1, PIN_EBI_LCD_RS
#define BOARD_LCD_BASE 0x61000000 /** Define ILI9325 base address. */
#define BOARD_LCD_RS (1 << 1) /** Define ILI9325 register select signal. */
//#endif // ARDUINO_MAIN

View File

@ -1,9 +1,13 @@
#include "Arduino.h"
/*
%atmel_license%
*/
#include "variant.h"
/*
* Pins descriptions
*/
extern const PinDescription APinDescription[]=
extern const PinDescription g_APinDescription[]=
{
// LEDS, 0..2
#if defined VARIANT_REV_A
@ -112,16 +116,15 @@ extern const PinDescription APinDescription[]=
{ NULL, 0, 0, PIO_NOT_A_PIN, PIO_DEFAULT } // END
} ;
#if 0
/*
* UART objects
*/
ring_buffer rx_buffer1 = { { 0 }, 0, 0 } ;
ring_buffer tx_buffer1 = { { 0 }, 0, 0 } ;
ring_buffer rx_buffer2 = { { 0 }, 0, 0 } ;
ring_buffer tx_buffer2 = { { 0 }, 0, 0 } ;
RingBuffer rx_buffer1 ;
RingBuffer tx_buffer1 ;
RingBuffer rx_buffer2 ;
RingBuffer tx_buffer2 ;
UARTClass Serial1( UART0, UART0_IRQn, ID_UART0, &rx_buffer1, &tx_buffer1 ) ;
UARTClass Serial( UART0, UART0_IRQn, ID_UART0, &rx_buffer1, &tx_buffer1 ) ;
UARTClass Serial2( UART1, UART1_IRQn, ID_UART1, &rx_buffer2, &tx_buffer2 ) ;
#ifdef __cplusplus
@ -131,7 +134,7 @@ extern "C" {
// IT handlers
extern void UART0_IrqHandler( void )
{
Serial1.IrqHandler() ;
Serial.IrqHandler() ;
}
extern void UART1_IrqHandler( void )
@ -142,18 +145,15 @@ extern void UART1_IrqHandler( void )
#ifdef __cplusplus
}
#endif
#endif // 0
// ----------------------------------------------------------------------------
#if 0
/*
* USART objects
*/
ring_buffer rx_buffer3 = { { 0 }, 0, 0 } ;
ring_buffer tx_buffer3 = { { 0 }, 0, 0 } ;
ring_buffer rx_buffer4 = { { 0 }, 0, 0 } ;
ring_buffer tx_buffer4 = { { 0 }, 0, 0 } ;
RingBuffer rx_buffer3 ;
RingBuffer tx_buffer3 ;
RingBuffer rx_buffer4 ;
RingBuffer tx_buffer4 ;
USARTClass Serial3( USART0, USART0_IRQn, ID_USART0, &rx_buffer3, &tx_buffer3 ) ;
USARTClass Serial4( USART1, USART1_IRQn, ID_USART1, &rx_buffer4, &tx_buffer4 ) ;
@ -177,6 +177,39 @@ extern void USART1_IrqHandler( void )
}
#endif
#endif // 0
// ----------------------------------------------------------------------------
#ifdef __cplusplus
extern "C" {
#endif
/**
*
*/
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 UART0, 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
}
#endif

View File

@ -1,3 +1,7 @@
/*
%atmel_license%
*/
#ifndef _VARIANT_
#define _VARIANT_
@ -5,7 +9,9 @@
* Headers
*----------------------------------------------------------------------------*/
#include "libsam/chip.h"
#include "Arduino.h"
#include "common/UART.h"
#include "common/USART.h"
/**
* Libc porting layers
@ -27,10 +33,10 @@
/** Name of the board */
#define VARIANT_NAME "SAM3S-EK"
#define VARIANT_REV_A
/*
#define VARIANT_REV_B
#define VARIANT_REV_A
*/
#define VARIANT_REV_B
/** Frequency of the board main oscillator */
#define VARIANT_MAINOSC 12000000
@ -38,23 +44,49 @@
/** Master clock frequency */
#define VARIANT_MCK 64000000
/*----------------------------------------------------------------------------
* Pins
*----------------------------------------------------------------------------*/
#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)
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)
#if defined VARIANT_REV_A
# define PIN_TSC_IRQ_WUP_ID (1UL << 3)
#elif defined VARIANT_REV_B
# define PIN_TSC_IRQ_WUP_ID (1UL << 15)
#else
#error "No board revision defined"
#endif
#define BOARD_LCD_PINS PIN_EBI_DATA_BUS, PIN_EBI_NRD, PIN_EBI_NWE, PIN_EBI_NCS1, PIN_EBI_LCD_RS
#define BOARD_LCD_BASE 0x61000000 /** Define ILI9325 base address. */
#define BOARD_LCD_RS (1 << 1) /** Define ILI9325 register select signal. */
/*----------------------------------------------------------------------------
* Arduino objects - C++ only
*----------------------------------------------------------------------------*/
# ifdef __cplusplus
#if 0
# include "UART.h"
# include "USART.h"
#ifdef __cplusplus
extern UARTClass Serial1 ;
extern UARTClass Serial ;
extern UARTClass Serial2 ;
#endif // 0
//extern USARTClass Serial3 ;
//extern USARTClass Serial4 ;
extern USARTClass Serial3 ;
extern USARTClass Serial4 ;
# endif
#endif
#endif /* #ifndef _VARIANT_ */
#endif /* _VARIANT_ */