Add all exercises

This commit is contained in:
Oystein Kristoffer Tveit 2022-08-27 16:26:13 +02:00
commit 35199c438c
Signed by: oysteikt
GPG Key ID: 9F2F7D8250F35146
29 changed files with 2644 additions and 0 deletions

5
.gitignore vendored Normal file
View File

@ -0,0 +1,5 @@
**/build
**/exe
**/lst
**/result

24
README.md Normal file
View File

@ -0,0 +1,24 @@
# TDT 4160 Solutions Autumn 2021
In order to build this code, you will need to have the following installed:
- Simplicity Studio
- The `EFM32GG-STK3700` adapter for Simplicity Studio
- GNU Make (haven't tested BSD Make)
For the assembly and C exercises, I'm using the makefile to build and flash the program to the Gecko Board.
```bash
cd o1 # or o2 / o3
make all
make flash
```
In order for the commands above to succeed, you might need to edit the makefile to point at your Simplicity Studio install.
The original makefile expected Simplicity Studio 3.
The paths is currently configured to point at Simplicity Studio 5, installed at `/opt/simplicitystudio5`.
The original makefiles are stored as `Makefile.original`, in order to make them easy to diff.
## Assembly cheatsheet from Azeria Labs
![azeria-labs.com](https://azeria-labs.com/downloads/cheatsheetv1.3-1920x1080.png)

BIN
kompendium_o123.pdf Normal file

Binary file not shown.

214
o1/Makefile Normal file
View File

@ -0,0 +1,214 @@
####################################################################
# Makefile #
####################################################################
.SUFFIXES: # ignore builtin rules
.PHONY: all debug release clean flash rammeverk
####################################################################
# Definitions #
####################################################################
# notdirx: version of notdir which allows spaces in path
s? = $(subst $(empty) ,?,$1)
?s = $(subst ?, ,$1)
notdirx = $(call ?s,$(notdir $(call s?,$1)))
DEVICE = EFM32GG990F1024
PROJECTNAME = $(call notdirx,$(CURDIR))
OBJ_DIR = build
EXE_DIR = exe
LST_DIR = lst
####################################################################
# Definitions of toolchain. #
# You might need to do changes to match your system setup #
####################################################################
RM := rm -rf
NULLDEVICE := /dev/null
SHELLNAMES := $(ComSpec)$(COMSPEC)
# This is only valid for my specific system.
TOOLCHAIN_BIN_DIR := /opt/simplicitystudio5/developer/toolchains/gnu_arm/10.2_2020q4/bin
CC := $(TOOLCHAIN_BIN_DIR)/arm-none-eabi-gcc
LD := $(TOOLCHAIN_BIN_DIR)/arm-none-eabi-ld
AR := $(TOOLCHAIN_BIN_DIR)/arm-none-eabi-ar
OBJCOPY := $(TOOLCHAIN_BIN_DIR)/arm-none-eabi-objcopy
DUMP := $(TOOLCHAIN_BIN_DIR)/arm-none-eabi-objdump
# Detect operating system
ifeq ($(SHELLNAMES),) # Linux
EACOM = /opt/simplicitystudio5/developer/adapter_packs/commander/commander
else
EACOM = C:\SiliconLabs\SimplicityStudio\v3\bgtool\commander\commander.exe
ifneq ($(COMSPEC),) # mingw/msys/cygwin platform running on Windows
ifeq ($(findstring cygdrive,$(shell set)),)
# We were not on a cygwin platform
NULLDEVICE := NUL
endif
else # Windows
NULLDEVICE := NUL
endif
endif
# Create directories and do a clean which is compatible with parallell make
$(shell mkdir $(OBJ_DIR)>$(NULLDEVICE) 2>&1)
$(shell mkdir $(EXE_DIR)>$(NULLDEVICE) 2>&1)
$(shell mkdir $(LST_DIR)>$(NULLDEVICE) 2>&1)
ifeq (clean,$(findstring clean, $(MAKECMDGOALS)))
ifneq ($(filter $(MAKECMDGOALS),all debug release),)
$(shell $(RM) $(OBJ_DIR)/*>$(NULLDEVICE) 2>&1)
$(shell $(RM) $(EXE_DIR)/*>$(NULLDEVICE) 2>&1)
$(shell $(RM) $(LST_DIR)/*>$(NULLDEVICE) 2>&1) #*/
endif
endif
####################################################################
# Flags #
####################################################################
# -MMD : Don't generate dependencies on system header files.
# -MP : Add phony targets, useful when a h-file is removed from a project.
# -MF : Specify a file to write the dependencies to.
DEPFLAGS = -MMD -MP -MF $(@:.o=.d)
#
# Add -Wa,-ahld=$(LST_DIR)/$(@F:.o=.lst) to CFLAGS to produce assembly list files
#
override CFLAGS += -D$(DEVICE) -Wall -Wextra -mcpu=cortex-m3 -mthumb -ffunction-sections \
-fdata-sections -mfix-cortex-m3-ldrd -fomit-frame-pointer -DDEBUG_EFM \
-O0 \
$(DEPFLAGS)
ASMFLAGS += -x assembler-with-cpp -mcpu=cortex-m3 -mthumb
#
# NOTE: The -Wl,--gc-sections flag may interfere with debugging using gdb.
#
override LDFLAGS += -Xlinker -Map=$(LST_DIR)/$(PROJECTNAME).map -mcpu=cortex-m3 \
-mthumb -Tefm32gg.ld --specs=nano.specs \
-Wl,--gc-sections
LIBS = -Wl,--start-group -lgcc -lc -lnosys -Wl,--end-group
INCLUDEPATHS += \
-I.. \
-I../common/CMSIS/Include \
-I../common/EFM32GG/Include \
-I../common/emlib/inc \
-I../common/EFM32/drivers \
-I../common/EFM32/bsp \
-I../common/EFM32GG_STK3700/config
####################################################################
# Files #
####################################################################
C_SRC += \
../common/EFM32GG/Source/system_efm32gg.c \
../common/EFM32/drivers/vddcheck.c \
../common/EFM32/drivers/segmentlcd.c \
../common/emlib/src/em_assert.c \
../common/emlib/src/em_cmu.c \
../common/emlib/src/em_emu.c \
../common/emlib/src/em_gpio.c \
../common/emlib/src/em_rtc.c \
../common/emlib/src/em_system.c \
../common/emlib/src/em_lcd.c \
../common/emlib/src/em_vcmp.c \
../common/emlib/src/em_usart.c \
../common/EFM32/bsp/bsp_stk.c \
../common/EFM32/bsp/bsp_stk_leds.c \
../common/EFM32/bsp/bsp_trace.c \
../common/$(PROJECTNAME)/init.c
s_SRC += \
../common/EFM32GG/Source/GCC/startup_efm32gg.s
STUDENT_SRC += \
$(PROJECTNAME).s \
gpio_constants.s \
sys-tick_constants.s
####################################################################
# Rules #
####################################################################
C_FILES = $(notdir $(C_SRC) )
S_FILES = $(notdir $(S_SRC) $(s_SRC) )
#make list of source paths, sort also removes duplicates
C_PATHS = $(sort $(dir $(C_SRC) ) )
S_PATHS = $(sort $(dir $(S_SRC) $(s_SRC) ) )
C_OBJS = $(addprefix $(OBJ_DIR)/, $(C_FILES:.c=.o))
S_OBJS = $(if $(S_SRC), $(addprefix $(OBJ_DIR)/, $(S_FILES:.S=.o)))
s_OBJS = $(if $(s_SRC), $(addprefix $(OBJ_DIR)/, $(S_FILES:.s=.o)))
C_DEPS = $(addprefix $(OBJ_DIR)/, $(C_FILES:.c=.d))
OBJS = $(C_OBJS) $(S_OBJS) $(s_OBJS)
STUDENT_OBJS = $(addprefix $(OBJ_DIR)/, $(STUDENT_SRC:.s=.o))
vpath %.c $(C_PATHS)
vpath %.s $(S_PATHS)
vpath %.S $(S_PATHS)
# Default build is debug build
all: debug
debug: CFLAGS += -DDEBUG -O0 -g3
debug: $(EXE_DIR)/$(PROJECTNAME).bin
release: CFLAGS += -DNDEBUG -O3 -g3
release: $(EXE_DIR)/$(PROJECTNAME).bin
rammeverk: $(OBJS)
# Create objects from C SRC files
$(OBJ_DIR)/%.o: %.c
@echo "Building file: $<"
$(CC) $(CFLAGS) $(INCLUDEPATHS) -c -o $@ $<
# Assemble .s/.S files
$(OBJ_DIR)/%.o: %.s
@echo "Assembling $<"
$(CC) $(ASMFLAGS) $(INCLUDEPATHS) -c -o $@ $<
$(OBJ_DIR)/%.o: %.S
@echo "Assembling $<"
$(CC) $(ASMFLAGS) $(INCLUDEPATHS) -c -o $@ $<
# Link
$(EXE_DIR)/$(PROJECTNAME).out: $(STUDENT_OBJS)
@echo "Linking target: $@"
$(CC) $(LDFLAGS) $(OBJS) $(STUDENT_OBJS) $(LIBS) -o $(EXE_DIR)/$(PROJECTNAME).out
# Create binary file
$(EXE_DIR)/$(PROJECTNAME).bin: $(EXE_DIR)/$(PROJECTNAME).out
@echo "Creating binary file"
$(OBJCOPY) -O binary $(EXE_DIR)/$(PROJECTNAME).out $(EXE_DIR)/$(PROJECTNAME).bin
# Uncomment next line to produce assembly listing of entire program
# $(DUMP) -h -S -C $(EXE_DIR)/$(PROJECTNAME).out>$(LST_DIR)/$(PROJECTNAME)out.lst
# Flash on!
ifeq ($(f), 1)
$(EACOM) flash $(EXE_DIR)/$(PROJECTNAME).bin
endif
clean:
ifeq ($(filter $(MAKECMDGOALS),all debug release),)
$(RM) $(LST_DIR) $(EXE_DIR)
$(RM) $(STUDENT_OBJS)
endif
# include auto-generated dependency files (explicit rules)
ifneq (clean,$(findstring clean, $(MAKECMDGOALS)))
-include $(C_DEPS)
endif
flash:
$(EACOM) flash $(EXE_DIR)/$(PROJECTNAME).bin
@echo "Completed!"

214
o1/Makefile.original Normal file
View File

@ -0,0 +1,214 @@
####################################################################
# Makefile #
####################################################################
.SUFFIXES: # ignore builtin rules
.PHONY: all debug release clean flash rammeverk
####################################################################
# Definitions #
####################################################################
# notdirx: version of notdir which allows spaces in path
s? = $(subst $(empty) ,?,$1)
?s = $(subst ?, ,$1)
notdirx = $(call ?s,$(notdir $(call s?,$1)))
DEVICE = EFM32GG990F1024
PROJECTNAME = $(call notdirx,$(CURDIR))
OBJ_DIR = build
EXE_DIR = exe
LST_DIR = lst
####################################################################
# Definitions of toolchain. #
# You might need to do changes to match your system setup #
####################################################################
RM := rm -rf
NULLDEVICE := /dev/null
SHELLNAMES := $(ComSpec)$(COMSPEC)
CC := arm-none-eabi-gcc
LD := arm-none-eabi-ld
AR := arm-none-eabi-ar
OBJCOPY := arm-none-eabi-objcopy
DUMP := arm-none-eabi-objdump
# Detect operating system
ifeq ($(SHELLNAMES),) # Linux
EACOM = /opt/SimplicityStudio_v3/bgtool/commander/commander
else
EACOM = C:\SiliconLabs\SimplicityStudio\v3\bgtool\commander\commander.exe
ifneq ($(COMSPEC),) # mingw/msys/cygwin platform running on Windows
ifeq ($(findstring cygdrive,$(shell set)),)
# We were not on a cygwin platform
NULLDEVICE := NUL
endif
else # Windows
NULLDEVICE := NUL
endif
endif
# Create directories and do a clean which is compatible with parallell make
$(shell mkdir $(OBJ_DIR)>$(NULLDEVICE) 2>&1)
$(shell mkdir $(EXE_DIR)>$(NULLDEVICE) 2>&1)
$(shell mkdir $(LST_DIR)>$(NULLDEVICE) 2>&1)
ifeq (clean,$(findstring clean, $(MAKECMDGOALS)))
ifneq ($(filter $(MAKECMDGOALS),all debug release),)
$(shell $(RM) $(OBJ_DIR)/*>$(NULLDEVICE) 2>&1)
$(shell $(RM) $(EXE_DIR)/*>$(NULLDEVICE) 2>&1)
$(shell $(RM) $(LST_DIR)/*>$(NULLDEVICE) 2>&1) #*/
endif
endif
####################################################################
# Flags #
####################################################################
# -MMD : Don't generate dependencies on system header files.
# -MP : Add phony targets, useful when a h-file is removed from a project.
# -MF : Specify a file to write the dependencies to.
DEPFLAGS = -MMD -MP -MF $(@:.o=.d)
#
# Add -Wa,-ahld=$(LST_DIR)/$(@F:.o=.lst) to CFLAGS to produce assembly list files
#
override CFLAGS += -D$(DEVICE) -Wall -Wextra -mcpu=cortex-m3 -mthumb -ffunction-sections \
-fdata-sections -mfix-cortex-m3-ldrd -fomit-frame-pointer -DDEBUG_EFM \
-O0 \
$(DEPFLAGS)
ASMFLAGS += -x assembler-with-cpp -mcpu=cortex-m3 -mthumb
#
# NOTE: The -Wl,--gc-sections flag may interfere with debugging using gdb.
#
override LDFLAGS += -Xlinker -Map=$(LST_DIR)/$(PROJECTNAME).map -mcpu=cortex-m3 \
-mthumb -Tefm32gg.ld --specs=nano.specs \
-Wl,--gc-sections
LIBS = -Wl,--start-group -lgcc -lc -lnosys -Wl,--end-group
INCLUDEPATHS += \
-I.. \
-I../common/CMSIS/Include \
-I../common/EFM32GG/Include \
-I../common/emlib/inc \
-I../common/EFM32/drivers \
-I../common/EFM32/bsp \
-I../common/EFM32GG_STK3700/config
####################################################################
# Files #
####################################################################
C_SRC += \
../common/EFM32GG/Source/system_efm32gg.c \
../common/EFM32/drivers/vddcheck.c \
../common/EFM32/drivers/segmentlcd.c \
../common/emlib/src/em_assert.c \
../common/emlib/src/em_cmu.c \
../common/emlib/src/em_emu.c \
../common/emlib/src/em_gpio.c \
../common/emlib/src/em_rtc.c \
../common/emlib/src/em_system.c \
../common/emlib/src/em_lcd.c \
../common/emlib/src/em_vcmp.c \
../common/emlib/src/em_usart.c \
../common/EFM32/bsp/bsp_stk.c \
../common/EFM32/bsp/bsp_stk_leds.c \
../common/EFM32/bsp/bsp_trace.c \
../common/$(PROJECTNAME)/init.c
s_SRC += \
../common/EFM32GG/Source/GCC/startup_efm32gg.s
STUDENT_SRC += \
$(PROJECTNAME).s \
gpio_constants.s \
sys-tick_constants.s
####################################################################
# Rules #
####################################################################
C_FILES = $(notdir $(C_SRC) )
S_FILES = $(notdir $(S_SRC) $(s_SRC) )
#make list of source paths, sort also removes duplicates
C_PATHS = $(sort $(dir $(C_SRC) ) )
S_PATHS = $(sort $(dir $(S_SRC) $(s_SRC) ) )
C_OBJS = $(addprefix $(OBJ_DIR)/, $(C_FILES:.c=.o))
S_OBJS = $(if $(S_SRC), $(addprefix $(OBJ_DIR)/, $(S_FILES:.S=.o)))
s_OBJS = $(if $(s_SRC), $(addprefix $(OBJ_DIR)/, $(S_FILES:.s=.o)))
C_DEPS = $(addprefix $(OBJ_DIR)/, $(C_FILES:.c=.d))
OBJS = $(C_OBJS) $(S_OBJS) $(s_OBJS)
STUDENT_OBJS = $(addprefix $(OBJ_DIR)/, $(STUDENT_SRC:.s=.o))
vpath %.c $(C_PATHS)
vpath %.s $(S_PATHS)
vpath %.S $(S_PATHS)
# Default build is debug build
all: debug
debug: CFLAGS += -DDEBUG -O0 -g3
debug: $(EXE_DIR)/$(PROJECTNAME).bin
release: CFLAGS += -DNDEBUG -O3 -g3
release: $(EXE_DIR)/$(PROJECTNAME).bin
rammeverk: $(OBJS)
# Create objects from C SRC files
$(OBJ_DIR)/%.o: %.c
@echo "Building file: $<"
$(CC) $(CFLAGS) $(INCLUDEPATHS) -c -o $@ $<
# Assemble .s/.S files
$(OBJ_DIR)/%.o: %.s
@echo "Assembling $<"
$(CC) $(ASMFLAGS) $(INCLUDEPATHS) -c -o $@ $<
$(OBJ_DIR)/%.o: %.S
@echo "Assembling $<"
$(CC) $(ASMFLAGS) $(INCLUDEPATHS) -c -o $@ $<
# Link
$(EXE_DIR)/$(PROJECTNAME).out: $(STUDENT_OBJS)
@echo "Linking target: $@"
$(CC) $(LDFLAGS) $(OBJS) $(STUDENT_OBJS) $(LIBS) -o $(EXE_DIR)/$(PROJECTNAME).out
# Create binary file
$(EXE_DIR)/$(PROJECTNAME).bin: $(EXE_DIR)/$(PROJECTNAME).out
@echo "Creating binary file"
$(OBJCOPY) -O binary $(EXE_DIR)/$(PROJECTNAME).out $(EXE_DIR)/$(PROJECTNAME).bin
# Uncomment next line to produce assembly listing of entire program
# $(DUMP) -h -S -C $(EXE_DIR)/$(PROJECTNAME).out>$(LST_DIR)/$(PROJECTNAME)out.lst
# Flash on!
ifeq ($(f), 1)
$(EACOM) flash $(EXE_DIR)/$(PROJECTNAME).bin
endif
clean:
ifeq ($(filter $(MAKECMDGOALS),all debug release),)
$(RM) $(LST_DIR) $(EXE_DIR)
$(RM) $(STUDENT_OBJS)
endif
# include auto-generated dependency files (explicit rules)
ifneq (clean,$(findstring clean, $(MAKECMDGOALS)))
-include $(C_DEPS)
endif
flash:
$(EACOM) flash $(EXE_DIR)/$(PROJECTNAME).bin
@echo "Completed!"

207
o1/efm32gg.ld Normal file
View File

@ -0,0 +1,207 @@
/* Linker script for Silicon Labs EFM32GG devices */
/* */
/* This file is subject to the license terms as defined in ARM's */
/* CMSIS END USER LICENSE AGREEMENT.pdf, governing the use of */
/* Example Code. */
/* */
/* Copyright 2018 Silicon Laboratories, Inc. http://www.silabs.com */
/* */
/* Version 5.5.0 */
/* */
MEMORY
{
FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 1048576
RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 131072
}
/* Linker script to place sections and symbol values. Should be used together
* with other linker script that defines memory regions FLASH and RAM.
* It references following symbols, which must be defined in code:
* Reset_Handler : Entry of reset handler
*
* It defines following symbols, which code can use without definition:
* __exidx_start
* __exidx_end
* __copy_table_start__
* __copy_table_end__
* __zero_table_start__
* __zero_table_end__
* __etext
* __data_start__
* __preinit_array_start
* __preinit_array_end
* __init_array_start
* __init_array_end
* __fini_array_start
* __fini_array_end
* __data_end__
* __bss_start__
* __bss_end__
* __end__
* end
* __HeapLimit
* __StackLimit
* __StackTop
* __stack
* __Vectors_End
* __Vectors_Size
*/
ENTRY(Reset_Handler)
SECTIONS
{
.text :
{
KEEP(*(.vectors))
__Vectors_End = .;
__Vectors_Size = __Vectors_End - __Vectors;
__end__ = .;
*(.text*)
KEEP(*(.init))
KEEP(*(.fini))
/* .ctors */
*crtbegin.o(.ctors)
*crtbegin?.o(.ctors)
*(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors)
*(SORT(.ctors.*))
*(.ctors)
/* .dtors */
*crtbegin.o(.dtors)
*crtbegin?.o(.dtors)
*(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors)
*(SORT(.dtors.*))
*(.dtors)
*(.rodata*)
KEEP(*(.eh_frame*))
} > FLASH
.ARM.extab :
{
*(.ARM.extab* .gnu.linkonce.armextab.*)
} > FLASH
__exidx_start = .;
.ARM.exidx :
{
*(.ARM.exidx* .gnu.linkonce.armexidx.*)
} > FLASH
__exidx_end = .;
/* To copy multiple ROM to RAM sections,
* uncomment .copy.table section and,
* define __STARTUP_COPY_MULTIPLE in startup_ARMCMx.S */
/*
.copy.table :
{
. = ALIGN(4);
__copy_table_start__ = .;
LONG (__etext)
LONG (__data_start__)
LONG (__data_end__ - __data_start__)
LONG (__etext2)
LONG (__data2_start__)
LONG (__data2_end__ - __data2_start__)
__copy_table_end__ = .;
} > FLASH
*/
/* To clear multiple BSS sections,
* uncomment .zero.table section and,
* define __STARTUP_CLEAR_BSS_MULTIPLE in startup_ARMCMx.S */
/*
.zero.table :
{
. = ALIGN(4);
__zero_table_start__ = .;
LONG (__bss_start__)
LONG (__bss_end__ - __bss_start__)
LONG (__bss2_start__)
LONG (__bss2_end__ - __bss2_start__)
__zero_table_end__ = .;
} > FLASH
*/
__etext = .;
.data : AT (__etext)
{
__data_start__ = .;
*(vtable)
*(.data*)
. = ALIGN (4);
*(.ram)
. = ALIGN(4);
/* preinit data */
PROVIDE_HIDDEN (__preinit_array_start = .);
KEEP(*(.preinit_array))
PROVIDE_HIDDEN (__preinit_array_end = .);
. = ALIGN(4);
/* init data */
PROVIDE_HIDDEN (__init_array_start = .);
KEEP(*(SORT(.init_array.*)))
KEEP(*(.init_array))
PROVIDE_HIDDEN (__init_array_end = .);
. = ALIGN(4);
/* finit data */
PROVIDE_HIDDEN (__fini_array_start = .);
KEEP(*(SORT(.fini_array.*)))
KEEP(*(.fini_array))
PROVIDE_HIDDEN (__fini_array_end = .);
KEEP(*(.jcr*))
. = ALIGN(4);
/* All data end */
__data_end__ = .;
} > RAM
.bss :
{
. = ALIGN(4);
__bss_start__ = .;
*(.bss*)
*(COMMON)
. = ALIGN(4);
__bss_end__ = .;
} > RAM
.heap (COPY):
{
__HeapBase = .;
__end__ = .;
end = __end__;
_end = __end__;
KEEP(*(.heap*))
__HeapLimit = .;
} > RAM
/* .stack_dummy section doesn't contains any symbols. It is only
* used for linker to calculate size of stack sections, and assign
* values to stack symbols later */
.stack_dummy (COPY):
{
KEEP(*(.stack*))
} > RAM
/* Set stack top to end of RAM, and stack limit move down by
* size of stack_dummy section */
__StackTop = ORIGIN(RAM) + LENGTH(RAM);
__StackLimit = __StackTop - SIZEOF(.stack_dummy);
PROVIDE(__stack = __StackTop);
/* Check if data + heap + stack exceeds RAM limit */
ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack")
/* Check if FLASH usage exceeds FLASH size */
ASSERT( LENGTH(FLASH) >= (__etext + SIZEOF(.data)), "FLASH memory overflowed !")
}

53
o1/gpio_constants.s Normal file
View File

@ -0,0 +1,53 @@
// GPIO base-adresse
GPIO_BASE = 0x40006000
// --- [Offset til GPIO-registrene]----------------------------------------- //
// --- [Offset til portregistrene ] ------------------------------- //
GPIO_PORT_CTRL = 0 // Port Control Register
GPIO_PORT_MODEL = 4 // Port Pin Mode Low Register
GPIO_PORT_MODEH = 8 // Port Pin Mode High Register
GPIO_PORT_DOUT = 12 // Port Data Out Register
GPIO_PORT_DOUTSET = 16 // Port Data Out Set Register
GPIO_PORT_DOUTCLR = 20 // Port Data Out Clear Register
GPIO_PORT_DOUTTGL = 24 // Port Data Out Toggle Register
GPIO_PORT_DIN = 28 // Port Data In Register
GPIO_PORT_PINLOCKN = 32 // Port Unlocked Pins Register
// ---------------------------------------------------------------- //
GPIO_EXTIPSELL = 256 // External Interrupt Port Select Low Register
GPIO_EXTIPSELH = 260 // External Interrupt Port Select High Register
GPIO_EXTIRISE = 264 // External Interrupt Rising Edge Trigger Register
GPIO_EXTIFALL = 268 // External Interrupt Falling Edge Trigger Register
GPIO_IEN = 272 // Interrupt Enable Register
GPIO_IF = 276 // Interrupt Flag Register
GPIO_IFS = 280 // Interrupt Flag Set Register
GPIO_IFC = 284 // Interrupt Flag Clear Register
GPIO_ROUTE = 288 // I/O Routing Register
GPIO_INSENSE = 292 // Input Sense Register
GPIO_LOCK = 296 // Configuration Lock Register
GPIO_CTRL = 300 // GPIO Control Register
GPIO_CMD = 304 // EM4 Wake-up Clear Register
GPIO_EM4WUEN = 308 // EM4 Wake-up Enable Register
GPIO_EM4WUPOL = 312 // EM4 Wake-up Polarity Register
GPIO_EM4WUCAUSE = 316 // EM4 Wake-up Cause Register
// ------------------------------------------------------------------------- //
// --- [Hjelpekonstanter til GPIO]------------------------------------------ //
// Porter
PORT_A = 0
PORT_B = 1
PORT_C = 2
PORT_D = 3
PORT_E = 4
PORT_F = 5
NUMBER_OF_PORTS = 6 // Antall porter
PORT_SIZE = 36 // Antall bytes i et sett med portregistre
// Enheter på kitet
LED_PORT = PORT_E
LED_PIN = 2
BUTTON_PORT = PORT_B
BUTTON_PIN = 9
// ------------------------------------------------------------------------- //

27
o1/o1.s Normal file
View File

@ -0,0 +1,27 @@
.thumb
.syntax unified
.include "gpio_constants.s" // Register-adresser og konstanter for GPIO
.text
.global Start
LED_PORT_BASE = GPIO_BASE + (LED_PORT * PORT_SIZE)
LED_SET_ADDR = LED_PORT_BASE + GPIO_PORT_DOUTSET
LED_CLEAR_ADDR = LED_PORT_BASE + GPIO_PORT_DOUTCLR
BUTTON_READ_ADDR = GPIO_BASE + (BUTTON_PORT * PORT_SIZE) + GPIO_PORT_DIN
Start:
LDR R0, =LED_SET_ADDR
LDR R1, =LED_CLEAR_ADDR
LDR R2, =BUTTON_READ_ADDR
Loop:
LDR R3, [R2] // Read value of BUTTON_READ_ADDR
AND R3, R3, 1 << BUTTON_PIN // Mask out the bit of interest
LSR R3, BUTTON_PIN - LED_PIN // Shift the bit to the LED_PIN position
STR R3, [R1] // Store the value into LED_SET_ADDR
EOR R3, R3, 1 << LED_PIN // Flip the bit
STR R3, [R0] // Store the opposite bit into LED_CLEAR_ADDR
B Loop // Repeat
NOP

19
o1/sys-tick_constants.s Normal file
View File

@ -0,0 +1,19 @@
// SysTick Base-addresse
SYSTICK_BASE = 0xE000E010
// ---[ Offset til sys-tick-registrene ]------------------------ //
SYSTICK_CTRL = 0 // SysTick Control and Status Register
SYSTICK_LOAD = 4 // SysTick Reload Value Register
SYSTICK_VAL = 8 // SysTick Current Value Register
SYSTICK_CALIB = 12 // SysTick Calibration Register
// ------------------------------------------------------------- //
// ---[ Hjelpekonstanter til sys-tick ]------------------------- //
FREQUENCY = 14000000 // Antall klokkesignaler per sekund
// CTRL-register-masker
SysTick_CTRL_CLKSOURCE_Msk = 0b100
SysTick_CTRL_TICKINT_Msk = 0b010
SysTick_CTRL_ENABLE_Msk = 0b001
// ------------------------------------------------------------- //

214
o2/Makefile Normal file
View File

@ -0,0 +1,214 @@
####################################################################
# Makefile #
####################################################################
.SUFFIXES: # ignore builtin rules
.PHONY: all debug release clean flash rammeverk
####################################################################
# Definitions #
####################################################################
# notdirx: version of notdir which allows spaces in path
s? = $(subst $(empty) ,?,$1)
?s = $(subst ?, ,$1)
notdirx = $(call ?s,$(notdir $(call s?,$1)))
DEVICE = EFM32GG990F1024
PROJECTNAME = $(call notdirx,$(CURDIR))
OBJ_DIR = build
EXE_DIR = exe
LST_DIR = lst
####################################################################
# Definitions of toolchain. #
# You might need to do changes to match your system setup #
####################################################################
RM := rm -rf
NULLDEVICE := /dev/null
SHELLNAMES := $(ComSpec)$(COMSPEC)
# This is only valid for my specific system.
TOOLCHAIN_BIN_DIR := /opt/simplicitystudio5/developer/toolchains/gnu_arm/10.2_2020q4/bin
CC := $(TOOLCHAIN_BIN_DIR)/arm-none-eabi-gcc
LD := $(TOOLCHAIN_BIN_DIR)/arm-none-eabi-ld
AR := $(TOOLCHAIN_BIN_DIR)/arm-none-eabi-ar
OBJCOPY := $(TOOLCHAIN_BIN_DIR)/arm-none-eabi-objcopy
DUMP := $(TOOLCHAIN_BIN_DIR)/arm-none-eabi-objdump
# Detect operating system
ifeq ($(SHELLNAMES),) # Linux
EACOM = /opt/simplicitystudio5/developer/adapter_packs/commander/commander
else
EACOM = C:\SiliconLabs\SimplicityStudio\v3\bgtool\commander\commander.exe
ifneq ($(COMSPEC),) # mingw/msys/cygwin platform running on Windows
ifeq ($(findstring cygdrive,$(shell set)),)
# We were not on a cygwin platform
NULLDEVICE := NUL
endif
else # Windows
NULLDEVICE := NUL
endif
endif
# Create directories and do a clean which is compatible with parallell make
$(shell mkdir $(OBJ_DIR)>$(NULLDEVICE) 2>&1)
$(shell mkdir $(EXE_DIR)>$(NULLDEVICE) 2>&1)
$(shell mkdir $(LST_DIR)>$(NULLDEVICE) 2>&1)
ifeq (clean,$(findstring clean, $(MAKECMDGOALS)))
ifneq ($(filter $(MAKECMDGOALS),all debug release),)
$(shell $(RM) $(OBJ_DIR)/*>$(NULLDEVICE) 2>&1)
$(shell $(RM) $(EXE_DIR)/*>$(NULLDEVICE) 2>&1)
$(shell $(RM) $(LST_DIR)/*>$(NULLDEVICE) 2>&1) #*/
endif
endif
####################################################################
# Flags #
####################################################################
# -MMD : Don't generate dependencies on system header files.
# -MP : Add phony targets, useful when a h-file is removed from a project.
# -MF : Specify a file to write the dependencies to.
DEPFLAGS = -MMD -MP -MF $(@:.o=.d)
#
# Add -Wa,-ahld=$(LST_DIR)/$(@F:.o=.lst) to CFLAGS to produce assembly list files
#
override CFLAGS += -D$(DEVICE) -Wall -Wextra -mcpu=cortex-m3 -mthumb -ffunction-sections \
-fdata-sections -mfix-cortex-m3-ldrd -fomit-frame-pointer -DDEBUG_EFM \
-O0 \
$(DEPFLAGS)
ASMFLAGS += -x assembler-with-cpp -mcpu=cortex-m3 -mthumb
#
# NOTE: The -Wl,--gc-sections flag may interfere with debugging using gdb.
#
override LDFLAGS += -Xlinker -Map=$(LST_DIR)/$(PROJECTNAME).map -mcpu=cortex-m3 \
-mthumb -Tefm32gg.ld --specs=nano.specs \
-Wl,--gc-sections
LIBS = -Wl,--start-group -lgcc -lc -lnosys -Wl,--end-group
INCLUDEPATHS += \
-I.. \
-I../common/CMSIS/Include \
-I../common/EFM32GG/Include \
-I../common/emlib/inc \
-I../common/EFM32/drivers \
-I../common/EFM32/bsp \
-I../common/EFM32GG_STK3700/config
####################################################################
# Files #
####################################################################
C_SRC += \
../common/EFM32GG/Source/system_efm32gg.c \
../common/EFM32/drivers/vddcheck.c \
../common/EFM32/drivers/segmentlcd.c \
../common/emlib/src/em_assert.c \
../common/emlib/src/em_cmu.c \
../common/emlib/src/em_emu.c \
../common/emlib/src/em_gpio.c \
../common/emlib/src/em_rtc.c \
../common/emlib/src/em_system.c \
../common/emlib/src/em_lcd.c \
../common/emlib/src/em_vcmp.c \
../common/emlib/src/em_usart.c \
../common/EFM32/bsp/bsp_stk.c \
../common/EFM32/bsp/bsp_stk_leds.c \
../common/EFM32/bsp/bsp_trace.c \
../common/$(PROJECTNAME)/init.c
s_SRC += \
../common/EFM32GG/Source/GCC/startup_efm32gg.s
STUDENT_SRC += \
$(PROJECTNAME).s \
gpio_constants.s \
sys-tick_constants.s
####################################################################
# Rules #
####################################################################
C_FILES = $(notdir $(C_SRC) )
S_FILES = $(notdir $(S_SRC) $(s_SRC) )
#make list of source paths, sort also removes duplicates
C_PATHS = $(sort $(dir $(C_SRC) ) )
S_PATHS = $(sort $(dir $(S_SRC) $(s_SRC) ) )
C_OBJS = $(addprefix $(OBJ_DIR)/, $(C_FILES:.c=.o))
S_OBJS = $(if $(S_SRC), $(addprefix $(OBJ_DIR)/, $(S_FILES:.S=.o)))
s_OBJS = $(if $(s_SRC), $(addprefix $(OBJ_DIR)/, $(S_FILES:.s=.o)))
C_DEPS = $(addprefix $(OBJ_DIR)/, $(C_FILES:.c=.d))
OBJS = $(C_OBJS) $(S_OBJS) $(s_OBJS)
STUDENT_OBJS = $(addprefix $(OBJ_DIR)/, $(STUDENT_SRC:.s=.o))
vpath %.c $(C_PATHS)
vpath %.s $(S_PATHS)
vpath %.S $(S_PATHS)
# Default build is debug build
all: debug
debug: CFLAGS += -DDEBUG -O0 -g3
debug: $(EXE_DIR)/$(PROJECTNAME).bin
release: CFLAGS += -DNDEBUG -O3 -g3
release: $(EXE_DIR)/$(PROJECTNAME).bin
rammeverk: $(OBJS)
# Create objects from C SRC files
$(OBJ_DIR)/%.o: %.c
@echo "Building file: $<"
$(CC) $(CFLAGS) $(INCLUDEPATHS) -c -o $@ $<
# Assemble .s/.S files
$(OBJ_DIR)/%.o: %.s
@echo "Assembling $<"
$(CC) $(ASMFLAGS) $(INCLUDEPATHS) -c -o $@ $<
$(OBJ_DIR)/%.o: %.S
@echo "Assembling $<"
$(CC) $(ASMFLAGS) $(INCLUDEPATHS) -c -o $@ $<
# Link
$(EXE_DIR)/$(PROJECTNAME).out: $(STUDENT_OBJS)
@echo "Linking target: $@"
$(CC) $(LDFLAGS) $(OBJS) $(STUDENT_OBJS) $(LIBS) -o $(EXE_DIR)/$(PROJECTNAME).out
# Create binary file
$(EXE_DIR)/$(PROJECTNAME).bin: $(EXE_DIR)/$(PROJECTNAME).out
@echo "Creating binary file"
$(OBJCOPY) -O binary $(EXE_DIR)/$(PROJECTNAME).out $(EXE_DIR)/$(PROJECTNAME).bin
# Uncomment next line to produce assembly listing of entire program
# $(DUMP) -h -S -C $(EXE_DIR)/$(PROJECTNAME).out>$(LST_DIR)/$(PROJECTNAME)out.lst
# Flash on!
ifeq ($(f), 1)
$(EACOM) flash $(EXE_DIR)/$(PROJECTNAME).bin
endif
clean:
ifeq ($(filter $(MAKECMDGOALS),all debug release),)
$(RM) $(LST_DIR) $(EXE_DIR)
$(RM) $(STUDENT_OBJS)
endif
# include auto-generated dependency files (explicit rules)
ifneq (clean,$(findstring clean, $(MAKECMDGOALS)))
-include $(C_DEPS)
endif
flash:
$(EACOM) flash $(EXE_DIR)/$(PROJECTNAME).bin
@echo "Completed!"

214
o2/Makefile.original Normal file
View File

@ -0,0 +1,214 @@
####################################################################
# Makefile #
####################################################################
.SUFFIXES: # ignore builtin rules
.PHONY: all debug release clean flash rammeverk
####################################################################
# Definitions #
####################################################################
# notdirx: version of notdir which allows spaces in path
s? = $(subst $(empty) ,?,$1)
?s = $(subst ?, ,$1)
notdirx = $(call ?s,$(notdir $(call s?,$1)))
DEVICE = EFM32GG990F1024
PROJECTNAME = $(call notdirx,$(CURDIR))
OBJ_DIR = build
EXE_DIR = exe
LST_DIR = lst
####################################################################
# Definitions of toolchain. #
# You might need to do changes to match your system setup #
####################################################################
RM := rm -rf
NULLDEVICE := /dev/null
SHELLNAMES := $(ComSpec)$(COMSPEC)
CC := arm-none-eabi-gcc
LD := arm-none-eabi-ld
AR := arm-none-eabi-ar
OBJCOPY := arm-none-eabi-objcopy
DUMP := arm-none-eabi-objdump
# Detect operating system
ifeq ($(SHELLNAMES),) # Linux
EACOM = /opt/SimplicityStudio_v3/bgtool/commander/commander
else
EACOM = C:\SiliconLabs\SimplicityStudio\v3\bgtool\commander\commander.exe
ifneq ($(COMSPEC),) # mingw/msys/cygwin platform running on Windows
ifeq ($(findstring cygdrive,$(shell set)),)
# We were not on a cygwin platform
NULLDEVICE := NUL
endif
else # Windows
NULLDEVICE := NUL
endif
endif
# Create directories and do a clean which is compatible with parallell make
$(shell mkdir $(OBJ_DIR)>$(NULLDEVICE) 2>&1)
$(shell mkdir $(EXE_DIR)>$(NULLDEVICE) 2>&1)
$(shell mkdir $(LST_DIR)>$(NULLDEVICE) 2>&1)
ifeq (clean,$(findstring clean, $(MAKECMDGOALS)))
ifneq ($(filter $(MAKECMDGOALS),all debug release),)
$(shell $(RM) $(OBJ_DIR)/*>$(NULLDEVICE) 2>&1)
$(shell $(RM) $(EXE_DIR)/*>$(NULLDEVICE) 2>&1)
$(shell $(RM) $(LST_DIR)/*>$(NULLDEVICE) 2>&1) #*/
endif
endif
####################################################################
# Flags #
####################################################################
# -MMD : Don't generate dependencies on system header files.
# -MP : Add phony targets, useful when a h-file is removed from a project.
# -MF : Specify a file to write the dependencies to.
DEPFLAGS = -MMD -MP -MF $(@:.o=.d)
#
# Add -Wa,-ahld=$(LST_DIR)/$(@F:.o=.lst) to CFLAGS to produce assembly list files
#
override CFLAGS += -D$(DEVICE) -Wall -Wextra -mcpu=cortex-m3 -mthumb -ffunction-sections \
-fdata-sections -mfix-cortex-m3-ldrd -fomit-frame-pointer -DDEBUG_EFM \
-O0 \
$(DEPFLAGS)
ASMFLAGS += -x assembler-with-cpp -mcpu=cortex-m3 -mthumb
#
# NOTE: The -Wl,--gc-sections flag may interfere with debugging using gdb.
#
override LDFLAGS += -Xlinker -Map=$(LST_DIR)/$(PROJECTNAME).map -mcpu=cortex-m3 \
-mthumb -Tefm32gg.ld --specs=nano.specs \
-Wl,--gc-sections
LIBS = -Wl,--start-group -lgcc -lc -lnosys -Wl,--end-group
INCLUDEPATHS += \
-I.. \
-I../common/CMSIS/Include \
-I../common/EFM32GG/Include \
-I../common/emlib/inc \
-I../common/EFM32/drivers \
-I../common/EFM32/bsp \
-I../common/EFM32GG_STK3700/config
####################################################################
# Files #
####################################################################
C_SRC += \
../common/EFM32GG/Source/system_efm32gg.c \
../common/EFM32/drivers/vddcheck.c \
../common/EFM32/drivers/segmentlcd.c \
../common/emlib/src/em_assert.c \
../common/emlib/src/em_cmu.c \
../common/emlib/src/em_emu.c \
../common/emlib/src/em_gpio.c \
../common/emlib/src/em_rtc.c \
../common/emlib/src/em_system.c \
../common/emlib/src/em_lcd.c \
../common/emlib/src/em_vcmp.c \
../common/emlib/src/em_usart.c \
../common/EFM32/bsp/bsp_stk.c \
../common/EFM32/bsp/bsp_stk_leds.c \
../common/EFM32/bsp/bsp_trace.c \
../common/$(PROJECTNAME)/init.c
s_SRC += \
../common/EFM32GG/Source/GCC/startup_efm32gg.s
STUDENT_SRC += \
$(PROJECTNAME).s \
gpio_constants.s \
sys-tick_constants.s
####################################################################
# Rules #
####################################################################
C_FILES = $(notdir $(C_SRC) )
S_FILES = $(notdir $(S_SRC) $(s_SRC) )
#make list of source paths, sort also removes duplicates
C_PATHS = $(sort $(dir $(C_SRC) ) )
S_PATHS = $(sort $(dir $(S_SRC) $(s_SRC) ) )
C_OBJS = $(addprefix $(OBJ_DIR)/, $(C_FILES:.c=.o))
S_OBJS = $(if $(S_SRC), $(addprefix $(OBJ_DIR)/, $(S_FILES:.S=.o)))
s_OBJS = $(if $(s_SRC), $(addprefix $(OBJ_DIR)/, $(S_FILES:.s=.o)))
C_DEPS = $(addprefix $(OBJ_DIR)/, $(C_FILES:.c=.d))
OBJS = $(C_OBJS) $(S_OBJS) $(s_OBJS)
STUDENT_OBJS = $(addprefix $(OBJ_DIR)/, $(STUDENT_SRC:.s=.o))
vpath %.c $(C_PATHS)
vpath %.s $(S_PATHS)
vpath %.S $(S_PATHS)
# Default build is debug build
all: debug
debug: CFLAGS += -DDEBUG -O0 -g3
debug: $(EXE_DIR)/$(PROJECTNAME).bin
release: CFLAGS += -DNDEBUG -O3 -g3
release: $(EXE_DIR)/$(PROJECTNAME).bin
rammeverk: $(OBJS)
# Create objects from C SRC files
$(OBJ_DIR)/%.o: %.c
@echo "Building file: $<"
$(CC) $(CFLAGS) $(INCLUDEPATHS) -c -o $@ $<
# Assemble .s/.S files
$(OBJ_DIR)/%.o: %.s
@echo "Assembling $<"
$(CC) $(ASMFLAGS) $(INCLUDEPATHS) -c -o $@ $<
$(OBJ_DIR)/%.o: %.S
@echo "Assembling $<"
$(CC) $(ASMFLAGS) $(INCLUDEPATHS) -c -o $@ $<
# Link
$(EXE_DIR)/$(PROJECTNAME).out: $(STUDENT_OBJS)
@echo "Linking target: $@"
$(CC) $(LDFLAGS) $(OBJS) $(STUDENT_OBJS) $(LIBS) -o $(EXE_DIR)/$(PROJECTNAME).out
# Create binary file
$(EXE_DIR)/$(PROJECTNAME).bin: $(EXE_DIR)/$(PROJECTNAME).out
@echo "Creating binary file"
$(OBJCOPY) -O binary $(EXE_DIR)/$(PROJECTNAME).out $(EXE_DIR)/$(PROJECTNAME).bin
# Uncomment next line to produce assembly listing of entire program
# $(DUMP) -h -S -C $(EXE_DIR)/$(PROJECTNAME).out>$(LST_DIR)/$(PROJECTNAME)out.lst
# Flash on!
ifeq ($(f), 1)
$(EACOM) flash $(EXE_DIR)/$(PROJECTNAME).bin
endif
clean:
ifeq ($(filter $(MAKECMDGOALS),all debug release),)
$(RM) $(LST_DIR) $(EXE_DIR)
$(RM) $(STUDENT_OBJS)
endif
# include auto-generated dependency files (explicit rules)
ifneq (clean,$(findstring clean, $(MAKECMDGOALS)))
-include $(C_DEPS)
endif
flash:
$(EACOM) flash $(EXE_DIR)/$(PROJECTNAME).bin
@echo "Completed!"

207
o2/efm32gg.ld Normal file
View File

@ -0,0 +1,207 @@
/* Linker script for Silicon Labs EFM32GG devices */
/* */
/* This file is subject to the license terms as defined in ARM's */
/* CMSIS END USER LICENSE AGREEMENT.pdf, governing the use of */
/* Example Code. */
/* */
/* Copyright 2018 Silicon Laboratories, Inc. http://www.silabs.com */
/* */
/* Version 5.5.0 */
/* */
MEMORY
{
FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 1048576
RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 131072
}
/* Linker script to place sections and symbol values. Should be used together
* with other linker script that defines memory regions FLASH and RAM.
* It references following symbols, which must be defined in code:
* Reset_Handler : Entry of reset handler
*
* It defines following symbols, which code can use without definition:
* __exidx_start
* __exidx_end
* __copy_table_start__
* __copy_table_end__
* __zero_table_start__
* __zero_table_end__
* __etext
* __data_start__
* __preinit_array_start
* __preinit_array_end
* __init_array_start
* __init_array_end
* __fini_array_start
* __fini_array_end
* __data_end__
* __bss_start__
* __bss_end__
* __end__
* end
* __HeapLimit
* __StackLimit
* __StackTop
* __stack
* __Vectors_End
* __Vectors_Size
*/
ENTRY(Reset_Handler)
SECTIONS
{
.text :
{
KEEP(*(.vectors))
__Vectors_End = .;
__Vectors_Size = __Vectors_End - __Vectors;
__end__ = .;
*(.text*)
KEEP(*(.init))
KEEP(*(.fini))
/* .ctors */
*crtbegin.o(.ctors)
*crtbegin?.o(.ctors)
*(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors)
*(SORT(.ctors.*))
*(.ctors)
/* .dtors */
*crtbegin.o(.dtors)
*crtbegin?.o(.dtors)
*(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors)
*(SORT(.dtors.*))
*(.dtors)
*(.rodata*)
KEEP(*(.eh_frame*))
} > FLASH
.ARM.extab :
{
*(.ARM.extab* .gnu.linkonce.armextab.*)
} > FLASH
__exidx_start = .;
.ARM.exidx :
{
*(.ARM.exidx* .gnu.linkonce.armexidx.*)
} > FLASH
__exidx_end = .;
/* To copy multiple ROM to RAM sections,
* uncomment .copy.table section and,
* define __STARTUP_COPY_MULTIPLE in startup_ARMCMx.S */
/*
.copy.table :
{
. = ALIGN(4);
__copy_table_start__ = .;
LONG (__etext)
LONG (__data_start__)
LONG (__data_end__ - __data_start__)
LONG (__etext2)
LONG (__data2_start__)
LONG (__data2_end__ - __data2_start__)
__copy_table_end__ = .;
} > FLASH
*/
/* To clear multiple BSS sections,
* uncomment .zero.table section and,
* define __STARTUP_CLEAR_BSS_MULTIPLE in startup_ARMCMx.S */
/*
.zero.table :
{
. = ALIGN(4);
__zero_table_start__ = .;
LONG (__bss_start__)
LONG (__bss_end__ - __bss_start__)
LONG (__bss2_start__)
LONG (__bss2_end__ - __bss2_start__)
__zero_table_end__ = .;
} > FLASH
*/
__etext = .;
.data : AT (__etext)
{
__data_start__ = .;
*(vtable)
*(.data*)
. = ALIGN (4);
*(.ram)
. = ALIGN(4);
/* preinit data */
PROVIDE_HIDDEN (__preinit_array_start = .);
KEEP(*(.preinit_array))
PROVIDE_HIDDEN (__preinit_array_end = .);
. = ALIGN(4);
/* init data */
PROVIDE_HIDDEN (__init_array_start = .);
KEEP(*(SORT(.init_array.*)))
KEEP(*(.init_array))
PROVIDE_HIDDEN (__init_array_end = .);
. = ALIGN(4);
/* finit data */
PROVIDE_HIDDEN (__fini_array_start = .);
KEEP(*(SORT(.fini_array.*)))
KEEP(*(.fini_array))
PROVIDE_HIDDEN (__fini_array_end = .);
KEEP(*(.jcr*))
. = ALIGN(4);
/* All data end */
__data_end__ = .;
} > RAM
.bss :
{
. = ALIGN(4);
__bss_start__ = .;
*(.bss*)
*(COMMON)
. = ALIGN(4);
__bss_end__ = .;
} > RAM
.heap (COPY):
{
__HeapBase = .;
__end__ = .;
end = __end__;
_end = __end__;
KEEP(*(.heap*))
__HeapLimit = .;
} > RAM
/* .stack_dummy section doesn't contains any symbols. It is only
* used for linker to calculate size of stack sections, and assign
* values to stack symbols later */
.stack_dummy (COPY):
{
KEEP(*(.stack*))
} > RAM
/* Set stack top to end of RAM, and stack limit move down by
* size of stack_dummy section */
__StackTop = ORIGIN(RAM) + LENGTH(RAM);
__StackLimit = __StackTop - SIZEOF(.stack_dummy);
PROVIDE(__stack = __StackTop);
/* Check if data + heap + stack exceeds RAM limit */
ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack")
/* Check if FLASH usage exceeds FLASH size */
ASSERT( LENGTH(FLASH) >= (__etext + SIZEOF(.data)), "FLASH memory overflowed !")
}

53
o2/gpio_constants.s Normal file
View File

@ -0,0 +1,53 @@
// GPIO base-adresse
GPIO_BASE = 0x40006000
// --- [Offset til GPIO-registrene]----------------------------------------- //
// --- [Offset til portregistrene ] ------------------------------- /<