mirror of
https://github.com/arduino/Arduino.git
synced 2025-02-20 14:54:31 +01:00
Adding minimal libboard with lowlevel init and vectors
This commit is contained in:
parent
f08e822b17
commit
fdfdd0b4bf
42
hardware/tools/libboard_sam3s-ek/board.h
Normal file
42
hardware/tools/libboard_sam3s-ek/board.h
Normal file
@ -0,0 +1,42 @@
|
||||
#ifndef _BOARD_
|
||||
#define _BOARD_
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Headers
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
#include "chip.h"
|
||||
|
||||
#include "include/bitbanding.h"
|
||||
#include "include/board_lowlevel.h"
|
||||
#include "include/timetick.h"
|
||||
|
||||
/**
|
||||
* Libc porting layers
|
||||
*/
|
||||
#if defined ( __GNUC__ ) /* GCC CS3 */
|
||||
# include "include/syscalls.h" /** RedHat Newlib minimal stub */
|
||||
#endif
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Definitions
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
/** Name of the board */
|
||||
#define BOARD_NAME "SAM3S-EK"
|
||||
|
||||
/*
|
||||
#define BOARD_REV_A
|
||||
*/
|
||||
#define BOARD_REV_B
|
||||
|
||||
/** Frequency of the board main oscillator */
|
||||
#define BOARD_MAINOSC 12000000
|
||||
|
||||
/** Master clock frequency (when using board_lowlevel.c) */
|
||||
#define BOARD_MCK 64000000
|
||||
|
||||
#endif /* #ifndef _BOARD_ */
|
||||
|
23
hardware/tools/libboard_sam3s-ek/build_gcc/Makefile
Normal file
23
hardware/tools/libboard_sam3s-ek/build_gcc/Makefile
Normal file
@ -0,0 +1,23 @@
|
||||
# Makefile for compiling libboard
|
||||
|
||||
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 sam3s_ek.mk
|
||||
@$(MAKE) $(SUBMAKE_OPTIONS) -f sam3s_ek.mk
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
@echo --- Cleaning sam3s_ek
|
||||
@$(MAKE) $(SUBMAKE_OPTIONS) -f sam3s_ek.mk $@
|
||||
@$(MAKE) DEBUG=1 $(SUBMAKE_OPTIONS) -f sam3s_ek.mk $@
|
||||
|
||||
|
7
hardware/tools/libboard_sam3s-ek/build_gcc/debug.mk
Normal file
7
hardware/tools/libboard_sam3s-ek/build_gcc/debug.mk
Normal 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
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
39
hardware/tools/libboard_sam3s-ek/build_gcc/gcc.mk
Normal file
39
hardware/tools/libboard_sam3s-ek/build_gcc/gcc.mk
Normal file
@ -0,0 +1,39 @@
|
||||
|
||||
# Tool suffix when cross-compiling
|
||||
#CROSS_COMPILE = ../../CodeSourcery_arm/bin/arm-none-eabi-
|
||||
CROSS_COMPILE = C:/CodeSourcery_2011.03-42/bin/arm-none-eabi-
|
||||
|
||||
# Compilation tools
|
||||
AR = $(CROSS_COMPILE)ar
|
||||
CC = $(CROSS_COMPILE)gcc
|
||||
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=/
|
||||
|
||||
# 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
|
||||
|
||||
# To reduce application size use only integer printf function.
|
||||
CFLAGS += -Dprintf=iprintf
|
||||
|
||||
CFLAGS += --param max-inline-insns-single=500 -mcpu=cortex-m3 -mthumb -mlong-calls -ffunction-sections
|
||||
CFLAGS += $(OPTIMIZATION) $(INCLUDES) -D$(CHIP)
|
||||
|
||||
ASFLAGS = -mcpu=cortex-m3 -mthumb -Wall -a -g $(INCLUDES)
|
7
hardware/tools/libboard_sam3s-ek/build_gcc/release.mk
Normal file
7
hardware/tools/libboard_sam3s-ek/build_gcc/release.mk
Normal 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 = -Os
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
122
hardware/tools/libboard_sam3s-ek/build_gcc/sam3s_ek.mk
Normal file
122
hardware/tools/libboard_sam3s-ek/build_gcc/sam3s_ek.mk
Normal file
@ -0,0 +1,122 @@
|
||||
# Makefile for compiling libboard
|
||||
.SUFFIXES: .o .a .c .s
|
||||
|
||||
CHIP=sam3s4
|
||||
BOARD=sam3s_ek
|
||||
LIBNAME=libboard
|
||||
TOOLCHAIN=gcc
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Path
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
# Output directories
|
||||
OUTPUT_BIN = ../lib
|
||||
|
||||
# Libraries
|
||||
PROJECT_BASE_PATH = ..
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Files
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
vpath %.h $(PROJECT_BASE_PATH)/include
|
||||
vpath %.c $(PROJECT_BASE_PATH)/source
|
||||
vpath %.s $(PROJECT_BASE_PATH)/source
|
||||
|
||||
VPATH+=$(PROJECT_BASE_PATH)/source
|
||||
|
||||
INCLUDES = -I$(PROJECT_BASE_PATH)
|
||||
INCLUDES += -I$(PROJECT_BASE_PATH)/include
|
||||
INCLUDES += -I$(PROJECT_BASE_PATH)/../libchip_sam3s
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
ifdef DEBUG
|
||||
include debug.mk
|
||||
else
|
||||
include release.mk
|
||||
endif
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Tools
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
include $(TOOLCHAIN).mk
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
ifdef DEBUG
|
||||
OUTPUT_OBJ=debug
|
||||
OUTPUT_LIB=$(LIBNAME)_$(BOARD)_$(TOOLCHAIN)_dbg.a
|
||||
else
|
||||
OUTPUT_OBJ=release
|
||||
OUTPUT_LIB=$(LIBNAME)_$(BOARD)_$(TOOLCHAIN)_rel.a
|
||||
endif
|
||||
|
||||
OUTPUT_PATH=$(OUTPUT_OBJ)_$(BOARD)
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# C source files and objects
|
||||
#-------------------------------------------------------------------------------
|
||||
C_SRC=$(wildcard $(PROJECT_BASE_PATH)/source/*.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))
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Assembler source files and objects
|
||||
#-------------------------------------------------------------------------------
|
||||
A_SRC=$(wildcard $(PROJECT_BASE_PATH)/source/*.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: $(BOARD)
|
||||
|
||||
$(BOARD): create_output $(OUTPUT_LIB)
|
||||
|
||||
.PHONY: create_output
|
||||
create_output:
|
||||
@echo --- Preparing $(BOARD) files $(OUTPUT_PATH) $(OUTPUT_BIN)
|
||||
# @echo -------------------------
|
||||
# @echo *$(C_SRC)
|
||||
# @echo -------------------------
|
||||
# @echo *$(C_OBJ)
|
||||
# @echo -------------------------
|
||||
# @echo *$(addprefix $(OUTPUT_PATH)/, $(C_OBJ))
|
||||
# @echo -------------------------
|
||||
# @echo *$(A_SRC)
|
||||
# @echo -------------------------
|
||||
|
||||
-@mkdir $(subst /,$(SEP),$(OUTPUT_BIN)) 1>NUL 2>&1
|
||||
-@mkdir $(OUTPUT_PATH) 1>NUL 2>&1
|
||||
|
||||
$(addprefix $(OUTPUT_PATH)/,$(C_OBJ)): $(OUTPUT_PATH)/%.o: %.c
|
||||
@$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
$(addprefix $(OUTPUT_PATH)/,$(A_OBJ)): $(OUTPUT_PATH)/%.o: %.s
|
||||
@$(AS) -c $(ASFLAGS) $< -o $@
|
||||
|
||||
$(OUTPUT_LIB): $(addprefix $(OUTPUT_PATH)/, $(C_OBJ)) $(addprefix $(OUTPUT_PATH)/, $(A_OBJ))
|
||||
@$(AR) -r "$(OUTPUT_BIN)/$@" $^
|
||||
@$(NM) "$(OUTPUT_BIN)/$@" > "$(OUTPUT_BIN)/$@.txt"
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
@echo --- Cleaning $(BOARD) files [$(OUTPUT_PATH)$(SEP)*.o]
|
||||
-@$(RM) $(OUTPUT_PATH) 1>NUL 2>&1
|
||||
-@$(RM) $(OUTPUT_BIN)/$(OUTPUT_LIB) 1>NUL 2>&1
|
||||
-@$(RM) $(OUTPUT_BIN)/$(OUTPUT_LIB).txt 1>NUL 2>&1
|
||||
|
||||
# dependencies
|
||||
$(addprefix $(OUTPUT_PATH)/,$(C_OBJ)): $(OUTPUT_PATH)/%.o: $(PROJECT_BASE_PATH)/board.h $(wildcard $(PROJECT_BASE_PATH)/include/*.h)
|
108
hardware/tools/libboard_sam3s-ek/include/bitbanding.h
Normal file
108
hardware/tools/libboard_sam3s-ek/include/bitbanding.h
Normal file
@ -0,0 +1,108 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* 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.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#ifndef _BITBANDING_
|
||||
#define _BITBANDING_
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* \file bitbanding.h
|
||||
* Include Defines & macros for bit-banding.
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Header files
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Global Macros
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* \brief Check if the address is in bit banding sram region.
|
||||
*
|
||||
* \note The address should be in area of 0x2000000 ~ 0x200FFFFF
|
||||
*
|
||||
* \param x The address to check.
|
||||
*/
|
||||
#define IS_BITBAND_SRAM_ADDR(x) \
|
||||
( ((uint32_t)(x)) >= 0x20000000 && \
|
||||
((uint32_t)(x)) < (0x20000000+0x100000) )
|
||||
|
||||
/**
|
||||
* \brief Check if the address is in bit banding peripheral region
|
||||
*
|
||||
* \note The address should be in area of 0x4000000 ~ 0x400FFFFF
|
||||
* \param x The address to check
|
||||
*/
|
||||
#define IS_BITBAND_PERIPH_ADDR(x) \
|
||||
( ((uint32_t)(x)) >= 0x40000000 && \
|
||||
((uint32_t)(x)) < (0x40000000+0x100000) )
|
||||
|
||||
/**
|
||||
* \brief Calculate bit band alias address.
|
||||
*
|
||||
* Calculate the bit band alias address and return a pointer address to word.
|
||||
*
|
||||
* \param addr The byte address of bitbanding bit.
|
||||
* \param bit The bit position of bitbanding bit.
|
||||
* \callergraph
|
||||
*/
|
||||
#define BITBAND_ALIAS_ADDRESS(addr, bit) \
|
||||
((volatile uint32_t*)((((uint32_t)(addr) & 0xF0000000) + 0x02000000) \
|
||||
+((((uint32_t)(addr)&0xFFFFF)*32)\
|
||||
+( (uint32_t)(bit)*4))))
|
||||
|
||||
/**
|
||||
* \brief Bit write through bit banding.
|
||||
*
|
||||
* \param addr32 32-bit aligned byte address where the bit exists.
|
||||
* \param bit Bit position.
|
||||
* \param val The value that the bit is set to.
|
||||
* \callergraph
|
||||
*/
|
||||
#define WRITE_BITBANDING(addr32, bit, val) do {\
|
||||
*BITBAND_ALIAS_ADDRESS(addr32,bit) = (val); \
|
||||
} while (0);
|
||||
|
||||
/**
|
||||
* \brief Toggle bit through bit banding
|
||||
*
|
||||
* \param addr32 32-bit aligned byte address where the bit exists.
|
||||
* \param bit Bit position.
|
||||
*/
|
||||
#define TOGGLE_BITBANDING(addr32, bit) do {\
|
||||
volatile uint32_t * p = \
|
||||
BITBAND_ALIAS_ADDRESS(addr32,bit); \
|
||||
if (*p) *p = 0; \
|
||||
else *p = 1; \
|
||||
}while(0);
|
||||
|
||||
#endif /* #ifndef _BITBANDING_ */
|
46
hardware/tools/libboard_sam3s-ek/include/board_lowlevel.h
Normal file
46
hardware/tools/libboard_sam3s-ek/include/board_lowlevel.h
Normal file
@ -0,0 +1,46 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* 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.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file
|
||||
*
|
||||
* Interface for the low-level initialization function.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef BOARD_LOWLEVEL_H
|
||||
#define BOARD_LOWLEVEL_H
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Exported functions
|
||||
*----------------------------------------------------------------------------*/
|
||||
extern void LowLevelInit( void ) ;
|
||||
|
||||
#endif /* BOARD_LOWLEVEL_H */
|
||||
|
65
hardware/tools/libboard_sam3s-ek/include/syscalls.h
Normal file
65
hardware/tools/libboard_sam3s-ek/include/syscalls.h
Normal file
@ -0,0 +1,65 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* 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.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file syscalls.h
|
||||
*
|
||||
* Implementation of newlib syscall.
|
||||
*
|
||||
*/
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Headers
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Exported functions
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
extern caddr_t _sbrk ( int incr ) ;
|
||||
|
||||
extern int link( char *old, char *new ) ;
|
||||
|
||||
extern int _close( int file ) ;
|
||||
|
||||
extern int _fstat( int file, struct stat *st ) ;
|
||||
|
||||
extern int _isatty( int file ) ;
|
||||
|
||||
extern int _lseek( int file, int ptr, int dir ) ;
|
||||
|
||||
extern int _read(int file, char *ptr, int len) ;
|
||||
|
||||
extern int _write( int file, char *ptr, int len ) ;
|
78
hardware/tools/libboard_sam3s-ek/include/timetick.h
Normal file
78
hardware/tools/libboard_sam3s-ek/include/timetick.h
Normal file
@ -0,0 +1,78 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* 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.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file
|
||||
*
|
||||
* \par Purpose
|
||||
*
|
||||
* Methods and definitions for Global time tick and wait functions.
|
||||
*
|
||||
* Defines a common and simpliest use of Time Tick, to increase tickCount
|
||||
* every 1ms, the application can get this value through GetTickCount().
|
||||
*
|
||||
* \par Usage
|
||||
*
|
||||
* -# Configure the System Tick with TimeTick_Configure() when MCK changed
|
||||
* \note
|
||||
* Must be done before any invoke of GetTickCount(), Wait() or Sleep().
|
||||
* -# Uses GetTickCount to get current tick value.
|
||||
* -# Uses Wait to wait several ms.
|
||||
* -# Uses Sleep to enter wait for interrupt mode to wait several ms.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _TIMETICK_
|
||||
#define _TIMETICK_
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Headers
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Definitions
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Global functions
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
extern uint32_t TimeTick_Configure( uint32_t dwNew_MCK ) ;
|
||||
|
||||
extern void TimeTick_Increment( void ) ;
|
||||
|
||||
extern uint32_t GetTickCount( void ) ;
|
||||
|
||||
extern void Wait( volatile uint32_t dwMs ) ;
|
||||
|
||||
extern void Sleep( volatile uint32_t dwMs ) ;
|
||||
|
||||
#endif /* _TIMETICK_ */
|
BIN
hardware/tools/libboard_sam3s-ek/lib/libboard_sam3s_ek_gcc_dbg.a
Normal file
BIN
hardware/tools/libboard_sam3s-ek/lib/libboard_sam3s_ek_gcc_dbg.a
Normal file
Binary file not shown.
@ -0,0 +1,85 @@
|
||||
|
||||
board_cstartup_gnu.o:
|
||||
00000000 W ACC_IrqHandler
|
||||
00000000 W ADC_IrqHandler
|
||||
00000000 W BusFault_Handler
|
||||
00000000 W CRCCU_IrqHandler
|
||||
00000000 W DAC_IrqHandler
|
||||
00000000 W DebugMon_Handler
|
||||
00000000 T Dummy_Handler
|
||||
00000000 W EEFC_IrqHandler
|
||||
00000000 W HardFault_Handler
|
||||
U LowLevelInit
|
||||
00000000 W MCI_IrqHandler
|
||||
00000000 W MemManage_Handler
|
||||
00000000 W NMI_Handler
|
||||
00000000 W PIOA_IrqHandler
|
||||
00000000 W PIOB_IrqHandler
|
||||
00000000 W PIOC_IrqHandler
|
||||
00000000 W PMC_IrqHandler
|
||||
00000000 W PWM_IrqHandler
|
||||
00000000 W PendSV_Handler
|
||||
00000000 W RSTC_IrqHandler
|
||||
00000000 W RTC_IrqHandler
|
||||
00000000 W RTT_IrqHandler
|
||||
00000000 T Reset_Handler
|
||||
00000000 W SMC_IrqHandler
|
||||
00000000 W SPI_IrqHandler
|
||||
00000000 W SSC_IrqHandler
|
||||
00000000 W SUPC_IrqHandler
|
||||
00000000 W SVC_Handler
|
||||
00000000 W SysTick_Handler
|
||||
00000000 W TC0_IrqHandler
|
||||
00000000 W TC1_IrqHandler
|
||||
00000000 W TC2_IrqHandler
|
||||
00000000 W TC3_IrqHandler
|
||||
00000000 W TC4_IrqHandler
|
||||
00000000 W TC5_IrqHandler
|
||||
00000000 W TWI0_IrqHandler
|
||||
00000000 W TWI1_IrqHandler
|
||||
00000000 W UART0_IrqHandler
|
||||
00000000 W UART1_IrqHandler
|
||||
00000000 W USART0_IrqHandler
|
||||
00000000 W USART1_IrqHandler
|
||||
00000000 W USBD_IrqHandler
|
||||
00000000 W UsageFault_Handler
|
||||
00000000 W WDT_IrqHandler
|
||||
U __libc_init_array
|
||||
U _erelocate
|
||||
U _etext
|
||||
U _ezero
|
||||
U _sfixed
|
||||
U _srelocate
|
||||
U _szero
|
||||
U main
|
||||
00000000 D pdwStack
|
||||
00000000 D vector_table
|
||||
|
||||
board_lowlevel.o:
|
||||
00000000 W LowLevelInit
|
||||
|
||||
syscalls.o:
|
||||
00000000 T _close
|
||||
U _end
|
||||
00000000 T _exit
|
||||
00000000 T _fstat
|
||||
00000000 T _getpid
|
||||
00000000 T _isatty
|
||||
00000000 T _kill
|
||||
00000000 T _lseek
|
||||
00000000 T _read
|
||||
00000000 T _sbrk
|
||||
00000000 T _write
|
||||
00000000 b heap.6737
|
||||
U iprintf
|
||||
00000000 T link
|
||||
|
||||
timetick.o:
|
||||
00000000 T GetTickCount
|
||||
00000000 t NVIC_SetPriority
|
||||
00000000 T Sleep
|
||||
00000000 t SysTick_Config
|
||||
00000000 T TimeTick_Configure
|
||||
00000000 T TimeTick_Increment
|
||||
00000000 T Wait
|
||||
00000000 b _dwTickCount
|
BIN
hardware/tools/libboard_sam3s-ek/lib/libboard_sam3s_ek_gcc_rel.a
Normal file
BIN
hardware/tools/libboard_sam3s-ek/lib/libboard_sam3s_ek_gcc_rel.a
Normal file
Binary file not shown.
@ -0,0 +1,83 @@
|
||||
|
||||
board_cstartup_gnu.o:
|
||||
00000000 W ACC_IrqHandler
|
||||
00000000 W ADC_IrqHandler
|
||||
00000000 W BusFault_Handler
|
||||
00000000 W CRCCU_IrqHandler
|
||||
00000000 W DAC_IrqHandler
|
||||
00000000 W DebugMon_Handler
|
||||
00000000 T Dummy_Handler
|
||||
00000000 W EEFC_IrqHandler
|
||||
00000000 W HardFault_Handler
|
||||
U LowLevelInit
|
||||
00000000 W MCI_IrqHandler
|
||||
00000000 W MemManage_Handler
|
||||
00000000 W NMI_Handler
|
||||
00000000 W PIOA_IrqHandler
|
||||
00000000 W PIOB_IrqHandler
|
||||
00000000 W PIOC_IrqHandler
|
||||
00000000 W PMC_IrqHandler
|
||||
00000000 W PWM_IrqHandler
|
||||
00000000 W PendSV_Handler
|
||||
00000000 W RSTC_IrqHandler
|
||||
00000000 W RTC_IrqHandler
|
||||
00000000 W RTT_IrqHandler
|
||||
00000000 T Reset_Handler
|
||||
00000000 W SMC_IrqHandler
|
||||
00000000 W SPI_IrqHandler
|
||||
00000000 W SSC_IrqHandler
|
||||
00000000 W SUPC_IrqHandler
|
||||
00000000 W SVC_Handler
|
||||
00000000 W SysTick_Handler
|
||||
00000000 W TC0_IrqHandler
|
||||
00000000 W TC1_IrqHandler
|
||||
00000000 W TC2_IrqHandler
|
||||
00000000 W TC3_IrqHandler
|
||||
00000000 W TC4_IrqHandler
|
||||
00000000 W TC5_IrqHandler
|
||||
00000000 W TWI0_IrqHandler
|
||||
00000000 W TWI1_IrqHandler
|
||||
00000000 W UART0_IrqHandler
|
||||
00000000 W UART1_IrqHandler
|
||||
00000000 W USART0_IrqHandler
|
||||
00000000 W USART1_IrqHandler
|
||||
00000000 W USBD_IrqHandler
|
||||
00000000 W UsageFault_Handler
|
||||
00000000 W WDT_IrqHandler
|
||||
U __libc_init_array
|
||||
U _erelocate
|
||||
U _etext
|
||||
U _ezero
|
||||
U _sfixed
|
||||
U _srelocate
|
||||
U _szero
|
||||
U main
|
||||
00000000 D pdwStack
|
||||
00000000 D vector_table
|
||||
|
||||
board_lowlevel.o:
|
||||
00000000 W LowLevelInit
|
||||
|
||||
syscalls.o:
|
||||
00000000 T _close
|
||||
U _end
|
||||
00000000 T _exit
|
||||
00000000 T _fstat
|
||||
00000000 T _getpid
|
||||
00000000 T _isatty
|
||||
00000000 T _kill
|
||||
00000000 T _lseek
|
||||
00000000 T _read
|
||||
00000000 T _sbrk
|
||||
00000000 T _write
|
||||
00000000 b heap.6728
|
||||
U iprintf
|
||||
00000000 T link
|
||||
|
||||
timetick.o:
|
||||
00000000 T GetTickCount
|
||||
00000000 T Sleep
|
||||
00000000 T TimeTick_Configure
|
||||
00000000 T TimeTick_Increment
|
||||
00000000 T Wait
|
||||
00000000 b _dwTickCount
|
0
hardware/tools/libboard_sam3s-ek/pins.txt
Normal file
0
hardware/tools/libboard_sam3s-ek/pins.txt
Normal file
227
hardware/tools/libboard_sam3s-ek/source/board_cstartup_gnu.c
Normal file
227
hardware/tools/libboard_sam3s-ek/source/board_cstartup_gnu.c
Normal file
@ -0,0 +1,227 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* ATMEL Microcontroller Software Support
|
||||
* ----------------------------------------------------------------------------
|
||||
* Copyright (c) 2010, 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.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Headers
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
#include "board.h"
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Exported variables
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
/* Stack Configuration */
|
||||
#define STACK_SIZE 0x900 /** Stack size (in DWords) */
|
||||
__attribute__ ((aligned(8),section(".stack")))
|
||||
uint32_t pdwStack[STACK_SIZE] ;
|
||||
|
||||
/* Initialize segments */
|
||||
extern uint32_t _sfixed;
|
||||
extern uint32_t _efixed;
|
||||
extern uint32_t _etext;
|
||||
extern uint32_t _srelocate;
|
||||
extern uint32_t _erelocate;
|
||||
extern uint32_t _szero;
|
||||
extern uint32_t _ezero;
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Prototypes
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
/** \cond DOXYGEN_SHOULD_SKIP_THIS */
|
||||
extern int main( void ) ;
|
||||
/** \endcond */
|
||||
void Reset_Handler( void ) ;
|
||||
extern void __libc_init_array( void ) ;
|
||||
|
||||
/* Default empty handler */
|
||||
void Dummy_Handler( void ) ;
|
||||
|
||||
/* Cortex-M3 core handlers */
|
||||
extern void NMI_Handler( void ) __attribute__ ((weak, alias ("Dummy_Handler"))) ;
|
||||
extern void HardFault_Handler( void ) __attribute__ ((weak, alias ("Dummy_Handler"))) ;
|
||||
extern void MemManage_Handler( void ) __attribute__ ((weak, alias ("Dummy_Handler"))) ;
|
||||
extern void BusFault_Handler( void ) __attribute__ ((weak, alias ("Dummy_Handler"))) ;
|
||||
extern void UsageFault_Handler( void ) __attribute__ ((weak, alias ("Dummy_Handler"))) ;
|
||||
extern void SVC_Handler( void ) __attribute__ ((weak, alias ("Dummy_Handler"))) ;
|
||||
extern void DebugMon_Handler( void ) __attribute__ ((weak, alias ("Dummy_Handler"))) ;
|
||||
extern void PendSV_Handler( void ) __attribute__ ((weak, alias ("Dummy_Handler"))) ;
|
||||
extern void SysTick_Handler( void ) __attribute__ ((weak, alias ("Dummy_Handler"))) ;
|
||||
|
||||
/* Peripherals handlers */
|
||||
extern void ACC_IrqHandler( void ) __attribute__ ((weak, alias ("Dummy_Handler"))) ;
|
||||
extern void ADC_IrqHandler( void ) __attribute__ ((weak, alias ("Dummy_Handler"))) ;
|
||||
extern void CRCCU_IrqHandler( void ) __attribute__ ((weak, alias ("Dummy_Handler"))) ;
|
||||
extern void DAC_IrqHandler( void ) __attribute__ ((weak, alias ("Dummy_Handler"))) ;
|
||||
extern void EEFC_IrqHandler( void ) __attribute__ ((weak, alias ("Dummy_Handler"))) ;
|
||||
extern void MCI_IrqHandler( void ) __attribute__ ((weak, alias ("Dummy_Handler"))) ;
|
||||
extern void PIOA_IrqHandler( void ) __attribute__ ((weak, alias ("Dummy_Handler"))) ;
|
||||
extern void PIOB_IrqHandler( void ) __attribute__ ((weak, alias ("Dummy_Handler"))) ;
|
||||
extern void PIOC_IrqHandler( void ) __attribute__ ((weak, alias ("Dummy_Handler"))) ;
|
||||
extern void PMC_IrqHandler( void ) __attribute__ ((weak, alias ("Dummy_Handler"))) ;
|
||||
extern void PWM_IrqHandler( void ) __attribute__ ((weak, alias ("Dummy_Handler"))) ;
|
||||
extern void RSTC_IrqHandler( void ) __attribute__ ((weak, alias ("Dummy_Handler"))) ;
|
||||
extern void RTC_IrqHandler( void ) __attribute__ ((weak, alias ("Dummy_Handler"))) ;
|
||||
extern void RTT_IrqHandler( void ) __attribute__ ((weak, alias ("Dummy_Handler"))) ;
|
||||
extern void SMC_IrqHandler( void ) __attribute__ ((weak, alias ("Dummy_Handler"))) ;
|
||||
extern void SPI_IrqHandler( void ) __attribute__ ((weak, alias ("Dummy_Handler"))) ;
|
||||
extern void SSC_IrqHandler( void ) __attribute__ ((weak, alias ("Dummy_Handler"))) ;
|
||||
extern void SUPC_IrqHandler( void ) __attribute__ ((weak, alias ("Dummy_Handler"))) ;
|
||||
extern void TC0_IrqHandler( void ) __attribute__ ((weak, alias ("Dummy_Handler"))) ;
|
||||
extern void TC1_IrqHandler( void ) __attribute__ ((weak, alias ("Dummy_Handler"))) ;
|
||||
extern void TC2_IrqHandler( void ) __attribute__ ((weak, alias ("Dummy_Handler"))) ;
|
||||
extern void TC3_IrqHandler( void ) __attribute__ ((weak, alias ("Dummy_Handler"))) ;
|
||||
extern void TC4_IrqHandler( void ) __attribute__ ((weak, alias ("Dummy_Handler"))) ;
|
||||
extern void TC5_IrqHandler( void ) __attribute__ ((weak, alias ("Dummy_Handler"))) ;
|
||||
extern void TWI0_IrqHandler( void ) __attribute__ ((weak, alias ("Dummy_Handler"))) ;
|
||||
extern void TWI1_IrqHandler( void ) __attribute__ ((weak, alias ("Dummy_Handler"))) ;
|
||||
extern void UART0_IrqHandler( void ) __attribute__ ((weak, alias ("Dummy_Handler"))) ;
|
||||
extern void UART1_IrqHandler( void ) __attribute__ ((weak, alias ("Dummy_Handler"))) ;
|
||||
extern void USART0_IrqHandler( void ) __attribute__ ((weak, alias ("Dummy_Handler"))) ;
|
||||
extern void USART1_IrqHandler( void ) __attribute__ ((weak, alias ("Dummy_Handler"))) ;
|
||||
extern void USBD_IrqHandler( void ) __attribute__ ((weak, alias ("Dummy_Handler"))) ;
|
||||
extern void WDT_IrqHandler( void ) __attribute__ ((weak, alias ("Dummy_Handler"))) ;
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Exception Table
|
||||
*------------------------------------------------------------------------------*/
|
||||
|
||||
void* vector_table[] __attribute__ ((section(".vectors"))) = {
|
||||
/* Configure Initial Stack Pointer, using linker-generated symbols */
|
||||
(IntFunc)(&pdwStack[STACK_SIZE-1]),
|
||||
Reset_Handler,
|
||||
|
||||
NMI_Handler,
|
||||
HardFault_Handler,
|
||||
MemManage_Handler,
|
||||
BusFault_Handler,
|
||||
UsageFault_Handler,
|
||||
0, 0, 0, 0, /* Reserved */
|
||||
SVC_Handler,
|
||||
DebugMon_Handler,
|
||||
0, /* Reserved */
|
||||
PendSV_Handler,
|
||||
SysTick_Handler,
|
||||
|
||||
/* Configurable interrupts */
|
||||
SUPC_IrqHandler, /* 0 Supply Controller */
|
||||
RSTC_IrqHandler, /* 1 Reset Controller */
|
||||
RTC_IrqHandler, /* 2 Real Time Clock */
|
||||
RTT_IrqHandler, /* 3 Real Time Timer */
|
||||
WDT_IrqHandler, /* 4 Watchdog Timer */
|
||||
PMC_IrqHandler, /* 5 PMC */
|
||||
EEFC_IrqHandler, /* 6 EEFC */
|
||||
Dummy_Handler, /* 7 Reserved */
|
||||
UART0_IrqHandler, /* 8 UART0 */
|
||||
UART1_IrqHandler, /* 9 UART1 */
|
||||
SMC_IrqHandler, /* 10 SMC */
|
||||
PIOA_IrqHandler, /* 11 Parallel IO Controller A */
|
||||
PIOB_IrqHandler, /* 12 Parallel IO Controller B */
|
||||
PIOC_IrqHandler, /* 13 Parallel IO Controller C */
|
||||
USART0_IrqHandler, /* 14 USART 0 */
|
||||
USART1_IrqHandler, /* 15 USART 1 */
|
||||
Dummy_Handler, /* 16 Reserved */
|
||||
Dummy_Handler, /* 17 Reserved */
|
||||
MCI_IrqHandler, /* 18 MCI */
|
||||
TWI0_IrqHandler, /* 19 TWI 0 */
|
||||
TWI1_IrqHandler, /* 20 TWI 1 */
|
||||
SPI_IrqHandler, /* 21 SPI */
|
||||
SSC_IrqHandler, /* 22 SSC */
|
||||
TC0_IrqHandler, /* 23 Timer Counter 0 */
|
||||
TC1_IrqHandler, /* 24 Timer Counter 1 */
|
||||
TC2_IrqHandler, /* 25 Timer Counter 2 */
|
||||
TC3_IrqHandler, /* 26 Timer Counter 3 */
|
||||
TC4_IrqHandler, /* 27 Timer Counter 4 */
|
||||
TC5_IrqHandler, /* 28 Timer Counter 5 */
|
||||
ADC_IrqHandler, /* 29 ADC controller */
|
||||
DAC_IrqHandler, /* 30 DAC controller */
|
||||
PWM_IrqHandler, /* 31 PWM */
|
||||
CRCCU_IrqHandler, /* 32 CRC Calculation Unit */
|
||||
ACC_IrqHandler, /* 33 Analog Comparator */
|
||||
USBD_IrqHandler, /* 34 USB Device Port */
|
||||
Dummy_Handler /* 35 not used */
|
||||
};
|
||||
|
||||
/**
|
||||
* \brief This is the code that gets called on processor reset.
|
||||
* To initialize the device, and call the main() routine.
|
||||
*/
|
||||
void Reset_Handler( void )
|
||||
{
|
||||
uint32_t *pSrc, *pDest ;
|
||||
|
||||
/* Low level Initialize */
|
||||
LowLevelInit() ;
|
||||
|
||||
/* Initialize the relocate segment */
|
||||
pSrc = &_etext ;
|
||||
pDest = &_srelocate ;
|
||||
|
||||
if ( pSrc != pDest )
|
||||
{
|
||||
for ( ; pDest < &_erelocate ; )
|
||||
{
|
||||
*pDest++ = *pSrc++ ;
|
||||
}
|
||||
}
|
||||
|
||||
/* Clear the zero segment */
|
||||
for ( pDest = &_szero ; pDest < &_ezero ; )
|
||||
{
|
||||
*pDest++ = 0;
|
||||
}
|
||||
|
||||
/* Set the vector table base address */
|
||||
pSrc = (uint32_t *)&_sfixed;
|
||||
SCB->VTOR = ( (uint32_t)pSrc & SCB_VTOR_TBLOFF_Msk ) ;
|
||||
|
||||
if ( ((uint32_t)pSrc >= IRAM_ADDR) && ((uint32_t)pSrc < IRAM_ADDR+IRAM_SIZE) )
|
||||
{
|
||||
SCB->VTOR |= 1 << SCB_VTOR_TBLBASE_Pos ;
|
||||
}
|
||||
|
||||
/* Initialize the C library */
|
||||
__libc_init_array() ;
|
||||
|
||||
/* Branch to main function */
|
||||
main() ;
|
||||
|
||||
/* Infinite loop */
|
||||
while ( 1 ) ;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Default interrupt handler for not used irq.
|
||||
*/
|
||||
void Dummy_Handler( void )
|
||||
{
|
||||
while ( 1 ) ;
|
||||
}
|
111
hardware/tools/libboard_sam3s-ek/source/board_lowlevel.c
Normal file
111
hardware/tools/libboard_sam3s-ek/source/board_lowlevel.c
Normal file
@ -0,0 +1,111 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* 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.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file
|
||||
*
|
||||
* Provides the low-level initialization function that called on chip startup.
|
||||
*/
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Headers
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
#include "board.h"
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Local definitions
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
/* Clock settings at 48MHz */
|
||||
#if (BOARD_MCK == 48000000)
|
||||
#define BOARD_OSCOUNT (CKGR_MOR_MOSCXTST(0x8))
|
||||
#define BOARD_PLLAR (CKGR_PLLAR_STUCKTO1 \
|
||||
| CKGR_PLLAR_MULA(0x7) \
|
||||
| CKGR_PLLAR_PLLACOUNT(0x1) \
|
||||
| CKGR_PLLAR_DIVA(0x1))
|
||||
#define BOARD_MCKR (PMC_MCKR_PRES_CLK_2 | PMC_MCKR_CSS_PLLA_CLK)
|
||||
|
||||
/* Clock settings at 64MHz */
|
||||
#elif (BOARD_MCK == 64000000)
|
||||
#define BOARD_OSCOUNT (CKGR_MOR_MOSCXTST(0x8))
|
||||
#define BOARD_PLLAR (CKGR_PLLAR_STUCKTO1 \
|
||||
| CKGR_PLLAR_MULA(0x0f) \
|
||||
| CKGR_PLLAR_PLLACOUNT(0x1) \
|
||||
| CKGR_PLLAR_DIVA(0x3))
|
||||
#define BOARD_MCKR (PMC_MCKR_PRES_CLK | PMC_MCKR_CSS_PLLA_CLK)
|
||||
|
||||
#else
|
||||
#error "No settings for current BOARD_MCK."
|
||||
#endif
|
||||
|
||||
/* Define clock timeout */
|
||||
#define CLOCK_TIMEOUT 0xFFFFFFFF
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Exported functions
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* \brief Performs the low-level initialization of the chip.
|
||||
* This includes EFC and master clock configuration.
|
||||
* It also enable a low level on the pin NRST triggers a user reset.
|
||||
*/
|
||||
extern WEAK void LowLevelInit( void )
|
||||
{
|
||||
uint32_t dwTimeOut = 0 ;
|
||||
|
||||
/* Set 3 FWS for Embedded Flash Access @ 64MHz, we are now at 4MHz on Internal FastRC */
|
||||
EFC->EEFC_FMR = EEFC_FMR_FWS( 3 ) ;
|
||||
|
||||
/* Initialize main oscillator */
|
||||
if ( !(PMC->CKGR_MOR & CKGR_MOR_MOSCSEL) )
|
||||
{
|
||||
PMC->CKGR_MOR = CKGR_MOR_KEY(0x37) | BOARD_OSCOUNT | CKGR_MOR_MOSCRCEN | CKGR_MOR_MOSCXTEN;
|
||||
for ( dwTimeOut = 0 ; !(PMC->PMC_SR & PMC_SR_MOSCXTS) && (dwTimeOut++ < CLOCK_TIMEOUT) ; ) ;
|
||||
}
|
||||
|
||||
/* Switch to 3-20MHz Xtal oscillator */
|
||||
PMC->CKGR_MOR = CKGR_MOR_KEY(0x37) | BOARD_OSCOUNT | CKGR_MOR_MOSCRCEN | CKGR_MOR_MOSCXTEN | CKGR_MOR_MOSCSEL;
|
||||
for ( dwTimeOut = 0 ; !(PMC->PMC_SR & PMC_SR_MOSCSELS) && (dwTimeOut++ < CLOCK_TIMEOUT) ; ) ;
|
||||
|
||||
PMC->PMC_MCKR = (PMC->PMC_MCKR & ~(uint32_t)PMC_MCKR_CSS_Msk) | PMC_MCKR_CSS_MAIN_CLK;
|
||||
for ( dwTimeOut = 0 ; !(PMC->PMC_SR & PMC_SR_MCKRDY) && (dwTimeOut++ < CLOCK_TIMEOUT) ; ) ;
|
||||
|
||||
/* Initialize PLLA */
|
||||
PMC->CKGR_PLLAR = BOARD_PLLAR ;
|
||||
for ( dwTimeOut = 0 ; !(PMC->PMC_SR & PMC_SR_LOCKA) && (dwTimeOut++ < CLOCK_TIMEOUT) ; ) ;
|
||||
|
||||
/* Switch to main clock */
|
||||
PMC->PMC_MCKR = (BOARD_MCKR & ~PMC_MCKR_CSS_Msk) | PMC_MCKR_CSS_MAIN_CLK;
|
||||
for ( dwTimeOut = 0 ; !(PMC->PMC_SR & PMC_SR_MCKRDY) && (dwTimeOut++ < CLOCK_TIMEOUT) ; ) ;
|
||||
|
||||
PMC->PMC_MCKR = BOARD_MCKR ;
|
||||
for ( dwTimeOut = 0 ; !(PMC->PMC_SR & PMC_SR_MCKRDY) && (dwTimeOut++ < CLOCK_TIMEOUT) ; ) ;
|
||||
}
|
141
hardware/tools/libboard_sam3s-ek/source/syscalls.c
Normal file
141
hardware/tools/libboard_sam3s-ek/source/syscalls.c
Normal file
@ -0,0 +1,141 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* 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.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file syscalls.c
|
||||
*
|
||||
* Implementation of newlib syscall.
|
||||
*
|
||||
*/
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Headers
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
#include "board.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Exported variables
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
#undef errno
|
||||
extern int errno ;
|
||||
extern int _end ;
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Exported functions
|
||||
*----------------------------------------------------------------------------*/
|
||||
extern void _exit( int status ) ;
|
||||
extern void _kill( int pid, int sig ) ;
|
||||
extern int _getpid ( void ) ;
|
||||
|
||||
extern caddr_t _sbrk ( int incr )
|
||||
{
|
||||
static unsigned char *heap = NULL ;
|
||||
unsigned char *prev_heap ;
|
||||
|
||||
if ( heap == NULL )
|
||||
{
|
||||
heap = (unsigned char *)&_end ;
|
||||
}
|
||||
prev_heap = heap;
|
||||
|
||||
heap += incr ;
|
||||
|
||||
return (caddr_t) prev_heap ;
|
||||
}
|
||||
|
||||
extern int link( char *old, char *new )
|
||||
{
|
||||
return -1 ;
|
||||
}
|
||||
|
||||
extern int _close( int file )
|
||||
{
|
||||
return -1 ;
|
||||
}
|
||||
|
||||
extern int _fstat( int file, struct stat *st )
|
||||
{
|
||||
st->st_mode = S_IFCHR ;
|
||||
|
||||
return 0 ;
|
||||
}
|
||||
|
||||
extern int _isatty( int file )
|
||||
{
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
extern int _lseek( int file, int ptr, int dir )
|
||||
{
|
||||
return 0 ;
|
||||
}
|
||||
|
||||
extern int _read(int file, char *ptr, int len)
|
||||
{
|
||||
return 0 ;
|
||||
}
|
||||
|
||||
extern int _write( int file, char *ptr, int len )
|
||||
{
|
||||
int iIndex ;
|
||||
|
||||
|
||||
// for ( ; *ptr != 0 ; ptr++ )
|
||||
for ( iIndex=0 ; iIndex < len ; iIndex++, ptr++ )
|
||||
{
|
||||
// UART_PutChar( *ptr ) ;
|
||||
}
|
||||
|
||||
return iIndex ;
|
||||
}
|
||||
|
||||
extern void _exit( int status )
|
||||
{
|
||||
printf( "Exiting with status %d.\n", status ) ;
|
||||
|
||||
for ( ; ; ) ;
|
||||
}
|
||||
|
||||
extern void _kill( int pid, int sig )
|
||||
{
|
||||
return ;
|
||||
}
|
||||
|
||||
extern int _getpid ( void )
|
||||
{
|
||||
return -1 ;
|
||||
}
|
118
hardware/tools/libboard_sam3s-ek/source/timetick.c
Normal file
118
hardware/tools/libboard_sam3s-ek/source/timetick.c
Normal file
@ -0,0 +1,118 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* 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.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file
|
||||
* Implement simple system tick usage.
|
||||
*/
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Headers
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
#include "board.h"
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Local variables
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
/** Tick Counter united by ms */
|
||||
static volatile uint32_t _dwTickCount=0 ;
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Exported Functions
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* \brief Handler for Sytem Tick interrupt.
|
||||
*/
|
||||
extern void TimeTick_Increment( void )
|
||||
{
|
||||
_dwTickCount++ ;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Configures the SAM3 SysTick & reset tickCount.
|
||||
* Systick interrupt handler will generates 1ms interrupt and increase a
|
||||
* tickCount.
|
||||
* \param dwNew_MCK Current master clock.
|
||||
*/
|
||||
extern uint32_t TimeTick_Configure( uint32_t dwNew_MCK )
|
||||
{
|
||||
_dwTickCount = 0 ;
|
||||
|
||||
return SysTick_Config( dwNew_MCK/1000 ) ;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Get current Tick Count, in ms.
|
||||
*/
|
||||
extern uint32_t GetTickCount( void )
|
||||
{
|
||||
return _dwTickCount ;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Sync Wait for several ms
|
||||
*/
|
||||
extern void Wait( volatile uint32_t dwMs )
|
||||
{
|
||||
uint32_t dwStart ;
|
||||
uint32_t dwCurrent ;
|
||||
|
||||
dwStart = _dwTickCount ;
|
||||
do
|
||||
{
|
||||
dwCurrent = _dwTickCount ;
|
||||
} while ( dwCurrent - dwStart < dwMs ) ;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Sync Sleep for several ms
|
||||
*/
|
||||
extern void Sleep( volatile uint32_t dwMs )
|
||||
{
|
||||
uint32_t dwStart ;
|
||||
uint32_t dwCurrent ;
|
||||
|
||||
dwStart = _dwTickCount ;
|
||||
|
||||
do
|
||||
{
|
||||
dwCurrent = _dwTickCount ;
|
||||
|
||||
if ( dwCurrent - dwStart > dwMs )
|
||||
{
|
||||
break ;
|
||||
}
|
||||
|
||||
__WFI() ;
|
||||
} while( 1 ) ;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user