Compare commits
37 Commits
b036e646b9
...
master
Author | SHA1 | Date | |
---|---|---|---|
|
f3c357db5e | ||
|
c8941003bb | ||
|
5f6e468c8e | ||
|
df0e302bf8 | ||
|
85e960e612 | ||
|
e3f57f80df | ||
|
eecbba48d2 | ||
|
17d4ee8ff9 | ||
|
a2852bd823 | ||
|
b0193ca45e | ||
|
9eaa749d68 | ||
|
3f379122db | ||
|
a1c89c96d5 | ||
|
76af8665b2 | ||
|
6e7b955d71 | ||
|
b93152db8f | ||
|
209c09cbf4 | ||
|
59ab17487f | ||
|
2e01aa6877 | ||
|
3093a80f2a | ||
|
f975a37bf3 | ||
|
53aa3ceda6 | ||
|
7f1721a536 | ||
|
44d7f39026 | ||
|
6bb235b676 | ||
|
67a28afd24 | ||
|
7a5a5930aa | ||
|
07301042f9 | ||
|
437ba90bc2 | ||
|
3729c0e2c0 | ||
|
f8166ed990 | ||
|
a8c8ffc10a | ||
|
7a3079bbea | ||
|
a2d2213d9a | ||
|
1ef95ea51c | ||
|
58faaecbe9 | ||
|
3a31e2bcb9 |
5
.vscode/settings.json
vendored
5
.vscode/settings.json
vendored
@@ -11,6 +11,9 @@
|
|||||||
"nrf52.h": "c",
|
"nrf52.h": "c",
|
||||||
"system_nrf52.h": "c",
|
"system_nrf52.h": "c",
|
||||||
"system_nrf.h": "c",
|
"system_nrf.h": "c",
|
||||||
"driver.h": "c"
|
"driver.h": "c",
|
||||||
|
"deque": "cpp",
|
||||||
|
"string": "cpp",
|
||||||
|
"vector": "cpp"
|
||||||
}
|
}
|
||||||
}
|
}
|
40
.vscode/tasks.json
vendored
40
.vscode/tasks.json
vendored
@@ -1,15 +1,18 @@
|
|||||||
{
|
{
|
||||||
// See https://go.microsoft.com/fwlink/?LinkId=733558
|
|
||||||
// for the documentation about the tasks.json format
|
|
||||||
"version": "2.0.0",
|
"version": "2.0.0",
|
||||||
"options": {
|
"options": {
|
||||||
"env": {
|
"env": {
|
||||||
"PLATFORM": "nrf52",
|
// "APPLICATION": "button",
|
||||||
// "PLATFORM": "posix",
|
// "APPLICATION": "spi",
|
||||||
// "APPLICATION": "blinky",
|
"APPLICATION": "st7789_lcd",
|
||||||
"APPLICATION": "button",
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
"presentation": {
|
||||||
|
"focus": true,
|
||||||
|
"reveal": "always",
|
||||||
|
"panel": "shared",
|
||||||
|
"clear": true,
|
||||||
|
},
|
||||||
"tasks": [
|
"tasks": [
|
||||||
{
|
{
|
||||||
"label": "all",
|
"label": "all",
|
||||||
@@ -78,12 +81,23 @@
|
|||||||
"kind": "build",
|
"kind": "build",
|
||||||
"isDefault": true
|
"isDefault": true
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
],
|
{
|
||||||
"presentation": {
|
"label": "check",
|
||||||
"focus": true,
|
"type":"shell",
|
||||||
"reveal": "always",
|
"command": "make check",
|
||||||
"panel": "shared",
|
"problemMatcher": {
|
||||||
"clear": true,
|
"base": "$gcc",
|
||||||
|
"owner": "gcc",
|
||||||
|
"fileLocation": [
|
||||||
|
"relative",
|
||||||
|
"${workspaceFolder}"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"group": {
|
||||||
|
"kind": "build",
|
||||||
|
"isDefault": true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
78
Makefile
78
Makefile
@@ -1,13 +1,22 @@
|
|||||||
.DEFAULT_GOAL := all
|
.DEFAULT_GOAL := all
|
||||||
|
|
||||||
APPLICATION ?= button
|
APPLICATION ?= blinky
|
||||||
|
|
||||||
|
PLATFORM ?= nrf52
|
||||||
|
|
||||||
|
ifneq "$(findstring $(PLATFORM), nrf52)" ""
|
||||||
|
CORE = cm4
|
||||||
|
endif
|
||||||
|
|
||||||
PLATFORM ?= posix
|
|
||||||
TARGET_FILE ?= $(APPLICATION).elf
|
TARGET_FILE ?= $(APPLICATION).elf
|
||||||
|
|
||||||
CC = $(CROSS_COMPILE)gcc
|
CC = $(CROSS_COMPILE)gcc
|
||||||
CPP = $(CROSS_COMPILE)cpp
|
CPP = $(CROSS_COMPILE)cpp
|
||||||
|
CXX = $(CROSS_COMPILE)g++
|
||||||
OBJCOPY = $(CROSS_COMPILE)objcopy
|
OBJCOPY = $(CROSS_COMPILE)objcopy
|
||||||
|
OBJDUMP = $(CROSS_COMPILE)objdump
|
||||||
|
SIZE = $(CROSS_COMPILE)size
|
||||||
|
CHECK = cppcheck
|
||||||
|
|
||||||
SRC_DIR = src
|
SRC_DIR = src
|
||||||
OBJ_DIR = obj/$(PLATFORM)
|
OBJ_DIR = obj/$(PLATFORM)
|
||||||
@@ -18,30 +27,48 @@ CPP_FLAGS += $(addprefix -I, $(INCLUDES))
|
|||||||
C_SRCS = $(wildcard $(SRC_DIR)/*.c)
|
C_SRCS = $(wildcard $(SRC_DIR)/*.c)
|
||||||
C_SRCS += $(wildcard $(SRC_DIR)/platform/$(PLATFORM)/*.c)
|
C_SRCS += $(wildcard $(SRC_DIR)/platform/$(PLATFORM)/*.c)
|
||||||
C_SRCS += $(wildcard $(SRC_DIR)/application/$(APPLICATION)/*.c)
|
C_SRCS += $(wildcard $(SRC_DIR)/application/$(APPLICATION)/*.c)
|
||||||
C_OBJS = $(patsubst $(SRC_DIR)%,$(OBJ_DIR)%,$(patsubst %.c,%.o,$(C_SRCS)))
|
C_OBJS = $(patsubst $(SRC_DIR)%,$(OBJ_DIR)%,$(patsubst %.c,%.c.o,$(C_SRCS)))
|
||||||
OBJS = $(NRF_A_OBJS) $(NRF_C_OBJS) $(C_OBJS)
|
|
||||||
|
CC_SRCS = $(wildcard $(SRC_DIR)/*.cc)
|
||||||
|
CC_SRCS += $(wildcard $(SRC_DIR)/platform/$(CORE)/*.cc)
|
||||||
|
CC_SRCS += $(wildcard $(SRC_DIR)/platform/$(PLATFORM)/*.cc)
|
||||||
|
CC_SRCS += $(wildcard $(SRC_DIR)/application/$(APPLICATION)/*.cc)
|
||||||
|
CC_SRCS += $(wildcard $(SRC_DIR)/virtual_timer/*.cc)
|
||||||
|
CC_OBJS = $(patsubst $(SRC_DIR)%,$(OBJ_DIR)%,$(patsubst %.cc,%.cc.o,$(CC_SRCS)))
|
||||||
|
|
||||||
|
OBJS = $(A_OBJS) $(C_OBJS) $(CC_OBJS)
|
||||||
|
|
||||||
TARGET = $(BIN_DIR)/$(TARGET_FILE)
|
TARGET = $(BIN_DIR)/$(TARGET_FILE)
|
||||||
TARGET_HEX = $(patsubst %.elf,%.hex,$(TARGET))
|
TARGET_HEX = $(patsubst %.elf,%.hex,$(TARGET))
|
||||||
TARGET_PACKAGE = $(patsubst %.hex,%.zip,$(TARGET_HEX))
|
TARGET_PACKAGE = $(patsubst %.hex,%.zip,$(TARGET_HEX))
|
||||||
THIS_MAKEFILE := $(lastword $(MAKEFILE_LIST))
|
THIS_MAKEFILE := $(lastword $(MAKEFILE_LIST))
|
||||||
|
|
||||||
|
INCLUDES += src/
|
||||||
|
INCLUDES += interfaces/
|
||||||
INCLUDES += include/
|
INCLUDES += include/
|
||||||
|
INCLUDES += include/platform/$(PLATFORM)
|
||||||
|
|
||||||
OPT = 3
|
OPT = 3
|
||||||
C_FLAGS += -O$(OPT) -g$(OPT)
|
C_FLAGS += -O$(OPT) -g$(OPT)
|
||||||
C_FLAGS += -Wall -Werror
|
C_FLAGS += -Wall -Werror
|
||||||
C_FLAGS += -ffunction-sections -fdata-sections -fno-strict-aliasing
|
C_FLAGS += -ffunction-sections -fdata-sections -fno-strict-aliasing
|
||||||
|
C_FLAGS += -DPLATFORM_$(PLATFORM)
|
||||||
|
|
||||||
LIBS += c nosys m
|
CXX_FLAGS += -O$(OPT) -g$(OPT)
|
||||||
|
CXX_FLAGS += -Wall -Werror
|
||||||
|
CXX_FLAGS += -ffunction-sections -fdata-sections -fno-strict-aliasing
|
||||||
|
CXX_FLAGS += -DPLATFORM_$(PLATFORM)
|
||||||
|
|
||||||
include Makefile.$(PLATFORM)
|
CHECK_FLAGS = $(addprefix -I,$(INCLUDES))
|
||||||
|
CHECK_FLAGS += --enable=all --template=gcc --error-exitcode=1 --suppress=missingIncludeSystem --inline-suppr --force --language=c++
|
||||||
|
|
||||||
.PHONY: all install uninstall clean distclean debug
|
include build_system/platform/$(PLATFORM)/Makefile
|
||||||
|
|
||||||
|
.PHONY: all install uninstall clean distclean debug check
|
||||||
all: $(TARGET)
|
all: $(TARGET)
|
||||||
|
|
||||||
debug:
|
debug:
|
||||||
@echo $(TARGET_HEX)
|
@echo $(CC_OBJS)
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f $(TARGET) $(TARGET_HEX) $(TARGET_PACKAGE)
|
rm -f $(TARGET) $(TARGET_HEX) $(TARGET_PACKAGE)
|
||||||
@@ -50,23 +77,48 @@ clean:
|
|||||||
distclean:
|
distclean:
|
||||||
rm -rf bin obj
|
rm -rf bin obj
|
||||||
|
|
||||||
|
.PHONY:
|
||||||
|
check: $(C_SRCS)
|
||||||
|
$(CHECK) $(CHECK_FLAGS) $(CC_SRCS)
|
||||||
|
|
||||||
$(TARGET): $(OBJS) $(THIS_MAKEFILE)
|
$(TARGET): $(OBJS) $(THIS_MAKEFILE)
|
||||||
@mkdir -p $(dir $@)
|
@mkdir -p $(dir $@)
|
||||||
$(CC) $(CC_FLAGS) $(LD_FLAGS) $(OBJS) $(addprefix -l,$(LIBS)) -o $@
|
$(CXX) $(CXX_FLAGS) $(LD_FLAGS) $(OBJS) $(addprefix -l,$(LIBS)) -Wl,-Map=$@.map -o $@
|
||||||
|
# $(OBJDUMP) --disassemble-all --section=.text --source -EL -C --wide --line-numbers --inlines $@ > $@.text.disassemble
|
||||||
ln -sf $(shell pwd)/$@ $(shell pwd)/bin/firmware.elf
|
ln -sf $(shell pwd)/$@ $(shell pwd)/bin/firmware.elf
|
||||||
|
$(SIZE) -x $@ > $@.size
|
||||||
|
@cat $@.size
|
||||||
|
|
||||||
$(TARGET_HEX): $(TARGET) $(THIS_MAKEFILE)
|
$(TARGET_HEX): $(TARGET) $(THIS_MAKEFILE)
|
||||||
$(OBJCOPY) -O ihex $(TARGET) $(TARGET_HEX)
|
$(OBJCOPY) -O ihex $(TARGET) $(TARGET_HEX)
|
||||||
ln -sf $(shell pwd)/$@ $(shell pwd)/bin/firmware.hex
|
ln -sf $(shell pwd)/$@ $(shell pwd)/bin/firmware.hex
|
||||||
|
|
||||||
$(OBJ_DIR)/%.d: $(SRC_DIR)/%.c
|
$(OBJ_DIR)/%.d: $(SRC_DIR)/%.S $(THIS_MAKEFILE)
|
||||||
@mkdir -p $(dir $@)
|
@mkdir -p $(dir $@)
|
||||||
$(CPP) -MM -MF $@ -MP -MT $(patsubst %.d,%.o,$@) $(C_FLAGS) $(CPP_FLAGS) $(patsubst $(OBJ_DIR)/%.d,$(SRC_DIR)/%.c,$@)
|
$(CPP) -MM -MF $@ -MP -MT $(patsubst %.d,%.o,$@) $(C_FLAGS) $(CPP_FLAGS) $(patsubst $(OBJ_DIR)/%.d,$(SRC_DIR)/%.S,$@)
|
||||||
|
|
||||||
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.c
|
$(OBJ_DIR)/%.c.d: $(SRC_DIR)/%.c $(THIS_MAKEFILE)
|
||||||
|
mkdir -p $(dir $@)
|
||||||
|
$(CPP) -MM -MF $@ -MP -MT $(patsubst %.c.d,%.c.o,$@) $(C_FLAGS) $(CPP_FLAGS) $(patsubst $(OBJ_DIR)/%.c.d,$(SRC_DIR)/%.c,$@)
|
||||||
|
|
||||||
|
$(OBJ_DIR)/%.cc.d: $(SRC_DIR)/%.cc $(THIS_MAKEFILE)
|
||||||
|
@mkdir -p $(dir $@)
|
||||||
|
$(CPP) -MM -MF $@ -MP -MT $(patsubst %.cc.d,%.cc.o,$@) $(CXX_FLAGS) $(CPP_FLAGS) $(patsubst $(OBJ_DIR)/%.cc.d,$(SRC_DIR)/%.cc,$@)
|
||||||
|
|
||||||
|
$(OBJ_DIR)/%.cc.o: $(SRC_DIR)/%.cc $(THIS_MAKEFILE)
|
||||||
|
@mkdir -p $(dir $@)
|
||||||
|
$(CXX) -c $(CPP_FLAGS) $(CXX_FLAGS) $< -o $@
|
||||||
|
|
||||||
|
$(OBJ_DIR)/%.c.o: $(SRC_DIR)/%.c $(THIS_MAKEFILE)
|
||||||
@mkdir -p $(dir $@)
|
@mkdir -p $(dir $@)
|
||||||
$(CC) -c $(CPP_FLAGS) $(C_FLAGS) $< -o $@
|
$(CC) -c $(CPP_FLAGS) $(C_FLAGS) $< -o $@
|
||||||
|
|
||||||
|
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.S $(THIS_MAKEFILE)
|
||||||
|
@mkdir -p $(dir $@)
|
||||||
|
$(CC) -c $(ASMFLAGS) $< -o $@
|
||||||
|
|
||||||
ifeq "$(findstring $(MAKECMDGOALS), clean distclean)" ""
|
ifeq "$(findstring $(MAKECMDGOALS), clean distclean)" ""
|
||||||
-include $(patsubst %.o,%.d,$(OBJS))
|
include $(patsubst %.o,%.d,$(A_OBJS))
|
||||||
|
include $(patsubst %.c.o,%.c.d,$(C_OBJS))
|
||||||
|
include $(patsubst %.cc.o,%.cc.d,$(CC_OBJS))
|
||||||
endif
|
endif
|
||||||
|
108
Makefile.nrf52
108
Makefile.nrf52
@@ -1,108 +0,0 @@
|
|||||||
CPU = cortex-m4
|
|
||||||
CROSS_COMPILE ?= arm-none-eabi-
|
|
||||||
|
|
||||||
NRF_PATH := nrf5sdk/
|
|
||||||
INCLUDES += $(NRF_PATH)components/
|
|
||||||
INCLUDES += $(NRF_PATH)modules/nrfx/mdk/
|
|
||||||
INCLUDES += $(NRF_PATH)components/libraries/strerror/
|
|
||||||
INCLUDES += $(NRF_PATH)components/softdevice/s132/headers/nrf52/
|
|
||||||
INCLUDES += $(NRF_PATH)components/toolchain/cmsis/include/
|
|
||||||
INCLUDES += $(NRF_PATH)components/libraries/util/
|
|
||||||
INCLUDES += $(NRF_PATH)components/libraries/balloc/
|
|
||||||
INCLUDES += $(NRF_PATH)components/libraries/ringbuf/
|
|
||||||
INCLUDES += $(NRF_PATH)modules/nrfx/hal/
|
|
||||||
INCLUDES += $(NRF_PATH)components/libraries/bsp/
|
|
||||||
INCLUDES += $(NRF_PATH)components/libraries/log/
|
|
||||||
INCLUDES += $(NRF_PATH)modules/nrfx/
|
|
||||||
INCLUDES += $(NRF_PATH)components/libraries/experimental_section_vars/
|
|
||||||
INCLUDES += $(NRF_PATH)components/softdevice/s132/headers/
|
|
||||||
INCLUDES += $(NRF_PATH)components/libraries/delay/
|
|
||||||
INCLUDES += $(NRF_PATH)integration/nrfx/
|
|
||||||
INCLUDES += $(NRF_PATH)components/libraries/atomic/
|
|
||||||
INCLUDES += $(NRF_PATH)components/boards/
|
|
||||||
INCLUDES += $(NRF_PATH)components/libraries/memobj/
|
|
||||||
INCLUDES += $(NRF_PATH)components/softdevice/common/
|
|
||||||
INCLUDES += $(NRF_PATH)external/fprintf/
|
|
||||||
INCLUDES += $(NRF_PATH)components/libraries/log/src/
|
|
||||||
|
|
||||||
NRF_C_SRCS += $(NRF_PATH)components/boards/boards.c
|
|
||||||
NRF_C_SRCS += $(NRF_PATH)modules/nrfx/mdk/system_nrf52.c
|
|
||||||
NRF_C_OBJS = $(patsubst $(NRF_PATH)%,$(OBJ_DIR)/%,$(patsubst %.c,%.o,$(NRF_C_SRCS)))
|
|
||||||
|
|
||||||
NRF_A_SRCS = $(NRF_PATH)modules/nrfx/mdk/gcc_startup_nrf52.S
|
|
||||||
NRF_A_OBJS = $(patsubst $(NRF_PATH)%,$(OBJ_DIR)/%,$(patsubst %.S,%.o,$(NRF_A_SRCS)))
|
|
||||||
|
|
||||||
C_FLAGS += -DBOARD_PCA10040
|
|
||||||
C_FLAGS += -DBSP_DEFINES_ONLY
|
|
||||||
C_FLAGS += -DCONFIG_GPIO_AS_PINRESET
|
|
||||||
C_FLAGS += -DFLOAT_ABI_HARD
|
|
||||||
C_FLAGS += -DNRF52
|
|
||||||
C_FLAGS += -DNRF52832_XXAA
|
|
||||||
C_FLAGS += -DNRF52_PAN_74
|
|
||||||
C_FLAGS += -DNRF_SD_BLE_API_VERSION=7
|
|
||||||
C_FLAGS += -DS132
|
|
||||||
C_FLAGS += -DSOFTDEVICE_PRESENT
|
|
||||||
C_FLAGS += -mcpu=$(CPU)
|
|
||||||
C_FLAGS += -mthumb -mabi=aapcs
|
|
||||||
C_FLAGS += -mfloat-abi=hard -mfpu=fpv4-sp-d16
|
|
||||||
C_FLAGS += -fno-builtin -fshort-enums
|
|
||||||
C_FLAGS += -D__HEAP_SIZE=8192
|
|
||||||
C_FLAGS += -D__HEAP_SIZE=8192
|
|
||||||
|
|
||||||
# Assembler flags common to all targets
|
|
||||||
A_FLAGS += -g$(OPT)
|
|
||||||
A_FLAGS += -mcpu=$(CPU)
|
|
||||||
A_FLAGS += -mthumb -mabi=aapcs
|
|
||||||
A_FLAGS += -mfloat-abi=hard -mfpu=fpv4-sp-d16
|
|
||||||
A_FLAGS += -DBOARD_PCA10040
|
|
||||||
A_FLAGS += -DBSP_DEFINES_ONLY
|
|
||||||
A_FLAGS += -DCONFIG_GPIO_AS_PINRESET
|
|
||||||
A_FLAGS += -DFLOAT_ABI_HARD
|
|
||||||
A_FLAGS += -DNRF52
|
|
||||||
A_FLAGS += -DNRF52832_XXAA
|
|
||||||
A_FLAGS += -DNRF52_PAN_74
|
|
||||||
A_FLAGS += -DNRF_SD_BLE_API_VERSION=7
|
|
||||||
A_FLAGS += -DS132
|
|
||||||
A_FLAGS += -DSOFTDEVICE_PRESENT
|
|
||||||
A_FLAGS += -D__HEAP_SIZE=8192
|
|
||||||
A_FLAGS += -D__HEAP_SIZE=8192
|
|
||||||
|
|
||||||
LINKER_SCRIPT = blinky_gcc_nrf52.ld
|
|
||||||
# Linker flags
|
|
||||||
LD_FLAGS += -O$(OPT) -g$(OPT)
|
|
||||||
LD_FLAGS += -mthumb -mabi=aapcs -L$(NRF_PATH)modules/nrfx/mdk -T$(LINKER_SCRIPT)
|
|
||||||
LD_FLAGS += -mcpu=$(CPU)
|
|
||||||
LD_FLAGS += -mfloat-abi=hard -mfpu=fpv4-sp-d16
|
|
||||||
LD_FLAGS += -Wl,--gc-sections
|
|
||||||
LD_FLAGS += --specs=nano.specs
|
|
||||||
|
|
||||||
.PHONY: package flash flash_softdevice erase
|
|
||||||
|
|
||||||
package: $(TARGET_HEX) $(THIS_MAKEFILE)
|
|
||||||
nrfutil pkg generate --hw-version 52 --application-version 1 --application $(TARGET_HEX) --sd-req 0xCB --sd-id 0xCB --key-file keys/private.key $(TARGET_PACKAGE)
|
|
||||||
|
|
||||||
flash: $(TARGET_HEX) $(THIS_MAKEFILE)
|
|
||||||
@echo Flashing: $(TARGET_HEX)
|
|
||||||
nrfjprog -f nrf52 --program $(TARGET_HEX) --sectorerase
|
|
||||||
nrfjprog -f nrf52 --reset
|
|
||||||
|
|
||||||
flash_softdevice:
|
|
||||||
@echo Flashing: $(NRF_PATH)/components/softdevice/s132/hex/s132_nrf52_7.0.1_softdevice.hex
|
|
||||||
nrfjprog -f nrf52 --program $(NRF_PATH)/components/softdevice/s132/hex/s132_nrf52_7.0.1_softdevice.hex --sectorerase
|
|
||||||
nrfjprog -f nrf52 --reset
|
|
||||||
|
|
||||||
erase:
|
|
||||||
nrfjprog -f nrf52 --eraseall
|
|
||||||
|
|
||||||
$(OBJ_DIR)/%.d: $(NRF_PATH)/%.S
|
|
||||||
@mkdir -p $(dir $@)
|
|
||||||
$(CPP) -MM -MF $@ -MP -MT $(patsubst %.d,%.o,$@) $(C_FLAGS) $(CPP_FLAGS) $(patsubst $(OBJ_DIR)/%.d,$(NRF_PATH)/%.S,$@)
|
|
||||||
|
|
||||||
$(OBJ_DIR)/%.o: $(NRF_PATH)/%.c
|
|
||||||
@mkdir -p $(dir $@)
|
|
||||||
$(CC) -std=c99 -MP -MD -c -o $@ $< $(C_FLAGS) $(CPP_FLAGS)
|
|
||||||
|
|
||||||
$(OBJ_DIR)/%.o: $(NRF_PATH)/%.S
|
|
||||||
@mkdir -p $(dir $@)
|
|
||||||
$(CC) -c $(ASMFLAGS) $< -o $@
|
|
||||||
|
|
95
build_system/platform/nrf52/Makefile
Normal file
95
build_system/platform/nrf52/Makefile
Normal file
@@ -0,0 +1,95 @@
|
|||||||
|
CPU = cortex-m4
|
||||||
|
CROSS_COMPILE ?= arm-none-eabi-
|
||||||
|
|
||||||
|
NRF_PATH := nrf5sdk/
|
||||||
|
|
||||||
|
INCLUDES += src/platform/nrf52/sdk
|
||||||
|
INCLUDES += src/platform/cm4/cmsis/include
|
||||||
|
|
||||||
|
NRF_C_SRCS += src/platform/nrf52/sdk/system_nrf52.c
|
||||||
|
C_OBJS += $(patsubst $(SRC_DIR)%,$(OBJ_DIR)%,$(patsubst %.c,%.c.o,$(NRF_C_SRCS)))
|
||||||
|
|
||||||
|
NRF_A_SRCS = src/platform/nrf52/sdk/gcc_startup_nrf52.S
|
||||||
|
A_OBJS += $(patsubst $(SRC_DIR)%,$(OBJ_DIR)/%,$(patsubst %.S,%.o,$(NRF_A_SRCS)))
|
||||||
|
|
||||||
|
C_FLAGS += -DBOARD_PCA10040
|
||||||
|
C_FLAGS += -DBSP_DEFINES_ONLY
|
||||||
|
C_FLAGS += -DCONFIG_GPIO_AS_PINRESET
|
||||||
|
C_FLAGS += -DFLOAT_ABI_HARD
|
||||||
|
C_FLAGS += -DNRF52
|
||||||
|
C_FLAGS += -DNRF52832_XXAA
|
||||||
|
C_FLAGS += -DNRF52_PAN_74
|
||||||
|
# C_FLAGS += -DNRF_SD_BLE_API_VERSION=7
|
||||||
|
# C_FLAGS += -DS132
|
||||||
|
# C_FLAGS += -DSOFTDEVICE_PRESENT
|
||||||
|
C_FLAGS += -mcpu=$(CPU)
|
||||||
|
C_FLAGS += -mthumb -mabi=aapcs
|
||||||
|
C_FLAGS += -mfloat-abi=hard -mfpu=fpv4-sp-d16
|
||||||
|
C_FLAGS += -fno-builtin -fshort-enums
|
||||||
|
C_FLAGS += -D__HEAP_SIZE=8192
|
||||||
|
C_FLAGS += -D__HEAP_SIZE=8192
|
||||||
|
|
||||||
|
CXX_FLAGS += -DBOARD_PCA10040
|
||||||
|
CXX_FLAGS += -DBSP_DEFINES_ONLY
|
||||||
|
CXX_FLAGS += -DCONFIG_GPIO_AS_PINRESET
|
||||||
|
CXX_FLAGS += -DFLOAT_ABI_HARD
|
||||||
|
CXX_FLAGS += -DNRF52
|
||||||
|
CXX_FLAGS += -DNRF52832_XXAA
|
||||||
|
CXX_FLAGS += -DNRF52_PAN_74
|
||||||
|
# CXX_FLAGS += -DNRF_SD_BLE_API_VERSION=7
|
||||||
|
# CXX_FLAGS += -DS132
|
||||||
|
# CXX_FLAGS += -DSOFTDEVICE_PRESENT
|
||||||
|
CXX_FLAGS += -mcpu=$(CPU)
|
||||||
|
CXX_FLAGS += -mthumb -mabi=aapcs
|
||||||
|
CXX_FLAGS += -mfloat-abi=hard -mfpu=fpv4-sp-d16
|
||||||
|
CXX_FLAGS += -fno-builtin -fshort-enums
|
||||||
|
CXX_FLAGS += -D__HEAP_SIZE=8192
|
||||||
|
CXX_FLAGS += -D__HEAP_SIZE=8192
|
||||||
|
|
||||||
|
# Assembler flags common to all targets
|
||||||
|
A_FLAGS += -g$(OPT)
|
||||||
|
A_FLAGS += -mcpu=$(CPU)
|
||||||
|
A_FLAGS += -mthumb -mabi=aapcs
|
||||||
|
A_FLAGS += -mfloat-abi=hard -mfpu=fpv4-sp-d16
|
||||||
|
A_FLAGS += -DBOARD_PCA10040
|
||||||
|
A_FLAGS += -DBSP_DEFINES_ONLY
|
||||||
|
A_FLAGS += -DCONFIG_GPIO_AS_PINRESET
|
||||||
|
A_FLAGS += -DFLOAT_ABI_HARD
|
||||||
|
A_FLAGS += -DNRF52
|
||||||
|
A_FLAGS += -DNRF52832_XXAA
|
||||||
|
A_FLAGS += -DNRF52_PAN_74
|
||||||
|
# A_FLAGS += -DNRF_SD_BLE_API_VERSION=7
|
||||||
|
# A_FLAGS += -DS132
|
||||||
|
# A_FLAGS += -DSOFTDEVICE_PRESENT
|
||||||
|
A_FLAGS += -D__HEAP_SIZE=8192
|
||||||
|
A_FLAGS += -D__HEAP_SIZE=8192
|
||||||
|
|
||||||
|
LINKER_SCRIPT = without_sd.ld
|
||||||
|
|
||||||
|
# Linker flags
|
||||||
|
LD_FLAGS += -O$(OPT) -g$(OPT)
|
||||||
|
LD_FLAGS += -mthumb -mabi=aapcs -Lbuild_system/platform/$(PLATFORM) -T$(LINKER_SCRIPT)
|
||||||
|
LD_FLAGS += -mcpu=$(CPU)
|
||||||
|
LD_FLAGS += -mfloat-abi=hard -mfpu=fpv4-sp-d16
|
||||||
|
LD_FLAGS += -Wl,--gc-sections
|
||||||
|
LD_FLAGS += --specs=nano.specs
|
||||||
|
|
||||||
|
LIBS += c nosys m
|
||||||
|
|
||||||
|
.PHONY: package flash flash_softdevice erase
|
||||||
|
|
||||||
|
package: $(TARGET_HEX)
|
||||||
|
nrfutil pkg generate --hw-version 52 --application-version 1 --application $(TARGET_HEX) --sd-req 0xCB --sd-id 0xCB --key-file keys/private.key $(TARGET_PACKAGE)
|
||||||
|
|
||||||
|
flash: $(TARGET_HEX)
|
||||||
|
@echo Flashing: $(TARGET_HEX)
|
||||||
|
nrfjprog -f nrf52 --program $(TARGET_HEX) --sectorerase
|
||||||
|
nrfjprog -f nrf52 --reset
|
||||||
|
|
||||||
|
flash_softdevice: $(THIS_MAKEFILE)
|
||||||
|
@echo Flashing: $(NRF_PATH)/components/softdevice/s132/hex/s132_nrf52_7.0.1_softdevice.hex
|
||||||
|
nrfjprog -f nrf52 --program $(NRF_PATH)/components/softdevice/s132/hex/s132_nrf52_7.0.1_softdevice.hex --sectorerase
|
||||||
|
nrfjprog -f nrf52 --reset
|
||||||
|
|
||||||
|
erase:
|
||||||
|
nrfjprog -f nrf52 --eraseall
|
168
build_system/platform/nrf52/nrf_common.ld
Normal file
168
build_system/platform/nrf52/nrf_common.ld
Normal file
@@ -0,0 +1,168 @@
|
|||||||
|
/* Linker script for Nordic Semiconductor nRF devices
|
||||||
|
*
|
||||||
|
* Version: Sourcery G++ 4.5-1
|
||||||
|
* Support: https://support.codesourcery.com/GNUToolchain/
|
||||||
|
*
|
||||||
|
* Copyright (c) 2007, 2008, 2009, 2010 CodeSourcery, Inc.
|
||||||
|
*
|
||||||
|
* The authors hereby grant permission to use, copy, modify, distribute,
|
||||||
|
* and license this software and its documentation for any purpose, provided
|
||||||
|
* that existing copyright notices are retained in all copies and that this
|
||||||
|
* notice is included verbatim in any distributions. No written agreement,
|
||||||
|
* license, or royalty fee is required for any of the authorized uses.
|
||||||
|
* Modifications to this software may be copyrighted by their authors
|
||||||
|
* and need not follow the licensing terms described here, provided that
|
||||||
|
* the new terms are clearly indicated on the first page of each file where
|
||||||
|
* they apply.
|
||||||
|
*/
|
||||||
|
OUTPUT_FORMAT ("elf32-littlearm", "elf32-bigarm", "elf32-littlearm")
|
||||||
|
|
||||||
|
/* 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
|
||||||
|
* __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
|
||||||
|
* __HeapBase
|
||||||
|
* __HeapLimit
|
||||||
|
* __StackLimit
|
||||||
|
* __StackTop
|
||||||
|
* __stack
|
||||||
|
*/
|
||||||
|
ENTRY(Reset_Handler)
|
||||||
|
|
||||||
|
SECTIONS
|
||||||
|
{
|
||||||
|
.text :
|
||||||
|
{
|
||||||
|
KEEP(*(.isr_vector))
|
||||||
|
*(.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 = .;
|
||||||
|
|
||||||
|
__etext = .;
|
||||||
|
|
||||||
|
.data : AT (__etext)
|
||||||
|
{
|
||||||
|
__data_start__ = .;
|
||||||
|
*(vtable)
|
||||||
|
*(.data*)
|
||||||
|
|
||||||
|
. = 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__ = .;
|
||||||
|
PROVIDE(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 text sections + data exceeds FLASH limit */
|
||||||
|
DataInitFlashUsed = __bss_start__ - __data_start__;
|
||||||
|
CodeFlashUsed = __etext - ORIGIN(FLASH);
|
||||||
|
TotalFlashUsed = CodeFlashUsed + DataInitFlashUsed;
|
||||||
|
ASSERT(TotalFlashUsed <= LENGTH(FLASH), "region FLASH overflowed with .data and user data")
|
||||||
|
|
||||||
|
}
|
64
build_system/platform/nrf52/without_sd.ld
Normal file
64
build_system/platform/nrf52/without_sd.ld
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
/* Linker script to configure memory regions. */
|
||||||
|
|
||||||
|
SEARCH_DIR(.)
|
||||||
|
GROUP(-lgcc -lc -lnosys)
|
||||||
|
|
||||||
|
MEMORY
|
||||||
|
{
|
||||||
|
FLASH (rx) : ORIGIN = 0x0, LENGTH = 0x80000
|
||||||
|
RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x10000
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTIONS
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTIONS
|
||||||
|
{
|
||||||
|
. = ALIGN(4);
|
||||||
|
.mem_section_dummy_ram :
|
||||||
|
{
|
||||||
|
}
|
||||||
|
.log_dynamic_data :
|
||||||
|
{
|
||||||
|
PROVIDE(__start_log_dynamic_data = .);
|
||||||
|
KEEP(*(SORT(.log_dynamic_data*)))
|
||||||
|
PROVIDE(__stop_log_dynamic_data = .);
|
||||||
|
} > RAM
|
||||||
|
.log_filter_data :
|
||||||
|
{
|
||||||
|
PROVIDE(__start_log_filter_data = .);
|
||||||
|
KEEP(*(SORT(.log_filter_data*)))
|
||||||
|
PROVIDE(__stop_log_filter_data = .);
|
||||||
|
} > RAM
|
||||||
|
|
||||||
|
} INSERT AFTER .data;
|
||||||
|
|
||||||
|
SECTIONS
|
||||||
|
{
|
||||||
|
.mem_section_dummy_rom :
|
||||||
|
{
|
||||||
|
}
|
||||||
|
.log_const_data :
|
||||||
|
{
|
||||||
|
PROVIDE(__start_log_const_data = .);
|
||||||
|
KEEP(*(SORT(.log_const_data*)))
|
||||||
|
PROVIDE(__stop_log_const_data = .);
|
||||||
|
} > FLASH
|
||||||
|
.log_backends :
|
||||||
|
{
|
||||||
|
PROVIDE(__start_log_backends = .);
|
||||||
|
KEEP(*(SORT(.log_backends*)))
|
||||||
|
PROVIDE(__stop_log_backends = .);
|
||||||
|
} > FLASH
|
||||||
|
.nrf_balloc :
|
||||||
|
{
|
||||||
|
PROVIDE(__start_nrf_balloc = .);
|
||||||
|
KEEP(*(.nrf_balloc))
|
||||||
|
PROVIDE(__stop_nrf_balloc = .);
|
||||||
|
} > FLASH
|
||||||
|
|
||||||
|
} INSERT AFTER .text
|
||||||
|
|
||||||
|
|
||||||
|
INCLUDE "nrf_common.ld"
|
@@ -1,8 +0,0 @@
|
|||||||
#ifndef __BOARD_H__
|
|
||||||
#define __BOARD_H__
|
|
||||||
|
|
||||||
#ifdef BOARD_PCA10040
|
|
||||||
#include "platform/narf52/narf52_dk.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
@@ -1,34 +0,0 @@
|
|||||||
#ifndef __DRIVER_H__
|
|
||||||
#define __DRIVER_H__
|
|
||||||
|
|
||||||
#include <stdarg.h>
|
|
||||||
|
|
||||||
struct driver;
|
|
||||||
|
|
||||||
typedef int (*fp_open_t)(const struct driver *);
|
|
||||||
typedef int (*fp_close_t)(const struct driver *);
|
|
||||||
typedef int (*fp_read_t)(const struct driver *, char *, unsigned int);
|
|
||||||
typedef int (*fp_write_t)(const struct driver *, const char *, unsigned int);
|
|
||||||
typedef int (*fp_ioctl_t)(const struct driver *, unsigned int, unsigned int argc, va_list);
|
|
||||||
|
|
||||||
struct driver_fp {
|
|
||||||
fp_open_t open;
|
|
||||||
fp_close_t close;
|
|
||||||
fp_read_t read;
|
|
||||||
fp_write_t write;
|
|
||||||
fp_ioctl_t ioctl;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct driver {
|
|
||||||
const char *name;
|
|
||||||
const struct driver_fp *fp;
|
|
||||||
const void *dev;
|
|
||||||
};
|
|
||||||
|
|
||||||
int drv_open(const struct driver *drv);
|
|
||||||
int drv_close(const struct driver *drv);
|
|
||||||
int drv_read(const struct driver *drv, char *buffer, unsigned int length);
|
|
||||||
int drv_write(const struct driver *drv, const char *buffer, unsigned int length);
|
|
||||||
int drv_ioctl(const struct driver *drv, unsigned int cmd, unsigned int argc, ...);
|
|
||||||
|
|
||||||
#endif
|
|
@@ -1,23 +0,0 @@
|
|||||||
#ifndef __GPIO_H__
|
|
||||||
#define __GPIO_H__
|
|
||||||
|
|
||||||
#include <stdarg.h>
|
|
||||||
|
|
||||||
#include "driver.h"
|
|
||||||
|
|
||||||
int gpio_open(const struct driver *drv);
|
|
||||||
int gpio_close(const struct driver *drv);
|
|
||||||
|
|
||||||
int gpio_read(const struct driver *drv, char *buffer, unsigned int len);
|
|
||||||
int gpio_write(const struct driver *drv, const char *buffer, unsigned int len);
|
|
||||||
int gpio_ioctl(const struct driver *drv, unsigned int cmd, unsigned int argc, va_list args);
|
|
||||||
|
|
||||||
static const struct driver_fp gpio_fp = {
|
|
||||||
.open = gpio_open,
|
|
||||||
.close = gpio_close,
|
|
||||||
.read = gpio_read,
|
|
||||||
.write = gpio_write,
|
|
||||||
.ioctl = gpio_ioctl
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
@@ -1,100 +0,0 @@
|
|||||||
#ifndef __PLATFORM_NARF52_NARF52_H__
|
|
||||||
#define __PLATFORM_NARF52_NARF52_H__
|
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
/* ======================================= ARM Cortex-M4 Specific Interrupt Numbers ======================================== */
|
|
||||||
Reset_IRQn = -15, /*!< -15 Reset Vector, invoked on Power up and warm reset */
|
|
||||||
NonMaskableInt_IRQn = -14, /*!< -14 Non maskable Interrupt, cannot be stopped or preempted */
|
|
||||||
HardFault_IRQn = -13, /*!< -13 Hard Fault, all classes of Fault */
|
|
||||||
MemoryManagement_IRQn = -12, /*!< -12 Memory Management, MPU mismatch, including Access Violation
|
|
||||||
and No Match */
|
|
||||||
BusFault_IRQn = -11, /*!< -11 Bus Fault, Pre-Fetch-, Memory Access Fault, other address/memory
|
|
||||||
related Fault */
|
|
||||||
UsageFault_IRQn = -10, /*!< -10 Usage Fault, i.e. Undef Instruction, Illegal State Transition */
|
|
||||||
SVCall_IRQn = -5, /*!< -5 System Service Call via SVC instruction */
|
|
||||||
DebugMonitor_IRQn = -4, /*!< -4 Debug Monitor */
|
|
||||||
PendSV_IRQn = -2, /*!< -2 Pendable request for system service */
|
|
||||||
SysTick_IRQn = -1, /*!< -1 System Tick Timer */
|
|
||||||
/* =========================================== nrf52 Specific Interrupt Numbers ============================================ */
|
|
||||||
POWER_CLOCK_IRQn = 0, /*!< 0 POWER_CLOCK */
|
|
||||||
RADIO_IRQn = 1, /*!< 1 RADIO */
|
|
||||||
UARTE0_UART0_IRQn = 2, /*!< 2 UARTE0_UART0 */
|
|
||||||
SPIM0_SPIS0_TWIM0_TWIS0_SPI0_TWI0_IRQn= 3, /*!< 3 SPIM0_SPIS0_TWIM0_TWIS0_SPI0_TWI0 */
|
|
||||||
SPIM1_SPIS1_TWIM1_TWIS1_SPI1_TWI1_IRQn= 4, /*!< 4 SPIM1_SPIS1_TWIM1_TWIS1_SPI1_TWI1 */
|
|
||||||
NFCT_IRQn = 5, /*!< 5 NFCT */
|
|
||||||
GPIOTE_IRQn = 6, /*!< 6 GPIOTE */
|
|
||||||
SAADC_IRQn = 7, /*!< 7 SAADC */
|
|
||||||
TIMER0_IRQn = 8, /*!< 8 TIMER0 */
|
|
||||||
TIMER1_IRQn = 9, /*!< 9 TIMER1 */
|
|
||||||
TIMER2_IRQn = 10, /*!< 10 TIMER2 */
|
|
||||||
RTC0_IRQn = 11, /*!< 11 RTC0 */
|
|
||||||
TEMP_IRQn = 12, /*!< 12 TEMP */
|
|
||||||
RNG_IRQn = 13, /*!< 13 RNG */
|
|
||||||
ECB_IRQn = 14, /*!< 14 ECB */
|
|
||||||
CCM_AAR_IRQn = 15, /*!< 15 CCM_AAR */
|
|
||||||
WDT_IRQn = 16, /*!< 16 WDT */
|
|
||||||
RTC1_IRQn = 17, /*!< 17 RTC1 */
|
|
||||||
QDEC_IRQn = 18, /*!< 18 QDEC */
|
|
||||||
COMP_LPCOMP_IRQn = 19, /*!< 19 COMP_LPCOMP */
|
|
||||||
SWI0_EGU0_IRQn = 20, /*!< 20 SWI0_EGU0 */
|
|
||||||
SWI1_EGU1_IRQn = 21, /*!< 21 SWI1_EGU1 */
|
|
||||||
SWI2_EGU2_IRQn = 22, /*!< 22 SWI2_EGU2 */
|
|
||||||
SWI3_EGU3_IRQn = 23, /*!< 23 SWI3_EGU3 */
|
|
||||||
SWI4_EGU4_IRQn = 24, /*!< 24 SWI4_EGU4 */
|
|
||||||
SWI5_EGU5_IRQn = 25, /*!< 25 SWI5_EGU5 */
|
|
||||||
TIMER3_IRQn = 26, /*!< 26 TIMER3 */
|
|
||||||
TIMER4_IRQn = 27, /*!< 27 TIMER4 */
|
|
||||||
PWM0_IRQn = 28, /*!< 28 PWM0 */
|
|
||||||
PDM_IRQn = 29, /*!< 29 PDM */
|
|
||||||
MWU_IRQn = 32, /*!< 32 MWU */
|
|
||||||
PWM1_IRQn = 33, /*!< 33 PWM1 */
|
|
||||||
PWM2_IRQn = 34, /*!< 34 PWM2 */
|
|
||||||
SPIM2_SPIS2_SPI2_IRQn = 35, /*!< 35 SPIM2_SPIS2_SPI2 */
|
|
||||||
RTC2_IRQn = 36, /*!< 36 RTC2 */
|
|
||||||
I2S_IRQn = 37, /*!< 37 I2S */
|
|
||||||
FPU_IRQn = 38 /*!< 38 FPU */
|
|
||||||
} IRQn_Type;
|
|
||||||
|
|
||||||
|
|
||||||
/* =========================================================================================================================== */
|
|
||||||
/* ================ Processor and Core Peripheral Section ================ */
|
|
||||||
/* =========================================================================================================================== */
|
|
||||||
|
|
||||||
/* =========================== Configuration of the ARM Cortex-M4 Processor and Core Peripherals =========================== */
|
|
||||||
#define __CM4_REV 0x0001U /*!< CM4 Core Revision */
|
|
||||||
#define __DSP_PRESENT 0 /*!< DSP present or not */
|
|
||||||
#define __VTOR_PRESENT 1 /*!< Set to 1 if CPU supports Vector Table Offset Register */
|
|
||||||
#define __NVIC_PRIO_BITS 3 /*!< Number of Bits used for Priority Levels */
|
|
||||||
#define __Vendor_SysTickConfig 0 /*!< Set to 1 if different SysTick Config is used */
|
|
||||||
#define __MPU_PRESENT 1 /*!< MPU present */
|
|
||||||
#define __FPU_PRESENT 1 /*!< FPU present */
|
|
||||||
|
|
||||||
#include "core_cm4.h"
|
|
||||||
|
|
||||||
struct narf52_gpio_type { /*!< (@ 0x50000000) P0 Structure */
|
|
||||||
__IM uint32_t RESERVED[321];
|
|
||||||
__IOM uint32_t OUT; /*!< (@ 0x00000504) Write GPIO port */
|
|
||||||
__IOM uint32_t OUTSET; /*!< (@ 0x00000508) Set individual bits in GPIO port */
|
|
||||||
__IOM uint32_t OUTCLR; /*!< (@ 0x0000050C) Clear individual bits in GPIO port */
|
|
||||||
__IM uint32_t IN; /*!< (@ 0x00000510) Read GPIO port */
|
|
||||||
__IOM uint32_t DIR; /*!< (@ 0x00000514) Direction of GPIO pins */
|
|
||||||
__IOM uint32_t DIRSET; /*!< (@ 0x00000518) DIR set register */
|
|
||||||
__IOM uint32_t DIRCLR; /*!< (@ 0x0000051C) DIR clear register */
|
|
||||||
__IOM uint32_t LATCH; /*!< (@ 0x00000520) Latch register indicating what GPIO pins that
|
|
||||||
have met the criteria set in the PIN_CNF[n].SENSE
|
|
||||||
registers */
|
|
||||||
__IOM uint32_t DETECTMODE; /*!< (@ 0x00000524) Select between default DETECT signal behaviour
|
|
||||||
and LDETECT mode */
|
|
||||||
__IM uint32_t RESERVED1[118];
|
|
||||||
__IOM uint32_t PIN_CNF[32]; /*!< (@ 0x00000700) Description collection[0]: Configuration of GPIO
|
|
||||||
pins */
|
|
||||||
}; /*!< Size = 1920 (0x780) */
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#define NARF_P0_BASE 0x50000000UL
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
|
@@ -1,131 +0,0 @@
|
|||||||
#ifndef __PLATFORM_NARF52_NARF52_DK_H
|
|
||||||
#define __PLATFORM_NARF52_NARF52_DK_H
|
|
||||||
|
|
||||||
#include "gpio.h"
|
|
||||||
#include "narf52_gpio.h"
|
|
||||||
|
|
||||||
#include "driver.h"
|
|
||||||
|
|
||||||
// LEDs
|
|
||||||
const struct narf52_gpio narf_led_1 = {
|
|
||||||
.pin_number = 17,
|
|
||||||
.dir = NARF_GPIO_DIR_OUT,
|
|
||||||
.input = NARF_GPIO_PIN_INPUT_DISCONNECT,
|
|
||||||
.pull = NARF_GPIO_PIN_NOPULL,
|
|
||||||
.drive = NARF_GPIO_PIN_S0S1,
|
|
||||||
.sense = NARF_GPIO_PIN_NOSENSE,
|
|
||||||
};
|
|
||||||
|
|
||||||
const struct driver led_1 = {
|
|
||||||
.name = "LED_1",
|
|
||||||
.fp = &gpio_fp,
|
|
||||||
.dev = (void *)&narf_led_1,
|
|
||||||
};
|
|
||||||
|
|
||||||
const struct narf52_gpio narf_led_2 = {
|
|
||||||
.pin_number = 18,
|
|
||||||
.dir = NARF_GPIO_DIR_OUT,
|
|
||||||
.input = NARF_GPIO_PIN_INPUT_DISCONNECT,
|
|
||||||
.pull = NARF_GPIO_PIN_NOPULL,
|
|
||||||
.drive = NARF_GPIO_PIN_S0S1,
|
|
||||||
.sense = NARF_GPIO_PIN_NOSENSE,
|
|
||||||
};
|
|
||||||
|
|
||||||
const struct driver led_2 = {
|
|
||||||
.name = "LED_2",
|
|
||||||
.fp = &gpio_fp,
|
|
||||||
.dev = (void *)&narf_led_2,
|
|
||||||
};
|
|
||||||
|
|
||||||
const struct narf52_gpio narf_led_3 = {
|
|
||||||
.pin_number = 19,
|
|
||||||
.dir = NARF_GPIO_DIR_OUT,
|
|
||||||
.input = NARF_GPIO_PIN_INPUT_DISCONNECT,
|
|
||||||
.pull = NARF_GPIO_PIN_NOPULL,
|
|
||||||
.drive = NARF_GPIO_PIN_S0S1,
|
|
||||||
.sense = NARF_GPIO_PIN_NOSENSE,
|
|
||||||
};
|
|
||||||
|
|
||||||
const struct driver led_3 = {
|
|
||||||
.name = "LED_3",
|
|
||||||
.fp = &gpio_fp,
|
|
||||||
.dev = (void *)&narf_led_3,
|
|
||||||
};
|
|
||||||
|
|
||||||
const struct narf52_gpio narf_led_4 = {
|
|
||||||
.pin_number = 20,
|
|
||||||
.dir = NARF_GPIO_DIR_OUT,
|
|
||||||
.input = NARF_GPIO_PIN_INPUT_DISCONNECT,
|
|
||||||
.pull = NARF_GPIO_PIN_NOPULL,
|
|
||||||
.drive = NARF_GPIO_PIN_S0S1,
|
|
||||||
.sense = NARF_GPIO_PIN_NOSENSE,
|
|
||||||
};
|
|
||||||
|
|
||||||
const struct driver led_4 = {
|
|
||||||
.name = "LED_4",
|
|
||||||
.fp = &gpio_fp,
|
|
||||||
.dev = (void *)&narf_led_4,
|
|
||||||
};
|
|
||||||
|
|
||||||
// BUTTONs
|
|
||||||
const struct narf52_gpio narf_button_1 = {
|
|
||||||
.pin_number = 13,
|
|
||||||
.dir = NARF_GPIO_DIR_IN,
|
|
||||||
.input = NARF_GPIO_PIN_INPUT_CONNECT,
|
|
||||||
.pull = NARF_GPIO_PIN_PULLUP,
|
|
||||||
.drive = NARF_GPIO_PIN_S0S1,
|
|
||||||
.sense = NARF_GPIO_PIN_NOSENSE,
|
|
||||||
};
|
|
||||||
|
|
||||||
const struct driver button_1 = {
|
|
||||||
.name = "BUTTON_1",
|
|
||||||
.fp = &gpio_fp,
|
|
||||||
.dev = (void *)&narf_button_1,
|
|
||||||
};
|
|
||||||
|
|
||||||
const struct narf52_gpio narf_button_2 = {
|
|
||||||
.pin_number = 14,
|
|
||||||
.dir = NARF_GPIO_DIR_IN,
|
|
||||||
.input = NARF_GPIO_PIN_INPUT_CONNECT,
|
|
||||||
.pull = NARF_GPIO_PIN_PULLUP,
|
|
||||||
.drive = NARF_GPIO_PIN_S0S1,
|
|
||||||
.sense = NARF_GPIO_PIN_NOSENSE,
|
|
||||||
};
|
|
||||||
|
|
||||||
const struct driver button_2 = {
|
|
||||||
.name = "BUTTON_2",
|
|
||||||
.fp = &gpio_fp,
|
|
||||||
.dev = (void *)&narf_button_2,
|
|
||||||
};
|
|
||||||
|
|
||||||
const struct narf52_gpio narf_button_3 = {
|
|
||||||
.pin_number = 15,
|
|
||||||
.dir = NARF_GPIO_DIR_IN,
|
|
||||||
.input = NARF_GPIO_PIN_INPUT_CONNECT,
|
|
||||||
.pull = NARF_GPIO_PIN_PULLUP,
|
|
||||||
.drive = NARF_GPIO_PIN_S0S1,
|
|
||||||
.sense = NARF_GPIO_PIN_NOSENSE,
|
|
||||||
};
|
|
||||||
|
|
||||||
const struct driver button_3 = {
|
|
||||||
.name = "BUTTON_3",
|
|
||||||
.fp = &gpio_fp,
|
|
||||||
.dev = (void *)&narf_button_3,
|
|
||||||
};
|
|
||||||
|
|
||||||
const struct narf52_gpio narf_button_4 = {
|
|
||||||
.pin_number = 16,
|
|
||||||
.dir = NARF_GPIO_DIR_IN,
|
|
||||||
.input = NARF_GPIO_PIN_INPUT_CONNECT,
|
|
||||||
.pull = NARF_GPIO_PIN_PULLUP,
|
|
||||||
.drive = NARF_GPIO_PIN_S0S1,
|
|
||||||
.sense = NARF_GPIO_PIN_NOSENSE,
|
|
||||||
};
|
|
||||||
|
|
||||||
const struct driver button_4 = {
|
|
||||||
.name = "BUTTON_4",
|
|
||||||
.fp = &gpio_fp,
|
|
||||||
.dev = (void *)&narf_button_4,
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
@@ -1,48 +0,0 @@
|
|||||||
#ifndef __PLATFORM_NARF52_NARF52_GPIO_H__
|
|
||||||
#define __PLATFORM_NARF52_NARF52_GPIO_H__
|
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
enum narf52_gpio_direction {
|
|
||||||
NARF_GPIO_DIR_IN = 0,
|
|
||||||
NARF_GPIO_DIR_OUT
|
|
||||||
};
|
|
||||||
|
|
||||||
enum narf52_gpio_pin_input {
|
|
||||||
NARF_GPIO_PIN_INPUT_CONNECT = 0, ///< Connect input buffer.
|
|
||||||
NARF_GPIO_PIN_INPUT_DISCONNECT ///< Disconnect input buffer.
|
|
||||||
};
|
|
||||||
|
|
||||||
enum narf52_gpio_pin_pull {
|
|
||||||
NARF_GPIO_PIN_NOPULL = 0, ///< Pin pull-up resistor disabled.
|
|
||||||
NARF_GPIO_PIN_PULLDOWN = 1, ///< Pin pull-down resistor enabled.
|
|
||||||
NARF_GPIO_PIN_PULLUP = 3 ///< Pin pull-up resistor enabled.
|
|
||||||
};
|
|
||||||
|
|
||||||
enum narf52_gpio_pin_drive {
|
|
||||||
NARF_GPIO_PIN_S0S1 = 0, ///< !< Standard '0', standard '1'.
|
|
||||||
NARF_GPIO_PIN_H0S1 = 1, ///< !< High-drive '0', standard '1'.
|
|
||||||
NARF_GPIO_PIN_S0H1 = 2, ///< !< Standard '0', high-drive '1'.
|
|
||||||
NARF_GPIO_PIN_H0H1 = 3, ///< !< High drive '0', high-drive '1'.
|
|
||||||
NARF_GPIO_PIN_D0S1 = 4, ///< !< Disconnect '0' standard '1'.
|
|
||||||
NARF_GPIO_PIN_D0H1 = 5, ///< !< Disconnect '0', high-drive '1'.
|
|
||||||
NARF_GPIO_PIN_S0D1 = 6, ///< !< Standard '0', disconnect '1'.
|
|
||||||
NARF_GPIO_PIN_H0D1 = 7 ///< !< High-drive '0', disconnect '1'.
|
|
||||||
};
|
|
||||||
|
|
||||||
enum narf52_gpio_pin_sense {
|
|
||||||
NARF_GPIO_PIN_NOSENSE = 0, ///< Pin sense level disabled.
|
|
||||||
NARF_GPIO_PIN_SENSE_LOW = 1, ///< Pin sense low level.
|
|
||||||
NARF_GPIO_PIN_SENSE_HIGH = 2 ///< Pin sense high level.
|
|
||||||
};
|
|
||||||
|
|
||||||
struct narf52_gpio {
|
|
||||||
uint32_t pin_number;
|
|
||||||
enum narf52_gpio_direction dir;
|
|
||||||
enum narf52_gpio_pin_input input;
|
|
||||||
enum narf52_gpio_pin_pull pull;
|
|
||||||
enum narf52_gpio_pin_drive drive;
|
|
||||||
enum narf52_gpio_pin_sense sense;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
19
interfaces/HwTimerInterface.h
Normal file
19
interfaces/HwTimerInterface.h
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
#ifndef __INTERFACES_HWTIMERINTERFACE_H__
|
||||||
|
#define __INTERFACES_HWTIMERINTERFACE_H__
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
|
namespace pinetime::interfaces
|
||||||
|
{
|
||||||
|
|
||||||
|
class HwTimerInterface
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual void enable_timer() = 0;
|
||||||
|
virtual void disable_timer() = 0;
|
||||||
|
virtual uint64_t tick() = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
19
interfaces/VirtualTimerInterface.h
Normal file
19
interfaces/VirtualTimerInterface.h
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
#ifndef __INTERFACES_VIRTUALTIMERINTERFACE_H__
|
||||||
|
#define __INTERFACES_VIRTUALTIMERINTERFACE_H__
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
|
namespace pinetime::interfaces
|
||||||
|
{
|
||||||
|
|
||||||
|
class VirtualTimerInterface
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual void timer_notification(uint64_t) = 0;
|
||||||
|
virtual void timer_enable() = 0;
|
||||||
|
virtual void timer_disable() = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
24
interfaces/gpio_interface.h
Normal file
24
interfaces/gpio_interface.h
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
#ifndef __INTERFACES_GPIO_INTERFACE_H__
|
||||||
|
#define __INTERFACES_GPIO_INTERFACE_H__
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
|
namespace pinetime::interfaces {
|
||||||
|
|
||||||
|
class GpioInterface
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
enum class direction {IN, OUT};
|
||||||
|
|
||||||
|
virtual void set_direction(direction, bool) = 0;
|
||||||
|
virtual uint32_t get() = 0;
|
||||||
|
virtual void set() = 0;
|
||||||
|
virtual void clear() = 0;
|
||||||
|
virtual void toggle() = 0;
|
||||||
|
|
||||||
|
virtual void handle() = 0;
|
||||||
|
virtual uint32_t pin_number() = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
#endif
|
16
interfaces/interrupt_interface.h
Normal file
16
interfaces/interrupt_interface.h
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
#ifndef __INTERFACES_INTERRUPT_INTERFACE_H__
|
||||||
|
#define __INTERFACES_INTERRUPT_INTERFACE_H__
|
||||||
|
|
||||||
|
namespace pinetime::interfaces {
|
||||||
|
|
||||||
|
class InterruptHandlerInterface
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual void handle() = 0;
|
||||||
|
virtual void enable() = 0;
|
||||||
|
virtual void disable() = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
16
interfaces/spi_interface.h
Normal file
16
interfaces/spi_interface.h
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
#ifndef __INTERFACES_SPI_INTERFACE_H__
|
||||||
|
#define __INTERFACES_SPI_INTERFACE_H__
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
|
namespace pinetime::interfaces {
|
||||||
|
|
||||||
|
class SpiInterface
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual void send(const uint8_t * buffer, uint32_t len) = 0;
|
||||||
|
virtual void recv(uint8_t * buffer, uint32_t len) = 0;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
56
src/Pool.h
Normal file
56
src/Pool.h
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
#ifndef __POOL_H__
|
||||||
|
#define __POOL_H__
|
||||||
|
|
||||||
|
#include <cstddef>
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
|
#include "platform/cm4/InterruptLock.h"
|
||||||
|
|
||||||
|
namespace pinetime
|
||||||
|
{
|
||||||
|
|
||||||
|
template <typename T, std::size_t sizeT>
|
||||||
|
class Pool
|
||||||
|
{
|
||||||
|
union Item
|
||||||
|
{
|
||||||
|
uint8_t item[sizeof(T)];
|
||||||
|
Item * next;
|
||||||
|
};
|
||||||
|
Item items[sizeT];
|
||||||
|
uint8_t map[sizeT];
|
||||||
|
|
||||||
|
public:
|
||||||
|
Pool()
|
||||||
|
{
|
||||||
|
for(unsigned int i = 0; i < sizeT; i++) {
|
||||||
|
map[i] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void *alloc()
|
||||||
|
{
|
||||||
|
pinetime::platform::cm4::InterruptLock lock;
|
||||||
|
void * res = nullptr;
|
||||||
|
for(unsigned int i = 0; i < sizeT; i++) {
|
||||||
|
if(map[i] == 0) {
|
||||||
|
map[i] = 0xff;
|
||||||
|
res = static_cast<void *>(items + i);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
void free(T * ptr)
|
||||||
|
{
|
||||||
|
pinetime::platform::cm4::InterruptLock lock;
|
||||||
|
// ptr is not assumed to be aligned, since the integer based aritmetic provides always the correct index and omits the ramainder.
|
||||||
|
std::size_t index = (reinterpret_cast<std::uintptr_t>(ptr) - reinterpret_cast<std::uintptr_t>(items)) / sizeof(Item);
|
||||||
|
map[index] = 0;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
@@ -1,26 +0,0 @@
|
|||||||
#include <stdbool.h>
|
|
||||||
#include <limits.h>
|
|
||||||
#include "nrf_delay.h"
|
|
||||||
#include "boards.h"
|
|
||||||
#include "platform/narf52/narf52_dk.h"
|
|
||||||
|
|
||||||
#include "driver.h"
|
|
||||||
|
|
||||||
int main(void)
|
|
||||||
{
|
|
||||||
drv_open(&led_1);
|
|
||||||
drv_open(&led_2);
|
|
||||||
drv_open(&led_3);
|
|
||||||
drv_open(&led_4);
|
|
||||||
|
|
||||||
while(true) {
|
|
||||||
for(unsigned int i = 0; i < UINT_MAX; i++) {
|
|
||||||
char x = 0x30 | (char)(1 & i);
|
|
||||||
drv_write(&led_1, &x, 1);
|
|
||||||
drv_write(&led_2, &x, 1);
|
|
||||||
drv_write(&led_3, &x, 1);
|
|
||||||
drv_write(&led_4, &x, 1);
|
|
||||||
nrf_delay_ms(500);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
56
src/application/blinky/main.cc
Normal file
56
src/application/blinky/main.cc
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
#include <array>
|
||||||
|
|
||||||
|
#include "virtual_timer/VirtualTimerDistributor.h"
|
||||||
|
|
||||||
|
#include "platform/cm4/InterruptHandler.h"
|
||||||
|
#include "platform/cm4/InterruptGuardian.h"
|
||||||
|
#include "platform/cm4/SystemTick.h"
|
||||||
|
|
||||||
|
#include "platform/nrf52/gpio.h"
|
||||||
|
#include "platform/nrf52/gpiote.h"
|
||||||
|
#include "platform/nrf52/InterruptHandler.h"
|
||||||
|
#include "platform/nrf52/InterruptGuardian.h"
|
||||||
|
|
||||||
|
#include "delay.h"
|
||||||
|
|
||||||
|
using namespace pinetime::platform;
|
||||||
|
using namespace pinetime::virtual_timer;
|
||||||
|
|
||||||
|
// IRQs
|
||||||
|
nrf52::InterruptGuardian nrf52::InterruptGuardian::instance;
|
||||||
|
cm4::InterruptGuardian cm4::InterruptGuardian::instance;
|
||||||
|
|
||||||
|
// GPIO events
|
||||||
|
nrf52::Gpiote gpiote;
|
||||||
|
|
||||||
|
// Timer
|
||||||
|
cm4::SystemTick system_tick;
|
||||||
|
VirtualTimerDistributor virtual_timer_distributor(system_tick.instance());
|
||||||
|
pinetime::Delay delay;
|
||||||
|
|
||||||
|
enum {
|
||||||
|
PIN_NUMBER_LED_1 = 17,
|
||||||
|
PIN_NUMBER_LED_2 = 18,
|
||||||
|
PIN_NUMBER_LED_3 = 19,
|
||||||
|
PIN_NUMBER_LED_4 = 20
|
||||||
|
};
|
||||||
|
|
||||||
|
// LEDs
|
||||||
|
nrf52::Gpio led_1(PIN_NUMBER_LED_1);
|
||||||
|
nrf52::Gpio led_2(PIN_NUMBER_LED_2);
|
||||||
|
nrf52::Gpio led_3(PIN_NUMBER_LED_3);
|
||||||
|
nrf52::Gpio led_4(PIN_NUMBER_LED_4);
|
||||||
|
std::array<nrf52::Gpio *, 4> leds = {&led_1, &led_2, &led_3, &led_4};
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
cm4::InterruptGuardian::enable_interrupts();
|
||||||
|
while(true) {
|
||||||
|
for(auto it = leds.begin(); it != leds.end(); ++it) {
|
||||||
|
nrf52::Gpio * led = *it;
|
||||||
|
led->toggle();
|
||||||
|
delay.ms(200);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
@@ -1,34 +0,0 @@
|
|||||||
#include <stdbool.h>
|
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
#include "board.h"
|
|
||||||
#include "driver.h"
|
|
||||||
|
|
||||||
int main(void)
|
|
||||||
{
|
|
||||||
// bsp_board_init(BSP_INIT_LEDS);
|
|
||||||
drv_open(&led_1);
|
|
||||||
drv_open(&led_2);
|
|
||||||
drv_open(&led_3);
|
|
||||||
drv_open(&led_4);
|
|
||||||
|
|
||||||
drv_open(&button_1);
|
|
||||||
drv_open(&button_2);
|
|
||||||
drv_open(&button_3);
|
|
||||||
drv_open(&button_4);
|
|
||||||
|
|
||||||
while(true) {
|
|
||||||
char x;
|
|
||||||
drv_read(&button_1, &x, 1);
|
|
||||||
drv_write(&led_1, &x, 1);
|
|
||||||
|
|
||||||
drv_read(&button_2, &x, 1);
|
|
||||||
drv_write(&led_2, &x, 1);
|
|
||||||
|
|
||||||
drv_read(&button_3, &x, 1);
|
|
||||||
drv_write(&led_3, &x, 1);
|
|
||||||
|
|
||||||
drv_read(&button_4, &x, 1);
|
|
||||||
drv_write(&led_4, &x, 1);
|
|
||||||
}
|
|
||||||
}
|
|
74
src/application/button/main.cc
Normal file
74
src/application/button/main.cc
Normal file
@@ -0,0 +1,74 @@
|
|||||||
|
#include <array>
|
||||||
|
|
||||||
|
#include "virtual_timer/VirtualTimerDistributor.h"
|
||||||
|
|
||||||
|
#include "platform/cm4/InterruptHandler.h"
|
||||||
|
#include "platform/cm4/InterruptGuardian.h"
|
||||||
|
#include "platform/cm4/SystemTick.h"
|
||||||
|
|
||||||
|
#include "platform/nrf52/gpio.h"
|
||||||
|
#include "platform/nrf52/gpiote.h"
|
||||||
|
#include "platform/nrf52/InterruptHandler.h"
|
||||||
|
#include "platform/nrf52/InterruptGuardian.h"
|
||||||
|
|
||||||
|
#include "gpio_interface.h"
|
||||||
|
#include "delay.h"
|
||||||
|
|
||||||
|
using namespace pinetime::platform;
|
||||||
|
using namespace pinetime::virtual_timer;
|
||||||
|
|
||||||
|
// IRQs
|
||||||
|
nrf52::InterruptGuardian nrf52::InterruptGuardian::instance;
|
||||||
|
cm4::InterruptGuardian cm4::InterruptGuardian::instance;
|
||||||
|
|
||||||
|
// GPIO events
|
||||||
|
nrf52::Gpiote gpiote;
|
||||||
|
|
||||||
|
// Timer
|
||||||
|
cm4::SystemTick system_tick;
|
||||||
|
VirtualTimerDistributor virtual_timer_distributor(system_tick.instance());
|
||||||
|
pinetime::Delay delay;
|
||||||
|
|
||||||
|
|
||||||
|
enum {
|
||||||
|
PIN_NUMBER_BUTTON_1 = 13,
|
||||||
|
PIN_NUMBER_BUTTON_2 = 14,
|
||||||
|
PIN_NUMBER_BUTTON_3 = 15,
|
||||||
|
PIN_NUMBER_BUTTON_4 = 16,
|
||||||
|
PIN_NUMBER_LED_1 = 17,
|
||||||
|
PIN_NUMBER_LED_2 = 18,
|
||||||
|
PIN_NUMBER_LED_3 = 19,
|
||||||
|
PIN_NUMBER_LED_4 = 20
|
||||||
|
};
|
||||||
|
|
||||||
|
// LEDs
|
||||||
|
nrf52::Gpio led_1(PIN_NUMBER_LED_1);
|
||||||
|
nrf52::Gpio led_2(PIN_NUMBER_LED_2);
|
||||||
|
nrf52::Gpio led_3(PIN_NUMBER_LED_3);
|
||||||
|
nrf52::Gpio led_4(PIN_NUMBER_LED_4);
|
||||||
|
std::array<nrf52::Gpio *, 4> leds = {&led_1, &led_2, &led_3, &led_4};
|
||||||
|
|
||||||
|
// Buttons
|
||||||
|
nrf52::Gpio button_1(PIN_NUMBER_BUTTON_1);
|
||||||
|
nrf52::Gpio button_2(PIN_NUMBER_BUTTON_2);
|
||||||
|
nrf52::Gpio button_3(PIN_NUMBER_BUTTON_3);
|
||||||
|
nrf52::Gpio button_4(PIN_NUMBER_BUTTON_4);
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
button_1.set_direction(pinetime::interfaces::GpioInterface::direction::IN, true);
|
||||||
|
cm4::InterruptGuardian::enable_interrupts();
|
||||||
|
while(true) {
|
||||||
|
for(auto it = leds.begin(); it != leds.end(); ++it) {
|
||||||
|
uint32_t b1 = button_1.get();
|
||||||
|
if(b1) {
|
||||||
|
nrf52::Gpio * led = *it;
|
||||||
|
led->toggle();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
__SEV();
|
||||||
|
__WFE();
|
||||||
|
__WFE();
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
28
src/application/spi/main.cc
Normal file
28
src/application/spi/main.cc
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
|
||||||
|
#include "platform/cm4/InterruptHandler.h"
|
||||||
|
#include "platform/cm4/InterruptGuardian.h"
|
||||||
|
|
||||||
|
#include "platform/nrf52/gpio.h"
|
||||||
|
#include "platform/nrf52/spi.h"
|
||||||
|
#include "platform/nrf52/InterruptHandler.h"
|
||||||
|
#include "platform/nrf52/InterruptGuardian.h"
|
||||||
|
|
||||||
|
using namespace pinetime::platform;
|
||||||
|
|
||||||
|
uint8_t buf[] = "Test";
|
||||||
|
|
||||||
|
nrf52::Gpio led_1(17);
|
||||||
|
nrf52::Gpio lcd_chip_select(25);
|
||||||
|
|
||||||
|
cm4::InterruptGuardian cm4::InterruptGuardian::instance;
|
||||||
|
nrf52::InterruptGuardian nrf52::InterruptGuardian::instance;
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
cm4::InterruptGuardian::enable_interrupts();
|
||||||
|
nrf52::Spi spi_0(0, 2, 3, 4, lcd_chip_select);
|
||||||
|
while(1) {
|
||||||
|
spi_0.send(buf, sizeof(buf));
|
||||||
|
led_1.toggle();
|
||||||
|
}
|
||||||
|
}
|
37
src/application/st7789_lcd/main.cc
Normal file
37
src/application/st7789_lcd/main.cc
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
#include "platform/cm4/InterruptHandler.h"
|
||||||
|
#include "platform/cm4/InterruptGuardian.h"
|
||||||
|
|
||||||
|
#include "platform/nrf52/gpio.h"
|
||||||
|
#include "platform/nrf52/gpiote.h"
|
||||||
|
#include "platform/nrf52/spi.h"
|
||||||
|
#include "platform/nrf52/InterruptHandler.h"
|
||||||
|
#include "platform/nrf52/InterruptGuardian.h"
|
||||||
|
#include "st7789.h"
|
||||||
|
|
||||||
|
using namespace pinetime::platform;
|
||||||
|
|
||||||
|
nrf52::Gpio led_1(17);
|
||||||
|
|
||||||
|
nrf52::Gpio lcd_reset(26);
|
||||||
|
nrf52::Gpio lcd_data_command(18);
|
||||||
|
nrf52::Gpio lcd_backlight(23);
|
||||||
|
nrf52::Gpio lcd_chip_select(25);
|
||||||
|
nrf52::Spi lcd_spi(0, 2, 3, 4, lcd_chip_select);
|
||||||
|
|
||||||
|
St7789 lcd(lcd_spi, lcd_reset, lcd_data_command, lcd_backlight);
|
||||||
|
|
||||||
|
cm4::InterruptGuardian cm4::InterruptGuardian::instance;
|
||||||
|
nrf52::InterruptGuardian nrf52::InterruptGuardian::instance;
|
||||||
|
|
||||||
|
// GPIO events
|
||||||
|
nrf52::Gpiote gpiote;
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
cm4::InterruptGuardian::enable_interrupts();
|
||||||
|
lcd.init();
|
||||||
|
lcd.clear(0);
|
||||||
|
while(true) {
|
||||||
|
led_1.toggle();
|
||||||
|
}
|
||||||
|
}
|
27
src/delay.cc
Normal file
27
src/delay.cc
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
#include "delay.h"
|
||||||
|
|
||||||
|
using namespace pinetime;
|
||||||
|
using namespace pinetime::virtual_timer;
|
||||||
|
|
||||||
|
Delay::Delay()
|
||||||
|
: VirtualTimer(0)
|
||||||
|
, pause(false)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void Delay::ms(uint64_t time_ms)
|
||||||
|
{
|
||||||
|
this->pause = true;
|
||||||
|
this->timer_set_period_ms(time_ms);
|
||||||
|
this->timer_enable();
|
||||||
|
while(this->pause) {
|
||||||
|
// FIXME: Low power
|
||||||
|
asm volatile("nop");
|
||||||
|
}
|
||||||
|
this->timer_disable();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Delay::notification()
|
||||||
|
{
|
||||||
|
this->pause = false;
|
||||||
|
}
|
25
src/delay.h
Normal file
25
src/delay.h
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
#ifndef __DELAY_H__
|
||||||
|
#define __DELAY_H__
|
||||||
|
|
||||||
|
#include "virtual_timer/VirtualTimer.h"
|
||||||
|
|
||||||
|
namespace pinetime
|
||||||
|
{
|
||||||
|
|
||||||
|
class Delay
|
||||||
|
: public pinetime::virtual_timer::VirtualTimer
|
||||||
|
{
|
||||||
|
|
||||||
|
public:
|
||||||
|
Delay();
|
||||||
|
void ms(uint64_t);
|
||||||
|
|
||||||
|
void notification();
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool pause;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
67
src/driver.c
67
src/driver.c
@@ -1,67 +0,0 @@
|
|||||||
#include <stdlib.h>
|
|
||||||
#include <assert.h>
|
|
||||||
|
|
||||||
#include "driver.h"
|
|
||||||
|
|
||||||
int drv_open(const struct driver *drv)
|
|
||||||
{
|
|
||||||
int res = -1;
|
|
||||||
assert(drv != NULL);
|
|
||||||
|
|
||||||
if(drv->fp->open) {
|
|
||||||
res = drv->fp->open(drv);
|
|
||||||
}
|
|
||||||
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
int drv_close(const struct driver *drv)
|
|
||||||
{
|
|
||||||
int res = -1;
|
|
||||||
assert(drv != NULL);
|
|
||||||
|
|
||||||
if(drv->fp->close) {
|
|
||||||
res = drv->fp->close(drv);
|
|
||||||
}
|
|
||||||
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
int drv_read(const struct driver *drv, char *buffer, unsigned int length)
|
|
||||||
{
|
|
||||||
int res = -1;
|
|
||||||
assert(drv != NULL);
|
|
||||||
|
|
||||||
if(drv->fp->read) {
|
|
||||||
res = drv->fp->read(drv, buffer, length);
|
|
||||||
}
|
|
||||||
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
int drv_write(const struct driver *drv, const char *buffer, unsigned int length)
|
|
||||||
{
|
|
||||||
int res = -1;
|
|
||||||
assert(drv != NULL);
|
|
||||||
|
|
||||||
if(drv->fp->write) {
|
|
||||||
res = drv->fp->write(drv, buffer, length);
|
|
||||||
}
|
|
||||||
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
int drv_ioctl(const struct driver *drv, unsigned int cmd, unsigned int argc, ...)
|
|
||||||
{
|
|
||||||
int res = -1;
|
|
||||||
assert(drv != NULL);
|
|
||||||
|
|
||||||
if(drv->fp->ioctl) {
|
|
||||||
va_list args;
|
|
||||||
va_start(args, argc);
|
|
||||||
res = drv->fp->ioctl(drv, cmd, argc, args);
|
|
||||||
va_end(args);
|
|
||||||
}
|
|
||||||
|
|
||||||
return res;
|
|
||||||
}
|
|
14
src/platform/cm4/InterruptGuardian.cc
Normal file
14
src/platform/cm4/InterruptGuardian.cc
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
#include "platform/cm4/InterruptHandler.h"
|
||||||
|
#include "platform/cm4/InterruptGuardian.h"
|
||||||
|
|
||||||
|
using namespace pinetime::platform::cm4;
|
||||||
|
|
||||||
|
InterruptGuardian::InterruptGuardian()
|
||||||
|
{
|
||||||
|
disable_interrupts();
|
||||||
|
}
|
||||||
|
|
||||||
|
void InterruptGuardian::register_handler(Cm4IrqN irq_nr, InterruptHandler &handler)
|
||||||
|
{
|
||||||
|
this->cm4_vector[irq_nr] = &handler;
|
||||||
|
}
|
59
src/platform/cm4/InterruptGuardian.h
Normal file
59
src/platform/cm4/InterruptGuardian.h
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
#ifndef __PINETIME_PLATFORM_CM4_INTERRUPTGUARDIAN_H__
|
||||||
|
#define __PINETIME_PLATFORM_CM4_INTERRUPTGUARDIAN_H__
|
||||||
|
|
||||||
|
#include <array>
|
||||||
|
|
||||||
|
extern "C" {
|
||||||
|
#include "nrf52.h"
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace pinetime::platform::cm4 {
|
||||||
|
|
||||||
|
class InterruptGuardian
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
InterruptGuardian();
|
||||||
|
|
||||||
|
enum Cm4IrqN {
|
||||||
|
RESET_IRQ = 0, //!< -15 Reset Vector, invoked on Power up and warm reset
|
||||||
|
NON_MASKABLE_INT_IRQ, //!< -14 Non maskable Interrupt, cannot be stopped or preempted
|
||||||
|
HARD_FAULT_IRQ, //!< -13 Hard Fault, all classes of Fault
|
||||||
|
MEMORY_MANAGEMENT_IRQ, //!< -12 Memory Management, MPU mismatch, including Access Violation and No Match
|
||||||
|
BUS_FAULT_IRQ, //!< -11 Bus Fault, Pre-Fetch-, Memory Access Fault, other address/memory related Fault
|
||||||
|
USAGE_FAULT_IRQ, //!< -10 Usage Fault, i.e. Undef Instruction, Illegal State Transition
|
||||||
|
SV_CALL_IRQ, //!< -5 System Service Call via SVC instruction
|
||||||
|
DEBUG_MONITOR_IRQ, //!< -4 Debug Monitor
|
||||||
|
PEND_SV_IRQ, //!< -2 Pendable request for system service
|
||||||
|
SYS_TICK_IRQ, //!< -1 System Tick Timer
|
||||||
|
};
|
||||||
|
|
||||||
|
private:
|
||||||
|
enum {
|
||||||
|
CM4_HANDLER_COUNT = SYS_TICK_IRQ + 1,
|
||||||
|
};
|
||||||
|
|
||||||
|
public:
|
||||||
|
static inline void enable_interrupts() { asm volatile("cpsie i"); }
|
||||||
|
static inline void disable_interrupts() { asm volatile("cpsid i"); }
|
||||||
|
static inline bool suspend_interrupts()
|
||||||
|
{
|
||||||
|
uint32_t mask;
|
||||||
|
asm volatile("mrs %0, primask" : "=r" (mask));
|
||||||
|
asm volatile("cpsid i");
|
||||||
|
return(mask & 0x01);
|
||||||
|
}
|
||||||
|
static inline void resume_interrupts(bool status)
|
||||||
|
{
|
||||||
|
asm volatile ("msr primask, %0" : : "r" (status) : "memory");
|
||||||
|
}
|
||||||
|
|
||||||
|
void register_handler(Cm4IrqN irq_nr, InterruptHandler &);
|
||||||
|
|
||||||
|
static InterruptGuardian instance;
|
||||||
|
|
||||||
|
std::array<InterruptHandler *, CM4_HANDLER_COUNT> cm4_vector;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
26
src/platform/cm4/InterruptHandler.cc
Normal file
26
src/platform/cm4/InterruptHandler.cc
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
#include <assert.h>
|
||||||
|
|
||||||
|
#include "platform/cm4/InterruptHandler.h"
|
||||||
|
#include "platform/cm4/InterruptGuardian.h"
|
||||||
|
|
||||||
|
using namespace pinetime::platform::cm4;
|
||||||
|
|
||||||
|
InterruptHandler::InterruptHandler(uint32_t irq_nr)
|
||||||
|
{
|
||||||
|
InterruptGuardian::instance.register_handler(static_cast<InterruptGuardian::Cm4IrqN>(irq_nr), *this);
|
||||||
|
}
|
||||||
|
|
||||||
|
void InterruptHandler::handle()
|
||||||
|
{
|
||||||
|
assert(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
void InterruptHandler::enable()
|
||||||
|
{
|
||||||
|
assert(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
void InterruptHandler::disable()
|
||||||
|
{
|
||||||
|
assert(false);
|
||||||
|
}
|
22
src/platform/cm4/InterruptHandler.h
Normal file
22
src/platform/cm4/InterruptHandler.h
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
#ifndef __PINETIME_PLATFORM_CM4_INTERRUPTHANDLER_H__
|
||||||
|
#define __PINETIME_PLATFORM_CM4_INTERRUPTHANDLER_H__
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
|
#include "interrupt_interface.h"
|
||||||
|
|
||||||
|
namespace pinetime::platform::cm4 {
|
||||||
|
|
||||||
|
class InterruptHandler : public pinetime::interfaces::InterruptHandlerInterface
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
InterruptHandler(uint32_t);
|
||||||
|
|
||||||
|
void handle() override;
|
||||||
|
void enable() override;
|
||||||
|
void disable() override;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
15
src/platform/cm4/InterruptLock.cc
Normal file
15
src/platform/cm4/InterruptLock.cc
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
#include "platform/cm4/InterruptHandler.h"
|
||||||
|
#include "platform/cm4/InterruptGuardian.h"
|
||||||
|
#include "platform/cm4/InterruptLock.h"
|
||||||
|
|
||||||
|
using namespace pinetime::platform::cm4;
|
||||||
|
|
||||||
|
InterruptLock::InterruptLock()
|
||||||
|
{
|
||||||
|
this->state = InterruptGuardian::suspend_interrupts();
|
||||||
|
}
|
||||||
|
|
||||||
|
InterruptLock::~InterruptLock()
|
||||||
|
{
|
||||||
|
InterruptGuardian::resume_interrupts(this->state);
|
||||||
|
}
|
18
src/platform/cm4/InterruptLock.h
Normal file
18
src/platform/cm4/InterruptLock.h
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
#ifndef __PLATFORM_CM$_INTERRUPTLOCK_H__
|
||||||
|
#define __PLATFORM_CM$_INTERRUPTLOCK_H__
|
||||||
|
|
||||||
|
namespace pinetime::platform::cm4 {
|
||||||
|
|
||||||
|
class InterruptLock
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
InterruptLock();
|
||||||
|
~InterruptLock();
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool state;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
38
src/platform/cm4/SystemTick.cc
Normal file
38
src/platform/cm4/SystemTick.cc
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
extern "C" {
|
||||||
|
#include "nrf52.h"
|
||||||
|
}
|
||||||
|
|
||||||
|
#include "virtual_timer/VirtualTimerDistributor.h"
|
||||||
|
#include "platform/cm4/InterruptHandler.h"
|
||||||
|
#include "platform/cm4/InterruptGuardian.h"
|
||||||
|
#include "platform/cm4/SystemTick.h"
|
||||||
|
|
||||||
|
using namespace pinetime::platform::cm4;
|
||||||
|
using namespace pinetime::virtual_timer;
|
||||||
|
|
||||||
|
SystemTick::SystemTick()
|
||||||
|
: InterruptHandler(InterruptGuardian::Cm4IrqN::SYS_TICK_IRQ)
|
||||||
|
, sys_tick(0)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void SystemTick::handle()
|
||||||
|
{
|
||||||
|
this->sys_tick++;
|
||||||
|
VirtualTimerDistributor::instance().notify(this->sys_tick);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SystemTick::enable_timer()
|
||||||
|
{
|
||||||
|
SysTick_Config(SystemCoreClock / 1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SystemTick::disable_timer()
|
||||||
|
{
|
||||||
|
SysTick->CTRL = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint64_t SystemTick::tick()
|
||||||
|
{
|
||||||
|
return this->sys_tick;
|
||||||
|
}
|
36
src/platform/cm4/SystemTick.h
Normal file
36
src/platform/cm4/SystemTick.h
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
#ifndef __PLATFORM_CM4_SYSTEMTICK_H__
|
||||||
|
#define __PLATFORM_CM4_SYSTEMTICK_H__
|
||||||
|
|
||||||
|
#include "HwTimerInterface.h"
|
||||||
|
#include "platform/cm4/InterruptHandler.h"
|
||||||
|
|
||||||
|
namespace pinetime::platform::cm4
|
||||||
|
{
|
||||||
|
class SystemTick;
|
||||||
|
}
|
||||||
|
extern pinetime::platform::cm4::SystemTick system_tick;
|
||||||
|
|
||||||
|
namespace pinetime::platform::cm4
|
||||||
|
{
|
||||||
|
class SystemTick
|
||||||
|
: public pinetime::platform::cm4::InterruptHandler
|
||||||
|
, public pinetime::interfaces::HwTimerInterface
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
SystemTick();
|
||||||
|
|
||||||
|
static inline SystemTick & instance() { return system_tick; }
|
||||||
|
|
||||||
|
void enable_timer() override;
|
||||||
|
void disable_timer() override;
|
||||||
|
uint64_t tick() override;
|
||||||
|
|
||||||
|
void handle() override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
uint64_t sys_tick;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
BIN
src/platform/cm4/cmsis/dsp/ARM/arm_cortexM4l_math.lib
Normal file
BIN
src/platform/cm4/cmsis/dsp/ARM/arm_cortexM4l_math.lib
Normal file
Binary file not shown.
BIN
src/platform/cm4/cmsis/dsp/ARM/arm_cortexM4lf_math.lib
Normal file
BIN
src/platform/cm4/cmsis/dsp/ARM/arm_cortexM4lf_math.lib
Normal file
Binary file not shown.
BIN
src/platform/cm4/cmsis/dsp/GCC/libarm_cortexM4l_math.a
Normal file
BIN
src/platform/cm4/cmsis/dsp/GCC/libarm_cortexM4l_math.a
Normal file
Binary file not shown.
BIN
src/platform/cm4/cmsis/dsp/GCC/libarm_cortexM4lf_math.a
Normal file
BIN
src/platform/cm4/cmsis/dsp/GCC/libarm_cortexM4lf_math.a
Normal file
Binary file not shown.
28
src/platform/cm4/cmsis/dsp/license.txt
Normal file
28
src/platform/cm4/cmsis/dsp/license.txt
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
All pre-build libraries contained in the folders "ARM" and "GCC"
|
||||||
|
are guided by the following license:
|
||||||
|
|
||||||
|
Copyright (C) 2009-2014 ARM Limited.
|
||||||
|
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 following disclaimer.
|
||||||
|
- Redistributions in binary form must reproduce the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer in the
|
||||||
|
documentation and/or other materials provided with the distribution.
|
||||||
|
- Neither the name of ARM nor the names of its contributors may be used
|
||||||
|
to endorse or promote products derived from this software without
|
||||||
|
specific prior written permission.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
|
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS 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.
|
136
src/platform/cm4/cmsis/include/arm_common_tables.h
Normal file
136
src/platform/cm4/cmsis/include/arm_common_tables.h
Normal file
@@ -0,0 +1,136 @@
|
|||||||
|
/* ----------------------------------------------------------------------
|
||||||
|
* Copyright (C) 2010-2014 ARM Limited. All rights reserved.
|
||||||
|
*
|
||||||
|
* $Date: 19. October 2015
|
||||||
|
* $Revision: V.1.4.5 a
|
||||||
|
*
|
||||||
|
* Project: CMSIS DSP Library
|
||||||
|
* Title: arm_common_tables.h
|
||||||
|
*
|
||||||
|
* Description: This file has extern declaration for common tables like Bitreverse, reciprocal etc which are used across different functions
|
||||||
|
*
|
||||||
|
* Target Processor: Cortex-M4/Cortex-M3
|
||||||
|
*
|
||||||
|
* 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 following disclaimer.
|
||||||
|
* - Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in
|
||||||
|
* the documentation and/or other materials provided with the
|
||||||
|
* distribution.
|
||||||
|
* - Neither the name of ARM LIMITED nor the names of its contributors
|
||||||
|
* may be used to endorse or promote products derived from this
|
||||||
|
* software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||||
|
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||||
|
* COPYRIGHT OWNER OR CONTRIBUTORS 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 _ARM_COMMON_TABLES_H
|
||||||
|
#define _ARM_COMMON_TABLES_H
|
||||||
|
|
||||||
|
#include "arm_math.h"
|
||||||
|
|
||||||
|
extern const uint16_t armBitRevTable[1024];
|
||||||
|
extern const q15_t armRecipTableQ15[64];
|
||||||
|
extern const q31_t armRecipTableQ31[64];
|
||||||
|
/* extern const q31_t realCoefAQ31[1024]; */
|
||||||
|
/* extern const q31_t realCoefBQ31[1024]; */
|
||||||
|
extern const float32_t twiddleCoef_16[32];
|
||||||
|
extern const float32_t twiddleCoef_32[64];
|
||||||
|
extern const float32_t twiddleCoef_64[128];
|
||||||
|
extern const float32_t twiddleCoef_128[256];
|
||||||
|
extern const float32_t twiddleCoef_256[512];
|
||||||
|
extern const float32_t twiddleCoef_512[1024];
|
||||||
|
extern const float32_t twiddleCoef_1024[2048];
|
||||||
|
extern const float32_t twiddleCoef_2048[4096];
|
||||||
|
extern const float32_t twiddleCoef_4096[8192];
|
||||||
|
#define twiddleCoef twiddleCoef_4096
|
||||||
|
extern const q31_t twiddleCoef_16_q31[24];
|
||||||
|
extern const q31_t twiddleCoef_32_q31[48];
|
||||||
|
extern const q31_t twiddleCoef_64_q31[96];
|
||||||
|
extern const q31_t twiddleCoef_128_q31[192];
|
||||||
|
extern const q31_t twiddleCoef_256_q31[384];
|
||||||
|
extern const q31_t twiddleCoef_512_q31[768];
|
||||||
|
extern const q31_t twiddleCoef_1024_q31[1536];
|
||||||
|
extern const q31_t twiddleCoef_2048_q31[3072];
|
||||||
|
extern const q31_t twiddleCoef_4096_q31[6144];
|
||||||
|
extern const q15_t twiddleCoef_16_q15[24];
|
||||||
|
extern const q15_t twiddleCoef_32_q15[48];
|
||||||
|
extern const q15_t twiddleCoef_64_q15[96];
|
||||||
|
extern const q15_t twiddleCoef_128_q15[192];
|
||||||
|
extern const q15_t twiddleCoef_256_q15[384];
|
||||||
|
extern const q15_t twiddleCoef_512_q15[768];
|
||||||
|
extern const q15_t twiddleCoef_1024_q15[1536];
|
||||||
|
extern const q15_t twiddleCoef_2048_q15[3072];
|
||||||
|
extern const q15_t twiddleCoef_4096_q15[6144];
|
||||||
|
extern const float32_t twiddleCoef_rfft_32[32];
|
||||||
|
extern const float32_t twiddleCoef_rfft_64[64];
|
||||||
|
extern const float32_t twiddleCoef_rfft_128[128];
|
||||||
|
extern const float32_t twiddleCoef_rfft_256[256];
|
||||||
|
extern const float32_t twiddleCoef_rfft_512[512];
|
||||||
|
extern const float32_t twiddleCoef_rfft_1024[1024];
|
||||||
|
extern const float32_t twiddleCoef_rfft_2048[2048];
|
||||||
|
extern const float32_t twiddleCoef_rfft_4096[4096];
|
||||||
|
|
||||||
|
|
||||||
|
/* floating-point bit reversal tables */
|
||||||
|
#define ARMBITREVINDEXTABLE__16_TABLE_LENGTH ((uint16_t)20 )
|
||||||
|
#define ARMBITREVINDEXTABLE__32_TABLE_LENGTH ((uint16_t)48 )
|
||||||
|
#define ARMBITREVINDEXTABLE__64_TABLE_LENGTH ((uint16_t)56 )
|
||||||
|
#define ARMBITREVINDEXTABLE_128_TABLE_LENGTH ((uint16_t)208 )
|
||||||
|
#define ARMBITREVINDEXTABLE_256_TABLE_LENGTH ((uint16_t)440 )
|
||||||
|
#define ARMBITREVINDEXTABLE_512_TABLE_LENGTH ((uint16_t)448 )
|
||||||
|
#define ARMBITREVINDEXTABLE1024_TABLE_LENGTH ((uint16_t)1800)
|
||||||
|
#define ARMBITREVINDEXTABLE2048_TABLE_LENGTH ((uint16_t)3808)
|
||||||
|
#define ARMBITREVINDEXTABLE4096_TABLE_LENGTH ((uint16_t)4032)
|
||||||
|
|
||||||
|
extern const uint16_t armBitRevIndexTable16[ARMBITREVINDEXTABLE__16_TABLE_LENGTH];
|
||||||
|
extern const uint16_t armBitRevIndexTable32[ARMBITREVINDEXTABLE__32_TABLE_LENGTH];
|
||||||
|
extern const uint16_t armBitRevIndexTable64[ARMBITREVINDEXTABLE__64_TABLE_LENGTH];
|
||||||
|
extern const uint16_t armBitRevIndexTable128[ARMBITREVINDEXTABLE_128_TABLE_LENGTH];
|
||||||
|
extern const uint16_t armBitRevIndexTable256[ARMBITREVINDEXTABLE_256_TABLE_LENGTH];
|
||||||
|
extern const uint16_t armBitRevIndexTable512[ARMBITREVINDEXTABLE_512_TABLE_LENGTH];
|
||||||
|
extern const uint16_t armBitRevIndexTable1024[ARMBITREVINDEXTABLE1024_TABLE_LENGTH];
|
||||||
|
extern const uint16_t armBitRevIndexTable2048[ARMBITREVINDEXTABLE2048_TABLE_LENGTH];
|
||||||
|
extern const uint16_t armBitRevIndexTable4096[ARMBITREVINDEXTABLE4096_TABLE_LENGTH];
|
||||||
|
|
||||||
|
/* fixed-point bit reversal tables */
|
||||||
|
#define ARMBITREVINDEXTABLE_FIXED___16_TABLE_LENGTH ((uint16_t)12 )
|
||||||
|
#define ARMBITREVINDEXTABLE_FIXED___32_TABLE_LENGTH ((uint16_t)24 )
|
||||||
|
#define ARMBITREVINDEXTABLE_FIXED___64_TABLE_LENGTH ((uint16_t)56 )
|
||||||
|
#define ARMBITREVINDEXTABLE_FIXED__128_TABLE_LENGTH ((uint16_t)112 )
|
||||||
|
#define ARMBITREVINDEXTABLE_FIXED__256_TABLE_LENGTH ((uint16_t)240 )
|
||||||
|
#define ARMBITREVINDEXTABLE_FIXED__512_TABLE_LENGTH ((uint16_t)480 )
|
||||||
|
#define ARMBITREVINDEXTABLE_FIXED_1024_TABLE_LENGTH ((uint16_t)992 )
|
||||||
|
#define ARMBITREVINDEXTABLE_FIXED_2048_TABLE_LENGTH ((uint16_t)1984)
|
||||||
|
#define ARMBITREVINDEXTABLE_FIXED_4096_TABLE_LENGTH ((uint16_t)4032)
|
||||||
|
|
||||||
|
extern const uint16_t armBitRevIndexTable_fixed_16[ARMBITREVINDEXTABLE_FIXED___16_TABLE_LENGTH];
|
||||||
|
extern const uint16_t armBitRevIndexTable_fixed_32[ARMBITREVINDEXTABLE_FIXED___32_TABLE_LENGTH];
|
||||||
|
extern const uint16_t armBitRevIndexTable_fixed_64[ARMBITREVINDEXTABLE_FIXED___64_TABLE_LENGTH];
|
||||||
|
extern const uint16_t armBitRevIndexTable_fixed_128[ARMBITREVINDEXTABLE_FIXED__128_TABLE_LENGTH];
|
||||||
|
extern const uint16_t armBitRevIndexTable_fixed_256[ARMBITREVINDEXTABLE_FIXED__256_TABLE_LENGTH];
|
||||||
|
extern const uint16_t armBitRevIndexTable_fixed_512[ARMBITREVINDEXTABLE_FIXED__512_TABLE_LENGTH];
|
||||||
|
extern const uint16_t armBitRevIndexTable_fixed_1024[ARMBITREVINDEXTABLE_FIXED_1024_TABLE_LENGTH];
|
||||||
|
extern const uint16_t armBitRevIndexTable_fixed_2048[ARMBITREVINDEXTABLE_FIXED_2048_TABLE_LENGTH];
|
||||||
|
extern const uint16_t armBitRevIndexTable_fixed_4096[ARMBITREVINDEXTABLE_FIXED_4096_TABLE_LENGTH];
|
||||||
|
|
||||||
|
/* Tables for Fast Math Sine and Cosine */
|
||||||
|
extern const float32_t sinTable_f32[FAST_MATH_TABLE_SIZE + 1];
|
||||||
|
extern const q31_t sinTable_q31[FAST_MATH_TABLE_SIZE + 1];
|
||||||
|
extern const q15_t sinTable_q15[FAST_MATH_TABLE_SIZE + 1];
|
||||||
|
|
||||||
|
#endif /* ARM_COMMON_TABLES_H */
|
79
src/platform/cm4/cmsis/include/arm_const_structs.h
Normal file
79
src/platform/cm4/cmsis/include/arm_const_structs.h
Normal file
@@ -0,0 +1,79 @@
|
|||||||
|
/* ----------------------------------------------------------------------
|
||||||
|
* Copyright (C) 2010-2014 ARM Limited. All rights reserved.
|
||||||
|
*
|
||||||
|
* $Date: 19. March 2015
|
||||||
|
* $Revision: V.1.4.5
|
||||||
|
*
|
||||||
|
* Project: CMSIS DSP Library
|
||||||
|
* Title: arm_const_structs.h
|
||||||
|
*
|
||||||
|
* Description: This file has constant structs that are initialized for
|
||||||
|
* user convenience. For example, some can be given as
|
||||||
|
* arguments to the arm_cfft_f32() function.
|
||||||
|
*
|
||||||
|
* Target Processor: Cortex-M4/Cortex-M3
|
||||||
|
*
|
||||||
|
* 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 following disclaimer.
|
||||||
|
* - Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in
|
||||||
|
* the documentation and/or other materials provided with the
|
||||||
|
* distribution.
|
||||||
|
* - Neither the name of ARM LIMITED nor the names of its contributors
|
||||||
|
* may be used to endorse or promote products derived from this
|
||||||
|
* software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||||
|
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||||
|
* COPYRIGHT OWNER OR CONTRIBUTORS 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 _ARM_CONST_STRUCTS_H
|
||||||
|
#define _ARM_CONST_STRUCTS_H
|
||||||
|
|
||||||
|
#include "arm_math.h"
|
||||||
|
#include "arm_common_tables.h"
|
||||||
|
|
||||||
|
extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len16;
|
||||||
|
extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len32;
|
||||||
|
extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len64;
|
||||||
|
extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len128;
|
||||||
|
extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len256;
|
||||||
|
extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len512;
|
||||||
|
extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len1024;
|
||||||
|
extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len2048;
|
||||||
|
extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len4096;
|
||||||
|
|
||||||
|
extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len16;
|
||||||
|
extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len32;
|
||||||
|
extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len64;
|
||||||
|
extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len128;
|
||||||
|
extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len256;
|
||||||
|
extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len512;
|
||||||
|
extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len1024;
|
||||||
|
extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len2048;
|
||||||
|
extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len4096;
|
||||||
|
|
||||||
|
extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len16;
|
||||||
|
extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len32;
|
||||||
|
extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len64;
|
||||||
|
extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len128;
|
||||||
|
extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len256;
|
||||||
|
extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len512;
|
||||||
|
extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len1024;
|
||||||
|
extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len2048;
|
||||||
|
extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len4096;
|
||||||
|
|
||||||
|
#endif
|
7030
src/platform/cm4/cmsis/include/arm_math.h
Normal file
7030
src/platform/cm4/cmsis/include/arm_math.h
Normal file
File diff suppressed because it is too large
Load Diff
734
src/platform/cm4/cmsis/include/cmsis_armcc.h
Normal file
734
src/platform/cm4/cmsis/include/cmsis_armcc.h
Normal file
@@ -0,0 +1,734 @@
|
|||||||
|
/**************************************************************************//**
|
||||||
|
* @file cmsis_armcc.h
|
||||||
|
* @brief CMSIS Cortex-M Core Function/Instruction Header File
|
||||||
|
* @version V4.30
|
||||||
|
* @date 20. October 2015
|
||||||
|
******************************************************************************/
|
||||||
|
/* Copyright (c) 2009 - 2015 ARM LIMITED
|
||||||
|
|
||||||
|
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 following disclaimer.
|
||||||
|
- Redistributions in binary form must reproduce the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer in the
|
||||||
|
documentation and/or other materials provided with the distribution.
|
||||||
|
- Neither the name of ARM nor the names of its contributors may be used
|
||||||
|
to endorse or promote products derived from this software without
|
||||||
|
specific prior written permission.
|
||||||
|
*
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
|
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS 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 __CMSIS_ARMCC_H
|
||||||
|
#define __CMSIS_ARMCC_H
|
||||||
|
|
||||||
|
|
||||||
|
#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 400677)
|
||||||
|
#error "Please use ARM Compiler Toolchain V4.0.677 or later!"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* ########################### Core Function Access ########################### */
|
||||||
|
/** \ingroup CMSIS_Core_FunctionInterface
|
||||||
|
\defgroup CMSIS_Core_RegAccFunctions CMSIS Core Register Access Functions
|
||||||
|
@{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* intrinsic void __enable_irq(); */
|
||||||
|
/* intrinsic void __disable_irq(); */
|
||||||
|
|
||||||
|
/**
|
||||||
|
\brief Get Control Register
|
||||||
|
\details Returns the content of the Control Register.
|
||||||
|
\return Control Register value
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE uint32_t __get_CONTROL(void)
|
||||||
|
{
|
||||||
|
register uint32_t __regControl __ASM("control");
|
||||||
|
return(__regControl);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
\brief Set Control Register
|
||||||
|
\details Writes the given value to the Control Register.
|
||||||
|
\param [in] control Control Register value to set
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE void __set_CONTROL(uint32_t control)
|
||||||
|
{
|
||||||
|
register uint32_t __regControl __ASM("control");
|
||||||
|
__regControl = control;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
\brief Get IPSR Register
|
||||||
|
\details Returns the content of the IPSR Register.
|
||||||
|
\return IPSR Register value
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE uint32_t __get_IPSR(void)
|
||||||
|
{
|
||||||
|
register uint32_t __regIPSR __ASM("ipsr");
|
||||||
|
return(__regIPSR);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
\brief Get APSR Register
|
||||||
|
\details Returns the content of the APSR Register.
|
||||||
|
\return APSR Register value
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE uint32_t __get_APSR(void)
|
||||||
|
{
|
||||||
|
register uint32_t __regAPSR __ASM("apsr");
|
||||||
|
return(__regAPSR);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
\brief Get xPSR Register
|
||||||
|
\details Returns the content of the xPSR Register.
|
||||||
|
\return xPSR Register value
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE uint32_t __get_xPSR(void)
|
||||||
|
{
|
||||||
|
register uint32_t __regXPSR __ASM("xpsr");
|
||||||
|
return(__regXPSR);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
\brief Get Process Stack Pointer
|
||||||
|
\details Returns the current value of the Process Stack Pointer (PSP).
|
||||||
|
\return PSP Register value
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE uint32_t __get_PSP(void)
|
||||||
|
{
|
||||||
|
register uint32_t __regProcessStackPointer __ASM("psp");
|
||||||
|
return(__regProcessStackPointer);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
\brief Set Process Stack Pointer
|
||||||
|
\details Assigns the given value to the Process Stack Pointer (PSP).
|
||||||
|
\param [in] topOfProcStack Process Stack Pointer value to set
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE void __set_PSP(uint32_t topOfProcStack)
|
||||||
|
{
|
||||||
|
register uint32_t __regProcessStackPointer __ASM("psp");
|
||||||
|
__regProcessStackPointer = topOfProcStack;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
\brief Get Main Stack Pointer
|
||||||
|
\details Returns the current value of the Main Stack Pointer (MSP).
|
||||||
|
\return MSP Register value
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE uint32_t __get_MSP(void)
|
||||||
|
{
|
||||||
|
register uint32_t __regMainStackPointer __ASM("msp");
|
||||||
|
return(__regMainStackPointer);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
\brief Set Main Stack Pointer
|
||||||
|
\details Assigns the given value to the Main Stack Pointer (MSP).
|
||||||
|
\param [in] topOfMainStack Main Stack Pointer value to set
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE void __set_MSP(uint32_t topOfMainStack)
|
||||||
|
{
|
||||||
|
register uint32_t __regMainStackPointer __ASM("msp");
|
||||||
|
__regMainStackPointer = topOfMainStack;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
\brief Get Priority Mask
|
||||||
|
\details Returns the current state of the priority mask bit from the Priority Mask Register.
|
||||||
|
\return Priority Mask value
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE uint32_t __get_PRIMASK(void)
|
||||||
|
{
|
||||||
|
register uint32_t __regPriMask __ASM("primask");
|
||||||
|
return(__regPriMask);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
\brief Set Priority Mask
|
||||||
|
\details Assigns the given value to the Priority Mask Register.
|
||||||
|
\param [in] priMask Priority Mask
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE void __set_PRIMASK(uint32_t priMask)
|
||||||
|
{
|
||||||
|
register uint32_t __regPriMask __ASM("primask");
|
||||||
|
__regPriMask = (priMask);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#if (__CORTEX_M >= 0x03U) || (__CORTEX_SC >= 300U)
|
||||||
|
|
||||||
|
/**
|
||||||
|
\brief Enable FIQ
|
||||||
|
\details Enables FIQ interrupts by clearing the F-bit in the CPSR.
|
||||||
|
Can only be executed in Privileged modes.
|
||||||
|
*/
|
||||||
|
#define __enable_fault_irq __enable_fiq
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
\brief Disable FIQ
|
||||||
|
\details Disables FIQ interrupts by setting the F-bit in the CPSR.
|
||||||
|
Can only be executed in Privileged modes.
|
||||||
|
*/
|
||||||
|
#define __disable_fault_irq __disable_fiq
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
\brief Get Base Priority
|
||||||
|
\details Returns the current value of the Base Priority register.
|
||||||
|
\return Base Priority register value
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE uint32_t __get_BASEPRI(void)
|
||||||
|
{
|
||||||
|
register uint32_t __regBasePri __ASM("basepri");
|
||||||
|
return(__regBasePri);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
\brief Set Base Priority
|
||||||
|
\details Assigns the given value to the Base Priority register.
|
||||||
|
\param [in] basePri Base Priority value to set
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE void __set_BASEPRI(uint32_t basePri)
|
||||||
|
{
|
||||||
|
register uint32_t __regBasePri __ASM("basepri");
|
||||||
|
__regBasePri = (basePri & 0xFFU);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
\brief Set Base Priority with condition
|
||||||
|
\details Assigns the given value to the Base Priority register only if BASEPRI masking is disabled,
|
||||||
|
or the new value increases the BASEPRI priority level.
|
||||||
|
\param [in] basePri Base Priority value to set
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE void __set_BASEPRI_MAX(uint32_t basePri)
|
||||||
|
{
|
||||||
|
register uint32_t __regBasePriMax __ASM("basepri_max");
|
||||||
|
__regBasePriMax = (basePri & 0xFFU);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
\brief Get Fault Mask
|
||||||
|
\details Returns the current value of the Fault Mask register.
|
||||||
|
\return Fault Mask register value
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE uint32_t __get_FAULTMASK(void)
|
||||||
|
{
|
||||||
|
register uint32_t __regFaultMask __ASM("faultmask");
|
||||||
|
return(__regFaultMask);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
\brief Set Fault Mask
|
||||||
|
\details Assigns the given value to the Fault Mask register.
|
||||||
|
\param [in] faultMask Fault Mask value to set
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE void __set_FAULTMASK(uint32_t faultMask)
|
||||||
|
{
|
||||||
|
register uint32_t __regFaultMask __ASM("faultmask");
|
||||||
|
__regFaultMask = (faultMask & (uint32_t)1);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* (__CORTEX_M >= 0x03U) || (__CORTEX_SC >= 300U) */
|
||||||
|
|
||||||
|
|
||||||
|
#if (__CORTEX_M == 0x04U) || (__CORTEX_M == 0x07U)
|
||||||
|
|
||||||
|
/**
|
||||||
|
\brief Get FPSCR
|
||||||
|
\details Returns the current value of the Floating Point Status/Control register.
|
||||||
|
\return Floating Point Status/Control register value
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE uint32_t __get_FPSCR(void)
|
||||||
|
{
|
||||||
|
#if (__FPU_PRESENT == 1U) && (__FPU_USED == 1U)
|
||||||
|
register uint32_t __regfpscr __ASM("fpscr");
|
||||||
|
return(__regfpscr);
|
||||||
|
#else
|
||||||
|
return(0U);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
\brief Set FPSCR
|
||||||
|
\details Assigns the given value to the Floating Point Status/Control register.
|
||||||
|
\param [in] fpscr Floating Point Status/Control value to set
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE void __set_FPSCR(uint32_t fpscr)
|
||||||
|
{
|
||||||
|
#if (__FPU_PRESENT == 1U) && (__FPU_USED == 1U)
|
||||||
|
register uint32_t __regfpscr __ASM("fpscr");
|
||||||
|
__regfpscr = (fpscr);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* (__CORTEX_M == 0x04U) || (__CORTEX_M == 0x07U) */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*@} end of CMSIS_Core_RegAccFunctions */
|
||||||
|
|
||||||
|
|
||||||
|
/* ########################## Core Instruction Access ######################### */
|
||||||
|
/** \defgroup CMSIS_Core_InstructionInterface CMSIS Core Instruction Interface
|
||||||
|
Access to dedicated instructions
|
||||||
|
@{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
\brief No Operation
|
||||||
|
\details No Operation does nothing. This instruction can be used for code alignment purposes.
|
||||||
|
*/
|
||||||
|
#define __NOP __nop
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
\brief Wait For Interrupt
|
||||||
|
\details Wait For Interrupt is a hint instruction that suspends execution until one of a number of events occurs.
|
||||||
|
*/
|
||||||
|
#define __WFI __wfi
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
\brief Wait For Event
|
||||||
|
\details Wait For Event is a hint instruction that permits the processor to enter
|
||||||
|
a low-power state until one of a number of events occurs.
|
||||||
|
*/
|
||||||
|
#define __WFE __wfe
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
\brief Send Event
|
||||||
|
\details Send Event is a hint instruction. It causes an event to be signaled to the CPU.
|
||||||
|
*/
|
||||||
|
#define __SEV __sev
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
\brief Instruction Synchronization Barrier
|
||||||
|
\details Instruction Synchronization Barrier flushes the pipeline in the processor,
|
||||||
|
so that all instructions following the ISB are fetched from cache or memory,
|
||||||
|
after the instruction has been completed.
|
||||||
|
*/
|
||||||
|
#define __ISB() do {\
|
||||||
|
__schedule_barrier();\
|
||||||
|
__isb(0xF);\
|
||||||
|
__schedule_barrier();\
|
||||||
|
} while (0U)
|
||||||
|
|
||||||
|
/**
|
||||||
|
\brief Data Synchronization Barrier
|
||||||
|
\details Acts as a special kind of Data Memory Barrier.
|
||||||
|
It completes when all explicit memory accesses before this instruction complete.
|
||||||
|
*/
|
||||||
|
#define __DSB() do {\
|
||||||
|
__schedule_barrier();\
|
||||||
|
__dsb(0xF);\
|
||||||
|
__schedule_barrier();\
|
||||||
|
} while (0U)
|
||||||
|
|
||||||
|
/**
|
||||||
|
\brief Data Memory Barrier
|
||||||
|
\details Ensures the apparent order of the explicit memory operations before
|
||||||
|
and after the instruction, without ensuring their completion.
|
||||||
|
*/
|
||||||
|
#define __DMB() do {\
|
||||||
|
__schedule_barrier();\
|
||||||
|
__dmb(0xF);\
|
||||||
|
__schedule_barrier();\
|
||||||
|
} while (0U)
|
||||||
|
|
||||||
|
/**
|
||||||
|
\brief Reverse byte order (32 bit)
|
||||||
|
\details Reverses the byte order in integer value.
|
||||||
|
\param [in] value Value to reverse
|
||||||
|
\return Reversed value
|
||||||
|
*/
|
||||||
|
#define __REV __rev
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
\brief Reverse byte order (16 bit)
|
||||||
|
\details Reverses the byte order in two unsigned short values.
|
||||||
|
\param [in] value Value to reverse
|
||||||
|
\return Reversed value
|
||||||
|
*/
|
||||||
|
#ifndef __NO_EMBEDDED_ASM
|
||||||
|
__attribute__((section(".rev16_text"))) __STATIC_INLINE __ASM uint32_t __REV16(uint32_t value)
|
||||||
|
{
|
||||||
|
rev16 r0, r0
|
||||||
|
bx lr
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
\brief Reverse byte order in signed short value
|
||||||
|
\details Reverses the byte order in a signed short value with sign extension to integer.
|
||||||
|
\param [in] value Value to reverse
|
||||||
|
\return Reversed value
|
||||||
|
*/
|
||||||
|
#ifndef __NO_EMBEDDED_ASM
|
||||||
|
__attribute__((section(".revsh_text"))) __STATIC_INLINE __ASM int32_t __REVSH(int32_t value)
|
||||||
|
{
|
||||||
|
revsh r0, r0
|
||||||
|
bx lr
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
\brief Rotate Right in unsigned value (32 bit)
|
||||||
|
\details Rotate Right (immediate) provides the value of the contents of a register rotated by a variable number of bits.
|
||||||
|
\param [in] value Value to rotate
|
||||||
|
\param [in] value Number of Bits to rotate
|
||||||
|
\return Rotated value
|
||||||
|
*/
|
||||||
|
#define __ROR __ror
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
\brief Breakpoint
|
||||||
|
\details Causes the processor to enter Debug state.
|
||||||
|
Debug tools can use this to investigate system state when the instruction at a particular address is reached.
|
||||||
|
\param [in] value is ignored by the processor.
|
||||||
|
If required, a debugger can use it to store additional information about the breakpoint.
|
||||||
|
*/
|
||||||
|
#define __BKPT(value) __breakpoint(value)
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
\brief Reverse bit order of value
|
||||||
|
\details Reverses the bit order of the given value.
|
||||||
|
\param [in] value Value to reverse
|
||||||
|
\return Reversed value
|
||||||
|
*/
|
||||||
|
#if (__CORTEX_M >= 0x03U) || (__CORTEX_SC >= 300U)
|
||||||
|
#define __RBIT __rbit
|
||||||
|
#else
|
||||||
|
__attribute__((always_inline)) __STATIC_INLINE uint32_t __RBIT(uint32_t value)
|
||||||
|
{
|
||||||
|
uint32_t result;
|
||||||
|
int32_t s = 4 /*sizeof(v)*/ * 8 - 1; /* extra shift needed at end */
|
||||||
|
|
||||||
|
result = value; /* r will be reversed bits of v; first get LSB of v */
|
||||||
|
for (value >>= 1U; value; value >>= 1U)
|
||||||
|
{
|
||||||
|
result <<= 1U;
|
||||||
|
result |= value & 1U;
|
||||||
|
s--;
|
||||||
|
}
|
||||||
|
result <<= s; /* shift when v's highest bits are zero */
|
||||||
|
return(result);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
\brief Count leading zeros
|
||||||
|
\details Counts the number of leading zeros of a data value.
|
||||||
|
\param [in] value Value to count the leading zeros
|
||||||
|
\return number of leading zeros in value
|
||||||
|
*/
|
||||||
|
#define __CLZ __clz
|
||||||
|
|
||||||
|
|
||||||
|
#if (__CORTEX_M >= 0x03U) || (__CORTEX_SC >= 300U)
|
||||||
|
|
||||||
|
/**
|
||||||
|
\brief LDR Exclusive (8 bit)
|
||||||
|
\details Executes a exclusive LDR instruction for 8 bit value.
|
||||||
|
\param [in] ptr Pointer to data
|
||||||
|
\return value of type uint8_t at (*ptr)
|
||||||
|
*/
|
||||||
|
#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 5060020)
|
||||||
|
#define __LDREXB(ptr) ((uint8_t ) __ldrex(ptr))
|
||||||
|
#else
|
||||||
|
#define __LDREXB(ptr) _Pragma("push") _Pragma("diag_suppress 3731") ((uint8_t ) __ldrex(ptr)) _Pragma("pop")
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
\brief LDR Exclusive (16 bit)
|
||||||
|
\details Executes a exclusive LDR instruction for 16 bit values.
|
||||||
|
\param [in] ptr Pointer to data
|
||||||
|
\return value of type uint16_t at (*ptr)
|
||||||
|
*/
|
||||||
|
#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 5060020)
|
||||||
|
#define __LDREXH(ptr) ((uint16_t) __ldrex(ptr))
|
||||||
|
#else
|
||||||
|
#define __LDREXH(ptr) _Pragma("push") _Pragma("diag_suppress 3731") ((uint16_t) __ldrex(ptr)) _Pragma("pop")
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
\brief LDR Exclusive (32 bit)
|
||||||
|
\details Executes a exclusive LDR instruction for 32 bit values.
|
||||||
|
\param [in] ptr Pointer to data
|
||||||
|
\return value of type uint32_t at (*ptr)
|
||||||
|
*/
|
||||||
|
#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 5060020)
|
||||||
|
#define __LDREXW(ptr) ((uint32_t ) __ldrex(ptr))
|
||||||
|
#else
|
||||||
|
#define __LDREXW(ptr) _Pragma("push") _Pragma("diag_suppress 3731") ((uint32_t ) __ldrex(ptr)) _Pragma("pop")
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
\brief STR Exclusive (8 bit)
|
||||||
|
\details Executes a exclusive STR instruction for 8 bit values.
|
||||||
|
\param [in] value Value to store
|
||||||
|
\param [in] ptr Pointer to location
|
||||||
|
\return 0 Function succeeded
|
||||||
|
\return 1 Function failed
|
||||||
|
*/
|
||||||
|
#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 5060020)
|
||||||
|
#define __STREXB(value, ptr) __strex(value, ptr)
|
||||||
|
#else
|
||||||
|
#define __STREXB(value, ptr) _Pragma("push") _Pragma("diag_suppress 3731") __strex(value, ptr) _Pragma("pop")
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
\brief STR Exclusive (16 bit)
|
||||||
|
\details Executes a exclusive STR instruction for 16 bit values.
|
||||||
|
\param [in] value Value to store
|
||||||
|
\param [in] ptr Pointer to location
|
||||||
|
\return 0 Function succeeded
|
||||||
|
\return 1 Function failed
|
||||||
|
*/
|
||||||
|
#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 5060020)
|
||||||
|
#define __STREXH(value, ptr) __strex(value, ptr)
|
||||||
|
#else
|
||||||
|
#define __STREXH(value, ptr) _Pragma("push") _Pragma("diag_suppress 3731") __strex(value, ptr) _Pragma("pop")
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
\brief STR Exclusive (32 bit)
|
||||||
|
\details Executes a exclusive STR instruction for 32 bit values.
|
||||||
|
\param [in] value Value to store
|
||||||
|
\param [in] ptr Pointer to location
|
||||||
|
\return 0 Function succeeded
|
||||||
|
\return 1 Function failed
|
||||||
|
*/
|
||||||
|
#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 5060020)
|
||||||
|
#define __STREXW(value, ptr) __strex(value, ptr)
|
||||||
|
#else
|
||||||
|
#define __STREXW(value, ptr) _Pragma("push") _Pragma("diag_suppress 3731") __strex(value, ptr) _Pragma("pop")
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
\brief Remove the exclusive lock
|
||||||
|
\details Removes the exclusive lock which is created by LDREX.
|
||||||
|
*/
|
||||||
|
#define __CLREX __clrex
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
\brief Signed Saturate
|
||||||
|
\details Saturates a signed value.
|
||||||
|
\param [in] value Value to be saturated
|
||||||
|
\param [in] sat Bit position to saturate to (1..32)
|
||||||
|
\return Saturated value
|
||||||
|
*/
|
||||||
|
#define __SSAT __ssat
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
\brief Unsigned Saturate
|
||||||
|
\details Saturates an unsigned value.
|
||||||
|
\param [in] value Value to be saturated
|
||||||
|
\param [in] sat Bit position to saturate to (0..31)
|
||||||
|
\return Saturated value
|
||||||
|
*/
|
||||||
|
#define __USAT __usat
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
\brief Rotate Right with Extend (32 bit)
|
||||||
|
\details Moves each bit of a bitstring right by one bit.
|
||||||
|
The carry input is shifted in at the left end of the bitstring.
|
||||||
|
\param [in] value Value to rotate
|
||||||
|
\return Rotated value
|
||||||
|
*/
|
||||||
|
#ifndef __NO_EMBEDDED_ASM
|
||||||
|
__attribute__((section(".rrx_text"))) __STATIC_INLINE __ASM uint32_t __RRX(uint32_t value)
|
||||||
|
{
|
||||||
|
rrx r0, r0
|
||||||
|
bx lr
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
\brief LDRT Unprivileged (8 bit)
|
||||||
|
\details Executes a Unprivileged LDRT instruction for 8 bit value.
|
||||||
|
\param [in] ptr Pointer to data
|
||||||
|
\return value of type uint8_t at (*ptr)
|
||||||
|
*/
|
||||||
|
#define __LDRBT(ptr) ((uint8_t ) __ldrt(ptr))
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
\brief LDRT Unprivileged (16 bit)
|
||||||
|
\details Executes a Unprivileged LDRT instruction for 16 bit values.
|
||||||
|
\param [in] ptr Pointer to data
|
||||||
|
\return value of type uint16_t at (*ptr)
|
||||||
|
*/
|
||||||
|
#define __LDRHT(ptr) ((uint16_t) __ldrt(ptr))
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
\brief LDRT Unprivileged (32 bit)
|
||||||
|
\details Executes a Unprivileged LDRT instruction for 32 bit values.
|
||||||
|
\param [in] ptr Pointer to data
|
||||||
|
\return value of type uint32_t at (*ptr)
|
||||||
|
*/
|
||||||
|
#define __LDRT(ptr) ((uint32_t ) __ldrt(ptr))
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
\brief STRT Unprivileged (8 bit)
|
||||||
|
\details Executes a Unprivileged STRT instruction for 8 bit values.
|
||||||
|
\param [in] value Value to store
|
||||||
|
\param [in] ptr Pointer to location
|
||||||
|
*/
|
||||||
|
#define __STRBT(value, ptr) __strt(value, ptr)
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
\brief STRT Unprivileged (16 bit)
|
||||||
|
\details Executes a Unprivileged STRT instruction for 16 bit values.
|
||||||
|
\param [in] value Value to store
|
||||||
|
\param [in] ptr Pointer to location
|
||||||
|
*/
|
||||||
|
#define __STRHT(value, ptr) __strt(value, ptr)
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
\brief STRT Unprivileged (32 bit)
|
||||||
|
\details Executes a Unprivileged STRT instruction for 32 bit values.
|
||||||
|
\param [in] value Value to store
|
||||||
|
\param [in] ptr Pointer to location
|
||||||
|
*/
|
||||||
|
#define __STRT(value, ptr) __strt(value, ptr)
|
||||||
|
|
||||||
|
#endif /* (__CORTEX_M >= 0x03U) || (__CORTEX_SC >= 300U) */
|
||||||
|
|
||||||
|
/*@}*/ /* end of group CMSIS_Core_InstructionInterface */
|
||||||
|
|
||||||
|
|
||||||
|
/* ################### Compiler specific Intrinsics ########################### */
|
||||||
|
/** \defgroup CMSIS_SIMD_intrinsics CMSIS SIMD Intrinsics
|
||||||
|
Access to dedicated SIMD instructions
|
||||||
|
@{
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if (__CORTEX_M >= 0x04U) /* only for Cortex-M4 and above */
|
||||||
|
|
||||||
|
#define __SADD8 __sadd8
|
||||||
|
#define __QADD8 __qadd8
|
||||||
|
#define __SHADD8 __shadd8
|
||||||
|
#define __UADD8 __uadd8
|
||||||
|
#define __UQADD8 __uqadd8
|
||||||
|
#define __UHADD8 __uhadd8
|
||||||
|
#define __SSUB8 __ssub8
|
||||||
|
#define __QSUB8 __qsub8
|
||||||
|
#define __SHSUB8 __shsub8
|
||||||
|
#define __USUB8 __usub8
|
||||||
|
#define __UQSUB8 __uqsub8
|
||||||
|
#define __UHSUB8 __uhsub8
|
||||||
|
#define __SADD16 __sadd16
|
||||||
|
#define __QADD16 __qadd16
|
||||||
|
#define __SHADD16 __shadd16
|
||||||
|
#define __UADD16 __uadd16
|
||||||
|
#define __UQADD16 __uqadd16
|
||||||
|
#define __UHADD16 __uhadd16
|
||||||
|
#define __SSUB16 __ssub16
|
||||||
|
#define __QSUB16 __qsub16
|
||||||
|
#define __SHSUB16 __shsub16
|
||||||
|
#define __USUB16 __usub16
|
||||||
|
#define __UQSUB16 __uqsub16
|
||||||
|
#define __UHSUB16 __uhsub16
|
||||||
|
#define __SASX __sasx
|
||||||
|
#define __QASX __qasx
|
||||||
|
#define __SHASX __shasx
|
||||||
|
#define __UASX __uasx
|
||||||
|
#define __UQASX __uqasx
|
||||||
|
#define __UHASX __uhasx
|
||||||
|
#define __SSAX __ssax
|
||||||
|
#define __QSAX __qsax
|
||||||
|
#define __SHSAX __shsax
|
||||||
|
#define __USAX __usax
|
||||||
|
#define __UQSAX __uqsax
|
||||||
|
#define __UHSAX __uhsax
|
||||||
|
#define __USAD8 __usad8
|
||||||
|
#define __USADA8 __usada8
|
||||||
|
#define __SSAT16 __ssat16
|
||||||
|
#define __USAT16 __usat16
|
||||||
|
#define __UXTB16 __uxtb16
|
||||||
|
#define __UXTAB16 __uxtab16
|
||||||
|
#define __SXTB16 __sxtb16
|
||||||
|
#define __SXTAB16 __sxtab16
|
||||||
|
#define __SMUAD __smuad
|
||||||
|
#define __SMUADX __smuadx
|
||||||
|
#define __SMLAD __smlad
|
||||||
|
#define __SMLADX __smladx
|
||||||
|
#define __SMLALD __smlald
|
||||||
|
#define __SMLALDX __smlaldx
|
||||||
|
#define __SMUSD __smusd
|
||||||
|
#define __SMUSDX __smusdx
|
||||||
|
#define __SMLSD __smlsd
|
||||||
|
#define __SMLSDX __smlsdx
|
||||||
|
#define __SMLSLD __smlsld
|
||||||
|
#define __SMLSLDX __smlsldx
|
||||||
|
#define __SEL __sel
|
||||||
|
#define __QADD __qadd
|
||||||
|
#define __QSUB __qsub
|
||||||
|
|
||||||
|
#define __PKHBT(ARG1,ARG2,ARG3) ( ((((uint32_t)(ARG1)) ) & 0x0000FFFFUL) | \
|
||||||
|
((((uint32_t)(ARG2)) << (ARG3)) & 0xFFFF0000UL) )
|
||||||
|
|
||||||
|
#define __PKHTB(ARG1,ARG2,ARG3) ( ((((uint32_t)(ARG1)) ) & 0xFFFF0000UL) | \
|
||||||
|
((((uint32_t)(ARG2)) >> (ARG3)) & 0x0000FFFFUL) )
|
||||||
|
|
||||||
|
#define __SMMLA(ARG1,ARG2,ARG3) ( (int32_t)((((int64_t)(ARG1) * (ARG2)) + \
|
||||||
|
((int64_t)(ARG3) << 32U) ) >> 32U))
|
||||||
|
|
||||||
|
#endif /* (__CORTEX_M >= 0x04) */
|
||||||
|
/*@} end of group CMSIS_SIMD_intrinsics */
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* __CMSIS_ARMCC_H */
|
1800
src/platform/cm4/cmsis/include/cmsis_armcc_V6.h
Normal file
1800
src/platform/cm4/cmsis/include/cmsis_armcc_V6.h
Normal file
File diff suppressed because it is too large
Load Diff
1373
src/platform/cm4/cmsis/include/cmsis_gcc.h
Normal file
1373
src/platform/cm4/cmsis/include/cmsis_gcc.h
Normal file
File diff suppressed because it is too large
Load Diff
798
src/platform/cm4/cmsis/include/core_cm0.h
Normal file
798
src/platform/cm4/cmsis/include/core_cm0.h
Normal file
@@ -0,0 +1,798 @@
|
|||||||
|
/**************************************************************************//**
|
||||||
|
* @file core_cm0.h
|
||||||
|
* @brief CMSIS Cortex-M0 Core Peripheral Access Layer Header File
|
||||||
|
* @version V4.30
|
||||||
|
* @date 20. October 2015
|
||||||
|
******************************************************************************/
|
||||||
|
/* Copyright (c) 2009 - 2015 ARM LIMITED
|
||||||
|
|
||||||
|
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 following disclaimer.
|
||||||
|
- Redistributions in binary form must reproduce the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer in the
|
||||||
|
documentation and/or other materials provided with the distribution.
|
||||||
|
- Neither the name of ARM nor the names of its contributors may be used
|
||||||
|
to endorse or promote products derived from this software without
|
||||||
|
specific prior written permission.
|
||||||
|
*
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
|
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS 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.
|
||||||
|
---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
|
||||||
|
#if defined ( __ICCARM__ )
|
||||||
|
#pragma system_include /* treat file as system include file for MISRA check */
|
||||||
|
#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
|
||||||
|
#pragma clang system_header /* treat file as system include file */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __CORE_CM0_H_GENERIC
|
||||||
|
#define __CORE_CM0_H_GENERIC
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
\page CMSIS_MISRA_Exceptions MISRA-C:2004 Compliance Exceptions
|
||||||
|
CMSIS violates the following MISRA-C:2004 rules:
|
||||||
|
|
||||||
|
\li Required Rule 8.5, object/function definition in header file.<br>
|
||||||
|
Function definitions in header files are used to allow 'inlining'.
|
||||||
|
|
||||||
|
\li Required Rule 18.4, declaration of union type or object of union type: '{...}'.<br>
|
||||||
|
Unions are used for effective representation of core registers.
|
||||||
|
|
||||||
|
\li Advisory Rule 19.7, Function-like macro defined.<br>
|
||||||
|
Function-like macros are used to allow more efficient code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* CMSIS definitions
|
||||||
|
******************************************************************************/
|
||||||
|
/**
|
||||||
|
\ingroup Cortex_M0
|
||||||
|
@{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* CMSIS CM0 definitions */
|
||||||
|
#define __CM0_CMSIS_VERSION_MAIN (0x04U) /*!< [31:16] CMSIS HAL main version */
|
||||||
|
#define __CM0_CMSIS_VERSION_SUB (0x1EU) /*!< [15:0] CMSIS HAL sub version */
|
||||||
|
#define __CM0_CMSIS_VERSION ((__CM0_CMSIS_VERSION_MAIN << 16U) | \
|
||||||
|
__CM0_CMSIS_VERSION_SUB ) /*!< CMSIS HAL version number */
|
||||||
|
|
||||||
|
#define __CORTEX_M (0x00U) /*!< Cortex-M Core */
|
||||||
|
|
||||||
|
|
||||||
|
#if defined ( __CC_ARM )
|
||||||
|
#define __ASM __asm /*!< asm keyword for ARM Compiler */
|
||||||
|
#define __INLINE __inline /*!< inline keyword for ARM Compiler */
|
||||||
|
#define __STATIC_INLINE static __inline
|
||||||
|
|
||||||
|
#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
|
||||||
|
#define __ASM __asm /*!< asm keyword for ARM Compiler */
|
||||||
|
#define __INLINE __inline /*!< inline keyword for ARM Compiler */
|
||||||
|
#define __STATIC_INLINE static __inline
|
||||||
|
|
||||||
|
#elif defined ( __GNUC__ )
|
||||||
|
#define __ASM __asm /*!< asm keyword for GNU Compiler */
|
||||||
|
#define __INLINE inline /*!< inline keyword for GNU Compiler */
|
||||||
|
#define __STATIC_INLINE static inline
|
||||||
|
|
||||||
|
#elif defined ( __ICCARM__ )
|
||||||
|
#define __ASM __asm /*!< asm keyword for IAR Compiler */
|
||||||
|
#define __INLINE inline /*!< inline keyword for IAR Compiler. Only available in High optimization mode! */
|
||||||
|
#define __STATIC_INLINE static inline
|
||||||
|
|
||||||
|
#elif defined ( __TMS470__ )
|
||||||
|
#define __ASM __asm /*!< asm keyword for TI CCS Compiler */
|
||||||
|
#define __STATIC_INLINE static inline
|
||||||
|
|
||||||
|
#elif defined ( __TASKING__ )
|
||||||
|
#define __ASM __asm /*!< asm keyword for TASKING Compiler */
|
||||||
|
#define __INLINE inline /*!< inline keyword for TASKING Compiler */
|
||||||
|
#define __STATIC_INLINE static inline
|
||||||
|
|
||||||
|
#elif defined ( __CSMC__ )
|
||||||
|
#define __packed
|
||||||
|
#define __ASM _asm /*!< asm keyword for COSMIC Compiler */
|
||||||
|
#define __INLINE inline /*!< inline keyword for COSMIC Compiler. Use -pc99 on compile line */
|
||||||
|
#define __STATIC_INLINE static inline
|
||||||
|
|
||||||
|
#else
|
||||||
|
#error Unknown compiler
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/** __FPU_USED indicates whether an FPU is used or not.
|
||||||
|
This core does not support an FPU at all
|
||||||
|
*/
|
||||||
|
#define __FPU_USED 0U
|
||||||
|
|
||||||
|
#if defined ( __CC_ARM )
|
||||||
|
#if defined __TARGET_FPU_VFP
|
||||||
|
#error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
|
||||||
|
#if defined __ARM_PCS_VFP
|
||||||
|
#error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#elif defined ( __GNUC__ )
|
||||||
|
#if defined (__VFP_FP__) && !defined(__SOFTFP__)
|
||||||
|
#error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#elif defined ( __ICCARM__ )
|
||||||
|
#if defined __ARMVFP__
|
||||||
|
#error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#elif defined ( __TMS470__ )
|
||||||
|
#if defined __TI_VFP_SUPPORT__
|
||||||
|
#error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#elif defined ( __TASKING__ )
|
||||||
|
#if defined __FPU_VFP__
|
||||||
|
#error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#elif defined ( __CSMC__ )
|
||||||
|
#if ( __CSMC__ & 0x400U)
|
||||||
|
#error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "core_cmInstr.h" /* Core Instruction Access */
|
||||||
|
#include "core_cmFunc.h" /* Core Function Access */
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* __CORE_CM0_H_GENERIC */
|
||||||
|
|
||||||
|
#ifndef __CMSIS_GENERIC
|
||||||
|
|
||||||
|
#ifndef __CORE_CM0_H_DEPENDANT
|
||||||
|
#define __CORE_CM0_H_DEPENDANT
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* check device defines and use defaults */
|
||||||
|
#if defined __CHECK_DEVICE_DEFINES
|
||||||
|
#ifndef __CM0_REV
|
||||||
|
#define __CM0_REV 0x0000U
|
||||||
|
#warning "__CM0_REV not defined in device header file; using default!"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __NVIC_PRIO_BITS
|
||||||
|
#define __NVIC_PRIO_BITS 2U
|
||||||
|
#warning "__NVIC_PRIO_BITS not defined in device header file; using default!"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __Vendor_SysTickConfig
|
||||||
|
#define __Vendor_SysTickConfig 0U
|
||||||
|
#warning "__Vendor_SysTickConfig not defined in device header file; using default!"
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* IO definitions (access restrictions to peripheral registers) */
|
||||||
|
/**
|
||||||
|
\defgroup CMSIS_glob_defs CMSIS Global Defines
|
||||||
|
|
||||||
|
<strong>IO Type Qualifiers</strong> are used
|
||||||
|
\li to specify the access to peripheral variables.
|
||||||
|
\li for automatic generation of peripheral register debug information.
|
||||||
|
*/
|
||||||
|
#ifdef __cplusplus
|
||||||
|
#define __I volatile /*!< Defines 'read only' permissions */
|
||||||
|
#else
|
||||||
|
#define __I volatile const /*!< Defines 'read only' permissions */
|
||||||
|
#endif
|
||||||
|
#define __O volatile /*!< Defines 'write only' permissions */
|
||||||
|
#define __IO volatile /*!< Defines 'read / write' permissions */
|
||||||
|
|
||||||
|
/* following defines should be used for structure members */
|
||||||
|
#define __IM volatile const /*! Defines 'read only' structure member permissions */
|
||||||
|
#define __OM volatile /*! Defines 'write only' structure member permissions */
|
||||||
|
#define __IOM volatile /*! Defines 'read / write' structure member permissions */
|
||||||
|
|
||||||
|
/*@} end of group Cortex_M0 */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Register Abstraction
|
||||||
|
Core Register contain:
|
||||||
|
- Core Register
|
||||||
|
- Core NVIC Register
|
||||||
|
- Core SCB Register
|
||||||
|
- Core SysTick Register
|
||||||
|
******************************************************************************/
|
||||||
|
/**
|
||||||
|
\defgroup CMSIS_core_register Defines and Type Definitions
|
||||||
|
\brief Type definitions and defines for Cortex-M processor based devices.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
\ingroup CMSIS_core_register
|
||||||
|
\defgroup CMSIS_CORE Status and Control Registers
|
||||||
|
\brief Core Register type definitions.
|
||||||
|
@{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
\brief Union type to access the Application Program Status Register (APSR).
|
||||||
|
*/
|
||||||
|
typedef union
|
||||||
|
{
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
uint32_t _reserved0:28; /*!< bit: 0..27 Reserved */
|
||||||
|
uint32_t V:1; /*!< bit: 28 Overflow condition code flag */
|
||||||
|
uint32_t C:1; /*!< bit: 29 Carry condition code flag */
|
||||||
|
uint32_t Z:1; /*!< bit: 30 Zero condition code flag */
|
||||||
|
uint32_t N:1; /*!< bit: 31 Negative condition code flag */
|
||||||
|
} b; /*!< Structure used for bit access */
|
||||||
|
uint32_t w; /*!< Type used for word access */
|
||||||
|
} APSR_Type;
|
||||||
|
|
||||||
|
/* APSR Register Definitions */
|
||||||
|
#define APSR_N_Pos 31U /*!< APSR: N Position */
|
||||||
|
#define APSR_N_Msk (1UL << APSR_N_Pos) /*!< APSR: N Mask */
|
||||||
|
|
||||||
|
#define APSR_Z_Pos 30U /*!< APSR: Z Position */
|
||||||
|
#define APSR_Z_Msk (1UL << APSR_Z_Pos) /*!< APSR: Z Mask */
|
||||||
|
|
||||||
|
#define APSR_C_Pos 29U /*!< APSR: C Position */
|
||||||
|
#define APSR_C_Msk (1UL << APSR_C_Pos) /*!< APSR: C Mask */
|
||||||
|
|
||||||
|
#define APSR_V_Pos 28U /*!< APSR: V Position */
|
||||||
|
#define APSR_V_Msk (1UL << APSR_V_Pos) /*!< APSR: V Mask */
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
\brief Union type to access the Interrupt Program Status Register (IPSR).
|
||||||
|
*/
|
||||||
|
typedef union
|
||||||
|
{
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */
|
||||||
|
uint32_t _reserved0:23; /*!< bit: 9..31 Reserved */
|
||||||
|
} b; /*!< Structure used for bit access */
|
||||||
|
uint32_t w; /*!< Type used for word access */
|
||||||
|
} IPSR_Type;
|
||||||
|
|
||||||
|
/* IPSR Register Definitions */
|
||||||
|
#define IPSR_ISR_Pos 0U /*!< IPSR: ISR Position */
|
||||||
|
#define IPSR_ISR_Msk (0x1FFUL /*<< IPSR_ISR_Pos*/) /*!< IPSR: ISR Mask */
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
\brief Union type to access the Special-Purpose Program Status Registers (xPSR).
|
||||||
|
*/
|
||||||
|
typedef union
|
||||||
|
{
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */
|
||||||
|
uint32_t _reserved0:15; /*!< bit: 9..23 Reserved */
|
||||||
|
uint32_t T:1; /*!< bit: 24 Thumb bit (read 0) */
|
||||||
|
uint32_t _reserved1:3; /*!< bit: 25..27 Reserved */
|
||||||
|
uint32_t V:1; /*!< bit: 28 Overflow condition code flag */
|
||||||
|
uint32_t C:1; /*!< bit: 29 Carry condition code flag */
|
||||||
|
uint32_t Z:1; /*!< bit: 30 Zero condition code flag */
|
||||||
|
uint32_t N:1; /*!< bit: 31 Negative condition code flag */
|
||||||
|
} b; /*!< Structure used for bit access */
|
||||||
|
uint32_t w; /*!< Type used for word access */
|
||||||
|
} xPSR_Type;
|
||||||
|
|
||||||
|
/* xPSR Register Definitions */
|
||||||
|
#define xPSR_N_Pos 31U /*!< xPSR: N Position */
|
||||||
|
#define xPSR_N_Msk (1UL << xPSR_N_Pos) /*!< xPSR: N Mask */
|
||||||
|
|
||||||
|
#define xPSR_Z_Pos 30U /*!< xPSR: Z Position */
|
||||||
|
#define xPSR_Z_Msk (1UL << xPSR_Z_Pos) /*!< xPSR: Z Mask */
|
||||||
|
|
||||||
|
#define xPSR_C_Pos 29U /*!< xPSR: C Position */
|
||||||
|
#define xPSR_C_Msk (1UL << xPSR_C_Pos) /*!< xPSR: C Mask */
|
||||||
|
|
||||||
|
#define xPSR_V_Pos 28U /*!< xPSR: V Position */
|
||||||
|
#define xPSR_V_Msk (1UL << xPSR_V_Pos) /*!< xPSR: V Mask */
|
||||||
|
|
||||||
|
#define xPSR_T_Pos 24U /*!< xPSR: T Position */
|
||||||
|
#define xPSR_T_Msk (1UL << xPSR_T_Pos) /*!< xPSR: T Mask */
|
||||||
|
|
||||||
|
#define xPSR_ISR_Pos 0U /*!< xPSR: ISR Position */
|
||||||
|
#define xPSR_ISR_Msk (0x1FFUL /*<< xPSR_ISR_Pos*/) /*!< xPSR: ISR Mask */
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
\brief Union type to access the Control Registers (CONTROL).
|
||||||
|
*/
|
||||||
|
typedef union
|
||||||
|
{
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
uint32_t _reserved0:1; /*!< bit: 0 Reserved */
|
||||||
|
uint32_t SPSEL:1; /*!< bit: 1 Stack to be used */
|
||||||
|
uint32_t _reserved1:30; /*!< bit: 2..31 Reserved */
|
||||||
|
} b; /*!< Structure used for bit access */
|
||||||
|
uint32_t w; /*!< Type used for word access */
|
||||||
|
} CONTROL_Type;
|
||||||
|
|
||||||
|
/* CONTROL Register Definitions */
|
||||||
|
#define CONTROL_SPSEL_Pos 1U /*!< CONTROL: SPSEL Position */
|
||||||
|
#define CONTROL_SPSEL_Msk (1UL << CONTROL_SPSEL_Pos) /*!< CONTROL: SPSEL Mask */
|
||||||
|
|
||||||
|
/*@} end of group CMSIS_CORE */
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
\ingroup CMSIS_core_register
|
||||||
|
\defgroup CMSIS_NVIC Nested Vectored Interrupt Controller (NVIC)
|
||||||
|
\brief Type definitions for the NVIC Registers
|
||||||
|
@{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
\brief Structure type to access the Nested Vectored Interrupt Controller (NVIC).
|
||||||
|
*/
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
__IOM uint32_t ISER[1U]; /*!< Offset: 0x000 (R/W) Interrupt Set Enable Register */
|
||||||
|
uint32_t RESERVED0[31U];
|
||||||
|
__IOM uint32_t ICER[1U]; /*!< Offset: 0x080 (R/W) Interrupt Clear Enable Register */
|
||||||
|
uint32_t RSERVED1[31U];
|
||||||
|
__IOM uint32_t ISPR[1U]; /*!< Offset: 0x100 (R/W) Interrupt Set Pending Register */
|
||||||
|
uint32_t RESERVED2[31U];
|
||||||
|
__IOM uint32_t ICPR[1U]; /*!< Offset: 0x180 (R/W) Interrupt Clear Pending Register */
|
||||||
|
uint32_t RESERVED3[31U];
|
||||||
|
uint32_t RESERVED4[64U];
|
||||||
|
__IOM uint32_t IP[8U]; /*!< Offset: 0x300 (R/W) Interrupt Priority Register */
|
||||||
|
} NVIC_Type;
|
||||||
|
|
||||||
|
/*@} end of group CMSIS_NVIC */
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
\ingroup CMSIS_core_register
|
||||||
|
\defgroup CMSIS_SCB System Control Block (SCB)
|
||||||
|
\brief Type definitions for the System Control Block Registers
|
||||||
|
@{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
\brief Structure type to access the System Control Block (SCB).
|
||||||
|
*/
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
__IM uint32_t CPUID; /*!< Offset: 0x000 (R/ ) CPUID Base Register */
|
||||||
|
__IOM uint32_t ICSR; /*!< Offset: 0x004 (R/W) Interrupt Control and State Register */
|
||||||
|
uint32_t RESERVED0;
|
||||||
|
__IOM uint32_t AIRCR; /*!< Offset: 0x00C (R/W) Application Interrupt and Reset Control Register */
|
||||||
|
__IOM uint32_t SCR; /*!< Offset: 0x010 (R/W) System Control Register */
|
||||||
|
__IOM uint32_t CCR; /*!< Offset: 0x014 (R/W) Configuration Control Register */
|
||||||
|
uint32_t RESERVED1;
|
||||||
|
__IOM uint32_t SHP[2U]; /*!< Offset: 0x01C (R/W) System Handlers Priority Registers. [0] is RESERVED */
|
||||||
|
__IOM uint32_t SHCSR; /*!< Offset: 0x024 (R/W) System Handler Control and State Register */
|
||||||
|
} SCB_Type;
|
||||||
|
|
||||||
|
/* SCB CPUID Register Definitions */
|
||||||
|
#define SCB_CPUID_IMPLEMENTER_Pos 24U /*!< SCB CPUID: IMPLEMENTER Position */
|
||||||
|
#define SCB_CPUID_IMPLEMENTER_Msk (0xFFUL << SCB_CPUID_IMPLEMENTER_Pos) /*!< SCB CPUID: IMPLEMENTER Mask */
|
||||||
|
|
||||||
|
#define SCB_CPUID_VARIANT_Pos 20U /*!< SCB CPUID: VARIANT Position */
|
||||||
|
#define SCB_CPUID_VARIANT_Msk (0xFUL << SCB_CPUID_VARIANT_Pos) /*!< SCB CPUID: VARIANT Mask */
|
||||||
|
|
||||||
|
#define SCB_CPUID_ARCHITECTURE_Pos 16U /*!< SCB CPUID: ARCHITECTURE Position */
|
||||||
|
#define SCB_CPUID_ARCHITECTURE_Msk (0xFUL << SCB_CPUID_ARCHITECTURE_Pos) /*!< SCB CPUID: ARCHITECTURE Mask */
|
||||||
|
|
||||||
|
#define SCB_CPUID_PARTNO_Pos 4U /*!< SCB CPUID: PARTNO Position */
|
||||||
|
#define SCB_CPUID_PARTNO_Msk (0xFFFUL << SCB_CPUID_PARTNO_Pos) /*!< SCB CPUID: PARTNO Mask */
|
||||||
|
|
||||||
|
#define SCB_CPUID_REVISION_Pos 0U /*!< SCB CPUID: REVISION Position */
|
||||||
|
#define SCB_CPUID_REVISION_Msk (0xFUL /*<< SCB_CPUID_REVISION_Pos*/) /*!< SCB CPUID: REVISION Mask */
|
||||||
|
|
||||||
|
/* SCB Interrupt Control State Register Definitions */
|
||||||
|
#define SCB_ICSR_NMIPENDSET_Pos 31U /*!< SCB ICSR: NMIPENDSET Position */
|
||||||
|
#define SCB_ICSR_NMIPENDSET_Msk (1UL << SCB_ICSR_NMIPENDSET_Pos) /*!< SCB ICSR: NMIPENDSET Mask */
|
||||||
|
|
||||||
|
#define SCB_ICSR_PENDSVSET_Pos 28U /*!< SCB ICSR: PENDSVSET Position */
|
||||||
|
#define SCB_ICSR_PENDSVSET_Msk (1UL << SCB_ICSR_PENDSVSET_Pos) /*!< SCB ICSR: PENDSVSET Mask */
|
||||||
|
|
||||||
|
#define SCB_ICSR_PENDSVCLR_Pos 27U /*!< SCB ICSR: PENDSVCLR Position */
|
||||||
|
#define SCB_ICSR_PENDSVCLR_Msk (1UL << SCB_ICSR_PENDSVCLR_Pos) /*!< SCB ICSR: PENDSVCLR Mask */
|
||||||
|
|
||||||
|
#define SCB_ICSR_PENDSTSET_Pos 26U /*!< SCB ICSR: PENDSTSET Position */
|
||||||
|
#define SCB_ICSR_PENDSTSET_Msk (1UL << SCB_ICSR_PENDSTSET_Pos) /*!< SCB ICSR: PENDSTSET Mask */
|
||||||
|
|
||||||
|
#define SCB_ICSR_PENDSTCLR_Pos 25U /*!< SCB ICSR: PENDSTCLR Position */
|
||||||
|
#define SCB_ICSR_PENDSTCLR_Msk (1UL << SCB_ICSR_PENDSTCLR_Pos) /*!< SCB ICSR: PENDSTCLR Mask */
|
||||||
|
|
||||||
|
#define SCB_ICSR_ISRPREEMPT_Pos 23U /*!< SCB ICSR: ISRPREEMPT Position */
|
||||||
|
#define SCB_ICSR_ISRPREEMPT_Msk (1UL << SCB_ICSR_ISRPREEMPT_Pos) /*!< SCB ICSR: ISRPREEMPT Mask */
|
||||||
|
|
||||||
|
#define SCB_ICSR_ISRPENDING_Pos 22U /*!< SCB ICSR: ISRPENDING Position */
|
||||||
|
#define SCB_ICSR_ISRPENDING_Msk (1UL << SCB_ICSR_ISRPENDING_Pos) /*!< SCB ICSR: ISRPENDING Mask */
|
||||||
|
|
||||||
|
#define SCB_ICSR_VECTPENDING_Pos 12U /*!< SCB ICSR: VECTPENDING Position */
|
||||||
|
#define SCB_ICSR_VECTPENDING_Msk (0x1FFUL << SCB_ICSR_VECTPENDING_Pos) /*!< SCB ICSR: VECTPENDING Mask */
|
||||||
|
|
||||||
|
#define SCB_ICSR_VECTACTIVE_Pos 0U /*!< SCB ICSR: VECTACTIVE Position */
|
||||||
|
#define SCB_ICSR_VECTACTIVE_Msk (0x1FFUL /*<< SCB_ICSR_VECTACTIVE_Pos*/) /*!< SCB ICSR: VECTACTIVE Mask */
|
||||||
|
|
||||||
|
/* SCB Application Interrupt and Reset Control Register Definitions */
|
||||||
|
#define SCB_AIRCR_VECTKEY_Pos 16U /*!< SCB AIRCR: VECTKEY Position */
|
||||||
|
#define SCB_AIRCR_VECTKEY_Msk (0xFFFFUL << SCB_AIRCR_VECTKEY_Pos) /*!< SCB AIRCR: VECTKEY Mask */
|
||||||
|
|
||||||
|
#define SCB_AIRCR_VECTKEYSTAT_Pos 16U /*!< SCB AIRCR: VECTKEYSTAT Position */
|
||||||
|
#define SCB_AIRCR_VECTKEYSTAT_Msk (0xFFFFUL << SCB_AIRCR_VECTKEYSTAT_Pos) /*!< SCB AIRCR: VECTKEYSTAT Mask */
|
||||||
|
|
||||||
|
#define SCB_AIRCR_ENDIANESS_Pos 15U /*!< SCB AIRCR: ENDIANESS Position */
|
||||||
|
#define SCB_AIRCR_ENDIANESS_Msk (1UL << SCB_AIRCR_ENDIANESS_Pos) /*!< SCB AIRCR: ENDIANESS Mask */
|
||||||
|
|
||||||
|
#define SCB_AIRCR_SYSRESETREQ_Pos 2U /*!< SCB AIRCR: SYSRESETREQ Position */
|
||||||
|
#define SCB_AIRCR_SYSRESETREQ_Msk (1UL << SCB_AIRCR_SYSRESETREQ_Pos) /*!< SCB AIRCR: SYSRESETREQ Mask */
|
||||||
|
|
||||||
|
#define SCB_AIRCR_VECTCLRACTIVE_Pos 1U /*!< SCB AIRCR: VECTCLRACTIVE Position */
|
||||||
|
#define SCB_AIRCR_VECTCLRACTIVE_Msk (1UL << SCB_AIRCR_VECTCLRACTIVE_Pos) /*!< SCB AIRCR: VECTCLRACTIVE Mask */
|
||||||
|
|
||||||
|
/* SCB System Control Register Definitions */
|
||||||
|
#define SCB_SCR_SEVONPEND_Pos 4U /*!< SCB SCR: SEVONPEND Position */
|
||||||
|
#define SCB_SCR_SEVONPEND_Msk (1UL << SCB_SCR_SEVONPEND_Pos) /*!< SCB SCR: SEVONPEND Mask */
|
||||||
|
|
||||||
|
#define SCB_SCR_SLEEPDEEP_Pos 2U /*!< SCB SCR: SLEEPDEEP Position */
|
||||||
|
#define SCB_SCR_SLEEPDEEP_Msk (1UL << SCB_SCR_SLEEPDEEP_Pos) /*!< SCB SCR: SLEEPDEEP Mask */
|
||||||
|
|
||||||
|
#define SCB_SCR_SLEEPONEXIT_Pos 1U /*!< SCB SCR: SLEEPONEXIT Position */
|
||||||
|
#define SCB_SCR_SLEEPONEXIT_Msk (1UL << SCB_SCR_SLEEPONEXIT_Pos) /*!< SCB SCR: SLEEPONEXIT Mask */
|
||||||
|
|
||||||
|
/* SCB Configuration Control Register Definitions */
|
||||||
|
#define SCB_CCR_STKALIGN_Pos 9U /*!< SCB CCR: STKALIGN Position */
|
||||||
|
#define SCB_CCR_STKALIGN_Msk (1UL << SCB_CCR_STKALIGN_Pos) /*!< SCB CCR: STKALIGN Mask */
|
||||||
|
|
||||||
|
#define SCB_CCR_UNALIGN_TRP_Pos 3U /*!< SCB CCR: UNALIGN_TRP Position */
|
||||||
|
#define SCB_CCR_UNALIGN_TRP_Msk (1UL << SCB_CCR_UNALIGN_TRP_Pos) /*!< SCB CCR: UNALIGN_TRP Mask */
|
||||||
|
|
||||||
|
/* SCB System Handler Control and State Register Definitions */
|
||||||
|
#define SCB_SHCSR_SVCALLPENDED_Pos 15U /*!< SCB SHCSR: SVCALLPENDED Position */
|
||||||
|
#define SCB_SHCSR_SVCALLPENDED_Msk (1UL << SCB_SHCSR_SVCALLPENDED_Pos) /*!< SCB SHCSR: SVCALLPENDED Mask */
|
||||||
|
|
||||||
|
/*@} end of group CMSIS_SCB */
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
\ingroup CMSIS_core_register
|
||||||
|
\defgroup CMSIS_SysTick System Tick Timer (SysTick)
|
||||||
|
\brief Type definitions for the System Timer Registers.
|
||||||
|
@{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
\brief Structure type to access the System Timer (SysTick).
|
||||||
|
*/
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
__IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) SysTick Control and Status Register */
|
||||||
|
__IOM uint32_t LOAD; /*!< Offset: 0x004 (R/W) SysTick Reload Value Register */
|
||||||
|
__IOM uint32_t VAL; /*!< Offset: 0x008 (R/W) SysTick Current Value Register */
|
||||||
|
__IM uint32_t CALIB; /*!< Offset: 0x00C (R/ ) SysTick Calibration Register */
|
||||||
|
} SysTick_Type;
|
||||||
|
|
||||||
|
/* SysTick Control / Status Register Definitions */
|
||||||
|
#define SysTick_CTRL_COUNTFLAG_Pos 16U /*!< SysTick CTRL: COUNTFLAG Position */
|
||||||
|
#define SysTick_CTRL_COUNTFLAG_Msk (1UL << SysTick_CTRL_COUNTFLAG_Pos) /*!< SysTick CTRL: COUNTFLAG Mask */
|
||||||
|
|
||||||
|
#define SysTick_CTRL_CLKSOURCE_Pos 2U /*!< SysTick CTRL: CLKSOURCE Position */
|
||||||
|
#define SysTick_CTRL_CLKSOURCE_Msk (1UL << SysTick_CTRL_CLKSOURCE_Pos) /*!< SysTick CTRL: CLKSOURCE Mask */
|
||||||
|
|
||||||
|
#define SysTick_CTRL_TICKINT_Pos 1U /*!< SysTick CTRL: TICKINT Position */
|
||||||
|
#define SysTick_CTRL_TICKINT_Msk (1UL << SysTick_CTRL_TICKINT_Pos) /*!< SysTick CTRL: TICKINT Mask */
|
||||||
|
|
||||||
|
#define SysTick_CTRL_ENABLE_Pos 0U /*!< SysTick CTRL: ENABLE Position */
|
||||||
|
#define SysTick_CTRL_ENABLE_Msk (1UL /*<< SysTick_CTRL_ENABLE_Pos*/) /*!< SysTick CTRL: ENABLE Mask */
|
||||||
|
|
||||||
|
/* SysTick Reload Register Definitions */
|
||||||
|
#define SysTick_LOAD_RELOAD_Pos 0U /*!< SysTick LOAD: RELOAD Position */
|
||||||
|
#define SysTick_LOAD_RELOAD_Msk (0xFFFFFFUL /*<< SysTick_LOAD_RELOAD_Pos*/) /*!< SysTick LOAD: RELOAD Mask */
|
||||||
|
|
||||||
|
/* SysTick Current Register Definitions */
|
||||||
|
#define SysTick_VAL_CURRENT_Pos 0U /*!< SysTick VAL: CURRENT Position */
|
||||||
|
#define SysTick_VAL_CURRENT_Msk (0xFFFFFFUL /*<< SysTick_VAL_CURRENT_Pos*/) /*!< SysTick VAL: CURRENT Mask */
|
||||||
|
|
||||||
|
/* SysTick Calibration Register Definitions */
|
||||||
|
#define SysTick_CALIB_NOREF_Pos 31U /*!< SysTick CALIB: NOREF Position */
|
||||||
|
#define SysTick_CALIB_NOREF_Msk (1UL << SysTick_CALIB_NOREF_Pos) /*!< SysTick CALIB: NOREF Mask */
|
||||||
|
|
||||||
|
#define SysTick_CALIB_SKEW_Pos 30U /*!< SysTick CALIB: SKEW Position */
|
||||||
|
#define SysTick_CALIB_SKEW_Msk (1UL << SysTick_CALIB_SKEW_Pos) /*!< SysTick CALIB: SKEW Mask */
|
||||||
|
|
||||||
|
#define SysTick_CALIB_TENMS_Pos 0U /*!< SysTick CALIB: TENMS Position */
|
||||||
|
#define SysTick_CALIB_TENMS_Msk (0xFFFFFFUL /*<< SysTick_CALIB_TENMS_Pos*/) /*!< SysTick CALIB: TENMS Mask */
|
||||||
|
|
||||||
|
/*@} end of group CMSIS_SysTick */
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
\ingroup CMSIS_core_register
|
||||||
|
\defgroup CMSIS_CoreDebug Core Debug Registers (CoreDebug)
|
||||||
|
\brief Cortex-M0 Core Debug Registers (DCB registers, SHCSR, and DFSR) are only accessible over DAP and not via processor.
|
||||||
|
Therefore they are not covered by the Cortex-M0 header file.
|
||||||
|
@{
|
||||||
|
*/
|
||||||
|
/*@} end of group CMSIS_CoreDebug */
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
\ingroup CMSIS_core_register
|
||||||
|
\defgroup CMSIS_core_bitfield Core register bit field macros
|
||||||
|
\brief Macros for use with bit field definitions (xxx_Pos, xxx_Msk).
|
||||||
|
@{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
\brief Mask and shift a bit field value for use in a register bit range.
|
||||||
|
\param[in] field Name of the register bit field.
|
||||||
|
\param[in] value Value of the bit field.
|
||||||
|
\return Masked and shifted value.
|
||||||
|
*/
|
||||||
|
#define _VAL2FLD(field, value) ((value << field ## _Pos) & field ## _Msk)
|
||||||
|
|
||||||
|
/**
|
||||||
|
\brief Mask and shift a register value to extract a bit filed value.
|
||||||
|
\param[in] field Name of the register bit field.
|
||||||
|
\param[in] value Value of register.
|
||||||
|
\return Masked and shifted bit field value.
|
||||||
|
*/
|
||||||
|
#define _FLD2VAL(field, value) ((value & field ## _Msk) >> field ## _Pos)
|
||||||
|
|
||||||
|
/*@} end of group CMSIS_core_bitfield */
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
\ingroup CMSIS_core_register
|
||||||
|
\defgroup CMSIS_core_base Core Definitions
|
||||||
|
\brief Definitions for base addresses, unions, and structures.
|
||||||
|
@{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Memory mapping of Cortex-M0 Hardware */
|
||||||
|
#define SCS_BASE (0xE000E000UL) /*!< System Control Space Base Address */
|
||||||
|
#define SysTick_BASE (SCS_BASE + 0x0010UL) /*!< SysTick Base Address */
|
||||||
|
#define NVIC_BASE (SCS_BASE + 0x0100UL) /*!< NVIC Base Address */
|
||||||
|
#define SCB_BASE (SCS_BASE + 0x0D00UL) /*!< System Control Block Base Address */
|
||||||
|
|
||||||
|
#define SCB ((SCB_Type *) SCB_BASE ) /*!< SCB configuration struct */
|
||||||
|
#define SysTick ((SysTick_Type *) SysTick_BASE ) /*!< SysTick configuration struct */
|
||||||
|
#define NVIC ((NVIC_Type *) NVIC_BASE ) /*!< NVIC configuration struct */
|
||||||
|
|
||||||
|
|
||||||
|
/*@} */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Hardware Abstraction Layer
|
||||||
|
Core Function Interface contains:
|
||||||
|
- Core NVIC Functions
|
||||||
|
- Core SysTick Functions
|
||||||
|
- Core Register Access Functions
|
||||||
|
******************************************************************************/
|
||||||
|
/**
|
||||||
|
\defgroup CMSIS_Core_FunctionInterface Functions and Instructions Reference
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* ########################## NVIC functions #################################### */
|
||||||
|
/**
|
||||||
|
\ingroup CMSIS_Core_FunctionInterface
|
||||||
|
\defgroup CMSIS_Core_NVICFunctions NVIC Functions
|
||||||
|
\brief Functions that manage interrupts and exceptions via the NVIC.
|
||||||
|
@{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Interrupt Priorities are WORD accessible only under ARMv6M */
|
||||||
|
/* The following MACROS handle generation of the register offset and byte masks */
|
||||||
|
#define _BIT_SHIFT(IRQn) ( ((((uint32_t)(int32_t)(IRQn)) ) & 0x03UL) * 8UL)
|
||||||
|
#define _SHP_IDX(IRQn) ( (((((uint32_t)(int32_t)(IRQn)) & 0x0FUL)-8UL) >> 2UL) )
|
||||||
|
#define _IP_IDX(IRQn) ( (((uint32_t)(int32_t)(IRQn)) >> 2UL) )
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
\brief Enable External Interrupt
|
||||||
|
\details Enables a device-specific interrupt in the NVIC interrupt controller.
|
||||||
|
\param [in] IRQn External interrupt number. Value cannot be negative.
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE void NVIC_EnableIRQ(IRQn_Type IRQn)
|
||||||
|
{
|
||||||
|
NVIC->ISER[0U] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
\brief Disable External Interrupt
|
||||||
|
\details Disables a device-specific interrupt in the NVIC interrupt controller.
|
||||||
|
\param [in] IRQn External interrupt number. Value cannot be negative.
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE void NVIC_DisableIRQ(IRQn_Type IRQn)
|
||||||
|
{
|
||||||
|
NVIC->ICER[0U] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
\brief Get Pending Interrupt
|
||||||
|
\details Reads the pending register in the NVIC and returns the pending bit for the specified interrupt.
|
||||||
|
\param [in] IRQn Interrupt number.
|
||||||
|
\return 0 Interrupt status is not pending.
|
||||||
|
\return 1 Interrupt status is pending.
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE uint32_t NVIC_GetPendingIRQ(IRQn_Type IRQn)
|
||||||
|
{
|
||||||
|
return((uint32_t)(((NVIC->ISPR[0U] & (1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
\brief Set Pending Interrupt
|
||||||
|
\details Sets the pending bit of an external interrupt.
|
||||||
|
\param [in] IRQn Interrupt number. Value cannot be negative.
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE void NVIC_SetPendingIRQ(IRQn_Type IRQn)
|
||||||
|
{
|
||||||
|
NVIC->ISPR[0U] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
\brief Clear Pending Interrupt
|
||||||
|
\details Clears the pending bit of an external interrupt.
|
||||||
|
\param [in] IRQn External interrupt number. Value cannot be negative.
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE void NVIC_ClearPendingIRQ(IRQn_Type IRQn)
|
||||||
|
{
|
||||||
|
NVIC->ICPR[0U] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
\brief Set Interrupt Priority
|
||||||
|
\details Sets the priority of an interrupt.
|
||||||
|
\note The priority cannot be set for every core interrupt.
|
||||||
|
\param [in] IRQn Interrupt number.
|
||||||
|
\param [in] priority Priority to set.
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE void NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority)
|
||||||
|
{
|
||||||
|
if ((int32_t)(IRQn) < 0)
|
||||||
|
{
|
||||||
|
SCB->SHP[_SHP_IDX(IRQn)] = ((uint32_t)(SCB->SHP[_SHP_IDX(IRQn)] & ~(0xFFUL << _BIT_SHIFT(IRQn))) |
|
||||||
|
(((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL) << _BIT_SHIFT(IRQn)));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
NVIC->IP[_IP_IDX(IRQn)] = ((uint32_t)(NVIC->IP[_IP_IDX(IRQn)] & ~(0xFFUL << _BIT_SHIFT(IRQn))) |
|
||||||
|
(((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL) << _BIT_SHIFT(IRQn)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
\brief Get Interrupt Priority
|
||||||
|
\details Reads the priority of an interrupt.
|
||||||
|
The interrupt number can be positive to specify an external (device specific) interrupt,
|
||||||
|
or negative to specify an internal (core) interrupt.
|
||||||
|
\param [in] IRQn Interrupt number.
|
||||||
|
\return Interrupt Priority.
|
||||||
|
Value is aligned automatically to the implemented priority bits of the microcontroller.
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE uint32_t NVIC_GetPriority(IRQn_Type IRQn)
|
||||||
|
{
|
||||||
|
|
||||||
|
if ((int32_t)(IRQn) < 0)
|
||||||
|
{
|
||||||
|
return((uint32_t)(((SCB->SHP[_SHP_IDX(IRQn)] >> _BIT_SHIFT(IRQn) ) & (uint32_t)0xFFUL) >> (8U - __NVIC_PRIO_BITS)));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return((uint32_t)(((NVIC->IP[ _IP_IDX(IRQn)] >> _BIT_SHIFT(IRQn) ) & (uint32_t)0xFFUL) >> (8U - __NVIC_PRIO_BITS)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
\brief System Reset
|
||||||
|
\details Initiates a system reset request to reset the MCU.
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE void NVIC_SystemReset(void)
|
||||||
|
{
|
||||||
|
__DSB(); /* Ensure all outstanding memory accesses included
|
||||||
|
buffered write are completed before reset */
|
||||||
|
SCB->AIRCR = ((0x5FAUL << SCB_AIRCR_VECTKEY_Pos) |
|
||||||
|
SCB_AIRCR_SYSRESETREQ_Msk);
|
||||||
|
__DSB(); /* Ensure completion of memory access */
|
||||||
|
|
||||||
|
for (;;) /* wait until reset */
|
||||||
|
{
|
||||||
|
__NOP();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*@} end of CMSIS_Core_NVICFunctions */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* ################################## SysTick function ############################################ */
|
||||||
|
/**
|
||||||
|
\ingroup CMSIS_Core_FunctionInterface
|
||||||
|
\defgroup CMSIS_Core_SysTickFunctions SysTick Functions
|
||||||
|
\brief Functions that configure the System.
|
||||||
|
@{
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if (__Vendor_SysTickConfig == 0U)
|
||||||
|
|
||||||
|
/**
|
||||||
|
\brief System Tick Configuration
|
||||||
|
\details Initializes the System Timer and its interrupt, and starts the System Tick Timer.
|
||||||
|
Counter is in free running mode to generate periodic interrupts.
|
||||||
|
\param [in] ticks Number of ticks between two interrupts.
|
||||||
|
\return 0 Function succeeded.
|
||||||
|
\return 1 Function failed.
|
||||||
|
\note When the variable <b>__Vendor_SysTickConfig</b> is set to 1, then the
|
||||||
|
function <b>SysTick_Config</b> is not included. In this case, the file <b><i>device</i>.h</b>
|
||||||
|
must contain a vendor-specific implementation of this function.
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE uint32_t SysTick_Config(uint32_t ticks)
|
||||||
|
{
|
||||||
|
if ((ticks - 1UL) > SysTick_LOAD_RELOAD_Msk)
|
||||||
|
{
|
||||||
|
return (1UL); /* Reload value impossible */
|
||||||
|
}
|
||||||
|
|
||||||
|
SysTick->LOAD = (uint32_t)(ticks - 1UL); /* set reload register */
|
||||||
|
NVIC_SetPriority (SysTick_IRQn, (1UL << __NVIC_PRIO_BITS) - 1UL); /* set Priority for Systick Interrupt */
|
||||||
|
SysTick->VAL = 0UL; /* Load the SysTick Counter Value */
|
||||||
|
SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk |
|
||||||
|
SysTick_CTRL_TICKINT_Msk |
|
||||||
|
SysTick_CTRL_ENABLE_Msk; /* Enable SysTick IRQ and SysTick Timer */
|
||||||
|
return (0UL); /* Function successful */
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*@} end of CMSIS_Core_SysTickFunctions */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* __CORE_CM0_H_DEPENDANT */
|
||||||
|
|
||||||
|
#endif /* __CMSIS_GENERIC */
|
914
src/platform/cm4/cmsis/include/core_cm0plus.h
Normal file
914
src/platform/cm4/cmsis/include/core_cm0plus.h
Normal file
@@ -0,0 +1,914 @@
|
|||||||
|
/**************************************************************************//**
|
||||||
|
* @file core_cm0plus.h
|
||||||
|
* @brief CMSIS Cortex-M0+ Core Peripheral Access Layer Header File
|
||||||
|
* @version V4.30
|
||||||
|
* @date 20. October 2015
|
||||||
|
******************************************************************************/
|
||||||
|
/* Copyright (c) 2009 - 2015 ARM LIMITED
|
||||||
|
|
||||||
|
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 following disclaimer.
|
||||||
|
- Redistributions in binary form must reproduce the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer in the
|
||||||
|
documentation and/or other materials provided with the distribution.
|
||||||
|
- Neither the name of ARM nor the names of its contributors may be used
|
||||||
|
to endorse or promote products derived from this software without
|
||||||
|
specific prior written permission.
|
||||||
|
*
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
|
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS 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.
|
||||||
|
---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
|
||||||
|
#if defined ( __ICCARM__ )
|
||||||
|
#pragma system_include /* treat file as system include file for MISRA check */
|
||||||
|
#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
|
||||||
|
#pragma clang system_header /* treat file as system include file */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __CORE_CM0PLUS_H_GENERIC
|
||||||
|
#define __CORE_CM0PLUS_H_GENERIC
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
\page CMSIS_MISRA_Exceptions MISRA-C:2004 Compliance Exceptions
|
||||||
|
CMSIS violates the following MISRA-C:2004 rules:
|
||||||
|
|
||||||
|
\li Required Rule 8.5, object/function definition in header file.<br>
|
||||||
|
Function definitions in header files are used to allow 'inlining'.
|
||||||
|
|
||||||
|
\li Required Rule 18.4, declaration of union type or object of union type: '{...}'.<br>
|
||||||
|
Unions are used for effective representation of core registers.
|
||||||
|
|
||||||
|
\li Advisory Rule 19.7, Function-like macro defined.<br>
|
||||||
|
Function-like macros are used to allow more efficient code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* CMSIS definitions
|
||||||
|
******************************************************************************/
|
||||||
|
/**
|
||||||
|
\ingroup Cortex-M0+
|
||||||
|
@{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* CMSIS CM0+ definitions */
|
||||||
|
#define __CM0PLUS_CMSIS_VERSION_MAIN (0x04U) /*!< [31:16] CMSIS HAL main version */
|
||||||
|
#define __CM0PLUS_CMSIS_VERSION_SUB (0x1EU) /*!< [15:0] CMSIS HAL sub version */
|
||||||
|
#define __CM0PLUS_CMSIS_VERSION ((__CM0PLUS_CMSIS_VERSION_MAIN << 16U) | \
|
||||||
|
__CM0PLUS_CMSIS_VERSION_SUB ) /*!< CMSIS HAL version number */
|
||||||
|
|
||||||
|
#define __CORTEX_M (0x00U) /*!< Cortex-M Core */
|
||||||
|
|
||||||
|
|
||||||
|
#if defined ( __CC_ARM )
|
||||||
|
#define __ASM __asm /*!< asm keyword for ARM Compiler */
|
||||||
|
#define __INLINE __inline /*!< inline keyword for ARM Compiler */
|
||||||
|
#define __STATIC_INLINE static __inline
|
||||||
|
|
||||||
|
#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
|
||||||
|
#define __ASM __asm /*!< asm keyword for ARM Compiler */
|
||||||
|
#define __INLINE __inline /*!< inline keyword for ARM Compiler */
|
||||||
|
#define __STATIC_INLINE static __inline
|
||||||
|
|
||||||
|
#elif defined ( __GNUC__ )
|
||||||
|
#define __ASM __asm /*!< asm keyword for GNU Compiler */
|
||||||
|
#define __INLINE inline /*!< inline keyword for GNU Compiler */
|
||||||
|
#define __STATIC_INLINE static inline
|
||||||
|
|
||||||
|
#elif defined ( __ICCARM__ )
|
||||||
|
#define __ASM __asm /*!< asm keyword for IAR Compiler */
|
||||||
|
#define __INLINE inline /*!< inline keyword for IAR Compiler. Only available in High optimization mode! */
|
||||||
|
#define __STATIC_INLINE static inline
|
||||||
|
|
||||||
|
#elif defined ( __TMS470__ )
|
||||||
|
#define __ASM __asm /*!< asm keyword for TI CCS Compiler */
|
||||||
|
#define __STATIC_INLINE static inline
|
||||||
|
|
||||||
|
#elif defined ( __TASKING__ )
|
||||||
|
#define __ASM __asm /*!< asm keyword for TASKING Compiler */
|
||||||
|
#define __INLINE inline /*!< inline keyword for TASKING Compiler */
|
||||||
|
#define __STATIC_INLINE static inline
|
||||||
|
|
||||||
|
#elif defined ( __CSMC__ )
|
||||||
|
#define __packed
|
||||||
|
#define __ASM _asm /*!< asm keyword for COSMIC Compiler */
|
||||||
|
#define __INLINE inline /*!< inline keyword for COSMIC Compiler. Use -pc99 on compile line */
|
||||||
|
#define __STATIC_INLINE static inline
|
||||||
|
|
||||||
|
#else
|
||||||
|
#error Unknown compiler
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/** __FPU_USED indicates whether an FPU is used or not.
|
||||||
|
This core does not support an FPU at all
|
||||||
|
*/
|
||||||
|
#define __FPU_USED 0U
|
||||||
|
|
||||||
|
#if defined ( __CC_ARM )
|
||||||
|
#if defined __TARGET_FPU_VFP
|
||||||
|
#error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
|
||||||
|
#if defined __ARM_PCS_VFP
|
||||||
|
#error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#elif defined ( __GNUC__ )
|
||||||
|
#if defined (__VFP_FP__) && !defined(__SOFTFP__)
|
||||||
|
#error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#elif defined ( __ICCARM__ )
|
||||||
|
#if defined __ARMVFP__
|
||||||
|
#error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#elif defined ( __TMS470__ )
|
||||||
|
#if defined __TI_VFP_SUPPORT__
|
||||||
|
#error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#elif defined ( __TASKING__ )
|
||||||
|
#if defined __FPU_VFP__
|
||||||
|
#error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#elif defined ( __CSMC__ )
|
||||||
|
#if ( __CSMC__ & 0x400U)
|
||||||
|
#error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "core_cmInstr.h" /* Core Instruction Access */
|
||||||
|
#include "core_cmFunc.h" /* Core Function Access */
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* __CORE_CM0PLUS_H_GENERIC */
|
||||||
|
|
||||||
|
#ifndef __CMSIS_GENERIC
|
||||||
|
|
||||||
|
#ifndef __CORE_CM0PLUS_H_DEPENDANT
|
||||||
|
#define __CORE_CM0PLUS_H_DEPENDANT
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* check device defines and use defaults */
|
||||||
|
#if defined __CHECK_DEVICE_DEFINES
|
||||||
|
#ifndef __CM0PLUS_REV
|
||||||
|
#define __CM0PLUS_REV 0x0000U
|
||||||
|
#warning "__CM0PLUS_REV not defined in device header file; using default!"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __MPU_PRESENT
|
||||||
|
#define __MPU_PRESENT 0U
|
||||||
|
#warning "__MPU_PRESENT not defined in device header file; using default!"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __VTOR_PRESENT
|
||||||
|
#define __VTOR_PRESENT 0U
|
||||||
|
#warning "__VTOR_PRESENT not defined in device header file; using default!"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __NVIC_PRIO_BITS
|
||||||
|
#define __NVIC_PRIO_BITS 2U
|
||||||
|
#warning "__NVIC_PRIO_BITS not defined in device header file; using default!"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __Vendor_SysTickConfig
|
||||||
|
#define __Vendor_SysTickConfig 0U
|
||||||
|
#warning "__Vendor_SysTickConfig not defined in device header file; using default!"
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* IO definitions (access restrictions to peripheral registers) */
|
||||||
|
/**
|
||||||
|
\defgroup CMSIS_glob_defs CMSIS Global Defines
|
||||||
|
|
||||||
|
<strong>IO Type Qualifiers</strong> are used
|
||||||
|
\li to specify the access to peripheral variables.
|
||||||
|
\li for automatic generation of peripheral register debug information.
|
||||||
|
*/
|
||||||
|
#ifdef __cplusplus
|
||||||
|
#define __I volatile /*!< Defines 'read only' permissions */
|
||||||
|
#else
|
||||||
|
#define __I volatile const /*!< Defines 'read only' permissions */
|
||||||
|
#endif
|
||||||
|
#define __O volatile /*!< Defines 'write only' permissions */
|
||||||
|
#define __IO volatile /*!< Defines 'read / write' permissions */
|
||||||
|
|
||||||
|
/* following defines should be used for structure members */
|
||||||
|
#define __IM volatile const /*! Defines 'read only' structure member permissions */
|
||||||
|
#define __OM volatile /*! Defines 'write only' structure member permissions */
|
||||||
|
#define __IOM volatile /*! Defines 'read / write' structure member permissions */
|
||||||
|
|
||||||
|
/*@} end of group Cortex-M0+ */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Register Abstraction
|
||||||
|
Core Register contain:
|
||||||
|
- Core Register
|
||||||
|
- Core NVIC Register
|
||||||
|
- Core SCB Register
|
||||||
|
- Core SysTick Register
|
||||||
|
- Core MPU Register
|
||||||
|
******************************************************************************/
|
||||||
|
/**
|
||||||
|
\defgroup CMSIS_core_register Defines and Type Definitions
|
||||||
|
\brief Type definitions and defines for Cortex-M processor based devices.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
\ingroup CMSIS_core_register
|
||||||
|
\defgroup CMSIS_CORE Status and Control Registers
|
||||||
|
\brief Core Register type definitions.
|
||||||
|
@{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
\brief Union type to access the Application Program Status Register (APSR).
|
||||||
|
*/
|
||||||
|
typedef union
|
||||||
|
{
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
uint32_t _reserved0:28; /*!< bit: 0..27 Reserved */
|
||||||
|
uint32_t V:1; /*!< bit: 28 Overflow condition code flag */
|
||||||
|
uint32_t C:1; /*!< bit: 29 Carry condition code flag */
|
||||||
|
uint32_t Z:1; /*!< bit: 30 Zero condition code flag */
|
||||||
|
uint32_t N:1; /*!< bit: 31 Negative condition code flag */
|
||||||
|
} b; /*!< Structure used for bit access */
|
||||||
|
uint32_t w; /*!< Type used for word access */
|
||||||
|
} APSR_Type;
|
||||||
|
|
||||||
|
/* APSR Register Definitions */
|
||||||
|
#define APSR_N_Pos 31U /*!< APSR: N Position */
|
||||||
|
#define APSR_N_Msk (1UL << APSR_N_Pos) /*!< APSR: N Mask */
|
||||||
|
|
||||||
|
#define APSR_Z_Pos 30U /*!< APSR: Z Position */
|
||||||
|
#define APSR_Z_Msk (1UL << APSR_Z_Pos) /*!< APSR: Z Mask */
|
||||||
|
|
||||||
|
#define APSR_C_Pos 29U /*!< APSR: C Position */
|
||||||
|
#define APSR_C_Msk (1UL << APSR_C_Pos) /*!< APSR: C Mask */
|
||||||
|
|
||||||
|
#define APSR_V_Pos 28U /*!< APSR: V Position */
|
||||||
|
#define APSR_V_Msk (1UL << APSR_V_Pos) /*!< APSR: V Mask */
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
\brief Union type to access the Interrupt Program Status Register (IPSR).
|
||||||
|
*/
|
||||||
|
typedef union
|
||||||
|
{
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */
|
||||||
|
uint32_t _reserved0:23; /*!< bit: 9..31 Reserved */
|
||||||
|
} b; /*!< Structure used for bit access */
|
||||||
|
uint32_t w; /*!< Type used for word access */
|
||||||
|
} IPSR_Type;
|
||||||
|
|
||||||
|
/* IPSR Register Definitions */
|
||||||
|
#define IPSR_ISR_Pos 0U /*!< IPSR: ISR Position */
|
||||||
|
#define IPSR_ISR_Msk (0x1FFUL /*<< IPSR_ISR_Pos*/) /*!< IPSR: ISR Mask */
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
\brief Union type to access the Special-Purpose Program Status Registers (xPSR).
|
||||||
|
*/
|
||||||
|
typedef union
|
||||||
|
{
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */
|
||||||
|
uint32_t _reserved0:15; /*!< bit: 9..23 Reserved */
|
||||||
|
uint32_t T:1; /*!< bit: 24 Thumb bit (read 0) */
|
||||||
|
uint32_t _reserved1:3; /*!< bit: 25..27 Reserved */
|
||||||
|
uint32_t V:1; /*!< bit: 28 Overflow condition code flag */
|
||||||
|
uint32_t C:1; /*!< bit: 29 Carry condition code flag */
|
||||||
|
uint32_t Z:1; /*!< bit: 30 Zero condition code flag */
|
||||||
|
uint32_t N:1; /*!< bit: 31 Negative condition code flag */
|
||||||
|
} b; /*!< Structure used for bit access */
|
||||||
|
uint32_t w; /*!< Type used for word access */
|
||||||
|
} xPSR_Type;
|
||||||
|
|
||||||
|
/* xPSR Register Definitions */
|
||||||
|
#define xPSR_N_Pos 31U /*!< xPSR: N Position */
|
||||||
|
#define xPSR_N_Msk (1UL << xPSR_N_Pos) /*!< xPSR: N Mask */
|
||||||
|
|
||||||
|
#define xPSR_Z_Pos 30U /*!< xPSR: Z Position */
|
||||||
|
#define xPSR_Z_Msk (1UL << xPSR_Z_Pos) /*!< xPSR: Z Mask */
|
||||||
|
|
||||||
|
#define xPSR_C_Pos 29U /*!< xPSR: C Position */
|
||||||
|
#define xPSR_C_Msk (1UL << xPSR_C_Pos) /*!< xPSR: C Mask */
|
||||||
|
|
||||||
|
#define xPSR_V_Pos 28U /*!< xPSR: V Position */
|
||||||
|
#define xPSR_V_Msk (1UL << xPSR_V_Pos) /*!< xPSR: V Mask */
|
||||||
|
|
||||||
|
#define xPSR_T_Pos 24U /*!< xPSR: T Position */
|
||||||
|
#define xPSR_T_Msk (1UL << xPSR_T_Pos) /*!< xPSR: T Mask */
|
||||||
|
|
||||||
|
#define xPSR_ISR_Pos 0U /*!< xPSR: ISR Position */
|
||||||
|
#define xPSR_ISR_Msk (0x1FFUL /*<< xPSR_ISR_Pos*/) /*!< xPSR: ISR Mask */
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
\brief Union type to access the Control Registers (CONTROL).
|
||||||
|
*/
|
||||||
|
typedef union
|
||||||
|
{
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
uint32_t nPRIV:1; /*!< bit: 0 Execution privilege in Thread mode */
|
||||||
|
uint32_t SPSEL:1; /*!< bit: 1 Stack to be used */
|
||||||
|
uint32_t _reserved1:30; /*!< bit: 2..31 Reserved */
|
||||||
|
} b; /*!< Structure used for bit access */
|
||||||
|
uint32_t w; /*!< Type used for word access */
|
||||||
|
} CONTROL_Type;
|
||||||
|
|
||||||
|
/* CONTROL Register Definitions */
|
||||||
|
#define CONTROL_SPSEL_Pos 1U /*!< CONTROL: SPSEL Position */
|
||||||
|
#define CONTROL_SPSEL_Msk (1UL << CONTROL_SPSEL_Pos) /*!< CONTROL: SPSEL Mask */
|
||||||
|
|
||||||
|
#define CONTROL_nPRIV_Pos 0U /*!< CONTROL: nPRIV Position */
|
||||||
|
#define CONTROL_nPRIV_Msk (1UL /*<< CONTROL_nPRIV_Pos*/) /*!< CONTROL: nPRIV Mask */
|
||||||
|
|
||||||
|
/*@} end of group CMSIS_CORE */
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
\ingroup CMSIS_core_register
|
||||||
|
\defgroup CMSIS_NVIC Nested Vectored Interrupt Controller (NVIC)
|
||||||
|
\brief Type definitions for the NVIC Registers
|
||||||
|
@{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
\brief Structure type to access the Nested Vectored Interrupt Controller (NVIC).
|
||||||
|
*/
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
__IOM uint32_t ISER[1U]; /*!< Offset: 0x000 (R/W) Interrupt Set Enable Register */
|
||||||
|
uint32_t RESERVED0[31U];
|
||||||
|
__IOM uint32_t ICER[1U]; /*!< Offset: 0x080 (R/W) Interrupt Clear Enable Register */
|
||||||
|
uint32_t RSERVED1[31U];
|
||||||
|
__IOM uint32_t ISPR[1U]; /*!< Offset: 0x100 (R/W) Interrupt Set Pending Register */
|
||||||
|
uint32_t RESERVED2[31U];
|
||||||
|
__IOM uint32_t ICPR[1U]; /*!< Offset: 0x180 (R/W) Interrupt Clear Pending Register */
|
||||||
|
uint32_t RESERVED3[31U];
|
||||||
|
uint32_t RESERVED4[64U];
|
||||||
|
__IOM uint32_t IP[8U]; /*!< Offset: 0x300 (R/W) Interrupt Priority Register */
|
||||||
|
} NVIC_Type;
|
||||||
|
|
||||||
|
/*@} end of group CMSIS_NVIC */
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
\ingroup CMSIS_core_register
|
||||||
|
\defgroup CMSIS_SCB System Control Block (SCB)
|
||||||
|
\brief Type definitions for the System Control Block Registers
|
||||||
|
@{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
\brief Structure type to access the System Control Block (SCB).
|
||||||
|
*/
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
__IM uint32_t CPUID; /*!< Offset: 0x000 (R/ ) CPUID Base Register */
|
||||||
|
__IOM uint32_t ICSR; /*!< Offset: 0x004 (R/W) Interrupt Control and State Register */
|
||||||
|
#if (__VTOR_PRESENT == 1U)
|
||||||
|
__IOM uint32_t VTOR; /*!< Offset: 0x008 (R/W) Vector Table Offset Register */
|
||||||
|
#else
|
||||||
|
uint32_t RESERVED0;
|
||||||
|
#endif
|
||||||
|
__IOM uint32_t AIRCR; /*!< Offset: 0x00C (R/W) Application Interrupt and Reset Control Register */
|
||||||
|
__IOM uint32_t SCR; /*!< Offset: 0x010 (R/W) System Control Register */
|
||||||
|
__IOM uint32_t CCR; /*!< Offset: 0x014 (R/W) Configuration Control Register */
|
||||||
|
uint32_t RESERVED1;
|
||||||
|
__IOM uint32_t SHP[2U]; /*!< Offset: 0x01C (R/W) System Handlers Priority Registers. [0] is RESERVED */
|
||||||
|
__IOM uint32_t SHCSR; /*!< Offset: 0x024 (R/W) System Handler Control and State Register */
|
||||||
|
} SCB_Type;
|
||||||
|
|
||||||
|
/* SCB CPUID Register Definitions */
|
||||||
|
#define SCB_CPUID_IMPLEMENTER_Pos 24U /*!< SCB CPUID: IMPLEMENTER Position */
|
||||||
|
#define SCB_CPUID_IMPLEMENTER_Msk (0xFFUL << SCB_CPUID_IMPLEMENTER_Pos) /*!< SCB CPUID: IMPLEMENTER Mask */
|
||||||
|
|
||||||
|
#define SCB_CPUID_VARIANT_Pos 20U /*!< SCB CPUID: VARIANT Position */
|
||||||
|
#define SCB_CPUID_VARIANT_Msk (0xFUL << SCB_CPUID_VARIANT_Pos) /*!< SCB CPUID: VARIANT Mask */
|
||||||
|
|
||||||
|
#define SCB_CPUID_ARCHITECTURE_Pos 16U /*!< SCB CPUID: ARCHITECTURE Position */
|
||||||
|
#define SCB_CPUID_ARCHITECTURE_Msk (0xFUL << SCB_CPUID_ARCHITECTURE_Pos) /*!< SCB CPUID: ARCHITECTURE Mask */
|
||||||
|
|
||||||
|
#define SCB_CPUID_PARTNO_Pos 4U /*!< SCB CPUID: PARTNO Position */
|
||||||
|
#define SCB_CPUID_PARTNO_Msk (0xFFFUL << SCB_CPUID_PARTNO_Pos) /*!< SCB CPUID: PARTNO Mask */
|
||||||
|
|
||||||
|
#define SCB_CPUID_REVISION_Pos 0U /*!< SCB CPUID: REVISION Position */
|
||||||
|
#define SCB_CPUID_REVISION_Msk (0xFUL /*<< SCB_CPUID_REVISION_Pos*/) /*!< SCB CPUID: REVISION Mask */
|
||||||
|
|
||||||
|
/* SCB Interrupt Control State Register Definitions */
|
||||||
|
#define SCB_ICSR_NMIPENDSET_Pos 31U /*!< SCB ICSR: NMIPENDSET Position */
|
||||||
|
#define SCB_ICSR_NMIPENDSET_Msk (1UL << SCB_ICSR_NMIPENDSET_Pos) /*!< SCB ICSR: NMIPENDSET Mask */
|
||||||
|
|
||||||
|
#define SCB_ICSR_PENDSVSET_Pos 28U /*!< SCB ICSR: PENDSVSET Position */
|
||||||
|
#define SCB_ICSR_PENDSVSET_Msk (1UL << SCB_ICSR_PENDSVSET_Pos) /*!< SCB ICSR: PENDSVSET Mask */
|
||||||
|
|
||||||
|
#define SCB_ICSR_PENDSVCLR_Pos 27U /*!< SCB ICSR: PENDSVCLR Position */
|
||||||
|
#define SCB_ICSR_PENDSVCLR_Msk (1UL << SCB_ICSR_PENDSVCLR_Pos) /*!< SCB ICSR: PENDSVCLR Mask */
|
||||||
|
|
||||||
|
#define SCB_ICSR_PENDSTSET_Pos 26U /*!< SCB ICSR: PENDSTSET Position */
|
||||||
|
#define SCB_ICSR_PENDSTSET_Msk (1UL << SCB_ICSR_PENDSTSET_Pos) /*!< SCB ICSR: PENDSTSET Mask */
|
||||||
|
|
||||||
|
#define SCB_ICSR_PENDSTCLR_Pos 25U /*!< SCB ICSR: PENDSTCLR Position */
|
||||||
|
#define SCB_ICSR_PENDSTCLR_Msk (1UL << SCB_ICSR_PENDSTCLR_Pos) /*!< SCB ICSR: PENDSTCLR Mask */
|
||||||
|
|
||||||
|
#define SCB_ICSR_ISRPREEMPT_Pos 23U /*!< SCB ICSR: ISRPREEMPT Position */
|
||||||
|
#define SCB_ICSR_ISRPREEMPT_Msk (1UL << SCB_ICSR_ISRPREEMPT_Pos) /*!< SCB ICSR: ISRPREEMPT Mask */
|
||||||
|
|
||||||
|
#define SCB_ICSR_ISRPENDING_Pos 22U /*!< SCB ICSR: ISRPENDING Position */
|
||||||
|
#define SCB_ICSR_ISRPENDING_Msk (1UL << SCB_ICSR_ISRPENDING_Pos) /*!< SCB ICSR: ISRPENDING Mask */
|
||||||
|
|
||||||
|
#define SCB_ICSR_VECTPENDING_Pos 12U /*!< SCB ICSR: VECTPENDING Position */
|
||||||
|
#define SCB_ICSR_VECTPENDING_Msk (0x1FFUL << SCB_ICSR_VECTPENDING_Pos) /*!< SCB ICSR: VECTPENDING Mask */
|
||||||
|
|
||||||
|
#define SCB_ICSR_VECTACTIVE_Pos 0U /*!< SCB ICSR: VECTACTIVE Position */
|
||||||
|
#define SCB_ICSR_VECTACTIVE_Msk (0x1FFUL /*<< SCB_ICSR_VECTACTIVE_Pos*/) /*!< SCB ICSR: VECTACTIVE Mask */
|
||||||
|
|
||||||
|
#if (__VTOR_PRESENT == 1U)
|
||||||
|
/* SCB Interrupt Control State Register Definitions */
|
||||||
|
#define SCB_VTOR_TBLOFF_Pos 8U /*!< SCB VTOR: TBLOFF Position */
|
||||||
|
#define SCB_VTOR_TBLOFF_Msk (0xFFFFFFUL << SCB_VTOR_TBLOFF_Pos) /*!< SCB VTOR: TBLOFF Mask */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* SCB Application Interrupt and Reset Control Register Definitions */
|
||||||
|
#define SCB_AIRCR_VECTKEY_Pos 16U /*!< SCB AIRCR: VECTKEY Position */
|
||||||
|
#define SCB_AIRCR_VECTKEY_Msk (0xFFFFUL << SCB_AIRCR_VECTKEY_Pos) /*!< SCB AIRCR: VECTKEY Mask */
|
||||||
|
|
||||||
|
#define SCB_AIRCR_VECTKEYSTAT_Pos 16U /*!< SCB AIRCR: VECTKEYSTAT Position */
|
||||||
|
#define SCB_AIRCR_VECTKEYSTAT_Msk (0xFFFFUL << SCB_AIRCR_VECTKEYSTAT_Pos) /*!< SCB AIRCR: VECTKEYSTAT Mask */
|
||||||
|
|
||||||
|
#define SCB_AIRCR_ENDIANESS_Pos 15U /*!< SCB AIRCR: ENDIANESS Position */
|
||||||
|
#define SCB_AIRCR_ENDIANESS_Msk (1UL << SCB_AIRCR_ENDIANESS_Pos) /*!< SCB AIRCR: ENDIANESS Mask */
|
||||||
|
|
||||||
|
#define SCB_AIRCR_SYSRESETREQ_Pos 2U /*!< SCB AIRCR: SYSRESETREQ Position */
|
||||||
|
#define SCB_AIRCR_SYSRESETREQ_Msk (1UL << SCB_AIRCR_SYSRESETREQ_Pos) /*!< SCB AIRCR: SYSRESETREQ Mask */
|
||||||
|
|
||||||
|
#define SCB_AIRCR_VECTCLRACTIVE_Pos 1U /*!< SCB AIRCR: VECTCLRACTIVE Position */
|
||||||
|
#define SCB_AIRCR_VECTCLRACTIVE_Msk (1UL << SCB_AIRCR_VECTCLRACTIVE_Pos) /*!< SCB AIRCR: VECTCLRACTIVE Mask */
|
||||||
|
|
||||||
|
/* SCB System Control Register Definitions */
|
||||||
|
#define SCB_SCR_SEVONPEND_Pos 4U /*!< SCB SCR: SEVONPEND Position */
|
||||||
|
#define SCB_SCR_SEVONPEND_Msk (1UL << SCB_SCR_SEVONPEND_Pos) /*!< SCB SCR: SEVONPEND Mask */
|
||||||
|
|
||||||
|
#define SCB_SCR_SLEEPDEEP_Pos 2U /*!< SCB SCR: SLEEPDEEP Position */
|
||||||
|
#define SCB_SCR_SLEEPDEEP_Msk (1UL << SCB_SCR_SLEEPDEEP_Pos) /*!< SCB SCR: SLEEPDEEP Mask */
|
||||||
|
|
||||||
|
#define SCB_SCR_SLEEPONEXIT_Pos 1U /*!< SCB SCR: SLEEPONEXIT Position */
|
||||||
|
#define SCB_SCR_SLEEPONEXIT_Msk (1UL << SCB_SCR_SLEEPONEXIT_Pos) /*!< SCB SCR: SLEEPONEXIT Mask */
|
||||||
|
|
||||||
|
/* SCB Configuration Control Register Definitions */
|
||||||
|
#define SCB_CCR_STKALIGN_Pos 9U /*!< SCB CCR: STKALIGN Position */
|
||||||
|
#define SCB_CCR_STKALIGN_Msk (1UL << SCB_CCR_STKALIGN_Pos) /*!< SCB CCR: STKALIGN Mask */
|
||||||
|
|
||||||
|
#define SCB_CCR_UNALIGN_TRP_Pos 3U /*!< SCB CCR: UNALIGN_TRP Position */
|
||||||
|
#define SCB_CCR_UNALIGN_TRP_Msk (1UL << SCB_CCR_UNALIGN_TRP_Pos) /*!< SCB CCR: UNALIGN_TRP Mask */
|
||||||
|
|
||||||
|
/* SCB System Handler Control and State Register Definitions */
|
||||||
|
#define SCB_SHCSR_SVCALLPENDED_Pos 15U /*!< SCB SHCSR: SVCALLPENDED Position */
|
||||||
|
#define SCB_SHCSR_SVCALLPENDED_Msk (1UL << SCB_SHCSR_SVCALLPENDED_Pos) /*!< SCB SHCSR: SVCALLPENDED Mask */
|
||||||
|
|
||||||
|
/*@} end of group CMSIS_SCB */
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
\ingroup CMSIS_core_register
|
||||||
|
\defgroup CMSIS_SysTick System Tick Timer (SysTick)
|
||||||
|
\brief Type definitions for the System Timer Registers.
|
||||||
|
@{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
\brief Structure type to access the System Timer (SysTick).
|
||||||
|
*/
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
__IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) SysTick Control and Status Register */
|
||||||
|
__IOM uint32_t LOAD; /*!< Offset: 0x004 (R/W) SysTick Reload Value Register */
|
||||||
|
__IOM uint32_t VAL; /*!< Offset: 0x008 (R/W) SysTick Current Value Register */
|
||||||
|
__IM uint32_t CALIB; /*!< Offset: 0x00C (R/ ) SysTick Calibration Register */
|
||||||
|
} SysTick_Type;
|
||||||
|
|
||||||
|
/* SysTick Control / Status Register Definitions */
|
||||||
|
#define SysTick_CTRL_COUNTFLAG_Pos 16U /*!< SysTick CTRL: COUNTFLAG Position */
|
||||||
|
#define SysTick_CTRL_COUNTFLAG_Msk (1UL << SysTick_CTRL_COUNTFLAG_Pos) /*!< SysTick CTRL: COUNTFLAG Mask */
|
||||||
|
|
||||||
|
#define SysTick_CTRL_CLKSOURCE_Pos 2U /*!< SysTick CTRL: CLKSOURCE Position */
|
||||||
|
#define SysTick_CTRL_CLKSOURCE_Msk (1UL << SysTick_CTRL_CLKSOURCE_Pos) /*!< SysTick CTRL: CLKSOURCE Mask */
|
||||||
|
|
||||||
|
#define SysTick_CTRL_TICKINT_Pos 1U /*!< SysTick CTRL: TICKINT Position */
|
||||||
|
#define SysTick_CTRL_TICKINT_Msk (1UL << SysTick_CTRL_TICKINT_Pos) /*!< SysTick CTRL: TICKINT Mask */
|
||||||
|
|
||||||
|
#define SysTick_CTRL_ENABLE_Pos 0U /*!< SysTick CTRL: ENABLE Position */
|
||||||
|
#define SysTick_CTRL_ENABLE_Msk (1UL /*<< SysTick_CTRL_ENABLE_Pos*/) /*!< SysTick CTRL: ENABLE Mask */
|
||||||
|
|
||||||
|
/* SysTick Reload Register Definitions */
|
||||||
|
#define SysTick_LOAD_RELOAD_Pos 0U /*!< SysTick LOAD: RELOAD Position */
|
||||||
|
#define SysTick_LOAD_RELOAD_Msk (0xFFFFFFUL /*<< SysTick_LOAD_RELOAD_Pos*/) /*!< SysTick LOAD: RELOAD Mask */
|
||||||
|
|
||||||
|
/* SysTick Current Register Definitions */
|
||||||
|
#define SysTick_VAL_CURRENT_Pos 0U /*!< SysTick VAL: CURRENT Position */
|
||||||
|
#define SysTick_VAL_CURRENT_Msk (0xFFFFFFUL /*<< SysTick_VAL_CURRENT_Pos*/) /*!< SysTick VAL: CURRENT Mask */
|
||||||
|
|
||||||
|
/* SysTick Calibration Register Definitions */
|
||||||
|
#define SysTick_CALIB_NOREF_Pos 31U /*!< SysTick CALIB: NOREF Position */
|
||||||
|
#define SysTick_CALIB_NOREF_Msk (1UL << SysTick_CALIB_NOREF_Pos) /*!< SysTick CALIB: NOREF Mask */
|
||||||
|
|
||||||
|
#define SysTick_CALIB_SKEW_Pos 30U /*!< SysTick CALIB: SKEW Position */
|
||||||
|
#define SysTick_CALIB_SKEW_Msk (1UL << SysTick_CALIB_SKEW_Pos) /*!< SysTick CALIB: SKEW Mask */
|
||||||
|
|
||||||
|
#define SysTick_CALIB_TENMS_Pos 0U /*!< SysTick CALIB: TENMS Position */
|
||||||
|
#define SysTick_CALIB_TENMS_Msk (0xFFFFFFUL /*<< SysTick_CALIB_TENMS_Pos*/) /*!< SysTick CALIB: TENMS Mask */
|
||||||
|
|
||||||
|
/*@} end of group CMSIS_SysTick */
|
||||||
|
|
||||||
|
#if (__MPU_PRESENT == 1U)
|
||||||
|
/**
|
||||||
|
\ingroup CMSIS_core_register
|
||||||
|
\defgroup CMSIS_MPU Memory Protection Unit (MPU)
|
||||||
|
\brief Type definitions for the Memory Protection Unit (MPU)
|
||||||
|
@{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
\brief Structure type to access the Memory Protection Unit (MPU).
|
||||||
|
*/
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
__IM uint32_t TYPE; /*!< Offset: 0x000 (R/ ) MPU Type Register */
|
||||||
|
__IOM uint32_t CTRL; /*!< Offset: 0x004 (R/W) MPU Control Register */
|
||||||
|
__IOM uint32_t RNR; /*!< Offset: 0x008 (R/W) MPU Region RNRber Register */
|
||||||
|
__IOM uint32_t RBAR; /*!< Offset: 0x00C (R/W) MPU Region Base Address Register */
|
||||||
|
__IOM uint32_t RASR; /*!< Offset: 0x010 (R/W) MPU Region Attribute and Size Register */
|
||||||
|
} MPU_Type;
|
||||||
|
|
||||||
|
/* MPU Type Register Definitions */
|
||||||
|
#define MPU_TYPE_IREGION_Pos 16U /*!< MPU TYPE: IREGION Position */
|
||||||
|
#define MPU_TYPE_IREGION_Msk (0xFFUL << MPU_TYPE_IREGION_Pos) /*!< MPU TYPE: IREGION Mask */
|
||||||
|
|
||||||
|
#define MPU_TYPE_DREGION_Pos 8U /*!< MPU TYPE: DREGION Position */
|
||||||
|
#define MPU_TYPE_DREGION_Msk (0xFFUL << MPU_TYPE_DREGION_Pos) /*!< MPU TYPE: DREGION Mask */
|
||||||
|
|
||||||
|
#define MPU_TYPE_SEPARATE_Pos 0U /*!< MPU TYPE: SEPARATE Position */
|
||||||
|
#define MPU_TYPE_SEPARATE_Msk (1UL /*<< MPU_TYPE_SEPARATE_Pos*/) /*!< MPU TYPE: SEPARATE Mask */
|
||||||
|
|
||||||
|
/* MPU Control Register Definitions */
|
||||||
|
#define MPU_CTRL_PRIVDEFENA_Pos 2U /*!< MPU CTRL: PRIVDEFENA Position */
|
||||||
|
#define MPU_CTRL_PRIVDEFENA_Msk (1UL << MPU_CTRL_PRIVDEFENA_Pos) /*!< MPU CTRL: PRIVDEFENA Mask */
|
||||||
|
|
||||||
|
#define MPU_CTRL_HFNMIENA_Pos 1U /*!< MPU CTRL: HFNMIENA Position */
|
||||||
|
#define MPU_CTRL_HFNMIENA_Msk (1UL << MPU_CTRL_HFNMIENA_Pos) /*!< MPU CTRL: HFNMIENA Mask */
|
||||||
|
|
||||||
|
#define MPU_CTRL_ENABLE_Pos 0U /*!< MPU CTRL: ENABLE Position */
|
||||||
|
#define MPU_CTRL_ENABLE_Msk (1UL /*<< MPU_CTRL_ENABLE_Pos*/) /*!< MPU CTRL: ENABLE Mask */
|
||||||
|
|
||||||
|
/* MPU Region Number Register Definitions */
|
||||||
|
#define MPU_RNR_REGION_Pos 0U /*!< MPU RNR: REGION Position */
|
||||||
|
#define MPU_RNR_REGION_Msk (0xFFUL /*<< MPU_RNR_REGION_Pos*/) /*!< MPU RNR: REGION Mask */
|
||||||
|
|
||||||
|
/* MPU Region Base Address Register Definitions */
|
||||||
|
#define MPU_RBAR_ADDR_Pos 8U /*!< MPU RBAR: ADDR Position */
|
||||||
|
#define MPU_RBAR_ADDR_Msk (0xFFFFFFUL << MPU_RBAR_ADDR_Pos) /*!< MPU RBAR: ADDR Mask */
|
||||||
|
|
||||||
|
#define MPU_RBAR_VALID_Pos 4U /*!< MPU RBAR: VALID Position */
|
||||||
|
#define MPU_RBAR_VALID_Msk (1UL << MPU_RBAR_VALID_Pos) /*!< MPU RBAR: VALID Mask */
|
||||||
|
|
||||||
|
#define MPU_RBAR_REGION_Pos 0U /*!< MPU RBAR: REGION Position */
|
||||||
|
#define MPU_RBAR_REGION_Msk (0xFUL /*<< MPU_RBAR_REGION_Pos*/) /*!< MPU RBAR: REGION Mask */
|
||||||
|
|
||||||
|
/* MPU Region Attribute and Size Register Definitions */
|
||||||
|
#define MPU_RASR_ATTRS_Pos 16U /*!< MPU RASR: MPU Region Attribute field Position */
|
||||||
|
#define MPU_RASR_ATTRS_Msk (0xFFFFUL << MPU_RASR_ATTRS_Pos) /*!< MPU RASR: MPU Region Attribute field Mask */
|
||||||
|
|
||||||
|
#define MPU_RASR_XN_Pos 28U /*!< MPU RASR: ATTRS.XN Position */
|
||||||
|
#define MPU_RASR_XN_Msk (1UL << MPU_RASR_XN_Pos) /*!< MPU RASR: ATTRS.XN Mask */
|
||||||
|
|
||||||
|
#define MPU_RASR_AP_Pos 24U /*!< MPU RASR: ATTRS.AP Position */
|
||||||
|
#define MPU_RASR_AP_Msk (0x7UL << MPU_RASR_AP_Pos) /*!< MPU RASR: ATTRS.AP Mask */
|
||||||
|
|
||||||
|
#define MPU_RASR_TEX_Pos 19U /*!< MPU RASR: ATTRS.TEX Position */
|
||||||
|
#define MPU_RASR_TEX_Msk (0x7UL << MPU_RASR_TEX_Pos) /*!< MPU RASR: ATTRS.TEX Mask */
|
||||||
|
|
||||||
|
#define MPU_RASR_S_Pos 18U /*!< MPU RASR: ATTRS.S Position */
|
||||||
|
#define MPU_RASR_S_Msk (1UL << MPU_RASR_S_Pos) /*!< MPU RASR: ATTRS.S Mask */
|
||||||
|
|
||||||
|
#define MPU_RASR_C_Pos 17U /*!< MPU RASR: ATTRS.C Position */
|
||||||
|
#define MPU_RASR_C_Msk (1UL << MPU_RASR_C_Pos) /*!< MPU RASR: ATTRS.C Mask */
|
||||||
|
|
||||||
|
#define MPU_RASR_B_Pos 16U /*!< MPU RASR: ATTRS.B Position */
|
||||||
|
#define MPU_RASR_B_Msk (1UL << MPU_RASR_B_Pos) /*!< MPU RASR: ATTRS.B Mask */
|
||||||
|
|
||||||
|
#define MPU_RASR_SRD_Pos 8U /*!< MPU RASR: Sub-Region Disable Position */
|
||||||
|
#define MPU_RASR_SRD_Msk (0xFFUL << MPU_RASR_SRD_Pos) /*!< MPU RASR: Sub-Region Disable Mask */
|
||||||
|
|
||||||
|
#define MPU_RASR_SIZE_Pos 1U /*!< MPU RASR: Region Size Field Position */
|
||||||
|
#define MPU_RASR_SIZE_Msk (0x1FUL << MPU_RASR_SIZE_Pos) /*!< MPU RASR: Region Size Field Mask */
|
||||||
|
|
||||||
|
#define MPU_RASR_ENABLE_Pos 0U /*!< MPU RASR: Region enable bit Position */
|
||||||
|
#define MPU_RASR_ENABLE_Msk (1UL /*<< MPU_RASR_ENABLE_Pos*/) /*!< MPU RASR: Region enable bit Disable Mask */
|
||||||
|
|
||||||
|
/*@} end of group CMSIS_MPU */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
\ingroup CMSIS_core_register
|
||||||
|
\defgroup CMSIS_CoreDebug Core Debug Registers (CoreDebug)
|
||||||
|
\brief Cortex-M0+ Core Debug Registers (DCB registers, SHCSR, and DFSR) are only accessible over DAP and not via processor.
|
||||||
|
Therefore they are not covered by the Cortex-M0+ header file.
|
||||||
|
@{
|
||||||
|
*/
|
||||||
|
/*@} end of group CMSIS_CoreDebug */
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
\ingroup CMSIS_core_register
|
||||||
|
\defgroup CMSIS_core_bitfield Core register bit field macros
|
||||||
|
\brief Macros for use with bit field definitions (xxx_Pos, xxx_Msk).
|
||||||
|
@{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
\brief Mask and shift a bit field value for use in a register bit range.
|
||||||
|
\param[in] field Name of the register bit field.
|
||||||
|
\param[in] value Value of the bit field.
|
||||||
|
\return Masked and shifted value.
|
||||||
|
*/
|
||||||
|
#define _VAL2FLD(field, value) ((value << field ## _Pos) & field ## _Msk)
|
||||||
|
|
||||||
|
/**
|
||||||
|
\brief Mask and shift a register value to extract a bit filed value.
|
||||||
|
\param[in] field Name of the register bit field.
|
||||||
|
\param[in] value Value of register.
|
||||||
|
\return Masked and shifted bit field value.
|
||||||
|
*/
|
||||||
|
#define _FLD2VAL(field, value) ((value & field ## _Msk) >> field ## _Pos)
|
||||||
|
|
||||||
|
/*@} end of group CMSIS_core_bitfield */
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
\ingroup CMSIS_core_register
|
||||||
|
\defgroup CMSIS_core_base Core Definitions
|
||||||
|
\brief Definitions for base addresses, unions, and structures.
|
||||||
|
@{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Memory mapping of Cortex-M0+ Hardware */
|
||||||
|
#define SCS_BASE (0xE000E000UL) /*!< System Control Space Base Address */
|
||||||
|
#define SysTick_BASE (SCS_BASE + 0x0010UL) /*!< SysTick Base Address */
|
||||||
|
#define NVIC_BASE (SCS_BASE + 0x0100UL) /*!< NVIC Base Address */
|
||||||
|
#define SCB_BASE (SCS_BASE + 0x0D00UL) /*!< System Control Block Base Address */
|
||||||
|
|
||||||
|
#define SCB ((SCB_Type *) SCB_BASE ) /*!< SCB configuration struct */
|
||||||
|
#define SysTick ((SysTick_Type *) SysTick_BASE ) /*!< SysTick configuration struct */
|
||||||
|
#define NVIC ((NVIC_Type *) NVIC_BASE ) /*!< NVIC configuration struct */
|
||||||
|
|
||||||
|
#if (__MPU_PRESENT == 1U)
|
||||||
|
#define MPU_BASE (SCS_BASE + 0x0D90UL) /*!< Memory Protection Unit */
|
||||||
|
#define MPU ((MPU_Type *) MPU_BASE ) /*!< Memory Protection Unit */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*@} */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Hardware Abstraction Layer
|
||||||
|
Core Function Interface contains:
|
||||||
|
- Core NVIC Functions
|
||||||
|
- Core SysTick Functions
|
||||||
|
- Core Register Access Functions
|
||||||
|
******************************************************************************/
|
||||||
|
/**
|
||||||
|
\defgroup CMSIS_Core_FunctionInterface Functions and Instructions Reference
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* ########################## NVIC functions #################################### */
|
||||||
|
/**
|
||||||
|
\ingroup CMSIS_Core_FunctionInterface
|
||||||
|
\defgroup CMSIS_Core_NVICFunctions NVIC Functions
|
||||||
|
\brief Functions that manage interrupts and exceptions via the NVIC.
|
||||||
|
@{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Interrupt Priorities are WORD accessible only under ARMv6M */
|
||||||
|
/* The following MACROS handle generation of the register offset and byte masks */
|
||||||
|
#define _BIT_SHIFT(IRQn) ( ((((uint32_t)(int32_t)(IRQn)) ) & 0x03UL) * 8UL)
|
||||||
|
#define _SHP_IDX(IRQn) ( (((((uint32_t)(int32_t)(IRQn)) & 0x0FUL)-8UL) >> 2UL) )
|
||||||
|
#define _IP_IDX(IRQn) ( (((uint32_t)(int32_t)(IRQn)) >> 2UL) )
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
\brief Enable External Interrupt
|
||||||
|
\details Enables a device-specific interrupt in the NVIC interrupt controller.
|
||||||
|
\param [in] IRQn External interrupt number. Value cannot be negative.
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE void NVIC_EnableIRQ(IRQn_Type IRQn)
|
||||||
|
{
|
||||||
|
NVIC->ISER[0U] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
\brief Disable External Interrupt
|
||||||
|
\details Disables a device-specific interrupt in the NVIC interrupt controller.
|
||||||
|
\param [in] IRQn External interrupt number. Value cannot be negative.
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE void NVIC_DisableIRQ(IRQn_Type IRQn)
|
||||||
|
{
|
||||||
|
NVIC->ICER[0U] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
\brief Get Pending Interrupt
|
||||||
|
\details Reads the pending register in the NVIC and returns the pending bit for the specified interrupt.
|
||||||
|
\param [in] IRQn Interrupt number.
|
||||||
|
\return 0 Interrupt status is not pending.
|
||||||
|
\return 1 Interrupt status is pending.
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE uint32_t NVIC_GetPendingIRQ(IRQn_Type IRQn)
|
||||||
|
{
|
||||||
|
return((uint32_t)(((NVIC->ISPR[0U] & (1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
\brief Set Pending Interrupt
|
||||||
|
\details Sets the pending bit of an external interrupt.
|
||||||
|
\param [in] IRQn Interrupt number. Value cannot be negative.
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE void NVIC_SetPendingIRQ(IRQn_Type IRQn)
|
||||||
|
{
|
||||||
|
NVIC->ISPR[0U] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
\brief Clear Pending Interrupt
|
||||||
|
\details Clears the pending bit of an external interrupt.
|
||||||
|
\param [in] IRQn External interrupt number. Value cannot be negative.
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE void NVIC_ClearPendingIRQ(IRQn_Type IRQn)
|
||||||
|
{
|
||||||
|
NVIC->ICPR[0U] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
\brief Set Interrupt Priority
|
||||||
|
\details Sets the priority of an interrupt.
|
||||||
|
\note The priority cannot be set for every core interrupt.
|
||||||
|
\param [in] IRQn Interrupt number.
|
||||||
|
\param [in] priority Priority to set.
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE void NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority)
|
||||||
|
{
|
||||||
|
if ((int32_t)(IRQn) < 0)
|
||||||
|
{
|
||||||
|
SCB->SHP[_SHP_IDX(IRQn)] = ((uint32_t)(SCB->SHP[_SHP_IDX(IRQn)] & ~(0xFFUL << _BIT_SHIFT(IRQn))) |
|
||||||
|
(((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL) << _BIT_SHIFT(IRQn)));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
NVIC->IP[_IP_IDX(IRQn)] = ((uint32_t)(NVIC->IP[_IP_IDX(IRQn)] & ~(0xFFUL << _BIT_SHIFT(IRQn))) |
|
||||||
|
(((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL) << _BIT_SHIFT(IRQn)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
\brief Get Interrupt Priority
|
||||||
|
\details Reads the priority of an interrupt.
|
||||||
|
The interrupt number can be positive to specify an external (device specific) interrupt,
|
||||||
|
or negative to specify an internal (core) interrupt.
|
||||||
|
\param [in] IRQn Interrupt number.
|
||||||
|
\return Interrupt Priority.
|
||||||
|
Value is aligned automatically to the implemented priority bits of the microcontroller.
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE uint32_t NVIC_GetPriority(IRQn_Type IRQn)
|
||||||
|
{
|
||||||
|
|
||||||
|
if ((int32_t)(IRQn) < 0)
|
||||||
|
{
|
||||||
|
return((uint32_t)(((SCB->SHP[_SHP_IDX(IRQn)] >> _BIT_SHIFT(IRQn) ) & (uint32_t)0xFFUL) >> (8U - __NVIC_PRIO_BITS)));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return((uint32_t)(((NVIC->IP[ _IP_IDX(IRQn)] >> _BIT_SHIFT(IRQn) ) & (uint32_t)0xFFUL) >> (8U - __NVIC_PRIO_BITS)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
\brief System Reset
|
||||||
|
\details Initiates a system reset request to reset the MCU.
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE void NVIC_SystemReset(void)
|
||||||
|
{
|
||||||
|
__DSB(); /* Ensure all outstanding memory accesses included
|
||||||
|
buffered write are completed before reset */
|
||||||
|
SCB->AIRCR = ((0x5FAUL << SCB_AIRCR_VECTKEY_Pos) |
|
||||||
|
SCB_AIRCR_SYSRESETREQ_Msk);
|
||||||
|
__DSB(); /* Ensure completion of memory access */
|
||||||
|
|
||||||
|
for (;;) /* wait until reset */
|
||||||
|
{
|
||||||
|
__NOP();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*@} end of CMSIS_Core_NVICFunctions */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* ################################## SysTick function ############################################ */
|
||||||
|
/**
|
||||||
|
\ingroup CMSIS_Core_FunctionInterface
|
||||||
|
\defgroup CMSIS_Core_SysTickFunctions SysTick Functions
|
||||||
|
\brief Functions that configure the System.
|
||||||
|
@{
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if (__Vendor_SysTickConfig == 0U)
|
||||||
|
|
||||||
|
/**
|
||||||
|
\brief System Tick Configuration
|
||||||
|
\details Initializes the System Timer and its interrupt, and starts the System Tick Timer.
|
||||||
|
Counter is in free running mode to generate periodic interrupts.
|
||||||
|
\param [in] ticks Number of ticks between two interrupts.
|
||||||
|
\return 0 Function succeeded.
|
||||||
|
\return 1 Function failed.
|
||||||
|
\note When the variable <b>__Vendor_SysTickConfig</b> is set to 1, then the
|
||||||
|
function <b>SysTick_Config</b> is not included. In this case, the file <b><i>device</i>.h</b>
|
||||||
|
must contain a vendor-specific implementation of this function.
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE uint32_t SysTick_Config(uint32_t ticks)
|
||||||
|
{
|
||||||
|
if ((ticks - 1UL) > SysTick_LOAD_RELOAD_Msk)
|
||||||
|
{
|
||||||
|
return (1UL); /* Reload value impossible */
|
||||||
|
}
|
||||||
|
|
||||||
|
SysTick->LOAD = (uint32_t)(ticks - 1UL); /* set reload register */
|
||||||
|
NVIC_SetPriority (SysTick_IRQn, (1UL << __NVIC_PRIO_BITS) - 1UL); /* set Priority for Systick Interrupt */
|
||||||
|
SysTick->VAL = 0UL; /* Load the SysTick Counter Value */
|
||||||
|
SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk |
|
||||||
|
SysTick_CTRL_TICKINT_Msk |
|
||||||
|
SysTick_CTRL_ENABLE_Msk; /* Enable SysTick IRQ and SysTick Timer */
|
||||||
|
return (0UL); /* Function successful */
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*@} end of CMSIS_Core_SysTickFunctions */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* __CORE_CM0PLUS_H_DEPENDANT */
|
||||||
|
|
||||||
|
#endif /* __CMSIS_GENERIC */
|
1763
src/platform/cm4/cmsis/include/core_cm3.h
Normal file
1763
src/platform/cm4/cmsis/include/core_cm3.h
Normal file
File diff suppressed because it is too large
Load Diff
1937
src/platform/cm4/cmsis/include/core_cm4.h
Normal file
1937
src/platform/cm4/cmsis/include/core_cm4.h
Normal file
File diff suppressed because it is too large
Load Diff
2512
src/platform/cm4/cmsis/include/core_cm7.h
Normal file
2512
src/platform/cm4/cmsis/include/core_cm7.h
Normal file
File diff suppressed because it is too large
Load Diff
86
src/platform/cm4/cmsis/include/core_cmFunc.h
Normal file
86
src/platform/cm4/cmsis/include/core_cmFunc.h
Normal file
@@ -0,0 +1,86 @@
|
|||||||
|
/**************************************************************************//**
|
||||||
|
* @file core_cmFunc.h
|
||||||
|
* @brief CMSIS Cortex-M Core Function Access Header File
|
||||||
|
* @version V4.30
|
||||||
|
* @date 20. October 2015
|
||||||
|
******************************************************************************/
|
||||||
|
/* Copyright (c) 2009 - 2015 ARM LIMITED
|
||||||
|
|
||||||
|
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 following disclaimer.
|
||||||
|
- Redistributions in binary form must reproduce the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer in the
|
||||||
|
documentation and/or other materials provided with the distribution.
|
||||||
|
- Neither the name of ARM nor the names of its contributors may be used
|
||||||
|
to endorse or promote products derived from this software without
|
||||||
|
specific prior written permission.
|
||||||
|
*
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
|
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS 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.
|
||||||
|
---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#if defined ( __ICCARM__ )
|
||||||
|
#pragma system_include /* treat file as system include file for MISRA check */
|
||||||
|
#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
|
||||||
|
#pragma clang system_header /* treat file as system include file */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __CORE_CMFUNC_H
|
||||||
|
#define __CORE_CMFUNC_H
|
||||||
|
|
||||||
|
|
||||||
|
/* ########################### Core Function Access ########################### */
|
||||||
|
/** \ingroup CMSIS_Core_FunctionInterface
|
||||||
|
\defgroup CMSIS_Core_RegAccFunctions CMSIS Core Register Access Functions
|
||||||
|
@{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*------------------ RealView Compiler -----------------*/
|
||||||
|
#if defined ( __CC_ARM )
|
||||||
|
#include "cmsis_armcc.h"
|
||||||
|
|
||||||
|
/*------------------ ARM Compiler V6 -------------------*/
|
||||||
|
#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
|
||||||
|
#include "cmsis_armcc_V6.h"
|
||||||
|
|
||||||
|
/*------------------ GNU Compiler ----------------------*/
|
||||||
|
#elif defined ( __GNUC__ )
|
||||||
|
#include "cmsis_gcc.h"
|
||||||
|
|
||||||
|
/*------------------ ICC Compiler ----------------------*/
|
||||||
|
#elif defined ( __ICCARM__ )
|
||||||
|
#include <cmsis_iar.h>
|
||||||
|
|
||||||
|
/*------------------ TI CCS Compiler -------------------*/
|
||||||
|
#elif defined ( __TMS470__ )
|
||||||
|
#include <cmsis_ccs.h>
|
||||||
|
|
||||||
|
/*------------------ TASKING Compiler ------------------*/
|
||||||
|
#elif defined ( __TASKING__ )
|
||||||
|
/*
|
||||||
|
* The CMSIS functions have been implemented as intrinsics in the compiler.
|
||||||
|
* Please use "carm -?i" to get an up to date list of all intrinsics,
|
||||||
|
* Including the CMSIS ones.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*------------------ COSMIC Compiler -------------------*/
|
||||||
|
#elif defined ( __CSMC__ )
|
||||||
|
#include <cmsis_csm.h>
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*@} end of CMSIS_Core_RegAccFunctions */
|
||||||
|
|
||||||
|
#endif /* __CORE_CMFUNC_H */
|
87
src/platform/cm4/cmsis/include/core_cmInstr.h
Normal file
87
src/platform/cm4/cmsis/include/core_cmInstr.h
Normal file
@@ -0,0 +1,87 @@
|
|||||||
|
/**************************************************************************//**
|
||||||
|
* @file core_cmInstr.h
|
||||||
|
* @brief CMSIS Cortex-M Core Instruction Access Header File
|
||||||
|
* @version V4.30
|
||||||
|
* @date 20. October 2015
|
||||||
|
******************************************************************************/
|
||||||
|
/* Copyright (c) 2009 - 2015 ARM LIMITED
|
||||||
|
|
||||||
|
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 following disclaimer.
|
||||||
|
- Redistributions in binary form must reproduce the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer in the
|
||||||
|
documentation and/or other materials provided with the distribution.
|
||||||
|
- Neither the name of ARM nor the names of its contributors may be used
|
||||||
|
to endorse or promote products derived from this software without
|
||||||
|
specific prior written permission.
|
||||||
|
*
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
|
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS 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.
|
||||||
|
---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
|
||||||
|
#if defined ( __ICCARM__ )
|
||||||
|
#pragma system_include /* treat file as system include file for MISRA check */
|
||||||
|
#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
|
||||||
|
#pragma clang system_header /* treat file as system include file */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __CORE_CMINSTR_H
|
||||||
|
#define __CORE_CMINSTR_H
|
||||||
|
|
||||||
|
|
||||||
|
/* ########################## Core Instruction Access ######################### */
|
||||||
|
/** \defgroup CMSIS_Core_InstructionInterface CMSIS Core Instruction Interface
|
||||||
|
Access to dedicated instructions
|
||||||
|
@{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*------------------ RealView Compiler -----------------*/
|
||||||
|
#if defined ( __CC_ARM )
|
||||||
|
#include "cmsis_armcc.h"
|
||||||
|
|
||||||
|
/*------------------ ARM Compiler V6 -------------------*/
|
||||||
|
#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
|
||||||
|
#include "cmsis_armcc_V6.h"
|
||||||
|
|
||||||
|
/*------------------ GNU Compiler ----------------------*/
|
||||||
|
#elif defined ( __GNUC__ )
|
||||||
|
#include "cmsis_gcc.h"
|
||||||
|
|
||||||
|
/*------------------ ICC Compiler ----------------------*/
|
||||||
|
#elif defined ( __ICCARM__ )
|
||||||
|
#include <cmsis_iar.h>
|
||||||
|
|
||||||
|
/*------------------ TI CCS Compiler -------------------*/
|
||||||
|
#elif defined ( __TMS470__ )
|
||||||
|
#include <cmsis_ccs.h>
|
||||||
|
|
||||||
|
/*------------------ TASKING Compiler ------------------*/
|
||||||
|
#elif defined ( __TASKING__ )
|
||||||
|
/*
|
||||||
|
* The CMSIS functions have been implemented as intrinsics in the compiler.
|
||||||
|
* Please use "carm -?i" to get an up to date list of all intrinsics,
|
||||||
|
* Including the CMSIS ones.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*------------------ COSMIC Compiler -------------------*/
|
||||||
|
#elif defined ( __CSMC__ )
|
||||||
|
#include <cmsis_csm.h>
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*@}*/ /* end of group CMSIS_Core_InstructionInterface */
|
||||||
|
|
||||||
|
#endif /* __CORE_CMINSTR_H */
|
96
src/platform/cm4/cmsis/include/core_cmSimd.h
Normal file
96
src/platform/cm4/cmsis/include/core_cmSimd.h
Normal file
@@ -0,0 +1,96 @@
|
|||||||
|
/**************************************************************************//**
|
||||||
|
* @file core_cmSimd.h
|
||||||
|
* @brief CMSIS Cortex-M SIMD Header File
|
||||||
|
* @version V4.30
|
||||||
|
* @date 20. October 2015
|
||||||
|
******************************************************************************/
|
||||||
|
/* Copyright (c) 2009 - 2015 ARM LIMITED
|
||||||
|
|
||||||
|
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 following disclaimer.
|
||||||
|
- Redistributions in binary form must reproduce the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer in the
|
||||||
|
documentation and/or other materials provided with the distribution.
|
||||||
|
- Neither the name of ARM nor the names of its contributors may be used
|
||||||
|
to endorse or promote products derived from this software without
|
||||||
|
specific prior written permission.
|
||||||
|
*
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
|
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS 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.
|
||||||
|
---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
|
||||||
|
#if defined ( __ICCARM__ )
|
||||||
|
#pragma system_include /* treat file as system include file for MISRA check */
|
||||||
|
#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
|
||||||
|
#pragma clang system_header /* treat file as system include file */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __CORE_CMSIMD_H
|
||||||
|
#define __CORE_CMSIMD_H
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/* ################### Compiler specific Intrinsics ########################### */
|
||||||
|
/** \defgroup CMSIS_SIMD_intrinsics CMSIS SIMD Intrinsics
|
||||||
|
Access to dedicated SIMD instructions
|
||||||
|
@{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*------------------ RealView Compiler -----------------*/
|
||||||
|
#if defined ( __CC_ARM )
|
||||||
|
#include "cmsis_armcc.h"
|
||||||
|
|
||||||
|
/*------------------ ARM Compiler V6 -------------------*/
|
||||||
|
#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
|
||||||
|
#include "cmsis_armcc_V6.h"
|
||||||
|
|
||||||
|
/*------------------ GNU Compiler ----------------------*/
|
||||||
|
#elif defined ( __GNUC__ )
|
||||||
|
#include "cmsis_gcc.h"
|
||||||
|
|
||||||
|
/*------------------ ICC Compiler ----------------------*/
|
||||||
|
#elif defined ( __ICCARM__ )
|
||||||
|
#include <cmsis_iar.h>
|
||||||
|
|
||||||
|
/*------------------ TI CCS Compiler -------------------*/
|
||||||
|
#elif defined ( __TMS470__ )
|
||||||
|
#include <cmsis_ccs.h>
|
||||||
|
|
||||||
|
/*------------------ TASKING Compiler ------------------*/
|
||||||
|
#elif defined ( __TASKING__ )
|
||||||
|
/*
|
||||||
|
* The CMSIS functions have been implemented as intrinsics in the compiler.
|
||||||
|
* Please use "carm -?i" to get an up to date list of all intrinsics,
|
||||||
|
* Including the CMSIS ones.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*------------------ COSMIC Compiler -------------------*/
|
||||||
|
#elif defined ( __CSMC__ )
|
||||||
|
#include <cmsis_csm.h>
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*@} end of group CMSIS_SIMD_intrinsics */
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* __CORE_CMSIMD_H */
|
926
src/platform/cm4/cmsis/include/core_sc000.h
Normal file
926
src/platform/cm4/cmsis/include/core_sc000.h
Normal file
@@ -0,0 +1,926 @@
|
|||||||
|
/**************************************************************************//**
|
||||||
|
* @file core_sc000.h
|
||||||
|
* @brief CMSIS SC000 Core Peripheral Access Layer Header File
|
||||||
|
* @version V4.30
|
||||||
|
* @date 20. October 2015
|
||||||
|
******************************************************************************/
|
||||||
|
/* Copyright (c) 2009 - 2015 ARM LIMITED
|
||||||
|
|
||||||
|
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 following disclaimer.
|
||||||
|
- Redistributions in binary form must reproduce the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer in the
|
||||||
|
documentation and/or other materials provided with the distribution.
|
||||||
|
- Neither the name of ARM nor the names of its contributors may be used
|
||||||
|
to endorse or promote products derived from this software without
|
||||||
|
specific prior written permission.
|
||||||
|
*
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
|
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS 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.
|
||||||
|
---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
|
||||||
|
#if defined ( __ICCARM__ )
|
||||||
|
#pragma system_include /* treat file as system include file for MISRA check */
|
||||||
|
#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
|
||||||
|
#pragma clang system_header /* treat file as system include file */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __CORE_SC000_H_GENERIC
|
||||||
|
#define __CORE_SC000_H_GENERIC
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
\page CMSIS_MISRA_Exceptions MISRA-C:2004 Compliance Exceptions
|
||||||
|
CMSIS violates the following MISRA-C:2004 rules:
|
||||||
|
|
||||||
|
\li Required Rule 8.5, object/function definition in header file.<br>
|
||||||
|
Function definitions in header files are used to allow 'inlining'.
|
||||||
|
|
||||||
|
\li Required Rule 18.4, declaration of union type or object of union type: '{...}'.<br>
|
||||||
|
Unions are used for effective representation of core registers.
|
||||||
|
|
||||||
|
\li Advisory Rule 19.7, Function-like macro defined.<br>
|
||||||
|
Function-like macros are used to allow more efficient code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* CMSIS definitions
|
||||||
|
******************************************************************************/
|
||||||
|
/**
|
||||||
|
\ingroup SC000
|
||||||
|
@{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* CMSIS SC000 definitions */
|
||||||
|
#define __SC000_CMSIS_VERSION_MAIN (0x04U) /*!< [31:16] CMSIS HAL main version */
|
||||||
|
#define __SC000_CMSIS_VERSION_SUB (0x1EU) /*!< [15:0] CMSIS HAL sub version */
|
||||||
|
#define __SC000_CMSIS_VERSION ((__SC000_CMSIS_VERSION_MAIN << 16U) | \
|
||||||
|
__SC000_CMSIS_VERSION_SUB ) /*!< CMSIS HAL version number */
|
||||||
|
|
||||||
|
#define __CORTEX_SC (000U) /*!< Cortex secure core */
|
||||||
|
|
||||||
|
|
||||||
|
#if defined ( __CC_ARM )
|
||||||
|
#define __ASM __asm /*!< asm keyword for ARM Compiler */
|
||||||
|
#define __INLINE __inline /*!< inline keyword for ARM Compiler */
|
||||||
|
#define __STATIC_INLINE static __inline
|
||||||
|
|
||||||
|
#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
|
||||||
|
#define __ASM __asm /*!< asm keyword for ARM Compiler */
|
||||||
|
#define __INLINE __inline /*!< inline keyword for ARM Compiler */
|
||||||
|
#define __STATIC_INLINE static __inline
|
||||||
|
|
||||||
|
#elif defined ( __GNUC__ )
|
||||||
|
#define __ASM __asm /*!< asm keyword for GNU Compiler */
|
||||||
|
#define __INLINE inline /*!< inline keyword for GNU Compiler */
|
||||||
|
#define __STATIC_INLINE static inline
|
||||||
|
|
||||||
|
#elif defined ( __ICCARM__ )
|
||||||
|
#define __ASM __asm /*!< asm keyword for IAR Compiler */
|
||||||
|
#define __INLINE inline /*!< inline keyword for IAR Compiler. Only available in High optimization mode! */
|
||||||
|
#define __STATIC_INLINE static inline
|
||||||
|
|
||||||
|
#elif defined ( __TMS470__ )
|
||||||
|
#define __ASM __asm /*!< asm keyword for TI CCS Compiler */
|
||||||
|
#define __STATIC_INLINE static inline
|
||||||
|
|
||||||
|
#elif defined ( __TASKING__ )
|
||||||
|
#define __ASM __asm /*!< asm keyword for TASKING Compiler */
|
||||||
|
#define __INLINE inline /*!< inline keyword for TASKING Compiler */
|
||||||
|
#define __STATIC_INLINE static inline
|
||||||
|
|
||||||
|
#elif defined ( __CSMC__ )
|
||||||
|
#define __packed
|
||||||
|
#define __ASM _asm /*!< asm keyword for COSMIC Compiler */
|
||||||
|
#define __INLINE inline /*!< inline keyword for COSMIC Compiler. Use -pc99 on compile line */
|
||||||
|
#define __STATIC_INLINE static inline
|
||||||
|
|
||||||
|
#else
|
||||||
|
#error Unknown compiler
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/** __FPU_USED indicates whether an FPU is used or not.
|
||||||
|
This core does not support an FPU at all
|
||||||
|
*/
|
||||||
|
#define __FPU_USED 0U
|
||||||
|
|
||||||
|
#if defined ( __CC_ARM )
|
||||||
|
#if defined __TARGET_FPU_VFP
|
||||||
|
#error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
|
||||||
|
#if defined __ARM_PCS_VFP
|
||||||
|
#error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#elif defined ( __GNUC__ )
|
||||||
|
#if defined (__VFP_FP__) && !defined(__SOFTFP__)
|
||||||
|
#error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#elif defined ( __ICCARM__ )
|
||||||
|
#if defined __ARMVFP__
|
||||||
|
#error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#elif defined ( __TMS470__ )
|
||||||
|
#if defined __TI_VFP_SUPPORT__
|
||||||
|
#error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#elif defined ( __TASKING__ )
|
||||||
|
#if defined __FPU_VFP__
|
||||||
|
#error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#elif defined ( __CSMC__ )
|
||||||
|
#if ( __CSMC__ & 0x400U)
|
||||||
|
#error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "core_cmInstr.h" /* Core Instruction Access */
|
||||||
|
#include "core_cmFunc.h" /* Core Function Access */
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* __CORE_SC000_H_GENERIC */
|
||||||
|
|
||||||
|
#ifndef __CMSIS_GENERIC
|
||||||
|
|
||||||
|
#ifndef __CORE_SC000_H_DEPENDANT
|
||||||
|
#define __CORE_SC000_H_DEPENDANT
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* check device defines and use defaults */
|
||||||
|
#if defined __CHECK_DEVICE_DEFINES
|
||||||
|
#ifndef __SC000_REV
|
||||||
|
#define __SC000_REV 0x0000U
|
||||||
|
#warning "__SC000_REV not defined in device header file; using default!"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __MPU_PRESENT
|
||||||
|
#define __MPU_PRESENT 0U
|
||||||
|
#warning "__MPU_PRESENT not defined in device header file; using default!"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __NVIC_PRIO_BITS
|
||||||
|
#define __NVIC_PRIO_BITS 2U
|
||||||
|
#warning "__NVIC_PRIO_BITS not defined in device header file; using default!"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __Vendor_SysTickConfig
|
||||||
|
#define __Vendor_SysTickConfig 0U
|
||||||
|
#warning "__Vendor_SysTickConfig not defined in device header file; using default!"
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* IO definitions (access restrictions to peripheral registers) */
|
||||||
|
/**
|
||||||
|
\defgroup CMSIS_glob_defs CMSIS Global Defines
|
||||||
|
|
||||||
|
<strong>IO Type Qualifiers</strong> are used
|
||||||
|
\li to specify the access to peripheral variables.
|
||||||
|
\li for automatic generation of peripheral register debug information.
|
||||||
|
*/
|
||||||
|
#ifdef __cplusplus
|
||||||
|
#define __I volatile /*!< Defines 'read only' permissions */
|
||||||
|
#else
|
||||||
|
#define __I volatile const /*!< Defines 'read only' permissions */
|
||||||
|
#endif
|
||||||
|
#define __O volatile /*!< Defines 'write only' permissions */
|
||||||
|
#define __IO volatile /*!< Defines 'read / write' permissions */
|
||||||
|
|
||||||
|
/* following defines should be used for structure members */
|
||||||
|
#define __IM volatile const /*! Defines 'read only' structure member permissions */
|
||||||
|
#define __OM volatile /*! Defines 'write only' structure member permissions */
|
||||||
|
#define __IOM volatile /*! Defines 'read / write' structure member permissions */
|
||||||
|
|
||||||
|
/*@} end of group SC000 */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Register Abstraction
|
||||||
|
Core Register contain:
|
||||||
|
- Core Register
|
||||||
|
- Core NVIC Register
|
||||||
|
- Core SCB Register
|
||||||
|
- Core SysTick Register
|
||||||
|
- Core MPU Register
|
||||||
|
******************************************************************************/
|
||||||
|
/**
|
||||||
|
\defgroup CMSIS_core_register Defines and Type Definitions
|
||||||
|
\brief Type definitions and defines for Cortex-M processor based devices.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
\ingroup CMSIS_core_register
|
||||||
|
\defgroup CMSIS_CORE Status and Control Registers
|
||||||
|
\brief Core Register type definitions.
|
||||||
|
@{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
\brief Union type to access the Application Program Status Register (APSR).
|
||||||
|
*/
|
||||||
|
typedef union
|
||||||
|
{
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
uint32_t _reserved0:28; /*!< bit: 0..27 Reserved */
|
||||||
|
uint32_t V:1; /*!< bit: 28 Overflow condition code flag */
|
||||||
|
uint32_t C:1; /*!< bit: 29 Carry condition code flag */
|
||||||
|
uint32_t Z:1; /*!< bit: 30 Zero condition code flag */
|
||||||
|
uint32_t N:1; /*!< bit: 31 Negative condition code flag */
|
||||||
|
} b; /*!< Structure used for bit access */
|
||||||
|
uint32_t w; /*!< Type used for word access */
|
||||||
|
} APSR_Type;
|
||||||
|
|
||||||
|
/* APSR Register Definitions */
|
||||||
|
#define APSR_N_Pos 31U /*!< APSR: N Position */
|
||||||
|
#define APSR_N_Msk (1UL << APSR_N_Pos) /*!< APSR: N Mask */
|
||||||
|
|
||||||
|
#define APSR_Z_Pos 30U /*!< APSR: Z Position */
|
||||||
|
#define APSR_Z_Msk (1UL << APSR_Z_Pos) /*!< APSR: Z Mask */
|
||||||
|
|
||||||
|
#define APSR_C_Pos 29U /*!< APSR: C Position */
|
||||||
|
#define APSR_C_Msk (1UL << APSR_C_Pos) /*!< APSR: C Mask */
|
||||||
|
|
||||||
|
#define APSR_V_Pos 28U /*!< APSR: V Position */
|
||||||
|
#define APSR_V_Msk (1UL << APSR_V_Pos) /*!< APSR: V Mask */
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
\brief Union type to access the Interrupt Program Status Register (IPSR).
|
||||||
|
*/
|
||||||
|
typedef union
|
||||||
|
{
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */
|
||||||
|
uint32_t _reserved0:23; /*!< bit: 9..31 Reserved */
|
||||||
|
} b; /*!< Structure used for bit access */
|
||||||
|
uint32_t w; /*!< Type used for word access */
|
||||||
|
} IPSR_Type;
|
||||||
|
|
||||||
|
/* IPSR Register Definitions */
|
||||||
|
#define IPSR_ISR_Pos 0U /*!< IPSR: ISR Position */
|
||||||
|
#define IPSR_ISR_Msk (0x1FFUL /*<< IPSR_ISR_Pos*/) /*!< IPSR: ISR Mask */
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
\brief Union type to access the Special-Purpose Program Status Registers (xPSR).
|
||||||
|
*/
|
||||||
|
typedef union
|
||||||
|
{
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */
|
||||||
|
uint32_t _reserved0:15; /*!< bit: 9..23 Reserved */
|
||||||
|
uint32_t T:1; /*!< bit: 24 Thumb bit (read 0) */
|
||||||
|
uint32_t _reserved1:3; /*!< bit: 25..27 Reserved */
|
||||||
|
uint32_t V:1; /*!< bit: 28 Overflow condition code flag */
|
||||||
|
uint32_t C:1; /*!< bit: 29 Carry condition code flag */
|
||||||
|
uint32_t Z:1; /*!< bit: 30 Zero condition code flag */
|
||||||
|
uint32_t N:1; /*!< bit: 31 Negative condition code flag */
|
||||||
|
} b; /*!< Structure used for bit access */
|
||||||
|
uint32_t w; /*!< Type used for word access */
|
||||||
|
} xPSR_Type;
|
||||||
|
|
||||||
|
/* xPSR Register Definitions */
|
||||||
|
#define xPSR_N_Pos 31U /*!< xPSR: N Position */
|
||||||
|
#define xPSR_N_Msk (1UL << xPSR_N_Pos) /*!< xPSR: N Mask */
|
||||||
|
|
||||||
|
#define xPSR_Z_Pos 30U /*!< xPSR: Z Position */
|
||||||
|
#define xPSR_Z_Msk (1UL << xPSR_Z_Pos) /*!< xPSR: Z Mask */
|
||||||
|
|
||||||
|
#define xPSR_C_Pos 29U /*!< xPSR: C Position */
|
||||||
|
#define xPSR_C_Msk (1UL << xPSR_C_Pos) /*!< xPSR: C Mask */
|
||||||
|
|
||||||
|
#define xPSR_V_Pos 28U /*!< xPSR: V Position */
|
||||||
|
#define xPSR_V_Msk (1UL << xPSR_V_Pos) /*!< xPSR: V Mask */
|
||||||
|
|
||||||
|
#define xPSR_T_Pos 24U /*!< xPSR: T Position */
|
||||||
|
#define xPSR_T_Msk (1UL << xPSR_T_Pos) /*!< xPSR: T Mask */
|
||||||
|
|
||||||
|
#define xPSR_ISR_Pos 0U /*!< xPSR: ISR Position */
|
||||||
|
#define xPSR_ISR_Msk (0x1FFUL /*<< xPSR_ISR_Pos*/) /*!< xPSR: ISR Mask */
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
\brief Union type to access the Control Registers (CONTROL).
|
||||||
|
*/
|
||||||
|
typedef union
|
||||||
|
{
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
uint32_t _reserved0:1; /*!< bit: 0 Reserved */
|
||||||
|
uint32_t SPSEL:1; /*!< bit: 1 Stack to be used */
|
||||||
|
uint32_t _reserved1:30; /*!< bit: 2..31 Reserved */
|
||||||
|
} b; /*!< Structure used for bit access */
|
||||||
|
uint32_t w; /*!< Type used for word access */
|
||||||
|
} CONTROL_Type;
|
||||||
|
|
||||||
|
/* CONTROL Register Definitions */
|
||||||
|
#define CONTROL_SPSEL_Pos 1U /*!< CONTROL: SPSEL Position */
|
||||||
|
#define CONTROL_SPSEL_Msk (1UL << CONTROL_SPSEL_Pos) /*!< CONTROL: SPSEL Mask */
|
||||||
|
|
||||||
|
/*@} end of group CMSIS_CORE */
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
\ingroup CMSIS_core_register
|
||||||
|
\defgroup CMSIS_NVIC Nested Vectored Interrupt Controller (NVIC)
|
||||||
|
\brief Type definitions for the NVIC Registers
|
||||||
|
@{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
\brief Structure type to access the Nested Vectored Interrupt Controller (NVIC).
|
||||||
|
*/
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
__IOM uint32_t ISER[1U]; /*!< Offset: 0x000 (R/W) Interrupt Set Enable Register */
|
||||||
|
uint32_t RESERVED0[31U];
|
||||||
|
__IOM uint32_t ICER[1U]; /*!< Offset: 0x080 (R/W) Interrupt Clear Enable Register */
|
||||||
|
uint32_t RSERVED1[31U];
|
||||||
|
__IOM uint32_t ISPR[1U]; /*!< Offset: 0x100 (R/W) Interrupt Set Pending Register */
|
||||||
|
uint32_t RESERVED2[31U];
|
||||||
|
__IOM uint32_t ICPR[1U]; /*!< Offset: 0x180 (R/W) Interrupt Clear Pending Register */
|
||||||
|
uint32_t RESERVED3[31U];
|
||||||
|
uint32_t RESERVED4[64U];
|
||||||
|
__IOM uint32_t IP[8U]; /*!< Offset: 0x300 (R/W) Interrupt Priority Register */
|
||||||
|
} NVIC_Type;
|
||||||
|
|
||||||
|
/*@} end of group CMSIS_NVIC */
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
\ingroup CMSIS_core_register
|
||||||
|
\defgroup CMSIS_SCB System Control Block (SCB)
|
||||||
|
\brief Type definitions for the System Control Block Registers
|
||||||
|
@{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
\brief Structure type to access the System Control Block (SCB).
|
||||||
|
*/
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
__IM uint32_t CPUID; /*!< Offset: 0x000 (R/ ) CPUID Base Register */
|
||||||
|
__IOM uint32_t ICSR; /*!< Offset: 0x004 (R/W) Interrupt Control and State Register */
|
||||||
|
__IOM uint32_t VTOR; /*!< Offset: 0x008 (R/W) Vector Table Offset Register */
|
||||||
|
__IOM uint32_t AIRCR; /*!< Offset: 0x00C (R/W) Application Interrupt and Reset Control Register */
|
||||||
|
__IOM uint32_t SCR; /*!< Offset: 0x010 (R/W) System Control Register */
|
||||||
|
__IOM uint32_t CCR; /*!< Offset: 0x014 (R/W) Configuration Control Register */
|
||||||
|
uint32_t RESERVED0[1U];
|
||||||
|
__IOM uint32_t SHP[2U]; /*!< Offset: 0x01C (R/W) System Handlers Priority Registers. [0] is RESERVED */
|
||||||
|
__IOM uint32_t SHCSR; /*!< Offset: 0x024 (R/W) System Handler Control and State Register */
|
||||||
|
uint32_t RESERVED1[154U];
|
||||||
|
__IOM uint32_t SFCR; /*!< Offset: 0x290 (R/W) Security Features Control Register */
|
||||||
|
} SCB_Type;
|
||||||
|
|
||||||
|
/* SCB CPUID Register Definitions */
|
||||||
|
#define SCB_CPUID_IMPLEMENTER_Pos 24U /*!< SCB CPUID: IMPLEMENTER Position */
|
||||||
|
#define SCB_CPUID_IMPLEMENTER_Msk (0xFFUL << SCB_CPUID_IMPLEMENTER_Pos) /*!< SCB CPUID: IMPLEMENTER Mask */
|
||||||
|
|
||||||
|
#define SCB_CPUID_VARIANT_Pos 20U /*!< SCB CPUID: VARIANT Position */
|
||||||
|
#define SCB_CPUID_VARIANT_Msk (0xFUL << SCB_CPUID_VARIANT_Pos) /*!< SCB CPUID: VARIANT Mask */
|
||||||
|
|
||||||
|
#define SCB_CPUID_ARCHITECTURE_Pos 16U /*!< SCB CPUID: ARCHITECTURE Position */
|
||||||
|
#define SCB_CPUID_ARCHITECTURE_Msk (0xFUL << SCB_CPUID_ARCHITECTURE_Pos) /*!< SCB CPUID: ARCHITECTURE Mask */
|
||||||
|
|
||||||
|
#define SCB_CPUID_PARTNO_Pos 4U /*!< SCB CPUID: PARTNO Position */
|
||||||
|
#define SCB_CPUID_PARTNO_Msk (0xFFFUL << SCB_CPUID_PARTNO_Pos) /*!< SCB CPUID: PARTNO Mask */
|
||||||
|
|
||||||
|
#define SCB_CPUID_REVISION_Pos 0U /*!< SCB CPUID: REVISION Position */
|
||||||
|
#define SCB_CPUID_REVISION_Msk (0xFUL /*<< SCB_CPUID_REVISION_Pos*/) /*!< SCB CPUID: REVISION Mask */
|
||||||
|
|
||||||
|
/* SCB Interrupt Control State Register Definitions */
|
||||||
|
#define SCB_ICSR_NMIPENDSET_Pos 31U /*!< SCB ICSR: NMIPENDSET Position */
|
||||||
|
#define SCB_ICSR_NMIPENDSET_Msk (1UL << SCB_ICSR_NMIPENDSET_Pos) /*!< SCB ICSR: NMIPENDSET Mask */
|
||||||
|
|
||||||
|
#define SCB_ICSR_PENDSVSET_Pos 28U /*!< SCB ICSR: PENDSVSET Position */
|
||||||
|
#define SCB_ICSR_PENDSVSET_Msk (1UL << SCB_ICSR_PENDSVSET_Pos) /*!< SCB ICSR: PENDSVSET Mask */
|
||||||
|
|
||||||
|
#define SCB_ICSR_PENDSVCLR_Pos 27U /*!< SCB ICSR: PENDSVCLR Position */
|
||||||
|
#define SCB_ICSR_PENDSVCLR_Msk (1UL << SCB_ICSR_PENDSVCLR_Pos) /*!< SCB ICSR: PENDSVCLR Mask */
|
||||||
|
|
||||||
|
#define SCB_ICSR_PENDSTSET_Pos 26U /*!< SCB ICSR: PENDSTSET Position */
|
||||||
|
#define SCB_ICSR_PENDSTSET_Msk (1UL << SCB_ICSR_PENDSTSET_Pos) /*!< SCB ICSR: PENDSTSET Mask */
|
||||||
|
|
||||||
|
#define SCB_ICSR_PENDSTCLR_Pos 25U /*!< SCB ICSR: PENDSTCLR Position */
|
||||||
|
#define SCB_ICSR_PENDSTCLR_Msk (1UL << SCB_ICSR_PENDSTCLR_Pos) /*!< SCB ICSR: PENDSTCLR Mask */
|
||||||
|
|
||||||
|
#define SCB_ICSR_ISRPREEMPT_Pos 23U /*!< SCB ICSR: ISRPREEMPT Position */
|
||||||
|
#define SCB_ICSR_ISRPREEMPT_Msk (1UL << SCB_ICSR_ISRPREEMPT_Pos) /*!< SCB ICSR: ISRPREEMPT Mask */
|
||||||
|
|
||||||
|
#define SCB_ICSR_ISRPENDING_Pos 22U /*!< SCB ICSR: ISRPENDING Position */
|
||||||
|
#define SCB_ICSR_ISRPENDING_Msk (1UL << SCB_ICSR_ISRPENDING_Pos) /*!< SCB ICSR: ISRPENDING Mask */
|
||||||
|
|
||||||
|
#define SCB_ICSR_VECTPENDING_Pos 12U /*!< SCB ICSR: VECTPENDING Position */
|
||||||
|
#define SCB_ICSR_VECTPENDING_Msk (0x1FFUL << SCB_ICSR_VECTPENDING_Pos) /*!< SCB ICSR: VECTPENDING Mask */
|
||||||
|
|
||||||
|
#define SCB_ICSR_VECTACTIVE_Pos 0U /*!< SCB ICSR: VECTACTIVE Position */
|
||||||
|
#define SCB_ICSR_VECTACTIVE_Msk (0x1FFUL /*<< SCB_ICSR_VECTACTIVE_Pos*/) /*!< SCB ICSR: VECTACTIVE Mask */
|
||||||
|
|
||||||
|
/* SCB Interrupt Control State Register Definitions */
|
||||||
|
#define SCB_VTOR_TBLOFF_Pos 7U /*!< SCB VTOR: TBLOFF Position */
|
||||||
|
#define SCB_VTOR_TBLOFF_Msk (0x1FFFFFFUL << SCB_VTOR_TBLOFF_Pos) /*!< SCB VTOR: TBLOFF Mask */
|
||||||
|
|
||||||
|
/* SCB Application Interrupt and Reset Control Register Definitions */
|
||||||
|
#define SCB_AIRCR_VECTKEY_Pos 16U /*!< SCB AIRCR: VECTKEY Position */
|
||||||
|
#define SCB_AIRCR_VECTKEY_Msk (0xFFFFUL << SCB_AIRCR_VECTKEY_Pos) /*!< SCB AIRCR: VECTKEY Mask */
|
||||||
|
|
||||||
|
#define SCB_AIRCR_VECTKEYSTAT_Pos 16U /*!< SCB AIRCR: VECTKEYSTAT Position */
|
||||||
|
#define SCB_AIRCR_VECTKEYSTAT_Msk (0xFFFFUL << SCB_AIRCR_VECTKEYSTAT_Pos) /*!< SCB AIRCR: VECTKEYSTAT Mask */
|
||||||
|
|
||||||
|
#define SCB_AIRCR_ENDIANESS_Pos 15U /*!< SCB AIRCR: ENDIANESS Position */
|
||||||
|
#define SCB_AIRCR_ENDIANESS_Msk (1UL << SCB_AIRCR_ENDIANESS_Pos) /*!< SCB AIRCR: ENDIANESS Mask */
|
||||||
|
|
||||||
|
#define SCB_AIRCR_SYSRESETREQ_Pos 2U /*!< SCB AIRCR: SYSRESETREQ Position */
|
||||||
|
#define SCB_AIRCR_SYSRESETREQ_Msk (1UL << SCB_AIRCR_SYSRESETREQ_Pos) /*!< SCB AIRCR: SYSRESETREQ Mask */
|
||||||
|
|
||||||
|
#define SCB_AIRCR_VECTCLRACTIVE_Pos 1U /*!< SCB AIRCR: VECTCLRACTIVE Position */
|
||||||
|
#define SCB_AIRCR_VECTCLRACTIVE_Msk (1UL << SCB_AIRCR_VECTCLRACTIVE_Pos) /*!< SCB AIRCR: VECTCLRACTIVE Mask */
|
||||||
|
|
||||||
|
/* SCB System Control Register Definitions */
|
||||||
|
#define SCB_SCR_SEVONPEND_Pos 4U /*!< SCB SCR: SEVONPEND Position */
|
||||||
|
#define SCB_SCR_SEVONPEND_Msk (1UL << SCB_SCR_SEVONPEND_Pos) /*!< SCB SCR: SEVONPEND Mask */
|
||||||
|
|
||||||
|
#define SCB_SCR_SLEEPDEEP_Pos 2U /*!< SCB SCR: SLEEPDEEP Position */
|
||||||
|
#define SCB_SCR_SLEEPDEEP_Msk (1UL << SCB_SCR_SLEEPDEEP_Pos) /*!< SCB SCR: SLEEPDEEP Mask */
|
||||||
|
|
||||||
|
#define SCB_SCR_SLEEPONEXIT_Pos 1U /*!< SCB SCR: SLEEPONEXIT Position */
|
||||||
|
#define SCB_SCR_SLEEPONEXIT_Msk (1UL << SCB_SCR_SLEEPONEXIT_Pos) /*!< SCB SCR: SLEEPONEXIT Mask */
|
||||||
|
|
||||||
|
/* SCB Configuration Control Register Definitions */
|
||||||
|
#define SCB_CCR_STKALIGN_Pos 9U /*!< SCB CCR: STKALIGN Position */
|
||||||
|
#define SCB_CCR_STKALIGN_Msk (1UL << SCB_CCR_STKALIGN_Pos) /*!< SCB CCR: STKALIGN Mask */
|
||||||
|
|
||||||
|
#define SCB_CCR_UNALIGN_TRP_Pos 3U /*!< SCB CCR: UNALIGN_TRP Position */
|
||||||
|
#define SCB_CCR_UNALIGN_TRP_Msk (1UL << SCB_CCR_UNALIGN_TRP_Pos) /*!< SCB CCR: UNALIGN_TRP Mask */
|
||||||
|
|
||||||
|
/* SCB System Handler Control and State Register Definitions */
|
||||||
|
#define SCB_SHCSR_SVCALLPENDED_Pos 15U /*!< SCB SHCSR: SVCALLPENDED Position */
|
||||||
|
#define SCB_SHCSR_SVCALLPENDED_Msk (1UL << SCB_SHCSR_SVCALLPENDED_Pos) /*!< SCB SHCSR: SVCALLPENDED Mask */
|
||||||
|
|
||||||
|
/*@} end of group CMSIS_SCB */
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
\ingroup CMSIS_core_register
|
||||||
|
\defgroup CMSIS_SCnSCB System Controls not in SCB (SCnSCB)
|
||||||
|
\brief Type definitions for the System Control and ID Register not in the SCB
|
||||||
|
@{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
\brief Structure type to access the System Control and ID Register not in the SCB.
|
||||||
|
*/
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
uint32_t RESERVED0[2U];
|
||||||
|
__IOM uint32_t ACTLR; /*!< Offset: 0x008 (R/W) Auxiliary Control Register */
|
||||||
|
} SCnSCB_Type;
|
||||||
|
|
||||||
|
/* Auxiliary Control Register Definitions */
|
||||||
|
#define SCnSCB_ACTLR_DISMCYCINT_Pos 0U /*!< ACTLR: DISMCYCINT Position */
|
||||||
|
#define SCnSCB_ACTLR_DISMCYCINT_Msk (1UL /*<< SCnSCB_ACTLR_DISMCYCINT_Pos*/) /*!< ACTLR: DISMCYCINT Mask */
|
||||||
|
|
||||||
|
/*@} end of group CMSIS_SCnotSCB */
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
\ingroup CMSIS_core_register
|
||||||
|
\defgroup CMSIS_SysTick System Tick Timer (SysTick)
|
||||||
|
\brief Type definitions for the System Timer Registers.
|
||||||
|
@{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
\brief Structure type to access the System Timer (SysTick).
|
||||||
|
*/
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
__IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) SysTick Control and Status Register */
|
||||||
|
__IOM uint32_t LOAD; /*!< Offset: 0x004 (R/W) SysTick Reload Value Register */
|
||||||
|
__IOM uint32_t VAL; /*!< Offset: 0x008 (R/W) SysTick Current Value Register */
|
||||||
|
__IM uint32_t CALIB; /*!< Offset: 0x00C (R/ ) SysTick Calibration Register */
|
||||||
|
} SysTick_Type;
|
||||||
|
|
||||||
|
/* SysTick Control / Status Register Definitions */
|
||||||
|
#define SysTick_CTRL_COUNTFLAG_Pos 16U /*!< SysTick CTRL: COUNTFLAG Position */
|
||||||
|
#define SysTick_CTRL_COUNTFLAG_Msk (1UL << SysTick_CTRL_COUNTFLAG_Pos) /*!< SysTick CTRL: COUNTFLAG Mask */
|
||||||
|
|
||||||
|
#define SysTick_CTRL_CLKSOURCE_Pos 2U /*!< SysTick CTRL: CLKSOURCE Position */
|
||||||
|
#define SysTick_CTRL_CLKSOURCE_Msk (1UL << SysTick_CTRL_CLKSOURCE_Pos) /*!< SysTick CTRL: CLKSOURCE Mask */
|
||||||
|
|
||||||
|
#define SysTick_CTRL_TICKINT_Pos 1U /*!< SysTick CTRL: TICKINT Position */
|
||||||
|
#define SysTick_CTRL_TICKINT_Msk (1UL << SysTick_CTRL_TICKINT_Pos) /*!< SysTick CTRL: TICKINT Mask */
|
||||||
|
|
||||||
|
#define SysTick_CTRL_ENABLE_Pos 0U /*!< SysTick CTRL: ENABLE Position */
|
||||||
|
#define SysTick_CTRL_ENABLE_Msk (1UL /*<< SysTick_CTRL_ENABLE_Pos*/) /*!< SysTick CTRL: ENABLE Mask */
|
||||||
|
|
||||||
|
/* SysTick Reload Register Definitions */
|
||||||
|
#define SysTick_LOAD_RELOAD_Pos 0U /*!< SysTick LOAD: RELOAD Position */
|
||||||
|
#define SysTick_LOAD_RELOAD_Msk (0xFFFFFFUL /*<< SysTick_LOAD_RELOAD_Pos*/) /*!< SysTick LOAD: RELOAD Mask */
|
||||||
|
|
||||||
|
/* SysTick Current Register Definitions */
|
||||||
|
#define SysTick_VAL_CURRENT_Pos 0U /*!< SysTick VAL: CURRENT Position */
|
||||||
|
#define SysTick_VAL_CURRENT_Msk (0xFFFFFFUL /*<< SysTick_VAL_CURRENT_Pos*/) /*!< SysTick VAL: CURRENT Mask */
|
||||||
|
|
||||||
|
/* SysTick Calibration Register Definitions */
|
||||||
|
#define SysTick_CALIB_NOREF_Pos 31U /*!< SysTick CALIB: NOREF Position */
|
||||||
|
#define SysTick_CALIB_NOREF_Msk (1UL << SysTick_CALIB_NOREF_Pos) /*!< SysTick CALIB: NOREF Mask */
|
||||||
|
|
||||||
|
#define SysTick_CALIB_SKEW_Pos 30U /*!< SysTick CALIB: SKEW Position */
|
||||||
|
#define SysTick_CALIB_SKEW_Msk (1UL << SysTick_CALIB_SKEW_Pos) /*!< SysTick CALIB: SKEW Mask */
|
||||||
|
|
||||||
|
#define SysTick_CALIB_TENMS_Pos 0U /*!< SysTick CALIB: TENMS Position */
|
||||||
|
#define SysTick_CALIB_TENMS_Msk (0xFFFFFFUL /*<< SysTick_CALIB_TENMS_Pos*/) /*!< SysTick CALIB: TENMS Mask */
|
||||||
|
|
||||||
|
/*@} end of group CMSIS_SysTick */
|
||||||
|
|
||||||
|
#if (__MPU_PRESENT == 1U)
|
||||||
|
/**
|
||||||
|
\ingroup CMSIS_core_register
|
||||||
|
\defgroup CMSIS_MPU Memory Protection Unit (MPU)
|
||||||
|
\brief Type definitions for the Memory Protection Unit (MPU)
|
||||||
|
@{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
\brief Structure type to access the Memory Protection Unit (MPU).
|
||||||
|
*/
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
__IM uint32_t TYPE; /*!< Offset: 0x000 (R/ ) MPU Type Register */
|
||||||
|
__IOM uint32_t CTRL; /*!< Offset: 0x004 (R/W) MPU Control Register */
|
||||||
|
__IOM uint32_t RNR; /*!< Offset: 0x008 (R/W) MPU Region RNRber Register */
|
||||||
|
__IOM uint32_t RBAR; /*!< Offset: 0x00C (R/W) MPU Region Base Address Register */
|
||||||
|
__IOM uint32_t RASR; /*!< Offset: 0x010 (R/W) MPU Region Attribute and Size Register */
|
||||||
|
} MPU_Type;
|
||||||
|
|
||||||
|
/* MPU Type Register Definitions */
|
||||||
|
#define MPU_TYPE_IREGION_Pos 16U /*!< MPU TYPE: IREGION Position */
|
||||||
|
#define MPU_TYPE_IREGION_Msk (0xFFUL << MPU_TYPE_IREGION_Pos) /*!< MPU TYPE: IREGION Mask */
|
||||||
|
|
||||||
|
#define MPU_TYPE_DREGION_Pos 8U /*!< MPU TYPE: DREGION Position */
|
||||||
|
#define MPU_TYPE_DREGION_Msk (0xFFUL << MPU_TYPE_DREGION_Pos) /*!< MPU TYPE: DREGION Mask */
|
||||||
|
|
||||||
|
#define MPU_TYPE_SEPARATE_Pos 0U /*!< MPU TYPE: SEPARATE Position */
|
||||||
|
#define MPU_TYPE_SEPARATE_Msk (1UL /*<< MPU_TYPE_SEPARATE_Pos*/) /*!< MPU TYPE: SEPARATE Mask */
|
||||||
|
|
||||||
|
/* MPU Control Register Definitions */
|
||||||
|
#define MPU_CTRL_PRIVDEFENA_Pos 2U /*!< MPU CTRL: PRIVDEFENA Position */
|
||||||
|
#define MPU_CTRL_PRIVDEFENA_Msk (1UL << MPU_CTRL_PRIVDEFENA_Pos) /*!< MPU CTRL: PRIVDEFENA Mask */
|
||||||
|
|
||||||
|
#define MPU_CTRL_HFNMIENA_Pos 1U /*!< MPU CTRL: HFNMIENA Position */
|
||||||
|
#define MPU_CTRL_HFNMIENA_Msk (1UL << MPU_CTRL_HFNMIENA_Pos) /*!< MPU CTRL: HFNMIENA Mask */
|
||||||
|
|
||||||
|
#define MPU_CTRL_ENABLE_Pos 0U /*!< MPU CTRL: ENABLE Position */
|
||||||
|
#define MPU_CTRL_ENABLE_Msk (1UL /*<< MPU_CTRL_ENABLE_Pos*/) /*!< MPU CTRL: ENABLE Mask */
|
||||||
|
|
||||||
|
/* MPU Region Number Register Definitions */
|
||||||
|
#define MPU_RNR_REGION_Pos 0U /*!< MPU RNR: REGION Position */
|
||||||
|
#define MPU_RNR_REGION_Msk (0xFFUL /*<< MPU_RNR_REGION_Pos*/) /*!< MPU RNR: REGION Mask */
|
||||||
|
|
||||||
|
/* MPU Region Base Address Register Definitions */
|
||||||
|
#define MPU_RBAR_ADDR_Pos 8U /*!< MPU RBAR: ADDR Position */
|
||||||
|
#define MPU_RBAR_ADDR_Msk (0xFFFFFFUL << MPU_RBAR_ADDR_Pos) /*!< MPU RBAR: ADDR Mask */
|
||||||
|
|
||||||
|
#define MPU_RBAR_VALID_Pos 4U /*!< MPU RBAR: VALID Position */
|
||||||
|
#define MPU_RBAR_VALID_Msk (1UL << MPU_RBAR_VALID_Pos) /*!< MPU RBAR: VALID Mask */
|
||||||
|
|
||||||
|
#define MPU_RBAR_REGION_Pos 0U /*!< MPU RBAR: REGION Position */
|
||||||
|
#define MPU_RBAR_REGION_Msk (0xFUL /*<< MPU_RBAR_REGION_Pos*/) /*!< MPU RBAR: REGION Mask */
|
||||||
|
|
||||||
|
/* MPU Region Attribute and Size Register Definitions */
|
||||||
|
#define MPU_RASR_ATTRS_Pos 16U /*!< MPU RASR: MPU Region Attribute field Position */
|
||||||
|
#define MPU_RASR_ATTRS_Msk (0xFFFFUL << MPU_RASR_ATTRS_Pos) /*!< MPU RASR: MPU Region Attribute field Mask */
|
||||||
|
|
||||||
|
#define MPU_RASR_XN_Pos 28U /*!< MPU RASR: ATTRS.XN Position */
|
||||||
|
#define MPU_RASR_XN_Msk (1UL << MPU_RASR_XN_Pos) /*!< MPU RASR: ATTRS.XN Mask */
|
||||||
|
|
||||||
|
#define MPU_RASR_AP_Pos 24U /*!< MPU RASR: ATTRS.AP Position */
|
||||||
|
#define MPU_RASR_AP_Msk (0x7UL << MPU_RASR_AP_Pos) /*!< MPU RASR: ATTRS.AP Mask */
|
||||||
|
|
||||||
|
#define MPU_RASR_TEX_Pos 19U /*!< MPU RASR: ATTRS.TEX Position */
|
||||||
|
#define MPU_RASR_TEX_Msk (0x7UL << MPU_RASR_TEX_Pos) /*!< MPU RASR: ATTRS.TEX Mask */
|
||||||
|
|
||||||
|
#define MPU_RASR_S_Pos 18U /*!< MPU RASR: ATTRS.S Position */
|
||||||
|
#define MPU_RASR_S_Msk (1UL << MPU_RASR_S_Pos) /*!< MPU RASR: ATTRS.S Mask */
|
||||||
|
|
||||||
|
#define MPU_RASR_C_Pos 17U /*!< MPU RASR: ATTRS.C Position */
|
||||||
|
#define MPU_RASR_C_Msk (1UL << MPU_RASR_C_Pos) /*!< MPU RASR: ATTRS.C Mask */
|
||||||
|
|
||||||
|
#define MPU_RASR_B_Pos 16U /*!< MPU RASR: ATTRS.B Position */
|
||||||
|
#define MPU_RASR_B_Msk (1UL << MPU_RASR_B_Pos) /*!< MPU RASR: ATTRS.B Mask */
|
||||||
|
|
||||||
|
#define MPU_RASR_SRD_Pos 8U /*!< MPU RASR: Sub-Region Disable Position */
|
||||||
|
#define MPU_RASR_SRD_Msk (0xFFUL << MPU_RASR_SRD_Pos) /*!< MPU RASR: Sub-Region Disable Mask */
|
||||||
|
|
||||||
|
#define MPU_RASR_SIZE_Pos 1U /*!< MPU RASR: Region Size Field Position */
|
||||||
|
#define MPU_RASR_SIZE_Msk (0x1FUL << MPU_RASR_SIZE_Pos) /*!< MPU RASR: Region Size Field Mask */
|
||||||
|
|
||||||
|
#define MPU_RASR_ENABLE_Pos 0U /*!< MPU RASR: Region enable bit Position */
|
||||||
|
#define MPU_RASR_ENABLE_Msk (1UL /*<< MPU_RASR_ENABLE_Pos*/) /*!< MPU RASR: Region enable bit Disable Mask */
|
||||||
|
|
||||||
|
/*@} end of group CMSIS_MPU */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
\ingroup CMSIS_core_register
|
||||||
|
\defgroup CMSIS_CoreDebug Core Debug Registers (CoreDebug)
|
||||||
|
\brief SC000 Core Debug Registers (DCB registers, SHCSR, and DFSR) are only accessible over DAP and not via processor.
|
||||||
|
Therefore they are not covered by the SC000 header file.
|
||||||
|
@{
|
||||||
|
*/
|
||||||
|
/*@} end of group CMSIS_CoreDebug */
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
\ingroup CMSIS_core_register
|
||||||
|
\defgroup CMSIS_core_bitfield Core register bit field macros
|
||||||
|
\brief Macros for use with bit field definitions (xxx_Pos, xxx_Msk).
|
||||||
|
@{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
\brief Mask and shift a bit field value for use in a register bit range.
|
||||||
|
\param[in] field Name of the register bit field.
|
||||||
|
\param[in] value Value of the bit field.
|
||||||
|
\return Masked and shifted value.
|
||||||
|
*/
|
||||||
|
#define _VAL2FLD(field, value) ((value << field ## _Pos) & field ## _Msk)
|
||||||
|
|
||||||
|
/**
|
||||||
|
\brief Mask and shift a register value to extract a bit filed value.
|
||||||
|
\param[in] field Name of the register bit field.
|
||||||
|
\param[in] value Value of register.
|
||||||
|
\return Masked and shifted bit field value.
|
||||||
|
*/
|
||||||
|
#define _FLD2VAL(field, value) ((value & field ## _Msk) >> field ## _Pos)
|
||||||
|
|
||||||
|
/*@} end of group CMSIS_core_bitfield */
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
\ingroup CMSIS_core_register
|
||||||
|
\defgroup CMSIS_core_base Core Definitions
|
||||||
|
\brief Definitions for base addresses, unions, and structures.
|
||||||
|
@{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Memory mapping of SC000 Hardware */
|
||||||
|
#define SCS_BASE (0xE000E000UL) /*!< System Control Space Base Address */
|
||||||
|
#define SysTick_BASE (SCS_BASE + 0x0010UL) /*!< SysTick Base Address */
|
||||||
|
#define NVIC_BASE (SCS_BASE + 0x0100UL) /*!< NVIC Base Address */
|
||||||
|
#define SCB_BASE (SCS_BASE + 0x0D00UL) /*!< System Control Block Base Address */
|
||||||
|
|
||||||
|
#define SCnSCB ((SCnSCB_Type *) SCS_BASE ) /*!< System control Register not in SCB */
|
||||||
|
#define SCB ((SCB_Type *) SCB_BASE ) /*!< SCB configuration struct */
|
||||||
|
#define SysTick ((SysTick_Type *) SysTick_BASE ) /*!< SysTick configuration struct */
|
||||||
|
#define NVIC ((NVIC_Type *) NVIC_BASE ) /*!< NVIC configuration struct */
|
||||||
|
|
||||||
|
#if (__MPU_PRESENT == 1U)
|
||||||
|
#define MPU_BASE (SCS_BASE + 0x0D90UL) /*!< Memory Protection Unit */
|
||||||
|
#define MPU ((MPU_Type *) MPU_BASE ) /*!< Memory Protection Unit */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*@} */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Hardware Abstraction Layer
|
||||||
|
Core Function Interface contains:
|
||||||
|
- Core NVIC Functions
|
||||||
|
- Core SysTick Functions
|
||||||
|
- Core Register Access Functions
|
||||||
|
******************************************************************************/
|
||||||
|
/**
|
||||||
|
\defgroup CMSIS_Core_FunctionInterface Functions and Instructions Reference
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* ########################## NVIC functions #################################### */
|
||||||
|
/**
|
||||||
|
\ingroup CMSIS_Core_FunctionInterface
|
||||||
|
\defgroup CMSIS_Core_NVICFunctions NVIC Functions
|
||||||
|
\brief Functions that manage interrupts and exceptions via the NVIC.
|
||||||
|
@{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Interrupt Priorities are WORD accessible only under ARMv6M */
|
||||||
|
/* The following MACROS handle generation of the register offset and byte masks */
|
||||||
|
#define _BIT_SHIFT(IRQn) ( ((((uint32_t)(int32_t)(IRQn)) ) & 0x03UL) * 8UL)
|
||||||
|
#define _SHP_IDX(IRQn) ( (((((uint32_t)(int32_t)(IRQn)) & 0x0FUL)-8UL) >> 2UL) )
|
||||||
|
#define _IP_IDX(IRQn) ( (((uint32_t)(int32_t)(IRQn)) >> 2UL) )
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
\brief Enable External Interrupt
|
||||||
|
\details Enables a device-specific interrupt in the NVIC interrupt controller.
|
||||||
|
\param [in] IRQn External interrupt number. Value cannot be negative.
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE void NVIC_EnableIRQ(IRQn_Type IRQn)
|
||||||
|
{
|
||||||
|
NVIC->ISER[0U] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
\brief Disable External Interrupt
|
||||||
|
\details Disables a device-specific interrupt in the NVIC interrupt controller.
|
||||||
|
\param [in] IRQn External interrupt number. Value cannot be negative.
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE void NVIC_DisableIRQ(IRQn_Type IRQn)
|
||||||
|
{
|
||||||
|
NVIC->ICER[0U] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
\brief Get Pending Interrupt
|
||||||
|
\details Reads the pending register in the NVIC and returns the pending bit for the specified interrupt.
|
||||||
|
\param [in] IRQn Interrupt number.
|
||||||
|
\return 0 Interrupt status is not pending.
|
||||||
|
\return 1 Interrupt status is pending.
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE uint32_t NVIC_GetPendingIRQ(IRQn_Type IRQn)
|
||||||
|
{
|
||||||
|
return((uint32_t)(((NVIC->ISPR[0U] & (1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
\brief Set Pending Interrupt
|
||||||
|
\details Sets the pending bit of an external interrupt.
|
||||||
|
\param [in] IRQn Interrupt number. Value cannot be negative.
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE void NVIC_SetPendingIRQ(IRQn_Type IRQn)
|
||||||
|
{
|
||||||
|
NVIC->ISPR[0U] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
\brief Clear Pending Interrupt
|
||||||
|
\details Clears the pending bit of an external interrupt.
|
||||||
|
\param [in] IRQn External interrupt number. Value cannot be negative.
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE void NVIC_ClearPendingIRQ(IRQn_Type IRQn)
|
||||||
|
{
|
||||||
|
NVIC->ICPR[0U] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
\brief Set Interrupt Priority
|
||||||
|
\details Sets the priority of an interrupt.
|
||||||
|
\note The priority cannot be set for every core interrupt.
|
||||||
|
\param [in] IRQn Interrupt number.
|
||||||
|
\param [in] priority Priority to set.
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE void NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority)
|
||||||
|
{
|
||||||
|
if ((int32_t)(IRQn) < 0)
|
||||||
|
{
|
||||||
|
SCB->SHP[_SHP_IDX(IRQn)] = ((uint32_t)(SCB->SHP[_SHP_IDX(IRQn)] & ~(0xFFUL << _BIT_SHIFT(IRQn))) |
|
||||||
|
(((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL) << _BIT_SHIFT(IRQn)));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
NVIC->IP[_IP_IDX(IRQn)] = ((uint32_t)(NVIC->IP[_IP_IDX(IRQn)] & ~(0xFFUL << _BIT_SHIFT(IRQn))) |
|
||||||
|
(((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL) << _BIT_SHIFT(IRQn)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
\brief Get Interrupt Priority
|
||||||
|
\details Reads the priority of an interrupt.
|
||||||
|
The interrupt number can be positive to specify an external (device specific) interrupt,
|
||||||
|
or negative to specify an internal (core) interrupt.
|
||||||
|
\param [in] IRQn Interrupt number.
|
||||||
|
\return Interrupt Priority.
|
||||||
|
Value is aligned automatically to the implemented priority bits of the microcontroller.
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE uint32_t NVIC_GetPriority(IRQn_Type IRQn)
|
||||||
|
{
|
||||||
|
|
||||||
|
if ((int32_t)(IRQn) < 0)
|
||||||
|
{
|
||||||
|
return((uint32_t)(((SCB->SHP[_SHP_IDX(IRQn)] >> _BIT_SHIFT(IRQn) ) & (uint32_t)0xFFUL) >> (8U - __NVIC_PRIO_BITS)));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return((uint32_t)(((NVIC->IP[ _IP_IDX(IRQn)] >> _BIT_SHIFT(IRQn) ) & (uint32_t)0xFFUL) >> (8U - __NVIC_PRIO_BITS)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
\brief System Reset
|
||||||
|
\details Initiates a system reset request to reset the MCU.
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE void NVIC_SystemReset(void)
|
||||||
|
{
|
||||||
|
__DSB(); /* Ensure all outstanding memory accesses included
|
||||||
|
buffered write are completed before reset */
|
||||||
|
SCB->AIRCR = ((0x5FAUL << SCB_AIRCR_VECTKEY_Pos) |
|
||||||
|
SCB_AIRCR_SYSRESETREQ_Msk);
|
||||||
|
__DSB(); /* Ensure completion of memory access */
|
||||||
|
|
||||||
|
for (;;) /* wait until reset */
|
||||||
|
{
|
||||||
|
__NOP();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*@} end of CMSIS_Core_NVICFunctions */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* ################################## SysTick function ############################################ */
|
||||||
|
/**
|
||||||
|
\ingroup CMSIS_Core_FunctionInterface
|
||||||
|
\defgroup CMSIS_Core_SysTickFunctions SysTick Functions
|
||||||
|
\brief Functions that configure the System.
|
||||||
|
@{
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if (__Vendor_SysTickConfig == 0U)
|
||||||
|
|
||||||
|
/**
|
||||||
|
\brief System Tick Configuration
|
||||||
|
\details Initializes the System Timer and its interrupt, and starts the System Tick Timer.
|
||||||
|
Counter is in free running mode to generate periodic interrupts.
|
||||||
|
\param [in] ticks Number of ticks between two interrupts.
|
||||||
|
\return 0 Function succeeded.
|
||||||
|
\return 1 Function failed.
|
||||||
|
\note When the variable <b>__Vendor_SysTickConfig</b> is set to 1, then the
|
||||||
|
function <b>SysTick_Config</b> is not included. In this case, the file <b><i>device</i>.h</b>
|
||||||
|
must contain a vendor-specific implementation of this function.
|
||||||
|
*/
|
||||||
|
__STATIC_INLINE uint32_t SysTick_Config(uint32_t ticks)
|
||||||
|
{
|
||||||
|
if ((ticks - 1UL) > SysTick_LOAD_RELOAD_Msk)
|
||||||
|
{
|
||||||
|
return (1UL); /* Reload value impossible */
|
||||||
|
}
|
||||||
|
|
||||||
|
SysTick->LOAD = (uint32_t)(ticks - 1UL); /* set reload register */
|
||||||
|
NVIC_SetPriority (SysTick_IRQn, (1UL << __NVIC_PRIO_BITS) - 1UL); /* set Priority for Systick Interrupt */
|
||||||
|
SysTick->VAL = 0UL; /* Load the SysTick Counter Value */
|
||||||
|
SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk |
|
||||||
|
SysTick_CTRL_TICKINT_Msk |
|
||||||
|
SysTick_CTRL_ENABLE_Msk; /* Enable SysTick IRQ and SysTick Timer */
|
||||||
|
return (0UL); /* Function successful */
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*@} end of CMSIS_Core_SysTickFunctions */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* __CORE_SC000_H_DEPENDANT */
|
||||||
|
|
||||||
|
#endif /* __CMSIS_GENERIC */
|
1745
src/platform/cm4/cmsis/include/core_sc300.h
Normal file
1745
src/platform/cm4/cmsis/include/core_sc300.h
Normal file
File diff suppressed because it is too large
Load Diff
28
src/platform/cm4/low_level_interrupt.cc
Normal file
28
src/platform/cm4/low_level_interrupt.cc
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
#include <cassert>
|
||||||
|
|
||||||
|
#include "platform/cm4/InterruptHandler.h"
|
||||||
|
#include "platform/cm4/InterruptGuardian.h"
|
||||||
|
|
||||||
|
extern "C" {
|
||||||
|
void NMI_Handler(void);
|
||||||
|
void HardFault_Handler(void);
|
||||||
|
void MemoryManagement_Handler(void);
|
||||||
|
void BusFault_Handler(void);
|
||||||
|
void UsageFault_Handler(void);
|
||||||
|
void SVC_Handler(void);
|
||||||
|
void DebugMon_Handler(void);
|
||||||
|
void PendSV_Handler(void);
|
||||||
|
void SysTick_Handler(void);
|
||||||
|
}
|
||||||
|
|
||||||
|
using namespace pinetime::platform::cm4;
|
||||||
|
|
||||||
|
void SysTick_Handler(void)
|
||||||
|
{
|
||||||
|
uint32_t irq_nr = InterruptGuardian::SYS_TICK_IRQ;
|
||||||
|
InterruptHandler *h = InterruptGuardian::instance.cm4_vector[irq_nr];
|
||||||
|
|
||||||
|
assert(h != nullptr);
|
||||||
|
|
||||||
|
h->handle();
|
||||||
|
}
|
13
src/platform/nrf52/InterruptGuardian.cc
Normal file
13
src/platform/nrf52/InterruptGuardian.cc
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
#include "platform/nrf52/InterruptHandler.h"
|
||||||
|
#include "platform/nrf52/InterruptGuardian.h"
|
||||||
|
|
||||||
|
using namespace pinetime::platform::nrf52;
|
||||||
|
|
||||||
|
InterruptGuardian::InterruptGuardian()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void InterruptGuardian::register_handler(Nrf52IrqN irq_nr, InterruptHandler &handler)
|
||||||
|
{
|
||||||
|
this->nrf52_vector[irq_nr] = &handler;
|
||||||
|
}
|
72
src/platform/nrf52/InterruptGuardian.h
Normal file
72
src/platform/nrf52/InterruptGuardian.h
Normal file
@@ -0,0 +1,72 @@
|
|||||||
|
#ifndef __PINETIME_PLATFORM_NRF52_INTERRUPTGUARDIAN_H__
|
||||||
|
#define __PINETIME_PLATFORM_NRF52_INTERRUPTGUARDIAN_H__
|
||||||
|
|
||||||
|
#include <array>
|
||||||
|
|
||||||
|
extern "C" {
|
||||||
|
#include "nrf52.h"
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace pinetime::platform::nrf52 {
|
||||||
|
|
||||||
|
class InterruptGuardian
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
InterruptGuardian();
|
||||||
|
|
||||||
|
enum Nrf52IrqN {
|
||||||
|
POWER_CLOCK_IRQ, //!< 0 POWER_CLOCK
|
||||||
|
RADIO_IRQ, //!< 1 RADIO
|
||||||
|
UARTE0_UART0_IRQ, //!< 2 UARTE0_UART0
|
||||||
|
SPIM0_SPIS0_TWIM0_TWIS0_SPI0_TWI0_IRQ, //!< 3 SPIM0_SPIS0_TWIM0_TWIS0_SPI0_TWI0
|
||||||
|
SPIM1_SPIS1_TWIM1_TWIS1_SPI1_TWI1_IRQ, //!< 4 SPIM1_SPIS1_TWIM1_TWIS1_SPI1_TWI1
|
||||||
|
NFCT_IRQ, //!< 5 NFCT
|
||||||
|
GPIOTE_IRQ, //!< 6 GPIOTE
|
||||||
|
SAADC_IRQ, //!< 7 SAADC
|
||||||
|
TIMER0_IRQ, //!< 8 TIMER0
|
||||||
|
TIMER1_IRQ, //!< 9 TIMER1
|
||||||
|
TIMER2_IRQ, //!< 10 TIMER2
|
||||||
|
RTC0_IRQ, //!< 11 RTC0
|
||||||
|
TEMP_IRQ, //!< 12 TEMP
|
||||||
|
RNG_IRQ, //!< 13 RNG
|
||||||
|
ECB_IRQ, //!< 14 ECB
|
||||||
|
CCM_AAR_IRQ, //!< 15 CCM_AAR
|
||||||
|
WDT_IRQ, //!< 16 WDT
|
||||||
|
RTC1_IRQ, //!< 17 RTC1
|
||||||
|
QDEC_IRQ, //!< 18 QDEC
|
||||||
|
COMP_LPCOMP_IRQ, //!< 19 COMP_LPCOMP
|
||||||
|
SWI0_EGU0_IRQ, //!< 20 SWI0_EGU0
|
||||||
|
SWI1_EGU1_IRQ, //!< 21 SWI1_EGU1
|
||||||
|
SWI2_EGU2_IRQ, //!< 22 SWI2_EGU2
|
||||||
|
SWI3_EGU3_IRQ, //!< 23 SWI3_EGU3
|
||||||
|
SWI4_EGU4_IRQ, //!< 24 SWI4_EGU4
|
||||||
|
SWI5_EGU5_IRQ, //!< 25 SWI5_EGU5
|
||||||
|
TIMER3_IRQ, //!< 26 TIMER3
|
||||||
|
TIMER4_IRQ, //!< 27 TIMER4
|
||||||
|
PWM0_IRQ, //!< 28 PWM0
|
||||||
|
PDM_IRQ, //!< 29 PDM
|
||||||
|
MWU_IRQ, //!< 32 MWU
|
||||||
|
PWM1_IRQ, //!< 33 PWM1
|
||||||
|
PWM2_IRQ, //!< 34 PWM2
|
||||||
|
SPIM2_SPIS2_SPI2_IRQ, //!< 35 SPIM2_SPIS2_SPI2
|
||||||
|
RTC2_IRQ, //!< 36 RTC2
|
||||||
|
I2S_IRQ, //!< 37 I2S
|
||||||
|
FPU_IRQ //!< 38 FPU
|
||||||
|
};
|
||||||
|
|
||||||
|
private:
|
||||||
|
enum {
|
||||||
|
NRF52_HANDLER_COUNT = FPU_IRQn + 1,
|
||||||
|
};
|
||||||
|
|
||||||
|
public:
|
||||||
|
void register_handler(Nrf52IrqN irq_nr, InterruptHandler &);
|
||||||
|
|
||||||
|
static InterruptGuardian instance;
|
||||||
|
|
||||||
|
std::array<InterruptHandler *, NRF52_HANDLER_COUNT> nrf52_vector;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
26
src/platform/nrf52/InterruptHandler.cc
Normal file
26
src/platform/nrf52/InterruptHandler.cc
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
#include <assert.h>
|
||||||
|
|
||||||
|
#include "platform/nrf52/InterruptHandler.h"
|
||||||
|
#include "platform/nrf52/InterruptGuardian.h"
|
||||||
|
|
||||||
|
using namespace pinetime::platform::nrf52;
|
||||||
|
|
||||||
|
InterruptHandler::InterruptHandler(uint32_t irq_nr)
|
||||||
|
{
|
||||||
|
InterruptGuardian::instance.register_handler(static_cast<InterruptGuardian::Nrf52IrqN>(irq_nr), *this);
|
||||||
|
}
|
||||||
|
|
||||||
|
void InterruptHandler::handle()
|
||||||
|
{
|
||||||
|
assert(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
void InterruptHandler::enable()
|
||||||
|
{
|
||||||
|
assert(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
void InterruptHandler::disable()
|
||||||
|
{
|
||||||
|
assert(false);
|
||||||
|
}
|
22
src/platform/nrf52/InterruptHandler.h
Normal file
22
src/platform/nrf52/InterruptHandler.h
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
#ifndef __PINETIME_PLATFORM_NRF52_INTERRUPTHANDLER_H__
|
||||||
|
#define __PINETIME_PLATFORM_NRF52_INTERRUPTHANDLER_H__
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
|
#include "interrupt_interface.h"
|
||||||
|
|
||||||
|
namespace pinetime::platform::nrf52 {
|
||||||
|
|
||||||
|
class InterruptHandler : public pinetime::interfaces::InterruptHandlerInterface
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
InterruptHandler(uint32_t);
|
||||||
|
|
||||||
|
void handle() override;
|
||||||
|
void enable() override;
|
||||||
|
void disable() override;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
@@ -1,82 +0,0 @@
|
|||||||
#include <assert.h>
|
|
||||||
#include <fcntl.h>
|
|
||||||
#include <stddef.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
#include "platform/narf52/narf52.h"
|
|
||||||
#include "platform/narf52/narf52_gpio.h"
|
|
||||||
|
|
||||||
#include "gpio.h"
|
|
||||||
|
|
||||||
int gpio_open(const struct driver *drv)
|
|
||||||
{
|
|
||||||
assert(NULL != drv);
|
|
||||||
|
|
||||||
int res = -1;
|
|
||||||
struct narf52_gpio *this = (struct narf52_gpio *)(drv->dev);
|
|
||||||
struct narf52_gpio_type *reg = (struct narf52_gpio_type *)NARF_P0_BASE;
|
|
||||||
|
|
||||||
reg->PIN_CNF[this->pin_number] = ((uint32_t)(this->dir) << 0)
|
|
||||||
| ((uint32_t)(this->input) << 1)
|
|
||||||
| ((uint32_t)(this->pull) << 2)
|
|
||||||
| ((uint32_t)(this->drive) << 8)
|
|
||||||
| ((uint32_t)(this->sense) << 16);
|
|
||||||
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
int gpio_close(const struct driver *drv)
|
|
||||||
{
|
|
||||||
assert(NULL != drv);
|
|
||||||
int res = -1;
|
|
||||||
struct gpio *this = (struct gpio *)(drv->dev);
|
|
||||||
this = this;
|
|
||||||
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
int gpio_read(const struct driver *drv, char *buffer, unsigned int len)
|
|
||||||
{
|
|
||||||
assert((NULL != drv) && (buffer != NULL));
|
|
||||||
if(len == 0) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
struct narf52_gpio *this = (struct narf52_gpio *)(drv->dev);
|
|
||||||
struct narf52_gpio_type *reg = (struct narf52_gpio_type *)NARF_P0_BASE;
|
|
||||||
uint32_t state = ((reg->IN) >> (this->pin_number) & 1UL);
|
|
||||||
if(state) {
|
|
||||||
buffer[0] = 0x31;
|
|
||||||
} else {
|
|
||||||
buffer[0] = 0x30;
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int gpio_write(const struct driver *drv, const char *buffer, unsigned int len)
|
|
||||||
{
|
|
||||||
assert((NULL != drv) && (buffer != NULL));
|
|
||||||
if(len == 0) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
struct narf52_gpio *this = (struct narf52_gpio *)(drv->dev);
|
|
||||||
struct narf52_gpio_type *reg = (struct narf52_gpio_type *)NARF_P0_BASE;
|
|
||||||
if(buffer[0] != 0x30) {
|
|
||||||
reg->OUTSET = 1 << (this->pin_number);
|
|
||||||
} else {
|
|
||||||
reg->OUTCLR = 1 << (this->pin_number);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int gpio_ioctl(const struct driver *drv, unsigned int cmd, unsigned int argc, va_list args)
|
|
||||||
{
|
|
||||||
assert(drv != 0);
|
|
||||||
|
|
||||||
int res = -1;
|
|
||||||
struct gpio *this = (struct gpio *)(drv->dev);
|
|
||||||
this = this;
|
|
||||||
|
|
||||||
return res;
|
|
||||||
}
|
|
107
src/platform/nrf52/gpio.cc
Normal file
107
src/platform/nrf52/gpio.cc
Normal file
@@ -0,0 +1,107 @@
|
|||||||
|
extern "C" {
|
||||||
|
#include "nrf52.h"
|
||||||
|
#include "nrf52_bitfields.h"
|
||||||
|
|
||||||
|
NRF_GPIO_Type *const GPIO_REGS = reinterpret_cast<NRF_GPIO_Type *>(NRF_P0_BASE);
|
||||||
|
NRF_GPIOTE_Type *const GPIOTE_REGS = reinterpret_cast<NRF_GPIOTE_Type *>(NRF_GPIOTE_BASE);
|
||||||
|
}
|
||||||
|
|
||||||
|
#include "gpiote.h"
|
||||||
|
|
||||||
|
extern pinetime::platform::nrf52::Gpiote gpiote;
|
||||||
|
|
||||||
|
#include "platform/nrf52/gpiote.h"
|
||||||
|
#include "platform/nrf52/gpio.h"
|
||||||
|
|
||||||
|
using namespace pinetime::platform::nrf52;
|
||||||
|
|
||||||
|
Gpio::Gpio()
|
||||||
|
: pin(0)
|
||||||
|
, blocking(false)
|
||||||
|
, wait_for_event(false)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
Gpio::Gpio(uint32_t pin)
|
||||||
|
: pin(pin)
|
||||||
|
, blocking(false)
|
||||||
|
, wait_for_event(false)
|
||||||
|
{
|
||||||
|
this->set_direction(direction::OUT);
|
||||||
|
this->clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Gpio::set_direction(direction dir, bool blocking_read)
|
||||||
|
{
|
||||||
|
uint32_t direct = GPIO_PIN_CNF_DIR_Output << GPIO_PIN_CNF_DIR_Pos;
|
||||||
|
uint32_t input = GPIO_PIN_CNF_INPUT_Disconnect << GPIO_PIN_CNF_INPUT_Pos;
|
||||||
|
uint32_t pull = GPIO_PIN_CNF_PULL_Disabled << GPIO_PIN_CNF_PULL_Pos;
|
||||||
|
uint32_t drive = GPIO_PIN_CNF_DRIVE_S0S1 << GPIO_PIN_CNF_DRIVE_Pos;
|
||||||
|
uint32_t sense = GPIO_PIN_CNF_SENSE_Disabled << GPIO_PIN_CNF_SENSE_Pos;
|
||||||
|
if(dir == direction::IN) {
|
||||||
|
direct = GPIO_PIN_CNF_DIR_Input << GPIO_PIN_CNF_DIR_Pos;
|
||||||
|
input = GPIO_PIN_CNF_INPUT_Connect << GPIO_PIN_CNF_INPUT_Pos;
|
||||||
|
|
||||||
|
// FIXME: Make this configurable
|
||||||
|
// GPIO_PIN_CNF_PULL_Disabled, ///< Pin pull-up resistor disabled.
|
||||||
|
// GPIO_PIN_CNF_PULL_Pulldown, ///< Pin pull-down resistor enabled.
|
||||||
|
// GPIO_PIN_CNF_PULL_Pullup, ///< Pin pull-up resistor enabled.
|
||||||
|
pull = GPIO_PIN_CNF_PULL_Pullup << GPIO_PIN_CNF_PULL_Pos;
|
||||||
|
drive = GPIO_PIN_CNF_DRIVE_S0S1 << GPIO_PIN_CNF_DRIVE_Pos;
|
||||||
|
sense = GPIO_PIN_CNF_SENSE_Low << GPIO_PIN_CNF_SENSE_Pos;
|
||||||
|
|
||||||
|
gpiote.instance().register_handler(this);
|
||||||
|
|
||||||
|
this->blocking = blocking_read;
|
||||||
|
|
||||||
|
gpiote.instance().enable();
|
||||||
|
}
|
||||||
|
GPIO_REGS->PIN_CNF[pin] = direct | input | pull | drive | sense;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Gpio::pin_number(uint32_t pin)
|
||||||
|
{
|
||||||
|
this->pin = pin;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t Gpio::pin_number()
|
||||||
|
{
|
||||||
|
return this->pin;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t Gpio::get()
|
||||||
|
{
|
||||||
|
if(this->blocking) {
|
||||||
|
this->wait_for_event = true;
|
||||||
|
while(this->wait_for_event == true) {
|
||||||
|
// FIXME: Low Power
|
||||||
|
asm volatile("nop");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
uint32_t res = (GPIO_REGS->IN >> pin) & 1UL;
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Gpio::set()
|
||||||
|
{
|
||||||
|
GPIO_REGS->OUTSET = 1UL << (this->pin);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Gpio::clear()
|
||||||
|
{
|
||||||
|
GPIO_REGS->OUTCLR = 1UL << (this->pin);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Gpio::toggle()
|
||||||
|
{
|
||||||
|
uint32_t state = GPIO_REGS->OUT;
|
||||||
|
|
||||||
|
GPIO_REGS->OUTSET = (~state & (1UL << (this->pin)));
|
||||||
|
GPIO_REGS->OUTCLR = (state & (1UL << (this->pin)));
|
||||||
|
}
|
||||||
|
|
||||||
|
void Gpio::handle()
|
||||||
|
{
|
||||||
|
this->wait_for_event = false;
|
||||||
|
}
|
34
src/platform/nrf52/gpio.h
Normal file
34
src/platform/nrf52/gpio.h
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
#ifndef __PLATFORM_NRF52_GPIO_H__
|
||||||
|
#define __PLATFORM_NRF52_GPIO_H__
|
||||||
|
|
||||||
|
#include "gpio_interface.h"
|
||||||
|
|
||||||
|
#include "platform/nrf52/InterruptHandler.h"
|
||||||
|
|
||||||
|
namespace pinetime::platform::nrf52 {
|
||||||
|
|
||||||
|
class Gpio : public pinetime::interfaces::GpioInterface
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Gpio();
|
||||||
|
Gpio(uint32_t);
|
||||||
|
void pin_number(uint32_t);
|
||||||
|
uint32_t pin_number() override;
|
||||||
|
|
||||||
|
void set_direction(direction, bool blocking_read=false) override;
|
||||||
|
uint32_t get() override;
|
||||||
|
void set() override;
|
||||||
|
void clear() override;
|
||||||
|
void toggle() override;
|
||||||
|
|
||||||
|
void handle() override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
uint32_t pin;
|
||||||
|
bool blocking;
|
||||||
|
volatile bool wait_for_event;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
77
src/platform/nrf52/gpiote.cc
Normal file
77
src/platform/nrf52/gpiote.cc
Normal file
@@ -0,0 +1,77 @@
|
|||||||
|
#include <cassert>
|
||||||
|
|
||||||
|
#include "platform/nrf52/InterruptHandler.h"
|
||||||
|
#include "platform/nrf52/InterruptGuardian.h"
|
||||||
|
|
||||||
|
#include "platform/nrf52/gpiote.h"
|
||||||
|
|
||||||
|
extern "C" {
|
||||||
|
#include "nrf52.h"
|
||||||
|
#include "nrf52_bitfields.h"
|
||||||
|
|
||||||
|
NRF_GPIOTE_Type *const GPIOTE_REGS = reinterpret_cast<NRF_GPIOTE_Type *>(NRF_GPIOTE_BASE);
|
||||||
|
}
|
||||||
|
|
||||||
|
using namespace pinetime::platform::nrf52;
|
||||||
|
|
||||||
|
Gpiote::Gpiote()
|
||||||
|
: InterruptHandler(InterruptGuardian::Nrf52IrqN::GPIOTE_IRQ)
|
||||||
|
, num_registered(0)
|
||||||
|
{
|
||||||
|
for(auto it = this->gpiote_channels.begin(); it != this->gpiote_channels.end(); ++it) {
|
||||||
|
*it = nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Gpiote::enable()
|
||||||
|
{
|
||||||
|
NVIC_SetPriority(GPIOTE_IRQn, 7);
|
||||||
|
NVIC_EnableIRQ(GPIOTE_IRQn);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Gpiote::disable()
|
||||||
|
{
|
||||||
|
NVIC_DisableIRQ(GPIOTE_IRQn);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Gpiote::register_handler(pinetime::interfaces::GpioInterface *gpio)
|
||||||
|
{
|
||||||
|
if(num_registered == GPIOTE_CHANNELS) {
|
||||||
|
//FIXME: Error notification
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(num_registered == 0) {
|
||||||
|
this->enable();
|
||||||
|
} else {
|
||||||
|
//check if gpio already registered
|
||||||
|
for(auto it = this->gpiote_channels.begin(); it != this->gpiote_channels.end(); ++it) {
|
||||||
|
if(*it == gpio) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
uint32_t i = 0;
|
||||||
|
for(auto it = this->gpiote_channels.begin(); it != this->gpiote_channels.end(); ++it) {
|
||||||
|
if(*it == nullptr) {
|
||||||
|
*it = gpio;
|
||||||
|
GPIOTE_REGS->INTENSET = GPIOTE_INTENSET_IN0_Msk;
|
||||||
|
GPIOTE_REGS->CONFIG[i] = (GPIOTE_CONFIG_POLARITY_Toggle << GPIOTE_CONFIG_POLARITY_Pos)
|
||||||
|
| ((gpio->pin_number()) << GPIOTE_CONFIG_PSEL_Pos)
|
||||||
|
| (GPIOTE_CONFIG_MODE_Event << GPIOTE_CONFIG_MODE_Pos);
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Gpiote::handle()
|
||||||
|
{
|
||||||
|
for(uint32_t i = 0; i < GPIOTE_CHANNELS; ++i) {
|
||||||
|
if(GPIOTE_REGS->EVENTS_IN[i] != 0) {
|
||||||
|
GPIOTE_REGS->EVENTS_IN[i] = 0;
|
||||||
|
pinetime::interfaces::GpioInterface *h = this->gpiote_channels[i];
|
||||||
|
assert(h != nullptr);
|
||||||
|
h->handle();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
44
src/platform/nrf52/gpiote.h
Normal file
44
src/platform/nrf52/gpiote.h
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
#ifndef __PLATFORM_NRF52_GPIOTE_H__
|
||||||
|
#define __PLATFORM_NRF52_GPIOTE_H__
|
||||||
|
|
||||||
|
#include <array>
|
||||||
|
|
||||||
|
#include "gpio_interface.h"
|
||||||
|
#include "platform/nrf52/InterruptHandler.h"
|
||||||
|
|
||||||
|
namespace pinetime::platform::nrf52
|
||||||
|
{
|
||||||
|
class Gpiote;
|
||||||
|
}
|
||||||
|
extern pinetime::platform::nrf52::Gpiote gpiote;
|
||||||
|
|
||||||
|
namespace pinetime::platform::nrf52
|
||||||
|
{
|
||||||
|
|
||||||
|
class Gpiote
|
||||||
|
: public pinetime::platform::nrf52::InterruptHandler
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Gpiote();
|
||||||
|
|
||||||
|
static inline Gpiote & instance() { return gpiote; }
|
||||||
|
|
||||||
|
void enable() override;
|
||||||
|
void disable() override;
|
||||||
|
|
||||||
|
void register_handler(pinetime::interfaces::GpioInterface *);
|
||||||
|
|
||||||
|
private:
|
||||||
|
void handle() override;
|
||||||
|
|
||||||
|
enum {
|
||||||
|
GPIOTE_CHANNELS = 8,
|
||||||
|
};
|
||||||
|
|
||||||
|
std::array<pinetime::interfaces::GpioInterface *, GPIOTE_CHANNELS> gpiote_channels;
|
||||||
|
uint32_t num_registered;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
66
src/platform/nrf52/low_level_interrupt.cc
Normal file
66
src/platform/nrf52/low_level_interrupt.cc
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
#include <cassert>
|
||||||
|
|
||||||
|
#include "platform/nrf52/InterruptHandler.h"
|
||||||
|
#include "platform/nrf52/InterruptGuardian.h"
|
||||||
|
|
||||||
|
extern "C" {
|
||||||
|
void POWER_CLOCK_IRQHandler(void);
|
||||||
|
void RADIO_IRQHandler(void);
|
||||||
|
void UARTE0_UART0_IRQHandler(void);
|
||||||
|
void SPIM0_SPIS0_TWIM0_TWIS0_SPI0_TWI0_IRQHandler(void);
|
||||||
|
void SPIM1_SPIS1_TWIM1_TWIS1_SPI1_TWI1_IRQHandler(void);
|
||||||
|
void NFCT_IRQHandler(void);
|
||||||
|
void GPIOTE_IRQHandler(void);
|
||||||
|
void SAADC_IRQHandler(void);
|
||||||
|
void TIMER0_IRQHandler(void);
|
||||||
|
void TIMER1_IRQHandler(void);
|
||||||
|
void TIMER2_IRQHandler(void);
|
||||||
|
void RTC0_IRQHandler(void);
|
||||||
|
void TEMP_IRQHandler(void);
|
||||||
|
void RNG_IRQHandler(void);
|
||||||
|
void ECB_IRQHandler(void);
|
||||||
|
void CCM_AAR_IRQHandler(void);
|
||||||
|
void WDT_IRQHandler(void);
|
||||||
|
void RTC1_IRQHandler(void);
|
||||||
|
void QDEC_IRQHandler(void);
|
||||||
|
void COMP_LPCOMP_IRQHandler(void);
|
||||||
|
void SWI0_EGU0_IRQHandler(void);
|
||||||
|
void SWI1_EGU1_IRQHandler(void);
|
||||||
|
void SWI2_EGU2_IRQHandler(void);
|
||||||
|
void SWI3_EGU3_IRQHandler(void);
|
||||||
|
void SWI4_EGU4_IRQHandler(void);
|
||||||
|
void SWI5_EGU5_IRQHandler(void);
|
||||||
|
void TIMER3_IRQHandler(void);
|
||||||
|
void TIMER4_IRQHandler(void);
|
||||||
|
void PWM0_IRQHandler(void);
|
||||||
|
void PDM_IRQHandler(void);
|
||||||
|
void MWU_IRQHandler(void);
|
||||||
|
void PWM1_IRQHandler(void);
|
||||||
|
void PWM2_IRQHandler(void);
|
||||||
|
void SPIM2_SPIS2_SPI2_IRQHandler(void);
|
||||||
|
void RTC2_IRQHandler(void);
|
||||||
|
void I2S_IRQHandler(void);
|
||||||
|
void FPU_IRQHandler(void);
|
||||||
|
}
|
||||||
|
|
||||||
|
using namespace pinetime::platform::nrf52;
|
||||||
|
|
||||||
|
void SPIM0_SPIS0_TWIM0_TWIS0_SPI0_TWI0_IRQHandler(void)
|
||||||
|
{
|
||||||
|
uint32_t irq_nr = InterruptGuardian::Nrf52IrqN::SPIM0_SPIS0_TWIM0_TWIS0_SPI0_TWI0_IRQ;
|
||||||
|
InterruptHandler *h = InterruptGuardian::instance.nrf52_vector[irq_nr];
|
||||||
|
|
||||||
|
assert(h != nullptr);
|
||||||
|
|
||||||
|
h->handle();
|
||||||
|
}
|
||||||
|
|
||||||
|
void GPIOTE_IRQHandler(void)
|
||||||
|
{
|
||||||
|
uint32_t irq_nr = InterruptGuardian::Nrf52IrqN::GPIOTE_IRQ;
|
||||||
|
InterruptHandler *h = InterruptGuardian::instance.nrf52_vector[irq_nr];
|
||||||
|
|
||||||
|
assert(h != nullptr);
|
||||||
|
|
||||||
|
h->handle();
|
||||||
|
}
|
404
src/platform/nrf52/sdk/gcc_startup_nrf52.S
Normal file
404
src/platform/nrf52/sdk/gcc_startup_nrf52.S
Normal file
@@ -0,0 +1,404 @@
|
|||||||
|
/*
|
||||||
|
|
||||||
|
Copyright (c) 2009-2018 ARM Limited. All rights reserved.
|
||||||
|
|
||||||
|
SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the License); you may
|
||||||
|
not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an AS IS BASIS, WITHOUT
|
||||||
|
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
|
||||||
|
NOTICE: This file has been modified by Nordic Semiconductor ASA.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
.syntax unified
|
||||||
|
.arch armv7e-m
|
||||||
|
|
||||||
|
#ifdef __STARTUP_CONFIG
|
||||||
|
#include "startup_config.h"
|
||||||
|
#ifndef __STARTUP_CONFIG_STACK_ALIGNEMENT
|
||||||
|
#define __STARTUP_CONFIG_STACK_ALIGNEMENT 3
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
.section .stack
|
||||||
|
#if defined(__STARTUP_CONFIG)
|
||||||
|
.align __STARTUP_CONFIG_STACK_ALIGNEMENT
|
||||||
|
.equ Stack_Size, __STARTUP_CONFIG_STACK_SIZE
|
||||||
|
#elif defined(__STACK_SIZE)
|
||||||
|
.align 3
|
||||||
|
.equ Stack_Size, __STACK_SIZE
|
||||||
|
#else
|
||||||
|
.align 3
|
||||||
|
.equ Stack_Size, 8192
|
||||||
|
#endif
|
||||||
|
.globl __StackTop
|
||||||
|
.globl __StackLimit
|
||||||
|
__StackLimit:
|
||||||
|
.space Stack_Size
|
||||||
|
.size __StackLimit, . - __StackLimit
|
||||||
|
__StackTop:
|
||||||
|
.size __StackTop, . - __StackTop
|
||||||
|
|
||||||
|
.section .heap
|
||||||
|
.align 3
|
||||||
|
#if defined(__STARTUP_CONFIG)
|
||||||
|
.equ Heap_Size, __STARTUP_CONFIG_HEAP_SIZE
|
||||||
|
#elif defined(__HEAP_SIZE)
|
||||||
|
.equ Heap_Size, __HEAP_SIZE
|
||||||
|
#else
|
||||||
|
.equ Heap_Size, 8192
|
||||||
|
#endif
|
||||||
|
.globl __HeapBase
|
||||||
|
.globl __HeapLimit
|
||||||
|
__HeapBase:
|
||||||
|
.if Heap_Size
|
||||||
|
.space Heap_Size
|
||||||
|
.endif
|
||||||
|
.size __HeapBase, . - __HeapBase
|
||||||
|
__HeapLimit:
|
||||||
|
.size __HeapLimit, . - __HeapLimit
|
||||||
|
|
||||||
|
.section .isr_vector
|
||||||
|
.align 2
|
||||||
|
.globl __isr_vector
|
||||||
|
__isr_vector:
|
||||||
|
.long __StackTop /* Top of Stack */
|
||||||
|
.long Reset_Handler
|
||||||
|
.long NMI_Handler
|
||||||
|
.long HardFault_Handler
|
||||||
|
.long MemoryManagement_Handler
|
||||||
|
.long BusFault_Handler
|
||||||
|
.long UsageFault_Handler
|
||||||
|
.long 0 /*Reserved */
|
||||||
|
.long 0 /*Reserved */
|
||||||
|
.long 0 /*Reserved */
|
||||||
|
.long 0 /*Reserved */
|
||||||
|
.long SVC_Handler
|
||||||
|
.long DebugMon_Handler
|
||||||
|
.long 0 /*Reserved */
|
||||||
|
.long PendSV_Handler
|
||||||
|
.long SysTick_Handler
|
||||||
|
|
||||||
|
/* External Interrupts */
|
||||||
|
.long POWER_CLOCK_IRQHandler
|
||||||
|
.long RADIO_IRQHandler
|
||||||
|
.long UARTE0_UART0_IRQHandler
|
||||||
|
.long SPIM0_SPIS0_TWIM0_TWIS0_SPI0_TWI0_IRQHandler
|
||||||
|
.long SPIM1_SPIS1_TWIM1_TWIS1_SPI1_TWI1_IRQHandler
|
||||||
|
.long NFCT_IRQHandler
|
||||||
|
.long GPIOTE_IRQHandler
|
||||||
|
.long SAADC_IRQHandler
|
||||||
|
.long TIMER0_IRQHandler
|
||||||
|
.long TIMER1_IRQHandler
|
||||||
|
.long TIMER2_IRQHandler
|
||||||
|
.long RTC0_IRQHandler
|
||||||
|
.long TEMP_IRQHandler
|
||||||
|
.long RNG_IRQHandler
|
||||||
|
.long ECB_IRQHandler
|
||||||
|
.long CCM_AAR_IRQHandler
|
||||||
|
.long WDT_IRQHandler
|
||||||
|
.long RTC1_IRQHandler
|
||||||
|
.long QDEC_IRQHandler
|
||||||
|
.long COMP_LPCOMP_IRQHandler
|
||||||
|
.long SWI0_EGU0_IRQHandler
|
||||||
|
.long SWI1_EGU1_IRQHandler
|
||||||
|
.long SWI2_EGU2_IRQHandler
|
||||||
|
.long SWI3_EGU3_IRQHandler
|
||||||
|
.long SWI4_EGU4_IRQHandler
|
||||||
|
.long SWI5_EGU5_IRQHandler
|
||||||
|
.long TIMER3_IRQHandler
|
||||||
|
.long TIMER4_IRQHandler
|
||||||
|
.long PWM0_IRQHandler
|
||||||
|
.long PDM_IRQHandler
|
||||||
|
.long 0 /*Reserved */
|
||||||
|
.long 0 /*Reserved */
|
||||||
|
.long MWU_IRQHandler
|
||||||
|
.long PWM1_IRQHandler
|
||||||
|
.long PWM2_IRQHandler
|
||||||
|
.long SPIM2_SPIS2_SPI2_IRQHandler
|
||||||
|
.long RTC2_IRQHandler
|
||||||
|
.long I2S_IRQHandler
|
||||||
|
.long FPU_IRQHandler
|
||||||
|
.long 0 /*Reserved */
|
||||||
|
.long 0 /*Reserved */
|
||||||
|
.long 0 /*Reserved */
|
||||||
|
.long 0 /*Reserved */
|
||||||
|
.long 0 /*Reserved */
|
||||||
|
.long 0 /*Reserved */
|
||||||
|
.long 0 /*Reserved */
|
||||||
|
.long 0 /*Reserved */
|
||||||
|
.long 0 /*Reserved */
|
||||||
|
.long 0 /*Reserved */
|
||||||
|
.long 0 /*Reserved */
|
||||||
|
.long 0 /*Reserved */
|
||||||
|
.long 0 /*Reserved */
|
||||||
|
.long 0 /*Reserved */
|
||||||
|
.long 0 /*Reserved */
|
||||||
|
.long 0 /*Reserved */
|
||||||
|
.long 0 /*Reserved */
|
||||||
|
.long 0 /*Reserved */
|
||||||
|
.long 0 /*Reserved */
|
||||||
|
.long 0 /*Reserved */
|
||||||
|
.long 0 /*Reserved */
|
||||||
|
.long 0 /*Reserved */
|
||||||
|
.long 0 /*Reserved */
|
||||||
|
.long 0 /*Reserved */
|
||||||
|
.long 0 /*Reserved */
|
||||||
|
.long 0 /*Reserved */
|
||||||
|
.long 0 /*Reserved */
|
||||||
|
.long 0 /*Reserved */
|
||||||
|
.long 0 /*Reserved */
|
||||||
|
.long 0 /*Reserved */
|
||||||
|
.long 0 /*Reserved */
|
||||||
|
.long 0 /*Reserved */
|
||||||
|
.long 0 /*Reserved */
|
||||||
|
.long 0 /*Reserved */
|
||||||
|
.long 0 /*Reserved */
|
||||||
|
.long 0 /*Reserved */
|
||||||
|
.long 0 /*Reserved */
|
||||||
|
.long 0 /*Reserved */
|
||||||
|
.long 0 /*Reserved */
|
||||||
|
.long 0 /*Reserved */
|
||||||
|
.long 0 /*Reserved */
|
||||||
|
.long 0 /*Reserved */
|
||||||
|
.long 0 /*Reserved */
|
||||||
|
.long 0 /*Reserved */
|
||||||
|
.long 0 /*Reserved */
|
||||||
|
.long 0 /*Reserved */
|
||||||
|
.long 0 /*Reserved */
|
||||||
|
.long 0 /*Reserved */
|
||||||
|
.long 0 /*Reserved */
|
||||||
|
.long 0 /*Reserved */
|
||||||
|
.long 0 /*Reserved */
|
||||||
|
.long 0 /*Reserved */
|
||||||
|
.long 0 /*Reserved */
|
||||||
|
.long 0 /*Reserved */
|
||||||
|
.long 0 /*Reserved */
|
||||||
|
.long 0 /*Reserved */
|
||||||
|
.long 0 /*Reserved */
|
||||||
|
.long 0 /*Reserved */
|
||||||
|
.long 0 /*Reserved */
|
||||||
|
.long 0 /*Reserved */
|
||||||
|
.long 0 /*Reserved */
|
||||||
|
.long 0 /*Reserved */
|
||||||
|
.long 0 /*Reserved */
|
||||||
|
.long 0 /*Reserved */
|
||||||
|
.long 0 /*Reserved */
|
||||||
|
.long 0 /*Reserved */
|
||||||
|
.long 0 /*Reserved */
|
||||||
|
.long 0 /*Reserved */
|
||||||
|
.long 0 /*Reserved */
|
||||||
|
.long 0 /*Reserved */
|
||||||
|
.long 0 /*Reserved */
|
||||||
|
.long 0 /*Reserved */
|
||||||
|
.long 0 /*Reserved */
|
||||||
|
|
||||||
|
.size __isr_vector, . - __isr_vector
|
||||||
|
|
||||||
|
/* Reset Handler */
|
||||||
|
|
||||||
|
|
||||||
|
.text
|
||||||
|
.thumb
|
||||||
|
.thumb_func
|
||||||
|
.align 1
|
||||||
|
.globl Reset_Handler
|
||||||
|
.type Reset_Handler, %function
|
||||||
|
Reset_Handler:
|
||||||
|
|
||||||
|
|
||||||
|
/* Loop to copy data from read only memory to RAM.
|
||||||
|
* The ranges of copy from/to are specified by following symbols:
|
||||||
|
* __etext: LMA of start of the section to copy from. Usually end of text
|
||||||
|
* __data_start__: VMA of start of the section to copy to.
|
||||||
|
* __bss_start__: VMA of end of the section to copy to. Normally __data_end__ is used, but by using __bss_start__
|
||||||
|
* the user can add their own initialized data section before BSS section with the INTERT AFTER command.
|
||||||
|
*
|
||||||
|
* All addresses must be aligned to 4 bytes boundary.
|
||||||
|
*/
|
||||||
|
ldr r1, =__etext
|
||||||
|
ldr r2, =__data_start__
|
||||||
|
ldr r3, =__bss_start__
|
||||||
|
|
||||||
|
subs r3, r3, r2
|
||||||
|
ble .L_loop1_done
|
||||||
|
|
||||||
|
.L_loop1:
|
||||||
|
subs r3, r3, #4
|
||||||
|
ldr r0, [r1,r3]
|
||||||
|
str r0, [r2,r3]
|
||||||
|
bgt .L_loop1
|
||||||
|
|
||||||
|
.L_loop1_done:
|
||||||
|
|
||||||
|
/* This part of work usually is done in C library startup code. Otherwise,
|
||||||
|
* define __STARTUP_CLEAR_BSS to enable it in this startup. This section
|
||||||
|
* clears the RAM where BSS data is located.
|
||||||
|
*
|
||||||
|
* The BSS section is specified by following symbols
|
||||||
|
* __bss_start__: start of the BSS section.
|
||||||
|
* __bss_end__: end of the BSS section.
|
||||||
|
*
|
||||||
|
* All addresses must be aligned to 4 bytes boundary.
|
||||||
|
*/
|
||||||
|
#ifdef __STARTUP_CLEAR_BSS
|
||||||
|
ldr r1, =__bss_start__
|
||||||
|
ldr r2, =__bss_end__
|
||||||
|
|
||||||
|
movs r0, 0
|
||||||
|
|
||||||
|
subs r2, r2, r1
|
||||||
|
ble .L_loop3_done
|
||||||
|
|
||||||
|
.L_loop3:
|
||||||
|
subs r2, r2, #4
|
||||||
|
str r0, [r1, r2]
|
||||||
|
bgt .L_loop3
|
||||||
|
|
||||||
|
.L_loop3_done:
|
||||||
|
#endif /* __STARTUP_CLEAR_BSS */
|
||||||
|
|
||||||
|
/* Execute SystemInit function. */
|
||||||
|
bl SystemInit
|
||||||
|
|
||||||
|
/* Call _start function provided by libraries.
|
||||||
|
* If those libraries are not accessible, define __START as your entry point.
|
||||||
|
*/
|
||||||
|
#ifndef __START
|
||||||
|
#define __START _start
|
||||||
|
#endif
|
||||||
|
bl __START
|
||||||
|
|
||||||
|
.pool
|
||||||
|
.size Reset_Handler,.-Reset_Handler
|
||||||
|
|
||||||
|
.section ".text"
|
||||||
|
|
||||||
|
|
||||||
|
/* Dummy Exception Handlers (infinite loops which can be modified) */
|
||||||
|
|
||||||
|
.weak NMI_Handler
|
||||||
|
.type NMI_Handler, %function
|
||||||
|
NMI_Handler:
|
||||||
|
b .
|
||||||
|
.size NMI_Handler, . - NMI_Handler
|
||||||
|
|
||||||
|
|
||||||
|
.weak HardFault_Handler
|
||||||
|
.type HardFault_Handler, %function
|
||||||
|
HardFault_Handler:
|
||||||
|
b .
|
||||||
|
.size HardFault_Handler, . - HardFault_Handler
|
||||||
|
|
||||||
|
|
||||||
|
.weak MemoryManagement_Handler
|
||||||
|
.type MemoryManagement_Handler, %function
|
||||||
|
MemoryManagement_Handler:
|
||||||
|
b .
|
||||||
|
.size MemoryManagement_Handler, . - MemoryManagement_Handler
|
||||||
|
|
||||||
|
|
||||||
|
.weak BusFault_Handler
|
||||||
|
.type BusFault_Handler, %function
|
||||||
|
BusFault_Handler:
|
||||||
|
b .
|
||||||
|
.size BusFault_Handler, . - BusFault_Handler
|
||||||
|
|
||||||
|
|
||||||
|
.weak UsageFault_Handler
|
||||||
|
.type UsageFault_Handler, %function
|
||||||
|
UsageFault_Handler:
|
||||||
|
b .
|
||||||
|
.size UsageFault_Handler, . - UsageFault_Handler
|
||||||
|
|
||||||
|
|
||||||
|
.weak SVC_Handler
|
||||||
|
.type SVC_Handler, %function
|
||||||
|
SVC_Handler:
|
||||||
|
b .
|
||||||
|
.size SVC_Handler, . - SVC_Handler
|
||||||
|
|
||||||
|
|
||||||
|
.weak DebugMon_Handler
|
||||||
|
.type DebugMon_Handler, %function
|
||||||
|
DebugMon_Handler:
|
||||||
|
b .
|
||||||
|
.size DebugMon_Handler, . - DebugMon_Handler
|
||||||
|
|
||||||
|
|
||||||
|
.weak PendSV_Handler
|
||||||
|
.type PendSV_Handler, %function
|
||||||
|
PendSV_Handler:
|
||||||
|
b .
|
||||||
|
.size PendSV_Handler, . - PendSV_Handler
|
||||||
|
|
||||||
|
|
||||||
|
.weak SysTick_Handler
|
||||||
|
.type SysTick_Handler, %function
|
||||||
|
SysTick_Handler:
|
||||||
|
b .
|
||||||
|
.size SysTick_Handler, . - SysTick_Handler
|
||||||
|
|
||||||
|
|
||||||
|
/* IRQ Handlers */
|
||||||
|
|
||||||
|
.globl Default_Handler
|
||||||
|
.type Default_Handler, %function
|
||||||
|
Default_Handler:
|
||||||
|
b .
|
||||||
|
.size Default_Handler, . - Default_Handler
|
||||||
|
|
||||||
|
.macro IRQ handler
|
||||||
|
.weak \handler
|
||||||
|
.set \handler, Default_Handler
|
||||||
|
.endm
|
||||||
|
|
||||||
|
IRQ POWER_CLOCK_IRQHandler
|
||||||
|
IRQ RADIO_IRQHandler
|
||||||
|
IRQ UARTE0_UART0_IRQHandler
|
||||||
|
IRQ SPIM0_SPIS0_TWIM0_TWIS0_SPI0_TWI0_IRQHandler
|
||||||
|
IRQ SPIM1_SPIS1_TWIM1_TWIS1_SPI1_TWI1_IRQHandler
|
||||||
|
IRQ NFCT_IRQHandler
|
||||||
|
IRQ GPIOTE_IRQHandler
|
||||||
|
IRQ SAADC_IRQHandler
|
||||||
|
IRQ TIMER0_IRQHandler
|
||||||
|
IRQ TIMER1_IRQHandler
|
||||||
|
IRQ TIMER2_IRQHandler
|
||||||
|
IRQ RTC0_IRQHandler
|
||||||
|
IRQ TEMP_IRQHandler
|
||||||
|
IRQ RNG_IRQHandler
|
||||||
|
IRQ ECB_IRQHandler
|
||||||
|
IRQ CCM_AAR_IRQHandler
|
||||||
|
IRQ WDT_IRQHandler
|
||||||
|
IRQ RTC1_IRQHandler
|
||||||
|
IRQ QDEC_IRQHandler
|
||||||
|
IRQ COMP_LPCOMP_IRQHandler
|
||||||
|
IRQ SWI0_EGU0_IRQHandler
|
||||||
|
IRQ SWI1_EGU1_IRQHandler
|
||||||
|
IRQ SWI2_EGU2_IRQHandler
|
||||||
|
IRQ SWI3_EGU3_IRQHandler
|
||||||
|
IRQ SWI4_EGU4_IRQHandler
|
||||||
|
IRQ SWI5_EGU5_IRQHandler
|
||||||
|
IRQ TIMER3_IRQHandler
|
||||||
|
IRQ TIMER4_IRQHandler
|
||||||
|
IRQ PWM0_IRQHandler
|
||||||
|
IRQ PDM_IRQHandler
|
||||||
|
IRQ MWU_IRQHandler
|
||||||
|
IRQ PWM1_IRQHandler
|
||||||
|
IRQ PWM2_IRQHandler
|
||||||
|
IRQ SPIM2_SPIS2_SPI2_IRQHandler
|
||||||
|
IRQ RTC2_IRQHandler
|
||||||
|
IRQ I2S_IRQHandler
|
||||||
|
IRQ FPU_IRQHandler
|
||||||
|
|
||||||
|
.end
|
2452
src/platform/nrf52/sdk/nrf52.h
Normal file
2452
src/platform/nrf52/sdk/nrf52.h
Normal file
File diff suppressed because it is too large
Load Diff
12663
src/platform/nrf52/sdk/nrf52_bitfields.h
Normal file
12663
src/platform/nrf52/sdk/nrf52_bitfields.h
Normal file
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
376
src/platform/nrf52/sdk/system_nrf52.c
Normal file
376
src/platform/nrf52/sdk/system_nrf52.c
Normal file
@@ -0,0 +1,376 @@
|
|||||||
|
/*
|
||||||
|
|
||||||
|
Copyright (c) 2009-2018 ARM Limited. All rights reserved.
|
||||||
|
|
||||||
|
SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the License); you may
|
||||||
|
not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an AS IS BASIS, WITHOUT
|
||||||
|
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
|
||||||
|
NOTICE: This file has been modified by Nordic Semiconductor ASA.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* NOTE: Template files (including this one) are application specific and therefore expected to
|
||||||
|
be copied into the application project folder prior to its use! */
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
|
#include "nrf52.h"
|
||||||
|
#include "nrf52_bitfields.h"
|
||||||
|
|
||||||
|
#include "system_nrf52.h"
|
||||||
|
|
||||||
|
/*lint ++flb "Enter library region" */
|
||||||
|
|
||||||
|
#define __SYSTEM_CLOCK_64M (64000000UL)
|
||||||
|
|
||||||
|
static bool errata_12(void);
|
||||||
|
static bool errata_16(void);
|
||||||
|
static bool errata_31(void);
|
||||||
|
static bool errata_32(void);
|
||||||
|
static bool errata_36(void);
|
||||||
|
static bool errata_37(void);
|
||||||
|
static bool errata_57(void);
|
||||||
|
static bool errata_66(void);
|
||||||
|
static bool errata_108(void);
|
||||||
|
static bool errata_136(void);
|
||||||
|
static bool errata_182(void);
|
||||||
|
|
||||||
|
|
||||||
|
#if defined ( __CC_ARM )
|
||||||
|
uint32_t SystemCoreClock __attribute__((used)) = __SYSTEM_CLOCK_64M;
|
||||||
|
#elif defined ( __ICCARM__ )
|
||||||
|
__root uint32_t SystemCoreClock = __SYSTEM_CLOCK_64M;
|
||||||
|
#elif defined ( __GNUC__ )
|
||||||
|
uint32_t SystemCoreClock __attribute__((used)) = __SYSTEM_CLOCK_64M;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void SystemCoreClockUpdate(void)
|
||||||
|
{
|
||||||
|
SystemCoreClock = __SYSTEM_CLOCK_64M;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SystemInit(void)
|
||||||
|
{
|
||||||
|
/* Enable SWO trace functionality. If ENABLE_SWO is not defined, SWO pin will be used as GPIO (see Product
|
||||||
|
Specification to see which one). */
|
||||||
|
#if defined (ENABLE_SWO)
|
||||||
|
CoreDebug->DEMCR |= CoreDebug_DEMCR_TRCENA_Msk;
|
||||||
|
NRF_CLOCK->TRACECONFIG |= CLOCK_TRACECONFIG_TRACEMUX_Serial << CLOCK_TRACECONFIG_TRACEMUX_Pos;
|
||||||
|
NRF_P0->PIN_CNF[18] = (GPIO_PIN_CNF_DRIVE_H0H1 << GPIO_PIN_CNF_DRIVE_Pos) | (GPIO_PIN_CNF_INPUT_Connect << GPIO_PIN_CNF_INPUT_Pos) | (GPIO_PIN_CNF_DIR_Output << GPIO_PIN_CNF_DIR_Pos);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Enable Trace functionality. If ENABLE_TRACE is not defined, TRACE pins will be used as GPIOs (see Product
|
||||||
|
Specification to see which ones). */
|
||||||
|
#if defined (ENABLE_TRACE)
|
||||||
|
CoreDebug->DEMCR |= CoreDebug_DEMCR_TRCENA_Msk;
|
||||||
|
NRF_CLOCK->TRACECONFIG |= CLOCK_TRACECONFIG_TRACEMUX_Parallel << CLOCK_TRACECONFIG_TRACEMUX_Pos;
|
||||||
|
NRF_P0->PIN_CNF[14] = (GPIO_PIN_CNF_DRIVE_H0H1 << GPIO_PIN_CNF_DRIVE_Pos) | (GPIO_PIN_CNF_INPUT_Connect << GPIO_PIN_CNF_INPUT_Pos) | (GPIO_PIN_CNF_DIR_Output << GPIO_PIN_CNF_DIR_Pos);
|
||||||
|
NRF_P0->PIN_CNF[15] = (GPIO_PIN_CNF_DRIVE_H0H1 << GPIO_PIN_CNF_DRIVE_Pos) | (GPIO_PIN_CNF_INPUT_Connect << GPIO_PIN_CNF_INPUT_Pos) | (GPIO_PIN_CNF_DIR_Output << GPIO_PIN_CNF_DIR_Pos);
|
||||||
|
NRF_P0->PIN_CNF[16] = (GPIO_PIN_CNF_DRIVE_H0H1 << GPIO_PIN_CNF_DRIVE_Pos) | (GPIO_PIN_CNF_INPUT_Connect << GPIO_PIN_CNF_INPUT_Pos) | (GPIO_PIN_CNF_DIR_Output << GPIO_PIN_CNF_DIR_Pos);
|
||||||
|
NRF_P0->PIN_CNF[18] = (GPIO_PIN_CNF_DRIVE_H0H1 << GPIO_PIN_CNF_DRIVE_Pos) | (GPIO_PIN_CNF_INPUT_Connect << GPIO_PIN_CNF_INPUT_Pos) | (GPIO_PIN_CNF_DIR_Output << GPIO_PIN_CNF_DIR_Pos);
|
||||||
|
NRF_P0->PIN_CNF[20] = (GPIO_PIN_CNF_DRIVE_H0H1 << GPIO_PIN_CNF_DRIVE_Pos) | (GPIO_PIN_CNF_INPUT_Connect << GPIO_PIN_CNF_INPUT_Pos) | (GPIO_PIN_CNF_DIR_Output << GPIO_PIN_CNF_DIR_Pos);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Workaround for Errata 12 "COMP: Reference ladder not correctly calibrated" found at the Errata document
|
||||||
|
for your device located at https://infocenter.nordicsemi.com/index.jsp */
|
||||||
|
if (errata_12()){
|
||||||
|
*(volatile uint32_t *)0x40013540 = (*(uint32_t *)0x10000324 & 0x00001F00) >> 8;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Workaround for Errata 16 "System: RAM may be corrupt on wakeup from CPU IDLE" found at the Errata document
|
||||||
|
for your device located at https://infocenter.nordicsemi.com/index.jsp */
|
||||||
|
if (errata_16()){
|
||||||
|
*(volatile uint32_t *)0x4007C074 = 3131961357ul;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Workaround for Errata 31 "CLOCK: Calibration values are not correctly loaded from FICR at reset" found at the Errata document
|
||||||
|
for your device located at https://infocenter.nordicsemi.com/index.jsp */
|
||||||
|
if (errata_31()){
|
||||||
|
*(volatile uint32_t *)0x4000053C = ((*(volatile uint32_t *)0x10000244) & 0x0000E000) >> 13;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Workaround for Errata 32 "DIF: Debug session automatically enables TracePort pins" found at the Errata document
|
||||||
|
for your device located at https://infocenter.nordicsemi.com/index.jsp */
|
||||||
|
if (errata_32()){
|
||||||
|
CoreDebug->DEMCR &= ~CoreDebug_DEMCR_TRCENA_Msk;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Workaround for Errata 36 "CLOCK: Some registers are not reset when expected" found at the Errata document
|
||||||
|
for your device located at https://infocenter.nordicsemi.com/index.jsp */
|
||||||
|
if (errata_36()){
|
||||||
|
NRF_CLOCK->EVENTS_DONE = 0;
|
||||||
|
NRF_CLOCK->EVENTS_CTTO = 0;
|
||||||
|
NRF_CLOCK->CTIV = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Workaround for Errata 37 "RADIO: Encryption engine is slow by default" found at the Errata document
|
||||||
|
for your device located at https://infocenter.nordicsemi.com/index.jsp */
|
||||||
|
if (errata_37()){
|
||||||
|
*(volatile uint32_t *)0x400005A0 = 0x3;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Workaround for Errata 57 "NFCT: NFC Modulation amplitude" found at the Errata document
|
||||||
|
for your device located at https://infocenter.nordicsemi.com/index.jsp */
|
||||||
|
if (errata_57()){
|
||||||
|
*(volatile uint32_t *)0x40005610 = 0x00000005;
|
||||||
|
*(volatile uint32_t *)0x40005688 = 0x00000001;
|
||||||
|
*(volatile uint32_t *)0x40005618 = 0x00000000;
|
||||||
|
*(volatile uint32_t *)0x40005614 = 0x0000003F;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Workaround for Errata 66 "TEMP: Linearity specification not met with default settings" found at the Errata document
|
||||||
|
for your device located at https://infocenter.nordicsemi.com/index.jsp */
|
||||||
|
if (errata_66()){
|
||||||
|
NRF_TEMP->A0 = NRF_FICR->TEMP.A0;
|
||||||
|
NRF_TEMP->A1 = NRF_FICR->TEMP.A1;
|
||||||
|
NRF_TEMP->A2 = NRF_FICR->TEMP.A2;
|
||||||
|
NRF_TEMP->A3 = NRF_FICR->TEMP.A3;
|
||||||
|
NRF_TEMP->A4 = NRF_FICR->TEMP.A4;
|
||||||
|
NRF_TEMP->A5 = NRF_FICR->TEMP.A5;
|
||||||
|
NRF_TEMP->B0 = NRF_FICR->TEMP.B0;
|
||||||
|
NRF_TEMP->B1 = NRF_FICR->TEMP.B1;
|
||||||
|
NRF_TEMP->B2 = NRF_FICR->TEMP.B2;
|
||||||
|
NRF_TEMP->B3 = NRF_FICR->TEMP.B3;
|
||||||
|
NRF_TEMP->B4 = NRF_FICR->TEMP.B4;
|
||||||
|
NRF_TEMP->B5 = NRF_FICR->TEMP.B5;
|
||||||
|
NRF_TEMP->T0 = NRF_FICR->TEMP.T0;
|
||||||
|
NRF_TEMP->T1 = NRF_FICR->TEMP.T1;
|
||||||
|
NRF_TEMP->T2 = NRF_FICR->TEMP.T2;
|
||||||
|
NRF_TEMP->T3 = NRF_FICR->TEMP.T3;
|
||||||
|
NRF_TEMP->T4 = NRF_FICR->TEMP.T4;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Workaround for Errata 108 "RAM: RAM content cannot be trusted upon waking up from System ON Idle or System OFF mode" found at the Errata document
|
||||||
|
for your device located at https://infocenter.nordicsemi.com/index.jsp */
|
||||||
|
if (errata_108()){
|
||||||
|
*(volatile uint32_t *)0x40000EE4ul = *(volatile uint32_t *)0x10000258ul & 0x0000004Ful;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Workaround for Errata 136 "System: Bits in RESETREAS are set when they should not be" found at the Errata document
|
||||||
|
for your device located at https://infocenter.nordicsemi.com/index.jsp */
|
||||||
|
if (errata_136()){
|
||||||
|
if (NRF_POWER->RESETREAS & POWER_RESETREAS_RESETPIN_Msk){
|
||||||
|
NRF_POWER->RESETREAS = ~POWER_RESETREAS_RESETPIN_Msk;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Workaround for Errata 182 "RADIO: Fixes for anomalies #102, #106, and #107 do not take effect" found at the Errata document
|
||||||
|
for your device located at https://infocenter.nordicsemi.com/index.jsp */
|
||||||
|
if (errata_182()){
|
||||||
|
*(volatile uint32_t *) 0x4000173C |= (0x1 << 10);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Enable the FPU if the compiler used floating point unit instructions. __FPU_USED is a MACRO defined by the
|
||||||
|
* compiler. Since the FPU consumes energy, remember to disable FPU use in the compiler if floating point unit
|
||||||
|
* operations are not used in your code. */
|
||||||
|
#if (__FPU_USED == 1)
|
||||||
|
SCB->CPACR |= (3UL << 20) | (3UL << 22);
|
||||||
|
__DSB();
|
||||||
|
__ISB();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Configure NFCT pins as GPIOs if NFCT is not to be used in your code. If CONFIG_NFCT_PINS_AS_GPIOS is not defined,
|
||||||
|
two GPIOs (see Product Specification to see which ones) will be reserved for NFC and will not be available as
|
||||||
|
normal GPIOs. */
|
||||||
|
#if defined (CONFIG_NFCT_PINS_AS_GPIOS)
|
||||||
|
if ((NRF_UICR->NFCPINS & UICR_NFCPINS_PROTECT_Msk) == (UICR_NFCPINS_PROTECT_NFC << UICR_NFCPINS_PROTECT_Pos)){
|
||||||
|
NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Wen << NVMC_CONFIG_WEN_Pos;
|
||||||
|
while (NRF_NVMC->READY == NVMC_READY_READY_Busy){}
|
||||||
|
NRF_UICR->NFCPINS &= ~UICR_NFCPINS_PROTECT_Msk;
|
||||||
|
while (NRF_NVMC->READY == NVMC_READY_READY_Busy){}
|
||||||
|
NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Ren << NVMC_CONFIG_WEN_Pos;
|
||||||
|
while (NRF_NVMC->READY == NVMC_READY_READY_Busy){}
|
||||||
|
NVIC_SystemReset();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Configure GPIO pads as pPin Reset pin if Pin Reset capabilities desired. If CONFIG_GPIO_AS_PINRESET is not
|
||||||
|
defined, pin reset will not be available. One GPIO (see Product Specification to see which one) will then be
|
||||||
|
reserved for PinReset and not available as normal GPIO. */
|
||||||
|
#if defined (CONFIG_GPIO_AS_PINRESET)
|
||||||
|
if (((NRF_UICR->PSELRESET[0] & UICR_PSELRESET_CONNECT_Msk) != (UICR_PSELRESET_CONNECT_Connected << UICR_PSELRESET_CONNECT_Pos)) ||
|
||||||
|
((NRF_UICR->PSELRESET[1] & UICR_PSELRESET_CONNECT_Msk) != (UICR_PSELRESET_CONNECT_Connected << UICR_PSELRESET_CONNECT_Pos))){
|
||||||
|
NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Wen << NVMC_CONFIG_WEN_Pos;
|
||||||
|
while (NRF_NVMC->READY == NVMC_READY_READY_Busy){}
|
||||||
|
NRF_UICR->PSELRESET[0] = 21;
|
||||||
|
while (NRF_NVMC->READY == NVMC_READY_READY_Busy){}
|
||||||
|
NRF_UICR->PSELRESET[1] = 21;
|
||||||
|
while (NRF_NVMC->READY == NVMC_READY_READY_Busy){}
|
||||||
|
NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Ren << NVMC_CONFIG_WEN_Pos;
|
||||||
|
while (NRF_NVMC->READY == NVMC_READY_READY_Busy){}
|
||||||
|
NVIC_SystemReset();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
SystemCoreClockUpdate();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static bool errata_12(void)
|
||||||
|
{
|
||||||
|
if ((((*(uint32_t *)0xF0000FE0) & 0x000000FF) == 0x6) && (((*(uint32_t *)0xF0000FE4) & 0x0000000F) == 0x0)){
|
||||||
|
if (((*(uint32_t *)0xF0000FE8) & 0x000000F0) == 0x30){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (((*(uint32_t *)0xF0000FE8) & 0x000000F0) == 0x40){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (((*(uint32_t *)0xF0000FE8) & 0x000000F0) == 0x50){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool errata_16(void)
|
||||||
|
{
|
||||||
|
if ((((*(uint32_t *)0xF0000FE0) & 0x000000FF) == 0x6) && (((*(uint32_t *)0xF0000FE4) & 0x0000000F) == 0x0)){
|
||||||
|
if (((*(uint32_t *)0xF0000FE8) & 0x000000F0) == 0x30){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool errata_31(void)
|
||||||
|
{
|
||||||
|
if ((((*(uint32_t *)0xF0000FE0) & 0x000000FF) == 0x6) && (((*(uint32_t *)0xF0000FE4) & 0x0000000F) == 0x0)){
|
||||||
|
if (((*(uint32_t *)0xF0000FE8) & 0x000000F0) == 0x30){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (((*(uint32_t *)0xF0000FE8) & 0x000000F0) == 0x40){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (((*(uint32_t *)0xF0000FE8) & 0x000000F0) == 0x50){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool errata_32(void)
|
||||||
|
{
|
||||||
|
if ((((*(uint32_t *)0xF0000FE0) & 0x000000FF) == 0x6) && (((*(uint32_t *)0xF0000FE4) & 0x0000000F) == 0x0)){
|
||||||
|
if (((*(uint32_t *)0xF0000FE8) & 0x000000F0) == 0x30){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool errata_36(void)
|
||||||
|
{
|
||||||
|
if ((((*(uint32_t *)0xF0000FE0) & 0x000000FF) == 0x6) && (((*(uint32_t *)0xF0000FE4) & 0x0000000F) == 0x0)){
|
||||||
|
if (((*(uint32_t *)0xF0000FE8) & 0x000000F0) == 0x30){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (((*(uint32_t *)0xF0000FE8) & 0x000000F0) == 0x40){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (((*(uint32_t *)0xF0000FE8) & 0x000000F0) == 0x50){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool errata_37(void)
|
||||||
|
{
|
||||||
|
if ((((*(uint32_t *)0xF0000FE0) & 0x000000FF) == 0x6) && (((*(uint32_t *)0xF0000FE4) & 0x0000000F) == 0x0)){
|
||||||
|
if (((*(uint32_t *)0xF0000FE8) & 0x000000F0) == 0x30){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool errata_57(void)
|
||||||
|
{
|
||||||
|
if ((((*(uint32_t *)0xF0000FE0) & 0x000000FF) == 0x6) && (((*(uint32_t *)0xF0000FE4) & 0x0000000F) == 0x0)){
|
||||||
|
if (((*(uint32_t *)0xF0000FE8) & 0x000000F0) == 0x30){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool errata_66(void)
|
||||||
|
{
|
||||||
|
if ((((*(uint32_t *)0xF0000FE0) & 0x000000FF) == 0x6) && (((*(uint32_t *)0xF0000FE4) & 0x0000000F) == 0x0)){
|
||||||
|
if (((*(uint32_t *)0xF0000FE8) & 0x000000F0) == 0x50){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static bool errata_108(void)
|
||||||
|
{
|
||||||
|
if ((((*(uint32_t *)0xF0000FE0) & 0x000000FF) == 0x6) && (((*(uint32_t *)0xF0000FE4) & 0x0000000F) == 0x0)){
|
||||||
|
if (((*(uint32_t *)0xF0000FE8) & 0x000000F0) == 0x30){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (((*(uint32_t *)0xF0000FE8) & 0x000000F0) == 0x40){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (((*(uint32_t *)0xF0000FE8) & 0x000000F0) == 0x50){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static bool errata_136(void)
|
||||||
|
{
|
||||||
|
if ((((*(uint32_t *)0xF0000FE0) & 0x000000FF) == 0x6) && (((*(uint32_t *)0xF0000FE4) & 0x0000000F) == 0x0)){
|
||||||
|
if (((*(uint32_t *)0xF0000FE8) & 0x000000F0) == 0x30){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (((*(uint32_t *)0xF0000FE8) & 0x000000F0) == 0x40){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (((*(uint32_t *)0xF0000FE8) & 0x000000F0) == 0x50){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static bool errata_182(void)
|
||||||
|
{
|
||||||
|
if (*(uint32_t *)0x10000130ul == 0x6ul){
|
||||||
|
if (*(uint32_t *)0x10000134ul == 0x6ul){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*lint --flb "Leave library region" */
|
61
src/platform/nrf52/sdk/system_nrf52.h
Normal file
61
src/platform/nrf52/sdk/system_nrf52.h
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
/*
|
||||||
|
|
||||||
|
Copyright (c) 2009-2018 ARM Limited. All rights reserved.
|
||||||
|
|
||||||
|
SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the License); you may
|
||||||
|
not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an AS IS BASIS, WITHOUT
|
||||||
|
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
|
||||||
|
NOTICE: This file has been modified by Nordic Semiconductor ASA.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef SYSTEM_NRF52_H
|
||||||
|
#define SYSTEM_NRF52_H
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
|
||||||
|
extern uint32_t SystemCoreClock; /*!< System Clock Frequency (Core Clock) */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize the system
|
||||||
|
*
|
||||||
|
* @param none
|
||||||
|
* @return none
|
||||||
|
*
|
||||||
|
* @brief Setup the microcontroller system.
|
||||||
|
* Initialize the System and update the SystemCoreClock variable.
|
||||||
|
*/
|
||||||
|
extern void SystemInit (void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update SystemCoreClock variable
|
||||||
|
*
|
||||||
|
* @param none
|
||||||
|
* @return none
|
||||||
|
*
|
||||||
|
* @brief Updates the SystemCoreClock with current core Clock
|
||||||
|
* retrieved from cpu registers.
|
||||||
|
*/
|
||||||
|
extern void SystemCoreClockUpdate (void);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* SYSTEM_NRF_H */
|
130
src/platform/nrf52/spi.cc
Normal file
130
src/platform/nrf52/spi.cc
Normal file
@@ -0,0 +1,130 @@
|
|||||||
|
#include <assert.h>
|
||||||
|
|
||||||
|
#include "platform/nrf52/InterruptHandler.h"
|
||||||
|
#include "platform/nrf52/InterruptGuardian.h"
|
||||||
|
|
||||||
|
#include "platform/nrf52/spi.h"
|
||||||
|
|
||||||
|
extern "C" {
|
||||||
|
#include "nrf52.h"
|
||||||
|
#include "nrf52_bitfields.h"
|
||||||
|
|
||||||
|
NRF_GPIO_Type *const GPIO_REGS = reinterpret_cast<NRF_GPIO_Type *>(NRF_P0_BASE);
|
||||||
|
NRF_SPIM_Type *SPIM_REGS = reinterpret_cast<NRF_SPIM_Type *>(NRF_SPIM0_BASE);
|
||||||
|
}
|
||||||
|
|
||||||
|
using namespace pinetime::platform::nrf52;
|
||||||
|
|
||||||
|
Spi::Spi(uint32_t instance, uint32_t sck, uint32_t mosi, uint32_t miso, pinetime::interfaces::GpioInterface & cs)
|
||||||
|
: InterruptHandler(InterruptGuardian::Nrf52IrqN::SPIM0_SPIS0_TWIM0_TWIS0_SPI0_TWI0_IRQ)
|
||||||
|
, chip_select(cs)
|
||||||
|
, xfer_active(false)
|
||||||
|
{
|
||||||
|
assert(instance < 3);
|
||||||
|
|
||||||
|
// sck pin
|
||||||
|
GPIO_REGS->OUTCLR = 1UL << sck;
|
||||||
|
GPIO_REGS->PIN_CNF[mosi] = GPIO_PIN_CNF_DIR_Output << GPIO_PIN_CNF_DIR_Pos
|
||||||
|
| GPIO_PIN_CNF_INPUT_Connect << GPIO_PIN_CNF_INPUT_Pos
|
||||||
|
| GPIO_PIN_CNF_PULL_Disabled << GPIO_PIN_CNF_PULL_Pos
|
||||||
|
| GPIO_PIN_CNF_DRIVE_S0S1 << GPIO_PIN_CNF_DRIVE_Pos
|
||||||
|
| GPIO_PIN_CNF_SENSE_Disabled << GPIO_PIN_CNF_SENSE_Pos;
|
||||||
|
// mosi pin
|
||||||
|
GPIO_REGS->OUTCLR = 1UL << mosi;
|
||||||
|
GPIO_REGS->PIN_CNF[mosi] = GPIO_PIN_CNF_DIR_Output << GPIO_PIN_CNF_DIR_Pos
|
||||||
|
| GPIO_PIN_CNF_INPUT_Disconnect << GPIO_PIN_CNF_INPUT_Pos
|
||||||
|
| GPIO_PIN_CNF_PULL_Disabled << GPIO_PIN_CNF_PULL_Pos
|
||||||
|
| GPIO_PIN_CNF_DRIVE_S0S1 << GPIO_PIN_CNF_DRIVE_Pos
|
||||||
|
| GPIO_PIN_CNF_SENSE_Disabled << GPIO_PIN_CNF_SENSE_Pos;
|
||||||
|
// miso pin
|
||||||
|
GPIO_REGS->PIN_CNF[miso] = GPIO_PIN_CNF_DIR_Input << GPIO_PIN_CNF_DIR_Pos
|
||||||
|
| GPIO_PIN_CNF_INPUT_Connect << GPIO_PIN_CNF_INPUT_Pos
|
||||||
|
| GPIO_PIN_CNF_PULL_Pulldown << GPIO_PIN_CNF_PULL_Pos
|
||||||
|
| GPIO_PIN_CNF_DRIVE_S0S1 << GPIO_PIN_CNF_DRIVE_Pos
|
||||||
|
| GPIO_PIN_CNF_SENSE_Disabled << GPIO_PIN_CNF_SENSE_Pos;
|
||||||
|
// ss already configured by gpio driver
|
||||||
|
|
||||||
|
IRQn_Type irq = SPIM0_SPIS0_TWIM0_TWIS0_SPI0_TWI0_IRQn;
|
||||||
|
if(instance == 2) {
|
||||||
|
SPIM_REGS = reinterpret_cast<NRF_SPIM_Type *>(NRF_SPIM2_BASE);
|
||||||
|
irq = SPIM2_SPIS2_SPI2_IRQn;
|
||||||
|
} else if(instance == 1) {
|
||||||
|
SPIM_REGS = reinterpret_cast<NRF_SPIM_Type *>(NRF_SPIM1_BASE);
|
||||||
|
irq = SPIM1_SPIS1_TWIM1_TWIS1_SPI1_TWI1_IRQn;
|
||||||
|
} else {
|
||||||
|
SPIM_REGS = reinterpret_cast<NRF_SPIM_Type *>(NRF_SPIM0_BASE);
|
||||||
|
irq = SPIM0_SPIS0_TWIM0_TWIS0_SPI0_TWI0_IRQn;
|
||||||
|
}
|
||||||
|
|
||||||
|
this->chip_select.set();
|
||||||
|
|
||||||
|
SPIM_REGS->ENABLE = 0;
|
||||||
|
SPIM_REGS->PSEL.SCK = sck;
|
||||||
|
SPIM_REGS->PSEL.MOSI = mosi;
|
||||||
|
SPIM_REGS->PSEL.MISO = miso;
|
||||||
|
SPIM_REGS->FREQUENCY = SPI_FREQUENCY_FREQUENCY_M8;
|
||||||
|
|
||||||
|
SPIM_REGS->CONFIG = (0x03 << 1); //Sample on trailing edge of clock, shift serial data on leading edge, SCK polarity Active low
|
||||||
|
SPIM_REGS->EVENTS_ENDRX = 0;
|
||||||
|
SPIM_REGS->EVENTS_ENDTX = 0;
|
||||||
|
SPIM_REGS->EVENTS_END = 0;
|
||||||
|
|
||||||
|
SPIM_REGS->INTENSET = (1 << 1) // Stopped
|
||||||
|
| (1 << 6) // End
|
||||||
|
| (1 << 19); // Started
|
||||||
|
|
||||||
|
SPIM_REGS->ENABLE = (SPIM_ENABLE_ENABLE_Enabled << SPIM_ENABLE_ENABLE_Pos);
|
||||||
|
|
||||||
|
NVIC_SetPriority(irq, 2);
|
||||||
|
NVIC_EnableIRQ(irq);
|
||||||
|
}
|
||||||
|
|
||||||
|
Spi::~Spi()
|
||||||
|
{
|
||||||
|
SPIM_REGS->ENABLE = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Spi::send(const uint8_t * buffer, uint32_t len)
|
||||||
|
{
|
||||||
|
this->chip_select.clear();
|
||||||
|
this->xfer_active = true;
|
||||||
|
|
||||||
|
SPIM_REGS->TXD.PTR = reinterpret_cast<uint32_t>(buffer);
|
||||||
|
SPIM_REGS->TXD.MAXCNT = len;
|
||||||
|
SPIM_REGS->TXD.LIST = 0;
|
||||||
|
|
||||||
|
SPIM_REGS->RXD.PTR = 0;
|
||||||
|
SPIM_REGS->RXD.MAXCNT = 0;
|
||||||
|
SPIM_REGS->RXD.LIST = 0;
|
||||||
|
|
||||||
|
SPIM_REGS->EVENTS_END = 0;
|
||||||
|
|
||||||
|
SPIM_REGS->TASKS_START = 1;
|
||||||
|
|
||||||
|
// FIXME: LOW POWER???
|
||||||
|
while(this->xfer_active);
|
||||||
|
|
||||||
|
this->chip_select.set();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Spi::recv(uint8_t * buffer, uint32_t len)
|
||||||
|
{
|
||||||
|
// FIXME: not implemented yet
|
||||||
|
}
|
||||||
|
|
||||||
|
void Spi::handle()
|
||||||
|
{
|
||||||
|
if((SPIM_REGS->INTENSET & (1 << 6)) && (SPIM_REGS->EVENTS_END == 1)) {
|
||||||
|
SPIM_REGS->EVENTS_END = 0;
|
||||||
|
this->xfer_active = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if((SPIM_REGS->INTENSET & (1 << 19)) && (SPIM_REGS->EVENTS_STARTED == 1)) {
|
||||||
|
SPIM_REGS->EVENTS_STARTED = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if((SPIM_REGS->INTENSET & (1 << 1)) && (SPIM_REGS->EVENTS_STOPPED == 1)) {
|
||||||
|
SPIM_REGS->EVENTS_STOPPED = 0;
|
||||||
|
this->xfer_active = false;
|
||||||
|
}
|
||||||
|
}
|
32
src/platform/nrf52/spi.h
Normal file
32
src/platform/nrf52/spi.h
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
#ifndef __PLATFORM_NRF52_SPI_H__
|
||||||
|
#define __PLATFORM_NRF52_SPI_H__
|
||||||
|
|
||||||
|
#include "gpio_interface.h"
|
||||||
|
#include "spi_interface.h"
|
||||||
|
|
||||||
|
#include "platform/nrf52/InterruptHandler.h"
|
||||||
|
|
||||||
|
namespace pinetime::platform::nrf52 {
|
||||||
|
|
||||||
|
class Spi
|
||||||
|
: public pinetime::platform::nrf52::InterruptHandler
|
||||||
|
, public pinetime::interfaces::SpiInterface
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Spi(uint32_t instance, uint32_t sck, uint32_t mosi, uint32_t miso, pinetime::interfaces::GpioInterface & cs);
|
||||||
|
~Spi();
|
||||||
|
void send(const uint8_t * buffer, uint32_t len) override;
|
||||||
|
void recv(uint8_t * buffer, uint32_t len) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
uint32_t transfer(uint32_t);
|
||||||
|
|
||||||
|
void handle() override;
|
||||||
|
|
||||||
|
pinetime::interfaces::GpioInterface & chip_select;
|
||||||
|
volatile bool xfer_active;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
154
src/st7789.cc
Normal file
154
src/st7789.cc
Normal file
@@ -0,0 +1,154 @@
|
|||||||
|
#include <array>
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
|
#include "st7789.h"
|
||||||
|
|
||||||
|
St7789::St7789(pinetime::interfaces::SpiInterface & spi_if,
|
||||||
|
pinetime::interfaces::GpioInterface & rst,
|
||||||
|
pinetime::interfaces::GpioInterface & dc,
|
||||||
|
pinetime::interfaces::GpioInterface & bl)
|
||||||
|
: spi(spi_if)
|
||||||
|
, reset(rst)
|
||||||
|
, data_command(dc)
|
||||||
|
, backlight(bl)
|
||||||
|
{
|
||||||
|
this->reset.set();
|
||||||
|
this->data_command.set();
|
||||||
|
this->backlight.set();
|
||||||
|
|
||||||
|
// hard reset
|
||||||
|
this->reset.clear();
|
||||||
|
// FIXME: add proper delay
|
||||||
|
// delay_ms(100);
|
||||||
|
for(volatile uint32_t cnt = 0; cnt < 100; ++cnt);
|
||||||
|
this->reset.set();
|
||||||
|
// FIXME: add proper delay
|
||||||
|
// delay_ms(100);
|
||||||
|
for(volatile uint32_t cnt = 0; cnt < 100; ++cnt);
|
||||||
|
}
|
||||||
|
|
||||||
|
void St7789::init()
|
||||||
|
{
|
||||||
|
send_cmd(0x36);
|
||||||
|
send_data(0x00);
|
||||||
|
|
||||||
|
send_cmd(0x3A);
|
||||||
|
send_data(0x05);
|
||||||
|
|
||||||
|
send_cmd(0xB2);
|
||||||
|
send_data(0x0C);
|
||||||
|
send_data(0x0C);
|
||||||
|
send_data(0x00);
|
||||||
|
send_data(0x33);
|
||||||
|
send_data(0x33);
|
||||||
|
|
||||||
|
send_cmd(0xB7); //Gate Control
|
||||||
|
send_data(0x35);
|
||||||
|
|
||||||
|
send_cmd(0xBB); //VCOM Setting
|
||||||
|
send_data(0x19);
|
||||||
|
|
||||||
|
send_cmd(0xC0); //LCM Control
|
||||||
|
send_data(0x2C);
|
||||||
|
|
||||||
|
send_cmd(0xC2); //VDV and VRH Command Enable
|
||||||
|
send_data(0x01);
|
||||||
|
send_cmd(0xC3); //VRH Set
|
||||||
|
send_data(0x12);
|
||||||
|
send_cmd(0xC4); //VDV Set
|
||||||
|
send_data(0x20);
|
||||||
|
|
||||||
|
send_cmd(0xC6); //Frame Rate Control in Normal Mode
|
||||||
|
send_data(0x0F);
|
||||||
|
|
||||||
|
send_cmd(0xD0); // Power Control 1
|
||||||
|
send_data(0xA4);
|
||||||
|
send_data(0xA1);
|
||||||
|
|
||||||
|
send_cmd(0xE0); //Positive Voltage Gamma Control
|
||||||
|
send_data(0xD0);
|
||||||
|
send_data(0x04);
|
||||||
|
send_data(0x0D);
|
||||||
|
send_data(0x11);
|
||||||
|
send_data(0x13);
|
||||||
|
send_data(0x2B);
|
||||||
|
send_data(0x3F);
|
||||||
|
send_data(0x54);
|
||||||
|
send_data(0x4C);
|
||||||
|
send_data(0x18);
|
||||||
|
send_data(0x0D);
|
||||||
|
send_data(0x0B);
|
||||||
|
send_data(0x1F);
|
||||||
|
send_data(0x23);
|
||||||
|
|
||||||
|
send_cmd(0xE1); //Negative Voltage Gamma Control
|
||||||
|
send_data(0xD0);
|
||||||
|
send_data(0x04);
|
||||||
|
send_data(0x0C);
|
||||||
|
send_data(0x11);
|
||||||
|
send_data(0x13);
|
||||||
|
send_data(0x2C);
|
||||||
|
send_data(0x3F);
|
||||||
|
send_data(0x44);
|
||||||
|
send_data(0x51);
|
||||||
|
send_data(0x2F);
|
||||||
|
send_data(0x1F);
|
||||||
|
send_data(0x1F);
|
||||||
|
send_data(0x20);
|
||||||
|
send_data(0x23);
|
||||||
|
|
||||||
|
send_cmd(0x21); //Display Inversion On
|
||||||
|
send_cmd(0x11); //Sleep Out
|
||||||
|
send_cmd(0x29); //Display On
|
||||||
|
}
|
||||||
|
|
||||||
|
void St7789::send_cmd(uint8_t cmd)
|
||||||
|
{
|
||||||
|
this->data_command.clear();
|
||||||
|
this->spi.send(&cmd, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void St7789::send_data(uint8_t data)
|
||||||
|
{
|
||||||
|
this->data_command.set();
|
||||||
|
this->spi.send(&data, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void St7789::clear(uint16_t Color)
|
||||||
|
{
|
||||||
|
unsigned int odd = 0;
|
||||||
|
std::array<uint8_t, 240> line;
|
||||||
|
for(auto it = line.begin(); it != line.end(); ++it) {
|
||||||
|
if(odd % 2 == 0) {
|
||||||
|
*it = static_cast<uint8_t>((Color >> 8) & 0xff);
|
||||||
|
} else {
|
||||||
|
*it = static_cast<uint8_t>(Color & 0xff);
|
||||||
|
}
|
||||||
|
odd++;
|
||||||
|
}
|
||||||
|
|
||||||
|
set_windows(0, 0, 240, 240);
|
||||||
|
this->data_command.set();
|
||||||
|
for(unsigned int i = 0; i < 240 * 2; i++) {
|
||||||
|
this->spi.send(line.data(), line.size());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void St7789::set_windows(uint16_t x_start, uint16_t y_start, uint16_t x_end, uint16_t y_end)
|
||||||
|
{
|
||||||
|
//set the X coordinates
|
||||||
|
send_cmd(0x2A);
|
||||||
|
send_data((x_start >> 8) & 0xFF);
|
||||||
|
send_data(x_start & 0xFF);
|
||||||
|
send_data(((x_end - 1) >> 8) & 0xFF);
|
||||||
|
send_data((x_end - 1) & 0xFF);
|
||||||
|
|
||||||
|
//set the Y coordinates
|
||||||
|
send_cmd(0x2B);
|
||||||
|
send_data((y_start >> 8) & 0xFF);
|
||||||
|
send_data(y_start & 0xFF);
|
||||||
|
send_data(((y_end - 1) >> 8) & 0xFF);
|
||||||
|
send_data((y_end - 1) & 0xFF);
|
||||||
|
|
||||||
|
send_cmd(0X2C);
|
||||||
|
}
|
30
src/st7789.h
Normal file
30
src/st7789.h
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
#ifndef __ST7789_H__
|
||||||
|
#define __ST7789_H__
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
#include "gpio_interface.h"
|
||||||
|
#include "spi_interface.h"
|
||||||
|
|
||||||
|
class St7789
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
St7789(pinetime::interfaces::SpiInterface &,
|
||||||
|
pinetime::interfaces::GpioInterface &,
|
||||||
|
pinetime::interfaces::GpioInterface &,
|
||||||
|
pinetime::interfaces::GpioInterface &);
|
||||||
|
|
||||||
|
void init();
|
||||||
|
void clear(uint16_t Color);
|
||||||
|
|
||||||
|
private:
|
||||||
|
pinetime::interfaces::SpiInterface & spi;
|
||||||
|
pinetime::interfaces::GpioInterface & reset;
|
||||||
|
pinetime::interfaces::GpioInterface & data_command;
|
||||||
|
pinetime::interfaces::GpioInterface & backlight;
|
||||||
|
|
||||||
|
void send_cmd(uint8_t);
|
||||||
|
void send_data(uint8_t);
|
||||||
|
void set_windows(uint16_t x_start, uint16_t y_start, uint16_t x_end, uint16_t y_end);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
38
src/virtual_timer/VirtualTimer.cc
Normal file
38
src/virtual_timer/VirtualTimer.cc
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
#include "virtual_timer/VirtualTimerDistributor.h"
|
||||||
|
#include "virtual_timer/VirtualTimer.h"
|
||||||
|
|
||||||
|
using namespace pinetime::virtual_timer;
|
||||||
|
|
||||||
|
VirtualTimer::VirtualTimer(uint64_t period_ms)
|
||||||
|
: period(period_ms)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void VirtualTimer::timer_enable()
|
||||||
|
{
|
||||||
|
VirtualTimerDistributor & distri = VirtualTimerDistributor::instance();
|
||||||
|
this->start_time = distri.tick();
|
||||||
|
distri.register_timer(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
void VirtualTimer::timer_disable()
|
||||||
|
{
|
||||||
|
VirtualTimerDistributor::instance().unregister_timer(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
void VirtualTimer::timer_notification(uint64_t tick_ms)
|
||||||
|
{
|
||||||
|
if((tick_ms - this->start_time) >= (this->period)) {
|
||||||
|
this->notification();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void VirtualTimer::timer_set_period_ms(uint64_t period_ms)
|
||||||
|
{
|
||||||
|
this->period = period_ms;
|
||||||
|
}
|
||||||
|
|
||||||
|
// void VirtualTimer::notify()
|
||||||
|
// {
|
||||||
|
// asm volatile("nop");
|
||||||
|
// }
|
30
src/virtual_timer/VirtualTimer.h
Normal file
30
src/virtual_timer/VirtualTimer.h
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
#ifndef __VIRTUAL_TIMER_VIRTUALTIMER_H__
|
||||||
|
#define __VIRTUAL_TIMER_VIRTUALTIMER_H__
|
||||||
|
|
||||||
|
#include "VirtualTimerInterface.h"
|
||||||
|
|
||||||
|
namespace pinetime::virtual_timer
|
||||||
|
{
|
||||||
|
|
||||||
|
class VirtualTimer
|
||||||
|
: public pinetime::interfaces::VirtualTimerInterface
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
VirtualTimer(uint64_t);
|
||||||
|
|
||||||
|
void timer_enable() override;
|
||||||
|
void timer_disable() override;
|
||||||
|
void timer_notification(uint64_t) override;
|
||||||
|
|
||||||
|
void timer_set_period_ms(uint64_t);
|
||||||
|
|
||||||
|
virtual void notification() = 0;
|
||||||
|
|
||||||
|
private:
|
||||||
|
uint64_t period;
|
||||||
|
uint64_t start_time;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
80
src/virtual_timer/VirtualTimerDistributor.cc
Normal file
80
src/virtual_timer/VirtualTimerDistributor.cc
Normal file
@@ -0,0 +1,80 @@
|
|||||||
|
#include "virtual_timer/VirtualTimer.h"
|
||||||
|
#include "virtual_timer/VirtualTimerDistributor.h"
|
||||||
|
|
||||||
|
using namespace pinetime::virtual_timer;
|
||||||
|
using namespace pinetime::interfaces;
|
||||||
|
|
||||||
|
VirtualTimerDistributor::VirtualTimerDistributor(pinetime::interfaces::HwTimerInterface & timer)
|
||||||
|
: hw_timer(timer)
|
||||||
|
, num_registered_timers(0)
|
||||||
|
{
|
||||||
|
for(auto it = this->virtual_timer_list.begin(); it != this->virtual_timer_list.end(); ++it) {
|
||||||
|
*it = nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void VirtualTimerDistributor::register_timer(VirtualTimerInterface *timer)
|
||||||
|
{
|
||||||
|
volatile bool enable = false;
|
||||||
|
if(num_registered_timers == MAX_TIMERS) {
|
||||||
|
// FIXME: Error notification
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(num_registered_timers == 0) {
|
||||||
|
// Timer list is empty - so - hw timer isn't running
|
||||||
|
enable = true;
|
||||||
|
} else {
|
||||||
|
// Check if timer already registered
|
||||||
|
for(auto it = this->virtual_timer_list.begin(); it != this->virtual_timer_list.end(); ++it) {
|
||||||
|
if(*it == timer) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for(auto it = this->virtual_timer_list.begin(); it != this->virtual_timer_list.end(); ++it) {
|
||||||
|
if(*it == nullptr) {
|
||||||
|
// FIXME: We might need an interrupt lock here?
|
||||||
|
*it = timer;
|
||||||
|
num_registered_timers++;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(enable) {
|
||||||
|
hw_timer.enable_timer();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void VirtualTimerDistributor::unregister_timer(VirtualTimerInterface *timer)
|
||||||
|
{
|
||||||
|
if(num_registered_timers == 0) {
|
||||||
|
// FIXME: Error notification
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
for(auto it = this->virtual_timer_list.begin(); it != this->virtual_timer_list.end(); ++it) {
|
||||||
|
if(*it == timer) {
|
||||||
|
// FIXME: We might need an interrupt lock here?
|
||||||
|
*it = nullptr;
|
||||||
|
num_registered_timers--;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(num_registered_timers == 0) {
|
||||||
|
hw_timer.disable_timer();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void VirtualTimerDistributor::notify(uint64_t time_ms)
|
||||||
|
{
|
||||||
|
// FIXME: We're still in interrupt context of hw timer interrupt.
|
||||||
|
for(auto it = this->virtual_timer_list.begin(); it != this->virtual_timer_list.end(); ++it) {
|
||||||
|
if(*it != nullptr) {
|
||||||
|
VirtualTimerInterface *vt = *it;
|
||||||
|
vt->timer_notification(time_ms);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
uint64_t VirtualTimerDistributor::tick()
|
||||||
|
{
|
||||||
|
return hw_timer.tick();
|
||||||
|
}
|
41
src/virtual_timer/VirtualTimerDistributor.h
Normal file
41
src/virtual_timer/VirtualTimerDistributor.h
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
#ifndef __VIRTUAL_TIMER_VIRTUALTIMERDISTRIBUTOR_H__
|
||||||
|
#define __VIRTUAL_TIMER_VIRTUALTIMERDISTRIBUTOR_H__
|
||||||
|
|
||||||
|
#include <array>
|
||||||
|
|
||||||
|
#include "HwTimerInterface.h"
|
||||||
|
#include "VirtualTimerInterface.h"
|
||||||
|
|
||||||
|
namespace pinetime::virtual_timer
|
||||||
|
{
|
||||||
|
class VirtualTimerDistributor;
|
||||||
|
}
|
||||||
|
extern pinetime::virtual_timer::VirtualTimerDistributor virtual_timer_distributor;
|
||||||
|
|
||||||
|
namespace pinetime::virtual_timer
|
||||||
|
{
|
||||||
|
|
||||||
|
class VirtualTimerDistributor
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
VirtualTimerDistributor(pinetime::interfaces::HwTimerInterface &);
|
||||||
|
|
||||||
|
static inline VirtualTimerDistributor& instance() { return virtual_timer_distributor; }
|
||||||
|
|
||||||
|
void register_timer(pinetime::interfaces::VirtualTimerInterface *);
|
||||||
|
void unregister_timer(pinetime::interfaces::VirtualTimerInterface *);
|
||||||
|
|
||||||
|
void notify(uint64_t);
|
||||||
|
uint64_t tick();
|
||||||
|
|
||||||
|
private:
|
||||||
|
static const uint32_t MAX_TIMERS = 8;
|
||||||
|
|
||||||
|
std::array<pinetime::interfaces::VirtualTimerInterface *, MAX_TIMERS> virtual_timer_list;
|
||||||
|
pinetime::interfaces::HwTimerInterface & hw_timer;
|
||||||
|
uint32_t num_registered_timers;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
Reference in New Issue
Block a user