Skip to content

Commit f08e822

Browse files
committed
Adding libchip_sam3s into tools, needed to add all SAM3S peripheral drivers
1 parent 4e0df49 commit f08e822

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

108 files changed

+20384
-0
lines changed
-537 Bytes
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Makefile for compiling libchip
2+
3+
SUBMAKE_OPTIONS=--no-builtin-rules --no-builtin-variables
4+
5+
#-------------------------------------------------------------------------------
6+
# Rules
7+
#-------------------------------------------------------------------------------
8+
9+
all: libchip_sam3s4_gcc_dbg.a libchip_sam3s4_gcc_rel.a
10+
11+
libchip_sam3s4_gcc_dbg.a:
12+
@echo --- Making $@
13+
@$(MAKE) CHIP=sam3s4 DEBUG=1 $(SUBMAKE_OPTIONS) -f sam3s.mk
14+
15+
libchip_sam3s4_gcc_rel.a:
16+
@echo --- Making $@
17+
@$(MAKE) CHIP=sam3s4 $(SUBMAKE_OPTIONS) -f sam3s.mk
18+
19+
.PHONY: clean
20+
clean:
21+
@echo --- Cleaning sam3s4 release and debug
22+
@$(MAKE) CHIP=sam3s4 $(SUBMAKE_OPTIONS) -f sam3s.mk $@
23+
@$(MAKE) CHIP=sam3s4 DEBUG=1 $(SUBMAKE_OPTIONS) -f sam3s.mk $@
24+
25+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Optimization level
2+
# -O1 Optimize
3+
# -O2 Optimize even more
4+
# -O3 Optimize yet more
5+
# -O0 Reduce compilation time and make debugging produce the expected results
6+
# -Os Optimize for size
7+
OPTIMIZATION = -g -O0 -DDEBUG
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
2+
# Tool suffix when cross-compiling
3+
#CROSS_COMPILE = ../../CodeSourcery_arm/bin/arm-none-eabi-
4+
CROSS_COMPILE = C:/CodeSourcery_2011.03-42/bin/arm-none-eabi-
5+
6+
# Compilation tools
7+
AR = $(CROSS_COMPILE)ar
8+
CC = $(CROSS_COMPILE)gcc
9+
AS = $(CROSS_COMPILE)as
10+
#LD = $(CROSS_COMPILE)ld
11+
#SIZE = $(CROSS_COMPILE)size
12+
NM = $(CROSS_COMPILE)nm
13+
#OBJCOPY = $(CROSS_COMPILE)objcopy
14+
RM=cs-rm -Rf
15+
SEP=/
16+
17+
# Flags
18+
19+
CFLAGS += -Wall -Wchar-subscripts -Wcomment -Wformat=2 -Wimplicit-int
20+
CFLAGS += -Werror-implicit-function-declaration -Wmain -Wparentheses
21+
CFLAGS += -Wsequence-point -Wreturn-type -Wswitch -Wtrigraphs -Wunused
22+
CFLAGS += -Wuninitialized -Wunknown-pragmas -Wfloat-equal -Wundef
23+
CFLAGS += -Wshadow -Wpointer-arith -Wbad-function-cast -Wwrite-strings
24+
CFLAGS += -Wsign-compare -Waggregate-return -Wstrict-prototypes
25+
CFLAGS += -Wmissing-prototypes -Wmissing-declarations
26+
CFLAGS += -Wformat -Wmissing-format-attribute -Wno-deprecated-declarations
27+
CFLAGS += -Wpacked -Wredundant-decls -Wnested-externs -Winline -Wlong-long
28+
CFLAGS += -Wunreachable-code
29+
CFLAGS += -Wcast-align
30+
#CFLAGS += -Wmissing-noreturn
31+
#CFLAGS += -Wconversion
32+
33+
# To reduce application size use only integer printf function.
34+
CFLAGS += -Dprintf=iprintf
35+
36+
CFLAGS += --param max-inline-insns-single=500 -mcpu=cortex-m3 -mthumb -mlong-calls -ffunction-sections
37+
CFLAGS += $(OPTIMIZATION) $(INCLUDES) -D$(CHIP)
38+
39+
ASFLAGS = -mcpu=cortex-m3 -mthumb -Wall -a -g $(INCLUDES)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Optimization level
2+
# -O1 Optimize
3+
# -O2 Optimize even more
4+
# -O3 Optimize yet more
5+
# -O0 Reduce compilation time and make debugging produce the expected results
6+
# -Os Optimize for size
7+
OPTIMIZATION = -Os
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
# Makefile for compiling libchip
2+
.SUFFIXES: .o .a .c .s
3+
SUB_MAKEFILES=debug.mk gcc.mk release.mk win.mk sam3s.mk
4+
5+
LIBNAME=libchip
6+
TOOLCHAIN=gcc
7+
8+
ifeq ($(CHIP),)
9+
$(error CHIP not defined)
10+
endif
11+
12+
#-------------------------------------------------------------------------------
13+
# Path
14+
#-------------------------------------------------------------------------------
15+
16+
# Output directories
17+
OUTPUT_BIN = ../lib
18+
19+
# Libraries
20+
PROJECT_BASE_PATH = ..
21+
22+
#-------------------------------------------------------------------------------
23+
# Files
24+
#-------------------------------------------------------------------------------
25+
26+
vpath %.h $(PROJECT_BASE_PATH)/include
27+
vpath %.c $(PROJECT_BASE_PATH)/source $(PROJECT_BASE_PATH)/cmsis
28+
vpath %.s $(PROJECT_BASE_PATH)/source $(PROJECT_BASE_PATH)/cmsis
29+
30+
VPATH+=$(PROJECT_BASE_PATH)/source
31+
VPATH+=$(PROJECT_BASE_PATH)/cmsis
32+
33+
INCLUDES = -I$(PROJECT_BASE_PATH)
34+
INCLUDES += -I$(PROJECT_BASE_PATH)/include
35+
INCLUDES += -I$(PROJECT_BASE_PATH)/cmsis
36+
37+
#-------------------------------------------------------------------------------
38+
ifdef DEBUG
39+
include debug.mk
40+
else
41+
include release.mk
42+
endif
43+
44+
#-------------------------------------------------------------------------------
45+
# Tools
46+
#-------------------------------------------------------------------------------
47+
48+
include $(TOOLCHAIN).mk
49+
50+
#-------------------------------------------------------------------------------
51+
ifdef DEBUG
52+
OUTPUT_OBJ=debug
53+
OUTPUT_LIB=$(LIBNAME)_$(CHIP)_$(TOOLCHAIN)_dbg.a
54+
else
55+
OUTPUT_OBJ=release
56+
OUTPUT_LIB=$(LIBNAME)_$(CHIP)_$(TOOLCHAIN)_rel.a
57+
endif
58+
59+
OUTPUT_PATH=$(OUTPUT_OBJ)_$(CHIP)
60+
61+
#-------------------------------------------------------------------------------
62+
# C source files and objects
63+
#-------------------------------------------------------------------------------
64+
C_SRC=$(wildcard $(PROJECT_BASE_PATH)/source/*.c)
65+
C_SRC+=$(wildcard $(PROJECT_BASE_PATH)/cmsis/*.c)
66+
67+
C_OBJ_TEMP=$(patsubst %.c, %.o, $(notdir $(C_SRC)))
68+
69+
# during development, remove some files
70+
C_OBJ_FILTER=pio_it.o
71+
72+
C_OBJ=$(filter-out $(C_OBJ_FILTER), $(C_OBJ_TEMP))
73+
74+
#-------------------------------------------------------------------------------
75+
# Assembler source files and objects
76+
#-------------------------------------------------------------------------------
77+
A_SRC=$(wildcard $(PROJECT_BASE_PATH)/source/*.s)
78+
A_SRC+=$(wildcard $(PROJECT_BASE_PATH)/cmsis/*.s)
79+
80+
A_OBJ_TEMP=$(patsubst %.s, %.o, $(notdir $(A_SRC)))
81+
82+
# during development, remove some files
83+
A_OBJ_FILTER=
84+
85+
A_OBJ=$(filter-out $(A_OBJ_FILTER), $(A_OBJ_TEMP))
86+
87+
#-------------------------------------------------------------------------------
88+
# Rules
89+
#-------------------------------------------------------------------------------
90+
all: $(CHIP)
91+
92+
$(CHIP): create_output $(OUTPUT_LIB)
93+
94+
.PHONY: create_output
95+
create_output:
96+
@echo --- Preparing $(CHIP) files $(OUTPUT_PATH) $(OUTPUT_BIN)
97+
# @echo -------------------------
98+
# @echo *$(C_SRC)
99+
# @echo -------------------------
100+
# @echo *$(C_OBJ)
101+
# @echo -------------------------
102+
# @echo *$(addprefix $(OUTPUT_PATH)/, $(C_OBJ))
103+
# @echo -------------------------
104+
# @echo *$(A_SRC)
105+
# @echo -------------------------
106+
107+
-@mkdir $(subst /,$(SEP),$(OUTPUT_BIN)) 1>NUL 2>&1
108+
-@mkdir $(OUTPUT_PATH) 1>NUL 2>&1
109+
110+
$(addprefix $(OUTPUT_PATH)/,$(C_OBJ)): $(OUTPUT_PATH)/%.o: %.c
111+
# "$(CC)" -v -c $(CFLAGS) -Wa,aln=$(subst .o,.s,$@) $< -o $@
112+
@"$(CC)" -c $(CFLAGS) $< -o $@
113+
114+
$(addprefix $(OUTPUT_PATH)/,$(A_OBJ)): $(OUTPUT_PATH)/%.o: %.s
115+
@"$(AS)" -c $(ASFLAGS) $< -o $@
116+
117+
$(OUTPUT_LIB): $(addprefix $(OUTPUT_PATH)/, $(C_OBJ)) $(addprefix $(OUTPUT_PATH)/, $(A_OBJ))
118+
@"$(AR)" -r "$(OUTPUT_BIN)/$@" $^
119+
@"$(NM)" "$(OUTPUT_BIN)/$@" > "$(OUTPUT_BIN)/$@.txt"
120+
121+
.PHONY: clean
122+
clean:
123+
@echo --- Cleaning $(CHIP) files
124+
-@$(RM) $(OUTPUT_PATH) 1>NUL 2>&1
125+
-@$(RM) $(subst /,$(SEP),$(OUTPUT_BIN)/$(OUTPUT_LIB)) 1>NUL 2>&1
126+
-@$(RM) $(subst /,$(SEP),$(OUTPUT_BIN)/$(OUTPUT_LIB)).txt 1>NUL 2>&1
127+
128+
# dependencies
129+
$(addprefix $(OUTPUT_PATH)/,$(C_OBJ)): $(OUTPUT_PATH)/%.o: $(PROJECT_BASE_PATH)/chip.h $(wildcard $(PROJECT_BASE_PATH)/include/*.h) $(wildcard $(PROJECT_BASE_PATH)/cmsis/*.h)

hardware/tools/libchip_sam3s/chip.h

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
#ifndef _LIB_SAM3S_
2+
#define _LIB_SAM3S_
3+
4+
/*
5+
* Peripherals registers definitions
6+
*/
7+
#if defined sam3s4
8+
#elif defined sam3s2
9+
#elif defined sam3s1
10+
#else
11+
#warning Library does not support the specified chip, specifying sam3s4.
12+
#define sam3s4
13+
#endif
14+
#include "include/SAM3S.h"
15+
16+
/** Define MAX number of Interrupts: (IRQn_Type+1) + 8 for CM3 core */
17+
#define EXTERNAL_NUM_INTERRUPTS (UDP_IRQn+1+8)
18+
19+
/* Define attribute */
20+
#if defined ( __GNUC__ ) /* GCC CS3 */
21+
#define WEAK __attribute__ ((weak))
22+
#endif
23+
24+
/* Define NO_INIT attribute */
25+
#if defined ( __GNUC__ )
26+
#define NO_INIT
27+
#endif
28+
29+
30+
/*
31+
* Core
32+
*/
33+
34+
#include "include/exceptions.h"
35+
36+
/*
37+
* Peripherals
38+
*/
39+
#include "include/acc.h"
40+
#include "include/adc.h"
41+
#include "include/async.h"
42+
#include "include/crccu.h"
43+
#include "include/dacc.h"
44+
#include "include/efc.h"
45+
#include "include/flashd.h"
46+
#include "include/pio.h"
47+
//#include "include/pio_it.h"
48+
#include "include/pio_capture.h"
49+
#include "include/pmc.h"
50+
#include "include/pwmc.h"
51+
#include "include/rtc.h"
52+
#include "include/rtt.h"
53+
#include "include/spi.h"
54+
#include "include/spi_pdc.h"
55+
#include "include/ssc.h"
56+
#include "include/tc.h"
57+
#include "include/twi.h"
58+
#include "include/twid.h"
59+
#include "include/usart.h"
60+
#include "include/wdt.h"
61+
62+
#endif /* _LIB_SAM3S_ */

0 commit comments

Comments
 (0)