initial commit
Signed-off-by: Sean Cross <sean@xobs.io>
This commit is contained in:
commit
8cc5028bd9
42
.vscode/c_cpp_properties.json
vendored
Normal file
42
.vscode/c_cpp_properties.json
vendored
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
{
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"name": "Win32",
|
||||||
|
"defines": [
|
||||||
|
"_DEBUG",
|
||||||
|
"UNICODE",
|
||||||
|
"_UNICODE"
|
||||||
|
],
|
||||||
|
"windowsSdkVersion": "10.0.18362.0",
|
||||||
|
"compilerPath": "C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.25.28610/bin/Hostx64/x64/cl.exe",
|
||||||
|
"cStandard": "c11",
|
||||||
|
"cppStandard": "c++17",
|
||||||
|
"includePath": [
|
||||||
|
"${default}",
|
||||||
|
"${workspaceFolder}/src/cmsis/include"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Simmel",
|
||||||
|
"defines": [
|
||||||
|
"ARM_MATH_CM4",
|
||||||
|
"__FPU_PRESENT=1"
|
||||||
|
],
|
||||||
|
"compilerPath": "C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.25.28610/bin/Hostx64/x64/cl.exe",
|
||||||
|
"cStandard": "c11",
|
||||||
|
"cppStandard": "c++17",
|
||||||
|
"includePath": [
|
||||||
|
"${default}",
|
||||||
|
"${workspaceFolder}/src/cmsis/include",
|
||||||
|
"${workspaceFolder}/lib/nrfx/hal",
|
||||||
|
"${workspaceFolder}/lib/nrfx/drivers/include",
|
||||||
|
"${workspaceFolder}/lib/nrfx",
|
||||||
|
"${workspaceFolder}/lib/nrfx/templates/nRF52833",
|
||||||
|
"${workspaceFolder}/lib/nrfx/mdk",
|
||||||
|
"${workspaceFolder}/lib/nrfx/templates",
|
||||||
|
"${workspaceFolder}/lib/tinyusb/src"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"version": 4
|
||||||
|
}
|
32
.vscode/settings.json
vendored
Normal file
32
.vscode/settings.json
vendored
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
{
|
||||||
|
"files.associations": {
|
||||||
|
"variant": "c",
|
||||||
|
"nrfx_power.h": "c",
|
||||||
|
"nrfx_nvmc.h": "c",
|
||||||
|
"app_scheduler.h": "c",
|
||||||
|
"dfu_transport.h": "c",
|
||||||
|
"bootloader_util.h": "c",
|
||||||
|
"esplanade_mac.h": "c"
|
||||||
|
},
|
||||||
|
"C_Cpp.vcpkg.enabled": false,
|
||||||
|
"C_Cpp.default.intelliSenseMode": "gcc-arm",
|
||||||
|
"C_Cpp.default.includePath": [
|
||||||
|
"${workspacePath}/src",
|
||||||
|
"${workspacePath}/lib/nrfx/hal",
|
||||||
|
"${workspacePath}/lib/nrfx/drivers/include",
|
||||||
|
"${workspacePath}/lib/nrfx/soc",
|
||||||
|
"${workspacePath}/lib/tinyusb/src",
|
||||||
|
"${workspacePath}/lib/tinyusb/src/device",
|
||||||
|
"${workspacePath}/lib/tinyusb/src/osal",
|
||||||
|
"${workspacePath}/lib/tinyusb/src/common",
|
||||||
|
],
|
||||||
|
"C_Cpp.dimInactiveRegions": false,
|
||||||
|
"C_Cpp.errorSquiggles": "Enabled",
|
||||||
|
"C_Cpp.default.forcedInclude": [
|
||||||
|
"src/cmsis/include/arm_math.h"
|
||||||
|
],
|
||||||
|
"C_Cpp.default.defines": [
|
||||||
|
"ARM_MATH_CM4",
|
||||||
|
"__FPU_PRESENT=1"
|
||||||
|
]
|
||||||
|
}
|
107
Makefile
Normal file
107
Makefile
Normal file
@ -0,0 +1,107 @@
|
|||||||
|
CC := $(CROSS_COMPILE)gcc
|
||||||
|
CXX := $(CROSS_COMPILE)g++
|
||||||
|
OBJCOPY := $(CROSS_COMPILE)objcopy
|
||||||
|
|
||||||
|
RM := rm -rf
|
||||||
|
COPY := cp -a
|
||||||
|
PATH_SEP := /
|
||||||
|
|
||||||
|
ifeq ($(OS),Windows_NT)
|
||||||
|
# When SHELL=sh.exe and this actually exists, make will silently
|
||||||
|
# switch to using that instead of cmd.exe. Unfortunately, there's
|
||||||
|
# no way to tell which environment we're running under without either
|
||||||
|
# (1) printing out an error message, or (2) finding something that
|
||||||
|
# works everywhere.
|
||||||
|
# As a result, we force the shell to be cmd.exe, so it works both
|
||||||
|
# under cygwin and normal Windows.
|
||||||
|
SHELL = cmd.exe
|
||||||
|
COPY = copy
|
||||||
|
RM = del
|
||||||
|
PATH_SEP = \\
|
||||||
|
endif
|
||||||
|
|
||||||
|
BASE_DIR := .
|
||||||
|
ADD_CFLAGS := -I$(BASE_DIR)/include -I$(BASE_DIR)/src/cmsis/include -DARM_MATH_CM0
|
||||||
|
ADD_LFLAGS :=
|
||||||
|
PACKAGE := bpsktest
|
||||||
|
|
||||||
|
SRC_DIR := $(BASE_DIR)/src
|
||||||
|
DBG_CFLAGS := -ggdb -g -DDEBUG -Wall -Og
|
||||||
|
DBG_LFLAGS := -ggdb -g -Wall
|
||||||
|
CFLAGS := $(ADD_CFLAGS) \
|
||||||
|
-Wall -Wextra \
|
||||||
|
-std=gnu11
|
||||||
|
CXXFLAGS := $(CFLAGS) -std=c++11
|
||||||
|
LFLAGS := $(CFLAGS) $(ADD_LFLAGS) -L$(LD_DIR)
|
||||||
|
LIBS := -lm
|
||||||
|
|
||||||
|
OBJ_DIR := .obj
|
||||||
|
|
||||||
|
CSOURCES := $(wildcard $(SRC_DIR)/*.c) $(wildcard src/cmsis/source/*.c) $(wildcard src/bpsk/*.c)
|
||||||
|
CPPSOURCES := $(wildcard $(SRC_DIR)/*.cpp) $(wildcard src/cmsis/*.cpp) $(wildcard src/bpsk/*.cpp)
|
||||||
|
ASOURCES := $(wildcard $(SRC_DIR)/*.S) $(wildcard src/cmsis/*.S) $(wildcard src/bpsk/*.S)
|
||||||
|
COBJS := $(addprefix $(OBJ_DIR)/, $(notdir $(CSOURCES:.c=.o)))
|
||||||
|
CXXOBJS := $(addprefix $(OBJ_DIR)/, $(notdir $(CPPSOURCES:.cpp=.o)))
|
||||||
|
AOBJS := $(addprefix $(OBJ_DIR)/, $(notdir $(ASOURCES:.S=.o)))
|
||||||
|
OBJECTS := $(COBJS) $(CXXOBJS) $(AOBJS)
|
||||||
|
VPATH := $(SRC_DIR) src/cmsis/source src/bpsk
|
||||||
|
|
||||||
|
QUIET := @
|
||||||
|
|
||||||
|
ALL := all
|
||||||
|
TARGET := $(PACKAGE)
|
||||||
|
CLEAN := clean
|
||||||
|
|
||||||
|
$(ALL): $(TARGET)
|
||||||
|
|
||||||
|
$(OBJECTS): | $(OBJ_DIR)
|
||||||
|
|
||||||
|
$(TARGET): $(OBJECTS) $(LDSCRIPTS)
|
||||||
|
$(QUIET) echo " LD $@"
|
||||||
|
$(QUIET) $(CC) $(OBJECTS) $(LFLAGS) -o $@ $(LIBS)
|
||||||
|
|
||||||
|
$(DEBUG): CFLAGS += $(DBG_CFLAGS)
|
||||||
|
$(DEBUG): LFLAGS += $(DBG_LFLAGS)
|
||||||
|
CFLAGS += $(DBG_CFLAGS)
|
||||||
|
LFLAGS += $(DBG_LFLAGS)
|
||||||
|
$(DEBUG): $(TARGET)
|
||||||
|
|
||||||
|
ifneq ($(BAUD_RATE),)
|
||||||
|
CFLAGS += -DBAUD_RATE=$(BAUD_RATE)
|
||||||
|
endif
|
||||||
|
ifneq ($(F_LO),)
|
||||||
|
CFLAGS += -DF_LO=$(F_LO)
|
||||||
|
endif
|
||||||
|
ifneq ($(F_HI),)
|
||||||
|
CFLAGS += -DF_HI=$(F_HI)
|
||||||
|
endif
|
||||||
|
ifneq ($(SAMPLE_RATE),)
|
||||||
|
CFLAGS += -DSAMPLE_RATE=$(SAMPLE_RATE)
|
||||||
|
endif
|
||||||
|
|
||||||
|
$(OBJ_DIR):
|
||||||
|
$(QUIET) mkdir $(OBJ_DIR)
|
||||||
|
|
||||||
|
$(COBJS) : $(OBJ_DIR)/%.o : %.c $(BASE_DIR)/Makefile
|
||||||
|
$(QUIET) echo " CC $< $(notdir $@)"
|
||||||
|
$(QUIET) $(CC) -c $< $(CFLAGS) -o $@ -MMD
|
||||||
|
|
||||||
|
$(OBJ_DIR)/%.o: %.cpp
|
||||||
|
$(QUIET) echo " CXX $< $(notdir $@)"
|
||||||
|
$(QUIET) $(CXX) -c $< $(CXXFLAGS) -o $@ -MMD
|
||||||
|
|
||||||
|
$(OBJ_DIR)/%.o: %.S
|
||||||
|
$(QUIET) echo " AS $< $(notdir $@)"
|
||||||
|
$(QUIET) $(CC) -x assembler-with-cpp -c $< $(CFLAGS) -o $@ -MMD
|
||||||
|
|
||||||
|
.PHONY: clean
|
||||||
|
|
||||||
|
clean:
|
||||||
|
$(QUIET) echo " RM $(subst /,$(PATH_SEP),$(wildcard $(OBJ_DIR)/*.d))"
|
||||||
|
-$(QUIET) $(RM) $(subst /,$(PATH_SEP),$(wildcard $(OBJ_DIR)/*.d))
|
||||||
|
$(QUIET) echo " RM $(subst /,$(PATH_SEP),$(wildcard $(OBJ_DIR)/*.d))"
|
||||||
|
-$(QUIET) $(RM) $(subst /,$(PATH_SEP),$(wildcard $(OBJ_DIR)/*.o))
|
||||||
|
$(QUIET) echo " RM $(TARGET) $(PACKAGE).bin $(PACKAGE).symbol $(PACKAGE).ihex $(PACKAGE).dfu"
|
||||||
|
-$(QUIET) $(RM) $(TARGET) $(PACKAGE).bin $(PACKAGE).symbol $(PACKAGE).ihex $(PACKAGE).dfu
|
||||||
|
|
||||||
|
include $(wildcard $(OBJ_DIR)/*.d)
|
157
src/bpsk.c
Normal file
157
src/bpsk.c
Normal file
@ -0,0 +1,157 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <assert.h>
|
||||||
|
#include <inttypes.h>
|
||||||
|
|
||||||
|
#include "bpsk.h"
|
||||||
|
|
||||||
|
#include "bpsk/demod.h"
|
||||||
|
#include "bpsk/mac.h"
|
||||||
|
#include "bpsk/murmur3.h"
|
||||||
|
|
||||||
|
#include "arm_math.h"
|
||||||
|
|
||||||
|
#include "printf.h"
|
||||||
|
|
||||||
|
static struct mac_state mac_state;
|
||||||
|
static int packet_count = 0;
|
||||||
|
static int corrupt_count = 0;
|
||||||
|
static demod_pkt_t packet;
|
||||||
|
|
||||||
|
volatile uint32_t debug_print_sync = 1;
|
||||||
|
volatile uint32_t debug_print_status = 1;
|
||||||
|
|
||||||
|
static int validate_packet(demod_pkt_t *pkt, int should_print)
|
||||||
|
{
|
||||||
|
unsigned int i;
|
||||||
|
demod_pkt_ctrl_t *cpkt = &pkt->ctrl_pkt;
|
||||||
|
demod_pkt_data_t *dpkt = &pkt->data_pkt;
|
||||||
|
uint32_t hash;
|
||||||
|
|
||||||
|
if (should_print)
|
||||||
|
{
|
||||||
|
printf("Got packet:\n");
|
||||||
|
printf(" Header:\n");
|
||||||
|
printf(" Version: %d\n", pkt->header.version);
|
||||||
|
printf(" Type: %" PRId32 " ", pkt->header.type);
|
||||||
|
}
|
||||||
|
switch (pkt->header.type)
|
||||||
|
{
|
||||||
|
|
||||||
|
case PKTTYPE_CTRL:
|
||||||
|
if (should_print)
|
||||||
|
{
|
||||||
|
printf("Ctrl Packet\n");
|
||||||
|
printf(" Reserved: %d\n", cpkt->reserved);
|
||||||
|
printf(" Length: %" PRId32 "\n", cpkt->length);
|
||||||
|
printf(" Full Hash: %" PRIx32 "\n", cpkt->fullhash);
|
||||||
|
printf(" GUID: ");
|
||||||
|
for (i = 0; i < 16; i++)
|
||||||
|
printf("%" PRIx8 " ", cpkt->guid[i]);
|
||||||
|
printf("\n");
|
||||||
|
printf(" Packet Hash: %" PRIx32 " ", cpkt->hash);
|
||||||
|
}
|
||||||
|
MurmurHash3_x86_32((uint8_t *)cpkt, sizeof(*cpkt) - sizeof(cpkt->hash),
|
||||||
|
MURMUR_SEED_BLOCK, &hash);
|
||||||
|
if (hash != cpkt->hash)
|
||||||
|
{
|
||||||
|
if (should_print)
|
||||||
|
printf("!= %" PRIx32 "\n", hash);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if (should_print)
|
||||||
|
printf("Ok\n");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PKTTYPE_DATA:
|
||||||
|
// unstripe the transition xor's used to keep baud sync. We
|
||||||
|
// don't xor the header or the ending hash, but xor
|
||||||
|
// everything else..
|
||||||
|
for (i = sizeof(pkt->header); i < sizeof(*dpkt) - sizeof(dpkt->hash);
|
||||||
|
i++)
|
||||||
|
{
|
||||||
|
if (pkt->header.version == PKT_VER_1)
|
||||||
|
{
|
||||||
|
// baud striping on alpha and before
|
||||||
|
if ((i % 16) == 7)
|
||||||
|
((uint8_t *)pkt)[i] ^= 0x55;
|
||||||
|
else if ((i % 16) == 15)
|
||||||
|
((uint8_t *)pkt)[i] ^= 0xAA;
|
||||||
|
}
|
||||||
|
else if (pkt->header.version == PKT_VER_2)
|
||||||
|
{
|
||||||
|
// more dense baud striping to be used on beta and
|
||||||
|
// beyond
|
||||||
|
if ((i % 3) == 0)
|
||||||
|
((uint8_t *)pkt)[i] ^= 0x35;
|
||||||
|
else if ((i % 3) == 1)
|
||||||
|
((uint8_t *)pkt)[i] ^= 0xac;
|
||||||
|
else if ((i % 3) == 2)
|
||||||
|
((uint8_t *)pkt)[i] ^= 0x95;
|
||||||
|
}
|
||||||
|
else if (pkt->header.version == PKT_VER_3)
|
||||||
|
{
|
||||||
|
// Nothing to do
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (should_print)
|
||||||
|
{
|
||||||
|
printf("Data Packet\n");
|
||||||
|
printf(" Block Number: %" PRId32 "\n", dpkt->block);
|
||||||
|
printf(" Packet Hash: %" PRIx32 " ", dpkt->hash);
|
||||||
|
}
|
||||||
|
/* Make sure the packet's hash is correct. */
|
||||||
|
MurmurHash3_x86_32((uint8_t *)dpkt, sizeof(*dpkt) - sizeof(dpkt->hash),
|
||||||
|
MURMUR_SEED_BLOCK, &hash);
|
||||||
|
if (hash != dpkt->hash)
|
||||||
|
{
|
||||||
|
if (should_print)
|
||||||
|
printf("!= %" PRIx32 "\n", hash);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if (should_print)
|
||||||
|
printf("Ok\n");
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
if (should_print)
|
||||||
|
printf(" (unknown type)\n");
|
||||||
|
return 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void bpsk_init(void)
|
||||||
|
{
|
||||||
|
bpsk_demod_init();
|
||||||
|
}
|
||||||
|
|
||||||
|
void bpsk_run(int16_t *samples, uint32_t nsamples)
|
||||||
|
{
|
||||||
|
uint32_t processed_samples;
|
||||||
|
|
||||||
|
int bit = 0;
|
||||||
|
while (nsamples > 0)
|
||||||
|
{
|
||||||
|
if (bpsk_demod(&bit, samples, nsamples, &processed_samples))
|
||||||
|
{
|
||||||
|
if (mac_put_bit(&mac_state, bit, &packet, sizeof(packet)))
|
||||||
|
{
|
||||||
|
if (validate_packet(&packet, 1))
|
||||||
|
{
|
||||||
|
packet_count++;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
corrupt_count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
assert(processed_samples <= nsamples);
|
||||||
|
nsamples -= processed_samples;
|
||||||
|
samples += processed_samples;
|
||||||
|
}
|
||||||
|
}
|
15
src/bpsk.h
Normal file
15
src/bpsk.h
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
#ifndef __AFSK_H__
|
||||||
|
#define __AFSK_H__
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
struct demod_config {
|
||||||
|
uint32_t sample_rate;
|
||||||
|
uint32_t carrier_tone;
|
||||||
|
uint32_t baud_rate;
|
||||||
|
};
|
||||||
|
|
||||||
|
void bpsk_init(void);
|
||||||
|
void bpsk_run(int16_t *samples, uint32_t nsamples);
|
||||||
|
|
||||||
|
#endif /* __AFSK_H__ */
|
382
src/bpsk/demod.c
Normal file
382
src/bpsk/demod.c
Normal file
@ -0,0 +1,382 @@
|
|||||||
|
#include <stdint.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
|
#include "arm_math.h"
|
||||||
|
|
||||||
|
#include "demod.h"
|
||||||
|
#include "mac.h"
|
||||||
|
|
||||||
|
#ifdef PLAYGROUND
|
||||||
|
#include "../printf.h"
|
||||||
|
#else
|
||||||
|
#include <stdio.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "fir_coefficients.h"
|
||||||
|
#include "lpf_coefficients.h"
|
||||||
|
|
||||||
|
struct nco_state
|
||||||
|
{
|
||||||
|
float32_t samplerate; // Hz
|
||||||
|
float32_t freq; // Hz
|
||||||
|
|
||||||
|
float32_t phase; // rad
|
||||||
|
};
|
||||||
|
|
||||||
|
struct bpsk_state
|
||||||
|
{
|
||||||
|
/// Convert incoming q15 values into f32 values into this
|
||||||
|
/// buffer, so that we can keep track of it between calls.
|
||||||
|
float32_t current[SAMPLES_PER_PERIOD];
|
||||||
|
uint32_t current_offset;
|
||||||
|
|
||||||
|
/// If there aren't enough samples to convert data from q15
|
||||||
|
/// to f32, store them in here and return.
|
||||||
|
demod_sample_t cached[SAMPLES_PER_PERIOD];
|
||||||
|
uint32_t cached_capacity;
|
||||||
|
|
||||||
|
arm_fir_instance_f32 fir;
|
||||||
|
float32_t fir_state[SAMPLES_PER_PERIOD + FIR_STAGES - 1];
|
||||||
|
|
||||||
|
struct nco_state nco;
|
||||||
|
float32_t nco_error;
|
||||||
|
|
||||||
|
arm_fir_instance_f32 i_lpf;
|
||||||
|
float32_t i_lpf_state[SAMPLES_PER_PERIOD + LPF_STAGES - 1];
|
||||||
|
|
||||||
|
arm_fir_instance_f32 q_lpf;
|
||||||
|
float32_t q_lpf_state[SAMPLES_PER_PERIOD + LPF_STAGES - 1];
|
||||||
|
|
||||||
|
float32_t i_lpf_samples[SAMPLES_PER_PERIOD];
|
||||||
|
|
||||||
|
float32_t agc;
|
||||||
|
float32_t agc_step;
|
||||||
|
float32_t agc_target_hi;
|
||||||
|
float32_t agc_target_low;
|
||||||
|
|
||||||
|
// Signal decoding
|
||||||
|
float32_t bit_pll;
|
||||||
|
float32_t pll_incr;
|
||||||
|
int bit_acc;
|
||||||
|
int last_state;
|
||||||
|
};
|
||||||
|
|
||||||
|
static struct bpsk_state bpsk_state;
|
||||||
|
|
||||||
|
extern char varcode_to_char(uint32_t c);
|
||||||
|
static void print_char(uint32_t c)
|
||||||
|
{
|
||||||
|
printf("%c", varcode_to_char(c >> 2));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void nco(float32_t control, uint32_t timestep, float32_t *i,
|
||||||
|
float32_t *q)
|
||||||
|
{
|
||||||
|
// control is a number from +1 to -1, which translates to -pi to +pi
|
||||||
|
// additional phase per time step timestep is the current time step,
|
||||||
|
// expressed in terms of samples since t=0 i is a pointer to the in-phase
|
||||||
|
// return value q is a pointer to the quadrature return value
|
||||||
|
|
||||||
|
bpsk_state.nco.phase += (control / PI);
|
||||||
|
|
||||||
|
*i = arm_cos_f32((((float32_t)timestep) * bpsk_state.nco.freq * 2 * PI) /
|
||||||
|
bpsk_state.nco.samplerate +
|
||||||
|
bpsk_state.nco.phase);
|
||||||
|
*q = arm_sin_f32((((float32_t)timestep) * bpsk_state.nco.freq * 2 * PI) /
|
||||||
|
bpsk_state.nco.samplerate +
|
||||||
|
bpsk_state.nco.phase);
|
||||||
|
}
|
||||||
|
|
||||||
|
void bpsk_demod_init(void)
|
||||||
|
{
|
||||||
|
arm_fir_init_f32(&bpsk_state.fir, FIR_STAGES, fir_coefficients,
|
||||||
|
bpsk_state.fir_state, SAMPLES_PER_PERIOD);
|
||||||
|
|
||||||
|
bpsk_state.nco.samplerate = SAMPLE_RATE;
|
||||||
|
bpsk_state.nco.freq = CARRIER_TONE;
|
||||||
|
bpsk_state.nco.phase = 0.0;
|
||||||
|
bpsk_state.nco_error = 0.0;
|
||||||
|
|
||||||
|
bpsk_state.agc = 1.0;
|
||||||
|
bpsk_state.agc_step = 0.05;
|
||||||
|
bpsk_state.agc_target_hi = 0.5;
|
||||||
|
bpsk_state.agc_target_low = 0.25;
|
||||||
|
|
||||||
|
// Force a buffer refill for the first iteration
|
||||||
|
bpsk_state.current_offset = SAMPLES_PER_PERIOD;
|
||||||
|
|
||||||
|
bpsk_state.cached_capacity = 0;
|
||||||
|
|
||||||
|
arm_fir_init_f32(&bpsk_state.i_lpf, LPF_STAGES, lpf_coefficients,
|
||||||
|
bpsk_state.i_lpf_state, SAMPLES_PER_PERIOD);
|
||||||
|
arm_fir_init_f32(&bpsk_state.q_lpf, LPF_STAGES, lpf_coefficients,
|
||||||
|
bpsk_state.q_lpf_state, SAMPLES_PER_PERIOD);
|
||||||
|
|
||||||
|
bpsk_state.bit_pll = 0.0;
|
||||||
|
bpsk_state.pll_incr = ((float)BAUD_RATE / (float)SAMPLE_RATE);
|
||||||
|
bpsk_state.bit_acc = 0;
|
||||||
|
bpsk_state.last_state = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Dump this with:
|
||||||
|
// ```
|
||||||
|
// dump binary memory sample.wav &sample_wave
|
||||||
|
// ((uint32_t)&sample_wave)+sizeof(sample_wave)
|
||||||
|
// ```
|
||||||
|
#ifdef CAPTURE_BUFFER
|
||||||
|
#define CAPTURE_BUFFER_COUNT (32768)
|
||||||
|
struct sample_wave
|
||||||
|
{
|
||||||
|
uint8_t header[44];
|
||||||
|
uint16_t saved_samples[CAPTURE_BUFFER_COUNT];
|
||||||
|
};
|
||||||
|
struct sample_wave sample_wave;
|
||||||
|
uint32_t saved_samples_ptr;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static FILE *output = NULL;
|
||||||
|
static void write_wav_stereo(int16_t *left, int16_t *right, unsigned int len,
|
||||||
|
const char *name)
|
||||||
|
{
|
||||||
|
if (!output)
|
||||||
|
{
|
||||||
|
static uint8_t wav_header[44] = {
|
||||||
|
0x52,
|
||||||
|
0x49,
|
||||||
|
0x46,
|
||||||
|
0x46,
|
||||||
|
0x1c,
|
||||||
|
0x12,
|
||||||
|
0x05,
|
||||||
|
0x00,
|
||||||
|
0x57,
|
||||||
|
0x41,
|
||||||
|
0x56,
|
||||||
|
0x45,
|
||||||
|
0x66,
|
||||||
|
0x6d,
|
||||||
|
0x74,
|
||||||
|
0x20,
|
||||||
|
0x10,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x01,
|
||||||
|
0x00,
|
||||||
|
0x02, // stereo
|
||||||
|
0x00,
|
||||||
|
0x11,
|
||||||
|
0x2b,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x22,
|
||||||
|
0x56,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x02,
|
||||||
|
0x00,
|
||||||
|
0x10,
|
||||||
|
0x00,
|
||||||
|
0x64,
|
||||||
|
0x61,
|
||||||
|
0x74,
|
||||||
|
0x61,
|
||||||
|
0xf8,
|
||||||
|
0x11,
|
||||||
|
0x05,
|
||||||
|
0x00,
|
||||||
|
};
|
||||||
|
|
||||||
|
output = fopen(name, "w+b");
|
||||||
|
if (!output)
|
||||||
|
{
|
||||||
|
perror("unable to open filtered file");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (fwrite(wav_header, sizeof(wav_header), 1, output) <= 0)
|
||||||
|
{
|
||||||
|
perror("error");
|
||||||
|
fclose(output);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (unsigned int i = 0; i < len; i++)
|
||||||
|
{
|
||||||
|
if (fwrite(&(left[i]), 2, 1, output) != 1)
|
||||||
|
{
|
||||||
|
perror("error");
|
||||||
|
fclose(output);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (fwrite(&(right[i]), 2, 1, output) != 1)
|
||||||
|
{
|
||||||
|
perror("error");
|
||||||
|
fclose(output);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void bpsk_core(void)
|
||||||
|
{
|
||||||
|
// Perform an initial FIR filter on the samples. This creates a LPF.
|
||||||
|
// This line may be omitted for testing.
|
||||||
|
arm_fir_f32(&bpsk_state.fir, bpsk_state.current, bpsk_state.current,
|
||||||
|
SAMPLES_PER_PERIOD);
|
||||||
|
|
||||||
|
// Scan for agc value. note values are normalized to +1.0/-1.0.
|
||||||
|
int above_hi = 0;
|
||||||
|
int above_low = 0;
|
||||||
|
for (int i = 0; i < SAMPLES_PER_PERIOD; i++)
|
||||||
|
{
|
||||||
|
bpsk_state.current[i] = bpsk_state.current[i] * bpsk_state.agc; // compute the agc
|
||||||
|
|
||||||
|
// then check if we're out of bounds
|
||||||
|
if (bpsk_state.current[i] > bpsk_state.agc_target_low)
|
||||||
|
{
|
||||||
|
above_low = 1;
|
||||||
|
}
|
||||||
|
if (bpsk_state.current[i] > bpsk_state.agc_target_hi)
|
||||||
|
{
|
||||||
|
above_hi = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (above_hi)
|
||||||
|
{
|
||||||
|
bpsk_state.agc = bpsk_state.agc * (1.0 - bpsk_state.agc_step);
|
||||||
|
}
|
||||||
|
else if (!above_low)
|
||||||
|
{
|
||||||
|
bpsk_state.agc = bpsk_state.agc * (1.0 + bpsk_state.agc_step);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Generate Numerically-Controlled Oscillator values for the
|
||||||
|
// current timestamp.
|
||||||
|
float32_t i_samps[SAMPLES_PER_PERIOD];
|
||||||
|
float32_t q_samps[SAMPLES_PER_PERIOD];
|
||||||
|
static int nco_offset = 0;
|
||||||
|
for (unsigned int i = 0; i < SAMPLES_PER_PERIOD; i++)
|
||||||
|
{
|
||||||
|
nco(bpsk_state.nco_error, i + nco_offset, &(i_samps[i]), &(q_samps[i]));
|
||||||
|
}
|
||||||
|
nco_offset += SAMPLES_PER_PERIOD;
|
||||||
|
|
||||||
|
static float32_t i_mult_samps[SAMPLES_PER_PERIOD];
|
||||||
|
static float32_t q_mult_samps[SAMPLES_PER_PERIOD];
|
||||||
|
arm_mult_f32(bpsk_state.current, i_samps, i_mult_samps, SAMPLES_PER_PERIOD);
|
||||||
|
arm_mult_f32(bpsk_state.current, q_samps, q_mult_samps, SAMPLES_PER_PERIOD);
|
||||||
|
|
||||||
|
// static float32_t bpsk_state.i_lpf_samples[SAMPLES_PER_PERIOD];
|
||||||
|
static float32_t q_lpf_samples[SAMPLES_PER_PERIOD];
|
||||||
|
arm_fir_f32(&bpsk_state.i_lpf, i_mult_samps, bpsk_state.i_lpf_samples, SAMPLES_PER_PERIOD);
|
||||||
|
arm_fir_f32(&bpsk_state.q_lpf, q_mult_samps, q_lpf_samples, SAMPLES_PER_PERIOD);
|
||||||
|
|
||||||
|
int16_t i_loop[SAMPLES_PER_PERIOD];
|
||||||
|
int16_t q_loop[SAMPLES_PER_PERIOD];
|
||||||
|
arm_float_to_q15(bpsk_state.i_lpf_samples, i_loop, SAMPLES_PER_PERIOD);
|
||||||
|
arm_float_to_q15(q_lpf_samples, q_loop, SAMPLES_PER_PERIOD);
|
||||||
|
write_wav_stereo(i_loop, q_loop, SAMPLES_PER_PERIOD, "quadrature_loop.wav");
|
||||||
|
|
||||||
|
float32_t errorwindow[SAMPLES_PER_PERIOD];
|
||||||
|
arm_mult_f32(bpsk_state.i_lpf_samples, q_lpf_samples, errorwindow,
|
||||||
|
SAMPLES_PER_PERIOD);
|
||||||
|
float32_t avg = 0;
|
||||||
|
for (int i = 0; i < SAMPLES_PER_PERIOD; i++)
|
||||||
|
{
|
||||||
|
avg += errorwindow[i];
|
||||||
|
}
|
||||||
|
avg /= ((float32_t)SAMPLES_PER_PERIOD);
|
||||||
|
bpsk_state.nco_error = -(avg);
|
||||||
|
// printf("err: %0.04f\n", bpsk_state.nco_error);
|
||||||
|
}
|
||||||
|
|
||||||
|
int bpsk_demod(int *bit, demod_sample_t *samples, uint32_t nb, uint32_t *processed_samples)
|
||||||
|
{
|
||||||
|
*processed_samples = 0;
|
||||||
|
while (1)
|
||||||
|
{
|
||||||
|
// If we've run out of samples, fill the sample buffer
|
||||||
|
bpsk_state.current_offset += 1;
|
||||||
|
if (bpsk_state.current_offset >= SAMPLES_PER_PERIOD)
|
||||||
|
{
|
||||||
|
bpsk_state.current_offset = 0;
|
||||||
|
|
||||||
|
// If there's data in the cache buffer, use that as the source
|
||||||
|
// for data.
|
||||||
|
if (bpsk_state.cached_capacity > 0)
|
||||||
|
{
|
||||||
|
// If there won't be enough data to process, so copy the
|
||||||
|
// remainder to the cache and return.
|
||||||
|
if (bpsk_state.cached_capacity + nb < SAMPLES_PER_PERIOD)
|
||||||
|
{
|
||||||
|
memcpy(bpsk_state.cached + bpsk_state.cached_capacity,
|
||||||
|
samples, nb * sizeof(uint16_t));
|
||||||
|
bpsk_state.cached_capacity += nb;
|
||||||
|
*processed_samples += nb;
|
||||||
|
fclose(output);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t samples_to_take = (SAMPLES_PER_PERIOD - bpsk_state.cached_capacity);
|
||||||
|
memcpy(bpsk_state.cached + bpsk_state.cached_capacity, samples,
|
||||||
|
samples_to_take * sizeof(uint16_t));
|
||||||
|
|
||||||
|
// There is enough data, so convert it to f32
|
||||||
|
arm_q15_to_float(bpsk_state.cached, bpsk_state.current,
|
||||||
|
SAMPLES_PER_PERIOD);
|
||||||
|
bpsk_state.cached_capacity = 0;
|
||||||
|
|
||||||
|
nb -= samples_to_take;
|
||||||
|
samples += samples_to_take;
|
||||||
|
(*processed_samples) += SAMPLES_PER_PERIOD;
|
||||||
|
}
|
||||||
|
// Otherwise, the cache is empty, so operate directly on sample data
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// If there isn't enough data to operate on, store it in the
|
||||||
|
// cache.
|
||||||
|
if (nb < SAMPLES_PER_PERIOD)
|
||||||
|
{
|
||||||
|
memcpy(bpsk_state.cached, samples, nb * sizeof(uint16_t));
|
||||||
|
bpsk_state.cached_capacity = nb;
|
||||||
|
(*processed_samples) += nb;
|
||||||
|
fclose(output);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Directly convert the sample data to f32
|
||||||
|
arm_q15_to_float(samples, bpsk_state.current, SAMPLES_PER_PERIOD);
|
||||||
|
nb -= SAMPLES_PER_PERIOD;
|
||||||
|
samples += SAMPLES_PER_PERIOD;
|
||||||
|
(*processed_samples) += SAMPLES_PER_PERIOD;
|
||||||
|
}
|
||||||
|
|
||||||
|
bpsk_core();
|
||||||
|
}
|
||||||
|
|
||||||
|
// If the PLL crosses the 50% threshold, indicate a new bit.
|
||||||
|
if (bpsk_state.bit_pll < 0.5 && (bpsk_state.bit_pll + bpsk_state.pll_incr) >= 0.5)
|
||||||
|
{
|
||||||
|
int state = bpsk_state.i_lpf_samples[bpsk_state.current_offset] > 0.0;
|
||||||
|
*bit = !(state ^ bpsk_state.last_state);
|
||||||
|
bpsk_state.last_state = state;
|
||||||
|
|
||||||
|
bpsk_state.bit_acc = (bpsk_state.bit_acc << 1) | *bit;
|
||||||
|
if ((bpsk_state.bit_acc & 3) == 0)
|
||||||
|
{
|
||||||
|
print_char(bpsk_state.bit_acc);
|
||||||
|
bpsk_state.bit_acc = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Advance the PLL, looping it when it passes 1
|
||||||
|
bpsk_state.bit_pll += bpsk_state.pll_incr;
|
||||||
|
if (bpsk_state.bit_pll >= 1)
|
||||||
|
{
|
||||||
|
bpsk_state.bit_pll -= 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
19
src/bpsk/demod.h
Normal file
19
src/bpsk/demod.h
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
#ifndef __ORCHARD_DEMOD__
|
||||||
|
#define __ORCHARD_DEMOD__
|
||||||
|
|
||||||
|
#include "arm_math.h"
|
||||||
|
|
||||||
|
typedef int16_t demod_sample_t;
|
||||||
|
struct bpsk_state;
|
||||||
|
|
||||||
|
#define SAMPLE_RATE 62500
|
||||||
|
#define CARRIER_TONE 20840
|
||||||
|
#define BAUD_RATE (651.0f) // 31.25
|
||||||
|
#define PLL_INCR (BAUD_RATE / (float32_t)(SAMPLE_RATE))
|
||||||
|
#define SAMPLES_PER_PERIOD 20 // Must evenly divide CARRIER_TONE
|
||||||
|
|
||||||
|
void bpsk_demod_init(void);
|
||||||
|
int bpsk_demod(int *bit, demod_sample_t *samples, uint32_t nb,
|
||||||
|
uint32_t *processed_samples);
|
||||||
|
|
||||||
|
#endif
|
12
src/bpsk/fir_coefficients.h
Normal file
12
src/bpsk/fir_coefficients.h
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
// Filter defined in `make_coefficients.py` with the following parameters:
|
||||||
|
// taps: 5
|
||||||
|
// rate: 62500
|
||||||
|
// bandwidth: 18000
|
||||||
|
#define FIR_STAGES 5
|
||||||
|
static float fir_coefficients[FIR_STAGES] = {
|
||||||
|
0.007602129069420533f,
|
||||||
|
-0.21697500566330508f,
|
||||||
|
0.5508457305345488f,
|
||||||
|
-0.21697500566330508f,
|
||||||
|
0.007602129069420533f,
|
||||||
|
};
|
24
src/bpsk/lpf_coefficients.h
Normal file
24
src/bpsk/lpf_coefficients.h
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
// Filter defined in `make_coefficients.py` with the following parameters:
|
||||||
|
// taps: 16
|
||||||
|
// rate: 62500
|
||||||
|
// tone: 20840
|
||||||
|
// bandwidth: 100
|
||||||
|
#define LPF_STAGES 16
|
||||||
|
static float lpf_coefficients[LPF_STAGES] = {
|
||||||
|
0.009772255068427597f,
|
||||||
|
0.014633627754595912f,
|
||||||
|
0.028376388957030364f,
|
||||||
|
0.048628398957956356f,
|
||||||
|
0.07188949768153266f,
|
||||||
|
0.0941372212972738f,
|
||||||
|
0.11152317756642983f,
|
||||||
|
0.12103943271675341f,
|
||||||
|
0.12103943271675341f,
|
||||||
|
0.11152317756642983f,
|
||||||
|
0.09413722129727382f,
|
||||||
|
0.07188949768153269f,
|
||||||
|
0.048628398957956356f,
|
||||||
|
0.028376388957030384f,
|
||||||
|
0.01463362775459592f,
|
||||||
|
0.009772255068427597f,
|
||||||
|
};
|
184
src/bpsk/mac.c
Normal file
184
src/bpsk/mac.c
Normal file
@ -0,0 +1,184 @@
|
|||||||
|
#include <stdint.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
|
#include "mac.h"
|
||||||
|
#ifdef PLAYGROUND
|
||||||
|
#include "../printf.h"
|
||||||
|
#else
|
||||||
|
#include <stdio.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
extern uint32_t debug_print_sync;
|
||||||
|
extern uint32_t debug_print_status;
|
||||||
|
|
||||||
|
// uint8_t byte_log[65536];
|
||||||
|
// uint8_t bit_offset = 8;
|
||||||
|
// uint32_t byte_log_offset;
|
||||||
|
|
||||||
|
// put_bit with a MAC layer on it
|
||||||
|
int mac_put_bit(struct mac_state *state, int bit, void *buffer,
|
||||||
|
unsigned int buffer_size) {
|
||||||
|
demod_pkt_t *pkt = (demod_pkt_t *)buffer;
|
||||||
|
int packet_done = 0;
|
||||||
|
|
||||||
|
assert(buffer_size >= sizeof(demod_pkt_t));
|
||||||
|
|
||||||
|
// byte_log[byte_log_offset] |= (bit << --bit_offset);
|
||||||
|
// if (!bit_offset) {
|
||||||
|
// byte_log_offset++;
|
||||||
|
// if (byte_log_offset > sizeof(byte_log)) {
|
||||||
|
// byte_log_offset = 0;
|
||||||
|
// }
|
||||||
|
// byte_log[byte_log_offset] = 0;
|
||||||
|
// bit_offset = 8;
|
||||||
|
// }
|
||||||
|
|
||||||
|
switch (state->mstate) {
|
||||||
|
case MAC_IDLE:
|
||||||
|
// Search until at least /n/ zeros are found.
|
||||||
|
// The next transition /might/ be sync.
|
||||||
|
if (state->idle_zeros > 32) {
|
||||||
|
if (bit != 0) {
|
||||||
|
state->mstate = MAC_SYNC;
|
||||||
|
// printf("Got bit, transitioning to MAC_SYNC\n");
|
||||||
|
state->bitpos = 6;
|
||||||
|
state->curbyte = 0x80;
|
||||||
|
state->sync_count = 0;
|
||||||
|
} else {
|
||||||
|
if (state->idle_zeros < 255) {
|
||||||
|
state->idle_zeros++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (bit != 0)
|
||||||
|
state->idle_zeros = 0;
|
||||||
|
else
|
||||||
|
state->idle_zeros++;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case MAC_SYNC:
|
||||||
|
// acculumate two bytes worth of temp data, then check to see if valid
|
||||||
|
// sync
|
||||||
|
state->curbyte >>= 1;
|
||||||
|
state->bitpos--;
|
||||||
|
if (bit) {
|
||||||
|
state->curbyte |= 0x80;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* We haven't yet read 8 bits */
|
||||||
|
if (state->bitpos) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// printf("Got MAC byte: %02x\n", state->curbyte);
|
||||||
|
/* 8 bits have been read. Process the resulting byte. */
|
||||||
|
|
||||||
|
/* Optimization: check to see if we just read an idle value. */
|
||||||
|
if (state->curbyte == 0x00) {
|
||||||
|
|
||||||
|
/* False noise trigger, go back to idle. */
|
||||||
|
state->mstate = MAC_IDLE;
|
||||||
|
state->idle_zeros = 8; /* We just saw 8 zeros, so count those */
|
||||||
|
if (debug_print_sync) printf("False sync\n");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Tally up the sync characters, make sure the sync matches. */
|
||||||
|
|
||||||
|
state->mac_sync[state->sync_count++] = state->curbyte;
|
||||||
|
if (state->sync_count >= 3) {
|
||||||
|
/* Test for sync sequence. It's one byte less than the # of
|
||||||
|
* leading zeros, to allow for the idle escape trick above to work
|
||||||
|
* in case of zero-biased noise.
|
||||||
|
*/
|
||||||
|
if ((state->mac_sync[0] == 0xAA) && (state->mac_sync[1] == 0x55) &&
|
||||||
|
(state->mac_sync[2] == 0x42)) {
|
||||||
|
// found the sync sequence, proceed to packet state
|
||||||
|
// osalDbgAssert(pktReady == 0,
|
||||||
|
// "Packet buffer full flag still set "
|
||||||
|
// "while new packet incoming\r\n");
|
||||||
|
if (debug_print_sync) printf("Found sync\n");
|
||||||
|
state->mstate = MAC_PACKET;
|
||||||
|
state->pkt_len = 0;
|
||||||
|
state->pkt_read = 0;
|
||||||
|
} else {
|
||||||
|
if (debug_print_sync)
|
||||||
|
printf("%02x %02x %02x not sync\n", state->mac_sync[0],
|
||||||
|
state->mac_sync[1], state->mac_sync[2]);
|
||||||
|
state->mstate = MAC_IDLE;
|
||||||
|
state->idle_zeros = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Move on to the next bit */
|
||||||
|
state->bitpos = 8;
|
||||||
|
state->curbyte = 0;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case MAC_PACKET:
|
||||||
|
/* If we haven't figured out the length, but we've read the entire
|
||||||
|
* header, figure out the length. Or exit the loop if it's not a
|
||||||
|
* valid packet.
|
||||||
|
*/
|
||||||
|
if (!state->pkt_len && state->pkt_read > sizeof(demod_pkt_header_t)) {
|
||||||
|
|
||||||
|
/* If the version number doesn't match, abandon ship. */
|
||||||
|
if ((pkt->header.version != PKT_VER_1) &&
|
||||||
|
(pkt->header.version != PKT_VER_2) &&
|
||||||
|
(pkt->header.version != PKT_VER_3)) {
|
||||||
|
if (debug_print_status) {
|
||||||
|
printf("Unrecognized packet version: %d\n", pkt->header.version);
|
||||||
|
}
|
||||||
|
goto make_idle;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pkt->header.type == PKTTYPE_CTRL)
|
||||||
|
state->pkt_len = CTRL_LEN;
|
||||||
|
else if (pkt->header.type == PKTTYPE_DATA)
|
||||||
|
state->pkt_len = DATA_LEN;
|
||||||
|
else {
|
||||||
|
/* Unrecognized packet type */
|
||||||
|
if (debug_print_status)
|
||||||
|
printf("Unrecognized packet header type %d\n",
|
||||||
|
pkt->header.type);
|
||||||
|
goto make_idle;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Load on the next bit. */
|
||||||
|
state->curbyte >>= 1;
|
||||||
|
state->bitpos--;
|
||||||
|
if (bit) {
|
||||||
|
state->curbyte |= 0x80;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* If we've finished this bit, add it to the packet. */
|
||||||
|
if (state->bitpos == 0) {
|
||||||
|
((uint8_t *)buffer)[state->pkt_read++] = state->curbyte;
|
||||||
|
state->bitpos = 8;
|
||||||
|
state->curbyte = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* If we've finished reading the packet, indicate it's ready */
|
||||||
|
if (state->pkt_len && state->pkt_read >= state->pkt_len) {
|
||||||
|
packet_done = 1; // flag that the packet is ready
|
||||||
|
goto make_idle;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
make_idle:
|
||||||
|
state->mstate = MAC_IDLE;
|
||||||
|
state->idle_zeros = 0;
|
||||||
|
return packet_done;
|
||||||
|
}
|
123
src/bpsk/mac.h
Normal file
123
src/bpsk/mac.h
Normal file
@ -0,0 +1,123 @@
|
|||||||
|
#ifndef __ORCHARD_MAC__
|
||||||
|
#define __ORCHARD_MAC__
|
||||||
|
|
||||||
|
#define PAYLOAD_LEN 256
|
||||||
|
|
||||||
|
#define MURMUR_SEED_BLOCK (0xdeadbeef)
|
||||||
|
#define MURMUR_SEED_TOTAL (0x32d0babe)
|
||||||
|
|
||||||
|
#ifdef __GNUC__
|
||||||
|
#define PACK(__Declaration__) __Declaration__ __attribute__((__packed__))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#define PACK(__Declaration__) \
|
||||||
|
__pragma(pack(push, 1)) __Declaration__ __pragma(pack(pop))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
PACK(struct demod_ph {
|
||||||
|
/* Protocol version */
|
||||||
|
uint8_t version;
|
||||||
|
|
||||||
|
/* Packet type */
|
||||||
|
uint8_t type;
|
||||||
|
});
|
||||||
|
typedef struct demod_ph demod_pkt_header_t;
|
||||||
|
|
||||||
|
PACK(struct demod_dp {
|
||||||
|
demod_pkt_header_t header;
|
||||||
|
|
||||||
|
/* Block number (offset is block * PAYLOAD_LEN) */
|
||||||
|
uint16_t block;
|
||||||
|
|
||||||
|
/* Payload contents */
|
||||||
|
uint8_t payload[PAYLOAD_LEN];
|
||||||
|
|
||||||
|
/* Hash of this data packet */
|
||||||
|
uint32_t hash;
|
||||||
|
});
|
||||||
|
typedef struct demod_dp demod_pkt_data_t;
|
||||||
|
|
||||||
|
PACK(struct demod_cp {
|
||||||
|
demod_pkt_header_t header;
|
||||||
|
|
||||||
|
/* Padding */
|
||||||
|
uint16_t reserved;
|
||||||
|
|
||||||
|
/* Total length of program in bytes (# blocks = ceil(length / blocksize) */
|
||||||
|
uint32_t length;
|
||||||
|
|
||||||
|
/* Lightweight data integrity hash, computed across "length"
|
||||||
|
* of program given above.
|
||||||
|
*/
|
||||||
|
uint32_t fullhash;
|
||||||
|
|
||||||
|
/* UID code for identifying a program uniquely, and globally */
|
||||||
|
uint8_t guid[16];
|
||||||
|
|
||||||
|
/* Hash check of /this/ packet */
|
||||||
|
uint32_t hash;
|
||||||
|
});
|
||||||
|
typedef struct demod_cp demod_pkt_ctrl_t;
|
||||||
|
|
||||||
|
PACK(union demod_packet {
|
||||||
|
demod_pkt_header_t header;
|
||||||
|
demod_pkt_ctrl_t ctrl_pkt;
|
||||||
|
demod_pkt_data_t data_pkt;
|
||||||
|
});
|
||||||
|
typedef union demod_packet demod_pkt_t;
|
||||||
|
|
||||||
|
// size of the largest packet we could receive
|
||||||
|
#define DATA_LEN (sizeof(demod_pkt_data_t))
|
||||||
|
#define CTRL_LEN (sizeof(demod_pkt_ctrl_t))
|
||||||
|
|
||||||
|
// bit 7 defines packet type on the version code (first byte received)
|
||||||
|
#define PKTTYPE_CTRL 0x01
|
||||||
|
#define PKTTYPE_DATA 0x02
|
||||||
|
|
||||||
|
#define PKT_VER_1 0x01
|
||||||
|
#define PKT_VER_2 0x02 /* Improved baud striping */
|
||||||
|
#define PKT_VER_3 0x03 /* Stuffed bits and transition-is-0 */
|
||||||
|
|
||||||
|
/// Internal state of the MAC
|
||||||
|
typedef enum current_mac_state {
|
||||||
|
/// Looking for a string of zeroes followed by a bit
|
||||||
|
MAC_IDLE = 0,
|
||||||
|
|
||||||
|
/// Found bits, looking for the sync word
|
||||||
|
MAC_SYNC = 1,
|
||||||
|
|
||||||
|
/// Found sync word, filling the packet buffer
|
||||||
|
MAC_PACKET = 2,
|
||||||
|
} current_mac_state_t;
|
||||||
|
|
||||||
|
struct mac_state {
|
||||||
|
/// Where we are inside the current bit
|
||||||
|
int bitpos; // Maybe default to 9?
|
||||||
|
|
||||||
|
/// Accumulator for the current bit
|
||||||
|
uint8_t curbyte;
|
||||||
|
|
||||||
|
/// Current state machine's state
|
||||||
|
current_mac_state_t mstate;
|
||||||
|
|
||||||
|
/// Length of the run of zeroes seen during MAC_IDLE
|
||||||
|
uint8_t idle_zeros;
|
||||||
|
|
||||||
|
/// Contents of the current sync byte
|
||||||
|
uint8_t mac_sync[4];
|
||||||
|
|
||||||
|
/// Number of sync bytes received so far
|
||||||
|
uint8_t sync_count;
|
||||||
|
|
||||||
|
/// Expected length of this packet
|
||||||
|
uint32_t pkt_len;
|
||||||
|
|
||||||
|
/// Number of bytes we've read so far
|
||||||
|
uint32_t pkt_read;
|
||||||
|
};
|
||||||
|
|
||||||
|
int mac_put_bit(struct mac_state *state, int bit, void *buffer,
|
||||||
|
unsigned int buffer_size);
|
||||||
|
|
||||||
|
#endif
|
133
src/bpsk/murmur3.c
Normal file
133
src/bpsk/murmur3.c
Normal file
@ -0,0 +1,133 @@
|
|||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// MurmurHash3 was written by Austin Appleby, and is placed in the public
|
||||||
|
// domain. The author hereby disclaims copyright to this source code.
|
||||||
|
|
||||||
|
// Note - The x86 and x64 versions do _not_ produce the same results, as the
|
||||||
|
// algorithms are optimized for their respective platforms. You can still
|
||||||
|
// compile and run any of them on any platform, but your performance with the
|
||||||
|
// non-native version will be less than optimal.
|
||||||
|
|
||||||
|
#include "murmur3.h"
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
#ifdef _MSC_FULL_VER
|
||||||
|
#define FORCE_INLINE static
|
||||||
|
#else
|
||||||
|
#define FORCE_INLINE inline __attribute__((always_inline))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
inline uint32_t rotl32 ( uint32_t x, int8_t r )
|
||||||
|
{
|
||||||
|
return (x << r) | (x >> (32 - r));
|
||||||
|
}
|
||||||
|
|
||||||
|
inline uint64_t rotl64 ( uint64_t x, int8_t r )
|
||||||
|
{
|
||||||
|
return (x << r) | (x >> (64 - r));
|
||||||
|
}
|
||||||
|
|
||||||
|
#define ROTL32(x,y)rotl32(x,y)
|
||||||
|
#define ROTL64(x,y)rotl64(x,y)
|
||||||
|
|
||||||
|
#define BIG_CONSTANT(x) (x##LLU)
|
||||||
|
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Block read - if your platform needs to do endian-swapping or can only
|
||||||
|
// handle aligned reads, do the conversion here
|
||||||
|
|
||||||
|
FORCE_INLINE uint32_t getblock32 ( const uint32_t * p, int i )
|
||||||
|
{
|
||||||
|
return p[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
FORCE_INLINE uint64_t getblock64 ( const uint64_t * p, int i )
|
||||||
|
{
|
||||||
|
return p[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Finalization mix - force all bits of a hash block to avalanche
|
||||||
|
|
||||||
|
FORCE_INLINE uint32_t fmix32 ( uint32_t h )
|
||||||
|
{
|
||||||
|
h ^= h >> 16;
|
||||||
|
h *= 0x85ebca6b;
|
||||||
|
h ^= h >> 13;
|
||||||
|
h *= 0xc2b2ae35;
|
||||||
|
h ^= h >> 16;
|
||||||
|
|
||||||
|
return h;
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------
|
||||||
|
|
||||||
|
FORCE_INLINE uint64_t fmix64 ( uint64_t k )
|
||||||
|
{
|
||||||
|
k ^= k >> 33;
|
||||||
|
k *= BIG_CONSTANT(0xff51afd7ed558ccd);
|
||||||
|
k ^= k >> 33;
|
||||||
|
k *= BIG_CONSTANT(0xc4ceb9fe1a85ec53);
|
||||||
|
k ^= k >> 33;
|
||||||
|
|
||||||
|
return k;
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
void MurmurHash3_x86_32 ( const void * key, int len,
|
||||||
|
uint32_t seed, void * out )
|
||||||
|
{
|
||||||
|
const uint8_t * data = (const uint8_t*)key;
|
||||||
|
const int nblocks = len / 4;
|
||||||
|
|
||||||
|
uint32_t h1 = seed;
|
||||||
|
|
||||||
|
const uint32_t c1 = 0xcc9e2d51;
|
||||||
|
const uint32_t c2 = 0x1b873593;
|
||||||
|
|
||||||
|
//----------
|
||||||
|
// body
|
||||||
|
|
||||||
|
const uint32_t * blocks = (const uint32_t *)(data + nblocks*4);
|
||||||
|
|
||||||
|
for(int i = -nblocks; i; i++)
|
||||||
|
{
|
||||||
|
uint32_t k1 = getblock32(blocks,i);
|
||||||
|
|
||||||
|
k1 *= c1;
|
||||||
|
k1 = ROTL32(k1,15);
|
||||||
|
k1 *= c2;
|
||||||
|
|
||||||
|
h1 ^= k1;
|
||||||
|
h1 = ROTL32(h1,13);
|
||||||
|
h1 = h1*5+0xe6546b64;
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------
|
||||||
|
// tail
|
||||||
|
|
||||||
|
const uint8_t * tail = (const uint8_t*)(data + nblocks*4);
|
||||||
|
|
||||||
|
uint32_t k1 = 0;
|
||||||
|
|
||||||
|
switch(len & 3)
|
||||||
|
{
|
||||||
|
case 3: k1 ^= tail[2] << 16; /* fall-through */
|
||||||
|
case 2: k1 ^= tail[1] << 8; /* fall-through */
|
||||||
|
case 1: k1 ^= tail[0];
|
||||||
|
k1 *= c1; k1 = ROTL32(k1,15); k1 *= c2; h1 ^= k1;
|
||||||
|
};
|
||||||
|
|
||||||
|
//----------
|
||||||
|
// finalization
|
||||||
|
|
||||||
|
h1 ^= len;
|
||||||
|
|
||||||
|
h1 = fmix32(h1);
|
||||||
|
|
||||||
|
*(uint32_t*)out = h1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
27
src/bpsk/murmur3.h
Normal file
27
src/bpsk/murmur3.h
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// MurmurHash3 was written by Austin Appleby, and is placed in the public
|
||||||
|
// domain. The author hereby disclaims copyright to this source code.
|
||||||
|
|
||||||
|
#ifndef _MURMURHASH3_H_
|
||||||
|
#define _MURMURHASH3_H_
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Platform-specific functions and macros
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void MurmurHash3_x86_32 ( const void * key, int len, uint32_t seed, void * out );
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#endif // _MURMURHASH3_H_
|
136
src/cmsis/include/arm_common_tables.h
Normal file
136
src/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/cmsis/include/arm_const_structs.h
Normal file
79
src/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
|
7548
src/cmsis/include/arm_math.h
Normal file
7548
src/cmsis/include/arm_math.h
Normal file
File diff suppressed because it is too large
Load Diff
734
src/cmsis/include/cmsis_armcc.h
Normal file
734
src/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/cmsis/include/cmsis_armcc_V6.h
Normal file
1800
src/cmsis/include/cmsis_armcc_V6.h
Normal file
File diff suppressed because it is too large
Load Diff
149
src/cmsis/include/cmsis_ccs.h
Normal file
149
src/cmsis/include/cmsis_ccs.h
Normal file
@ -0,0 +1,149 @@
|
|||||||
|
//*****************************************************************************
|
||||||
|
//
|
||||||
|
// cmsis_ccs.h - Include file containing #defines necessary to build the CMSIS
|
||||||
|
// dsp libraries using compiler intrinsics for the TMS470 compiler.
|
||||||
|
//
|
||||||
|
// Copyright (c) 2012 Texas Instruments Incorporated. All rights reserved.
|
||||||
|
// Software License Agreement
|
||||||
|
//
|
||||||
|
// Texas Instruments (TI) is supplying this software for use solely and
|
||||||
|
// exclusively on TI's microcontroller products. The software is owned by
|
||||||
|
// TI and/or its suppliers, and is protected under applicable copyright
|
||||||
|
// laws. You may not combine this software with "viral" open-source
|
||||||
|
// software in order to form a larger program.
|
||||||
|
//
|
||||||
|
// THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS.
|
||||||
|
// NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT
|
||||||
|
// NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
// A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. TI SHALL NOT, UNDER ANY
|
||||||
|
// CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
|
||||||
|
// DAMAGES, FOR ANY REASON WHATSOEVER.
|
||||||
|
//
|
||||||
|
// This is part of revision 8542 of the CMSIS DSP Application Note.
|
||||||
|
//
|
||||||
|
//*****************************************************************************
|
||||||
|
|
||||||
|
#ifndef CMSIS_CCS_H_
|
||||||
|
#define CMSIS_CCS_H_
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// v5e, v6, Cortex-M3, Cortex-M4, Cortex-R4, and Cortex-A8 compiler intrinsics
|
||||||
|
//
|
||||||
|
#define __CLZ _norm
|
||||||
|
#define __SXTB _sxtb
|
||||||
|
#define __SXTH _sxth
|
||||||
|
#define __UXTB _uxtb
|
||||||
|
#define __UXTH _uxth
|
||||||
|
// CCS supports intrinsics to take advantage of the shift operand left/right
|
||||||
|
// before saturation extension of SSAT, but CMSIS does not take advantage
|
||||||
|
// of those, so tell the compiler to use a sat & shift left with a shift
|
||||||
|
// value of 0 whenever it encounters an SSAT
|
||||||
|
#define __SSAT(VAL, BITPOS) \
|
||||||
|
_ssatl(VAL , 0, BITPOS)
|
||||||
|
|
||||||
|
//
|
||||||
|
// Only define M4 based intrinsics if we're not using an M4
|
||||||
|
//
|
||||||
|
#if defined (__TI_TMS470_V7M4__)
|
||||||
|
#define __ROR __ror
|
||||||
|
#define __SXTB16(src1) _sxtb16(src1,0) // The TI ARM compiler rotamt (2nd)
|
||||||
|
// argument set to zero, as not in the ARM compiler intrinsic
|
||||||
|
//
|
||||||
|
// V5E, V6, Cortex-M4, Cortex-R4, and Cortex-A8 compiler intrinsics
|
||||||
|
//
|
||||||
|
#define __QADD _sadd
|
||||||
|
#define __QDADD _sdadd
|
||||||
|
#define __QDSUB _sdsub
|
||||||
|
#define __SMLABB _smlabb
|
||||||
|
#define __SMLABT _smlabt
|
||||||
|
#define __SMLALBB _smlalbb
|
||||||
|
#define __SMLALBT _smlalbt
|
||||||
|
#define __SMLALTB _smlaltb
|
||||||
|
#define __SMLALTT _smlaltt
|
||||||
|
#define __SMLATB _smlatb
|
||||||
|
#define __SMLATT _smlatt
|
||||||
|
#define __SMLAWB _smlawb
|
||||||
|
#define __SMLAWT _smlawt
|
||||||
|
|
||||||
|
#define __SMULBB _smulbb
|
||||||
|
#define __SMULBT _smulbt
|
||||||
|
#define __SMULTB _smultb
|
||||||
|
#define __SMULTT _smultt
|
||||||
|
#define __SMULWB _smulwb
|
||||||
|
#define __SMULWT _smulwt
|
||||||
|
#define __QSUB _ssub
|
||||||
|
#define __SUBC _subc
|
||||||
|
|
||||||
|
//
|
||||||
|
// v6, Cortex-M4, Cortex-R4, and Cortex-A8 compiler intrinsics
|
||||||
|
//
|
||||||
|
#define __SHASX _shaddsubx
|
||||||
|
#define __SHSAX _shsubaddx
|
||||||
|
#define __PKHBT _pkhbt
|
||||||
|
#define __PKHTB _pkhtb
|
||||||
|
#define __QADD16 _qadd16
|
||||||
|
#define __QADD8 _qadd8
|
||||||
|
#define __QSUB16 _qsub16
|
||||||
|
#define __QSUB8 _qsub8
|
||||||
|
#define __QASX _saddsubx
|
||||||
|
#define __QSAX _qsubaddx
|
||||||
|
#define __SADD16 _sadd16
|
||||||
|
#define __SADD8 _sadd8
|
||||||
|
#define __SASX _saddsubx
|
||||||
|
#define __SEL _sel
|
||||||
|
#define __SHADD16 _shadd16
|
||||||
|
#define __SHADD8 _shadd8
|
||||||
|
#define __SHSUB16 _shsub16
|
||||||
|
#define __SHSUB8 _shsub8
|
||||||
|
#define __SMLAD _smlad
|
||||||
|
#define __SMLADX _smladx
|
||||||
|
#define __SMLALD _smlald
|
||||||
|
#define __SMLALDX _smlaldx
|
||||||
|
#define __SMLSD _smlsd
|
||||||
|
#define __SMLSDX _smlsdx
|
||||||
|
#define __SMLSLD _smlsld
|
||||||
|
#define __SMLSLDX _smlsldx
|
||||||
|
#define __SMMLA _smmla
|
||||||
|
#define __SMMLAR _smmlar
|
||||||
|
#define __SMMLS _smmls
|
||||||
|
#define __SMMLSR _smmlsr
|
||||||
|
#define __SMMUL _smmul
|
||||||
|
#define __SMMULR _smmulr
|
||||||
|
#define __SMUAD _smuad
|
||||||
|
#define __SMUADX _smuadx
|
||||||
|
#define __SMUSD _smusd
|
||||||
|
#define __SMUSDX _smusd
|
||||||
|
#define __SSAT16 _ssat16
|
||||||
|
#define __SSUB16 _ssub16
|
||||||
|
#define __SSUB8 _ssub8
|
||||||
|
#define __SSAX _ssubaddx
|
||||||
|
#define __SXTAB _sxtab
|
||||||
|
#define __SXTAB16 _sxtab16
|
||||||
|
#define __SXTAH _sxtah
|
||||||
|
#define __UMAAL _umaal
|
||||||
|
#define __UADD16 _uadd16
|
||||||
|
#define __UADD8 _uadd8
|
||||||
|
#define __UHADD16 _uhadd16
|
||||||
|
#define __UHADD8 _uhadd8
|
||||||
|
#define __UASX _uaddsubx
|
||||||
|
#define __UHSUB16 _uhsub16
|
||||||
|
#define __UHSUB8 _uhsub8
|
||||||
|
#define __UQADD16 _uqadd16
|
||||||
|
#define __UQADD8 _uqadd8
|
||||||
|
#define __UQASX _uqaddsubx
|
||||||
|
#define __UQSUB16 _uqsub16
|
||||||
|
#define __UQSUB8 _uqsub8
|
||||||
|
#define __UQSAX _uqsubaddx
|
||||||
|
#define __USAD8 _usad8
|
||||||
|
#define __USAT16 _usat16
|
||||||
|
#define __USUB16 _usub16
|
||||||
|
#define __USUB8 _usub8
|
||||||
|
#define __USAX _usubaddx
|
||||||
|
#define __UXTAB _uxtab
|
||||||
|
#define __UXTAB16 _uxtab16
|
||||||
|
#define __UXTAH _uxtah
|
||||||
|
#define __UXTB16 _uxtb16
|
||||||
|
#endif /*__TI_TMS470_V7M4__*/
|
||||||
|
|
||||||
|
#endif /*CMSIS_CCS_H_*/
|
1373
src/cmsis/include/cmsis_gcc.h
Normal file
1373
src/cmsis/include/cmsis_gcc.h
Normal file
File diff suppressed because it is too large
Load Diff
798
src/cmsis/include/core_cm0.h
Normal file
798
src/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/cmsis/include/core_cm0plus.h
Normal file
914
src/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/cmsis/include/core_cm3.h
Normal file
1763
src/cmsis/include/core_cm3.h
Normal file
File diff suppressed because it is too large
Load Diff
1937
src/cmsis/include/core_cm4.h
Normal file
1937
src/cmsis/include/core_cm4.h
Normal file
File diff suppressed because it is too large
Load Diff
2512
src/cmsis/include/core_cm7.h
Normal file
2512
src/cmsis/include/core_cm7.h
Normal file
File diff suppressed because it is too large
Load Diff
87
src/cmsis/include/core_cmFunc.h
Normal file
87
src/cmsis/include/core_cmFunc.h
Normal file
@ -0,0 +1,87 @@
|
|||||||
|
/**************************************************************************//**
|
||||||
|
* @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/cmsis/include/core_cmInstr.h
Normal file
87
src/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/cmsis/include/core_cmSimd.h
Normal file
96
src/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/cmsis/include/core_sc000.h
Normal file
926
src/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/cmsis/include/core_sc300.h
Normal file
1745
src/cmsis/include/core_sc300.h
Normal file
File diff suppressed because it is too large
Load Diff
150
src/cmsis/source/arm_add_f32.c
Normal file
150
src/cmsis/source/arm_add_f32.c
Normal file
@ -0,0 +1,150 @@
|
|||||||
|
/* ----------------------------------------------------------------------
|
||||||
|
* Copyright (C) 2010-2014 ARM Limited. All rights reserved.
|
||||||
|
*
|
||||||
|
* $Date: 19. March 2015
|
||||||
|
* $Revision: V.1.4.5
|
||||||
|
*
|
||||||
|
* Project: CMSIS DSP Library
|
||||||
|
* Title: arm_add_f32.c
|
||||||
|
*
|
||||||
|
* Description: Floating-point vector addition.
|
||||||
|
*
|
||||||
|
* Target Processor: Cortex-M4/Cortex-M3/Cortex-M0
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
* ---------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
#include "arm_math.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ingroup groupMath
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @defgroup BasicAdd Vector Addition
|
||||||
|
*
|
||||||
|
* Element-by-element addition of two vectors.
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
* pDst[n] = pSrcA[n] + pSrcB[n], 0 <= n < blockSize.
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* There are separate functions for floating-point, Q7, Q15, and Q31 data types.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @addtogroup BasicAdd
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Floating-point vector addition.
|
||||||
|
* @param[in] *pSrcA points to the first input vector
|
||||||
|
* @param[in] *pSrcB points to the second input vector
|
||||||
|
* @param[out] *pDst points to the output vector
|
||||||
|
* @param[in] blockSize number of samples in each vector
|
||||||
|
* @return none.
|
||||||
|
*/
|
||||||
|
|
||||||
|
void arm_add_f32(
|
||||||
|
float32_t * pSrcA,
|
||||||
|
float32_t * pSrcB,
|
||||||
|
float32_t * pDst,
|
||||||
|
uint32_t blockSize)
|
||||||
|
{
|
||||||
|
uint32_t blkCnt; /* loop counter */
|
||||||
|
|
||||||
|
#ifndef ARM_MATH_CM0_FAMILY
|
||||||
|
|
||||||
|
/* Run the below code for Cortex-M4 and Cortex-M3 */
|
||||||
|
float32_t inA1, inA2, inA3, inA4; /* temporary input variabels */
|
||||||
|
float32_t inB1, inB2, inB3, inB4; /* temporary input variables */
|
||||||
|
|
||||||
|
/*loop Unrolling */
|
||||||
|
blkCnt = blockSize >> 2u;
|
||||||
|
|
||||||
|
/* First part of the processing with loop unrolling. Compute 4 outputs at a time.
|
||||||
|
** a second loop below computes the remaining 1 to 3 samples. */
|
||||||
|
while(blkCnt > 0u)
|
||||||
|
{
|
||||||
|
/* C = A + B */
|
||||||
|
/* Add and then store the results in the destination buffer. */
|
||||||
|
|
||||||
|
/* read four inputs from sourceA and four inputs from sourceB */
|
||||||
|
inA1 = *pSrcA;
|
||||||
|
inB1 = *pSrcB;
|
||||||
|
inA2 = *(pSrcA + 1);
|
||||||
|
inB2 = *(pSrcB + 1);
|
||||||
|
inA3 = *(pSrcA + 2);
|
||||||
|
inB3 = *(pSrcB + 2);
|
||||||
|
inA4 = *(pSrcA + 3);
|
||||||
|
inB4 = *(pSrcB + 3);
|
||||||
|
|
||||||
|
/* C = A + B */
|
||||||
|
/* add and store result to destination */
|
||||||
|
*pDst = inA1 + inB1;
|
||||||
|
*(pDst + 1) = inA2 + inB2;
|
||||||
|
*(pDst + 2) = inA3 + inB3;
|
||||||
|
*(pDst + 3) = inA4 + inB4;
|
||||||
|
|
||||||
|
/* update pointers to process next samples */
|
||||||
|
pSrcA += 4u;
|
||||||
|
pSrcB += 4u;
|
||||||
|
pDst += 4u;
|
||||||
|
|
||||||
|
|
||||||
|
/* Decrement the loop counter */
|
||||||
|
blkCnt--;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* If the blockSize is not a multiple of 4, compute any remaining output samples here.
|
||||||
|
** No loop unrolling is used. */
|
||||||
|
blkCnt = blockSize % 0x4u;
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
/* Run the below code for Cortex-M0 */
|
||||||
|
|
||||||
|
/* Initialize blkCnt with number of samples */
|
||||||
|
blkCnt = blockSize;
|
||||||
|
|
||||||
|
#endif /* #ifndef ARM_MATH_CM0_FAMILY */
|
||||||
|
|
||||||
|
while(blkCnt > 0u)
|
||||||
|
{
|
||||||
|
/* C = A + B */
|
||||||
|
/* Add and then store the results in the destination buffer. */
|
||||||
|
*pDst++ = (*pSrcA++) + (*pSrcB++);
|
||||||
|
|
||||||
|
/* Decrement the loop counter */
|
||||||
|
blkCnt--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @} end of BasicAdd group
|
||||||
|
*/
|
27251
src/cmsis/source/arm_common_tables.c
Normal file
27251
src/cmsis/source/arm_common_tables.c
Normal file
File diff suppressed because it is too large
Load Diff
127
src/cmsis/source/arm_cos_f32.c
Normal file
127
src/cmsis/source/arm_cos_f32.c
Normal file
@ -0,0 +1,127 @@
|
|||||||
|
/* ----------------------------------------------------------------------
|
||||||
|
* Copyright (C) 2010-2014 ARM Limited. All rights reserved.
|
||||||
|
*
|
||||||
|
* $Date: 21. September 2015
|
||||||
|
* $Revision: V.1.4.5 a
|
||||||
|
*
|
||||||
|
* Project: CMSIS DSP Library
|
||||||
|
* Title: arm_cos_f32.c
|
||||||
|
*
|
||||||
|
* Description: Fast cosine calculation for floating-point values.
|
||||||
|
*
|
||||||
|
* Target Processor: Cortex-M4/Cortex-M3/Cortex-M0
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
* -------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
#include "arm_math.h"
|
||||||
|
#include "arm_common_tables.h"
|
||||||
|
/**
|
||||||
|
* @ingroup groupFastMath
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @defgroup cos Cosine
|
||||||
|
*
|
||||||
|
* Computes the trigonometric cosine function using a combination of table lookup
|
||||||
|
* and linear interpolation. There are separate functions for
|
||||||
|
* Q15, Q31, and floating-point data types.
|
||||||
|
* The input to the floating-point version is in radians while the
|
||||||
|
* fixed-point Q15 and Q31 have a scaled input with the range
|
||||||
|
* [0 +0.9999] mapping to [0 2*pi). The fixed-point range is chosen so that a
|
||||||
|
* value of 2*pi wraps around to 0.
|
||||||
|
*
|
||||||
|
* The implementation is based on table lookup using 256 values together with linear interpolation.
|
||||||
|
* The steps used are:
|
||||||
|
* -# Calculation of the nearest integer table index
|
||||||
|
* -# Compute the fractional portion (fract) of the table index.
|
||||||
|
* -# The final result equals <code>(1.0f-fract)*a + fract*b;</code>
|
||||||
|
*
|
||||||
|
* where
|
||||||
|
* <pre>
|
||||||
|
* b=Table[index+0];
|
||||||
|
* c=Table[index+1];
|
||||||
|
* </pre>
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @addtogroup cos
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Fast approximation to the trigonometric cosine function for floating-point data.
|
||||||
|
* @param[in] x input value in radians.
|
||||||
|
* @return cos(x).
|
||||||
|
*/
|
||||||
|
|
||||||
|
float32_t arm_cos_f32(
|
||||||
|
float32_t x)
|
||||||
|
{
|
||||||
|
float32_t cosVal, fract, in; /* Temporary variables for input, output */
|
||||||
|
uint16_t index; /* Index variable */
|
||||||
|
float32_t a, b; /* Two nearest output values */
|
||||||
|
int32_t n;
|
||||||
|
float32_t findex;
|
||||||
|
|
||||||
|
/* input x is in radians */
|
||||||
|
/* Scale the input to [0 1] range from [0 2*PI] , divide input by 2*pi, add 0.25 (pi/2) to read sine table */
|
||||||
|
in = x * 0.159154943092f + 0.25f;
|
||||||
|
|
||||||
|
/* Calculation of floor value of input */
|
||||||
|
n = (int32_t) in;
|
||||||
|
|
||||||
|
/* Make negative values towards -infinity */
|
||||||
|
if(in < 0.0f)
|
||||||
|
{
|
||||||
|
n--;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Map input value to [0 1] */
|
||||||
|
in = in - (float32_t) n;
|
||||||
|
|
||||||
|
/* Calculation of index of the table */
|
||||||
|
findex = (float32_t) FAST_MATH_TABLE_SIZE * in;
|
||||||
|
index = ((uint16_t)findex) & 0x1ff;
|
||||||
|
|
||||||
|
/* fractional value calculation */
|
||||||
|
fract = findex - (float32_t) index;
|
||||||
|
|
||||||
|
/* Read two nearest values of input value from the cos table */
|
||||||
|
a = sinTable_f32[index];
|
||||||
|
b = sinTable_f32[index+1];
|
||||||
|
|
||||||
|
/* Linear interpolation process */
|
||||||
|
cosVal = (1.0f-fract)*a + fract*b;
|
||||||
|
|
||||||
|
/* Return the output value */
|
||||||
|
return (cosVal);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @} end of cos group
|
||||||
|
*/
|
997
src/cmsis/source/arm_fir_f32.c
Normal file
997
src/cmsis/source/arm_fir_f32.c
Normal file
@ -0,0 +1,997 @@
|
|||||||
|
/* ----------------------------------------------------------------------
|
||||||
|
* Copyright (C) 2010-2014 ARM Limited. All rights reserved.
|
||||||
|
*
|
||||||
|
* $Date: 19. March 2015
|
||||||
|
* $Revision: V.1.4.5
|
||||||
|
*
|
||||||
|
* Project: CMSIS DSP Library
|
||||||
|
* Title: arm_fir_f32.c
|
||||||
|
*
|
||||||
|
* Description: Floating-point FIR filter processing function.
|
||||||
|
*
|
||||||
|
* Target Processor: Cortex-M4/Cortex-M3/Cortex-M0
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
* -------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
#include "arm_math.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ingroup groupFilters
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @defgroup FIR Finite Impulse Response (FIR) Filters
|
||||||
|
*
|
||||||
|
* This set of functions implements Finite Impulse Response (FIR) filters
|
||||||
|
* for Q7, Q15, Q31, and floating-point data types. Fast versions of Q15 and Q31 are also provided.
|
||||||
|
* The functions operate on blocks of input and output data and each call to the function processes
|
||||||
|
* <code>blockSize</code> samples through the filter. <code>pSrc</code> and
|
||||||
|
* <code>pDst</code> points to input and output arrays containing <code>blockSize</code> values.
|
||||||
|
*
|
||||||
|
* \par Algorithm:
|
||||||
|
* The FIR filter algorithm is based upon a sequence of multiply-accumulate (MAC) operations.
|
||||||
|
* Each filter coefficient <code>b[n]</code> is multiplied by a state variable which equals a previous input sample <code>x[n]</code>.
|
||||||
|
* <pre>
|
||||||
|
* y[n] = b[0] * x[n] + b[1] * x[n-1] + b[2] * x[n-2] + ...+ b[numTaps-1] * x[n-numTaps+1]
|
||||||
|
* </pre>
|
||||||
|
* \par
|
||||||
|
* \image html FIR.gif "Finite Impulse Response filter"
|
||||||
|
* \par
|
||||||
|
* <code>pCoeffs</code> points to a coefficient array of size <code>numTaps</code>.
|
||||||
|
* Coefficients are stored in time reversed order.
|
||||||
|
* \par
|
||||||
|
* <pre>
|
||||||
|
* {b[numTaps-1], b[numTaps-2], b[N-2], ..., b[1], b[0]}
|
||||||
|
* </pre>
|
||||||
|
* \par
|
||||||
|
* <code>pState</code> points to a state array of size <code>numTaps + blockSize - 1</code>.
|
||||||
|
* Samples in the state buffer are stored in the following order.
|
||||||
|
* \par
|
||||||
|
* <pre>
|
||||||
|
* {x[n-numTaps+1], x[n-numTaps], x[n-numTaps-1], x[n-numTaps-2]....x[0], x[1], ..., x[blockSize-1]}
|
||||||
|
* </pre>
|
||||||
|
* \par
|
||||||
|
* Note that the length of the state buffer exceeds the length of the coefficient array by <code>blockSize-1</code>.
|
||||||
|
* The increased state buffer length allows circular addressing, which is traditionally used in the FIR filters,
|
||||||
|
* to be avoided and yields a significant speed improvement.
|
||||||
|
* The state variables are updated after each block of data is processed; the coefficients are untouched.
|
||||||
|
* \par Instance Structure
|
||||||
|
* The coefficients and state variables for a filter are stored together in an instance data structure.
|
||||||
|
* A separate instance structure must be defined for each filter.
|
||||||
|
* Coefficient arrays may be shared among several instances while state variable arrays cannot be shared.
|
||||||
|
* There are separate instance structure declarations for each of the 4 supported data types.
|
||||||
|
*
|
||||||
|
* \par Initialization Functions
|
||||||
|
* There is also an associated initialization function for each data type.
|
||||||
|
* The initialization function performs the following operations:
|
||||||
|
* - Sets the values of the internal structure fields.
|
||||||
|
* - Zeros out the values in the state buffer.
|
||||||
|
* To do this manually without calling the init function, assign the follow subfields of the instance structure:
|
||||||
|
* numTaps, pCoeffs, pState. Also set all of the values in pState to zero.
|
||||||
|
*
|
||||||
|
* \par
|
||||||
|
* Use of the initialization function is optional.
|
||||||
|
* However, if the initialization function is used, then the instance structure cannot be placed into a const data section.
|
||||||
|
* To place an instance structure into a const data section, the instance structure must be manually initialized.
|
||||||
|
* Set the values in the state buffer to zeros before static initialization.
|
||||||
|
* The code below statically initializes each of the 4 different data type filter instance structures
|
||||||
|
* <pre>
|
||||||
|
*arm_fir_instance_f32 S = {numTaps, pState, pCoeffs};
|
||||||
|
*arm_fir_instance_q31 S = {numTaps, pState, pCoeffs};
|
||||||
|
*arm_fir_instance_q15 S = {numTaps, pState, pCoeffs};
|
||||||
|
*arm_fir_instance_q7 S = {numTaps, pState, pCoeffs};
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* where <code>numTaps</code> is the number of filter coefficients in the filter; <code>pState</code> is the address of the state buffer;
|
||||||
|
* <code>pCoeffs</code> is the address of the coefficient buffer.
|
||||||
|
*
|
||||||
|
* \par Fixed-Point Behavior
|
||||||
|
* Care must be taken when using the fixed-point versions of the FIR filter functions.
|
||||||
|
* In particular, the overflow and saturation behavior of the accumulator used in each function must be considered.
|
||||||
|
* Refer to the function specific documentation below for usage guidelines.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @addtogroup FIR
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param[in] *S points to an instance of the floating-point FIR filter structure.
|
||||||
|
* @param[in] *pSrc points to the block of input data.
|
||||||
|
* @param[out] *pDst points to the block of output data.
|
||||||
|
* @param[in] blockSize number of samples to process per call.
|
||||||
|
* @return none.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if defined(ARM_MATH_CM7)
|
||||||
|
|
||||||
|
void arm_fir_f32(
|
||||||
|
const arm_fir_instance_f32 * S,
|
||||||
|
float32_t * pSrc,
|
||||||
|
float32_t * pDst,
|
||||||
|
uint32_t blockSize)
|
||||||
|
{
|
||||||
|
float32_t *pState = S->pState; /* State pointer */
|
||||||
|
float32_t *pCoeffs = S->pCoeffs; /* Coefficient pointer */
|
||||||
|
float32_t *pStateCurnt; /* Points to the current sample of the state */
|
||||||
|
float32_t *px, *pb; /* Temporary pointers for state and coefficient buffers */
|
||||||
|
float32_t acc0, acc1, acc2, acc3, acc4, acc5, acc6, acc7; /* Accumulators */
|
||||||
|
float32_t x0, x1, x2, x3, x4, x5, x6, x7, c0; /* Temporary variables to hold state and coefficient values */
|
||||||
|
uint32_t numTaps = S->numTaps; /* Number of filter coefficients in the filter */
|
||||||
|
uint32_t i, tapCnt, blkCnt; /* Loop counters */
|
||||||
|
|
||||||
|
/* S->pState points to state array which contains previous frame (numTaps - 1) samples */
|
||||||
|
/* pStateCurnt points to the location where the new input data should be written */
|
||||||
|
pStateCurnt = &(S->pState[(numTaps - 1u)]);
|
||||||
|
|
||||||
|
/* Apply loop unrolling and compute 8 output values simultaneously.
|
||||||
|
* The variables acc0 ... acc7 hold output values that are being computed:
|
||||||
|
*
|
||||||
|
* acc0 = b[numTaps-1] * x[n-numTaps-1] + b[numTaps-2] * x[n-numTaps-2] + b[numTaps-3] * x[n-numTaps-3] +...+ b[0] * x[0]
|
||||||
|
* acc1 = b[numTaps-1] * x[n-numTaps] + b[numTaps-2] * x[n-numTaps-1] + b[numTaps-3] * x[n-numTaps-2] +...+ b[0] * x[1]
|
||||||
|
* acc2 = b[numTaps-1] * x[n-numTaps+1] + b[numTaps-2] * x[n-numTaps] + b[numTaps-3] * x[n-numTaps-1] +...+ b[0] * x[2]
|
||||||
|
* acc3 = b[numTaps-1] * x[n-numTaps+2] + b[numTaps-2] * x[n-numTaps+1] + b[numTaps-3] * x[n-numTaps] +...+ b[0] * x[3]
|
||||||
|
*/
|
||||||
|
blkCnt = blockSize >> 3;
|
||||||
|
|
||||||
|
/* First part of the processing with loop unrolling. Compute 8 outputs at a time.
|
||||||
|
** a second loop below computes the remaining 1 to 7 samples. */
|
||||||
|
while(blkCnt > 0u)
|
||||||
|
{
|
||||||
|
/* Copy four new input samples into the state buffer */
|
||||||
|
*pStateCurnt++ = *pSrc++;
|
||||||
|
*pStateCurnt++ = *pSrc++;
|
||||||
|
*pStateCurnt++ = *pSrc++;
|
||||||
|
*pStateCurnt++ = *pSrc++;
|
||||||
|
|
||||||
|
/* Set all accumulators to zero */
|
||||||
|
acc0 = 0.0f;
|
||||||
|
acc1 = 0.0f;
|
||||||
|
acc2 = 0.0f;
|
||||||
|
acc3 = 0.0f;
|
||||||
|
acc4 = 0.0f;
|
||||||
|
acc5 = 0.0f;
|
||||||
|
acc6 = 0.0f;
|
||||||
|
acc7 = 0.0f;
|
||||||
|
|
||||||
|
/* Initialize state pointer */
|
||||||
|
px = pState;
|
||||||
|
|
||||||
|
/* Initialize coeff pointer */
|
||||||
|
pb = (pCoeffs);
|
||||||
|
|
||||||
|
/* This is separated from the others to avoid
|
||||||
|
* a call to __aeabi_memmove which would be slower
|
||||||
|
*/
|
||||||
|
*pStateCurnt++ = *pSrc++;
|
||||||
|
*pStateCurnt++ = *pSrc++;
|
||||||
|
*pStateCurnt++ = *pSrc++;
|
||||||
|
*pStateCurnt++ = *pSrc++;
|
||||||
|
|
||||||
|
/* Read the first seven samples from the state buffer: x[n-numTaps], x[n-numTaps-1], x[n-numTaps-2] */
|
||||||
|
x0 = *px++;
|
||||||
|
x1 = *px++;
|
||||||
|
x2 = *px++;
|
||||||
|
x3 = *px++;
|
||||||
|
x4 = *px++;
|
||||||
|
x5 = *px++;
|
||||||
|
x6 = *px++;
|
||||||
|
|
||||||
|
/* Loop unrolling. Process 8 taps at a time. */
|
||||||
|
tapCnt = numTaps >> 3u;
|
||||||
|
|
||||||
|
/* Loop over the number of taps. Unroll by a factor of 8.
|
||||||
|
** Repeat until we've computed numTaps-8 coefficients. */
|
||||||
|
while(tapCnt > 0u)
|
||||||
|
{
|
||||||
|
/* Read the b[numTaps-1] coefficient */
|
||||||
|
c0 = *(pb++);
|
||||||
|
|
||||||
|
/* Read x[n-numTaps-3] sample */
|
||||||
|
x7 = *(px++);
|
||||||
|
|
||||||
|
/* acc0 += b[numTaps-1] * x[n-numTaps] */
|
||||||
|
acc0 += x0 * c0;
|
||||||
|
|
||||||
|
/* acc1 += b[numTaps-1] * x[n-numTaps-1] */
|
||||||
|
acc1 += x1 * c0;
|
||||||
|
|
||||||
|
/* acc2 += b[numTaps-1] * x[n-numTaps-2] */
|
||||||
|
acc2 += x2 * c0;
|
||||||
|
|
||||||
|
/* acc3 += b[numTaps-1] * x[n-numTaps-3] */
|
||||||
|
acc3 += x3 * c0;
|
||||||
|
|
||||||
|
/* acc4 += b[numTaps-1] * x[n-numTaps-4] */
|
||||||
|
acc4 += x4 * c0;
|
||||||
|
|
||||||
|
/* acc1 += b[numTaps-1] * x[n-numTaps-5] */
|
||||||
|
acc5 += x5 * c0;
|
||||||
|
|
||||||
|
/* acc2 += b[numTaps-1] * x[n-numTaps-6] */
|
||||||
|
acc6 += x6 * c0;
|
||||||
|
|
||||||
|
/* acc3 += b[numTaps-1] * x[n-numTaps-7] */
|
||||||
|
acc7 += x7 * c0;
|
||||||
|
|
||||||
|
/* Read the b[numTaps-2] coefficient */
|
||||||
|
c0 = *(pb++);
|
||||||
|
|
||||||
|
/* Read x[n-numTaps-4] sample */
|
||||||
|
x0 = *(px++);
|
||||||
|
|
||||||
|
/* Perform the multiply-accumulate */
|
||||||
|
acc0 += x1 * c0;
|
||||||
|
acc1 += x2 * c0;
|
||||||
|
acc2 += x3 * c0;
|
||||||
|
acc3 += x4 * c0;
|
||||||
|
acc4 += x5 * c0;
|
||||||
|
acc5 += x6 * c0;
|
||||||
|
acc6 += x7 * c0;
|
||||||
|
acc7 += x0 * c0;
|
||||||
|
|
||||||
|
/* Read the b[numTaps-3] coefficient */
|
||||||
|
c0 = *(pb++);
|
||||||
|
|
||||||
|
/* Read x[n-numTaps-5] sample */
|
||||||
|
x1 = *(px++);
|
||||||
|
|
||||||
|
/* Perform the multiply-accumulates */
|
||||||
|
acc0 += x2 * c0;
|
||||||
|
acc1 += x3 * c0;
|
||||||
|
acc2 += x4 * c0;
|
||||||
|
acc3 += x5 * c0;
|
||||||
|
acc4 += x6 * c0;
|
||||||
|
acc5 += x7 * c0;
|
||||||
|
acc6 += x0 * c0;
|
||||||
|
acc7 += x1 * c0;
|
||||||
|
|
||||||
|
/* Read the b[numTaps-4] coefficient */
|
||||||
|
c0 = *(pb++);
|
||||||
|
|
||||||
|
/* Read x[n-numTaps-6] sample */
|
||||||
|
x2 = *(px++);
|
||||||
|
|
||||||
|
/* Perform the multiply-accumulates */
|
||||||
|
acc0 += x3 * c0;
|
||||||
|
acc1 += x4 * c0;
|
||||||
|
acc2 += x5 * c0;
|
||||||
|
acc3 += x6 * c0;
|
||||||
|
acc4 += x7 * c0;
|
||||||
|
acc5 += x0 * c0;
|
||||||
|
acc6 += x1 * c0;
|
||||||
|
acc7 += x2 * c0;
|
||||||
|
|
||||||
|
/* Read the b[numTaps-4] coefficient */
|
||||||
|
c0 = *(pb++);
|
||||||
|
|
||||||
|
/* Read x[n-numTaps-6] sample */
|
||||||
|
x3 = *(px++);
|
||||||
|
/* Perform the multiply-accumulates */
|
||||||
|
acc0 += x4 * c0;
|
||||||
|
acc1 += x5 * c0;
|
||||||
|
acc2 += x6 * c0;
|
||||||
|
acc3 += x7 * c0;
|
||||||
|
acc4 += x0 * c0;
|
||||||
|
acc5 += x1 * c0;
|
||||||
|
acc6 += x2 * c0;
|
||||||
|
acc7 += x3 * c0;
|
||||||
|
|
||||||
|
/* Read the b[numTaps-4] coefficient */
|
||||||
|
c0 = *(pb++);
|
||||||
|
|
||||||
|
/* Read x[n-numTaps-6] sample */
|
||||||
|
x4 = *(px++);
|
||||||
|
|
||||||
|
/* Perform the multiply-accumulates */
|
||||||
|
acc0 += x5 * c0;
|
||||||
|
acc1 += x6 * c0;
|
||||||
|
acc2 += x7 * c0;
|
||||||
|
acc3 += x0 * c0;
|
||||||
|
acc4 += x1 * c0;
|
||||||
|
acc5 += x2 * c0;
|
||||||
|
acc6 += x3 * c0;
|
||||||
|
acc7 += x4 * c0;
|
||||||
|
|
||||||
|
/* Read the b[numTaps-4] coefficient */
|
||||||
|
c0 = *(pb++);
|
||||||
|
|
||||||
|
/* Read x[n-numTaps-6] sample */
|
||||||
|
x5 = *(px++);
|
||||||
|
|
||||||
|
/* Perform the multiply-accumulates */
|
||||||
|
acc0 += x6 * c0;
|
||||||
|
acc1 += x7 * c0;
|
||||||
|
acc2 += x0 * c0;
|
||||||
|
acc3 += x1 * c0;
|
||||||
|
acc4 += x2 * c0;
|
||||||
|
acc5 += x3 * c0;
|
||||||
|
acc6 += x4 * c0;
|
||||||
|
acc7 += x5 * c0;
|
||||||
|
|
||||||
|
/* Read the b[numTaps-4] coefficient */
|
||||||
|
c0 = *(pb++);
|
||||||
|
|
||||||
|
/* Read x[n-numTaps-6] sample */
|
||||||
|
x6 = *(px++);
|
||||||
|
|
||||||
|
/* Perform the multiply-accumulates */
|
||||||
|
acc0 += x7 * c0;
|
||||||
|
acc1 += x0 * c0;
|
||||||
|
acc2 += x1 * c0;
|
||||||
|
acc3 += x2 * c0;
|
||||||
|
acc4 += x3 * c0;
|
||||||
|
acc5 += x4 * c0;
|
||||||
|
acc6 += x5 * c0;
|
||||||
|
acc7 += x6 * c0;
|
||||||
|
|
||||||
|
tapCnt--;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* If the filter length is not a multiple of 8, compute the remaining filter taps */
|
||||||
|
tapCnt = numTaps % 0x8u;
|
||||||
|
|
||||||
|
while(tapCnt > 0u)
|
||||||
|
{
|
||||||
|
/* Read coefficients */
|
||||||
|
c0 = *(pb++);
|
||||||
|
|
||||||
|
/* Fetch 1 state variable */
|
||||||
|
x7 = *(px++);
|
||||||
|
|
||||||
|
/* Perform the multiply-accumulates */
|
||||||
|
acc0 += x0 * c0;
|
||||||
|
acc1 += x1 * c0;
|
||||||
|
acc2 += x2 * c0;
|
||||||
|
acc3 += x3 * c0;
|
||||||
|
acc4 += x4 * c0;
|
||||||
|
acc5 += x5 * c0;
|
||||||
|
acc6 += x6 * c0;
|
||||||
|
acc7 += x7 * c0;
|
||||||
|
|
||||||
|
/* Reuse the present sample states for next sample */
|
||||||
|
x0 = x1;
|
||||||
|
x1 = x2;
|
||||||
|
x2 = x3;
|
||||||
|
x3 = x4;
|
||||||
|
x4 = x5;
|
||||||
|
x5 = x6;
|
||||||
|
x6 = x7;
|
||||||
|
|
||||||
|
/* Decrement the loop counter */
|
||||||
|
tapCnt--;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Advance the state pointer by 8 to process the next group of 8 samples */
|
||||||
|
pState = pState + 8;
|
||||||
|
|
||||||
|
/* The results in the 8 accumulators, store in the destination buffer. */
|
||||||
|
*pDst++ = acc0;
|
||||||
|
*pDst++ = acc1;
|
||||||
|
*pDst++ = acc2;
|
||||||
|
*pDst++ = acc3;
|
||||||
|
*pDst++ = acc4;
|
||||||
|
*pDst++ = acc5;
|
||||||
|
*pDst++ = acc6;
|
||||||
|
*pDst++ = acc7;
|
||||||
|
|
||||||
|
blkCnt--;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* If the blockSize is not a multiple of 8, compute any remaining output samples here.
|
||||||
|
** No loop unrolling is used. */
|
||||||
|
blkCnt = blockSize % 0x8u;
|
||||||
|
|
||||||
|
while(blkCnt > 0u)
|
||||||
|
{
|
||||||
|
/* Copy one sample at a time into state buffer */
|
||||||
|
*pStateCurnt++ = *pSrc++;
|
||||||
|
|
||||||
|
/* Set the accumulator to zero */
|
||||||
|
acc0 = 0.0f;
|
||||||
|
|
||||||
|
/* Initialize state pointer */
|
||||||
|
px = pState;
|
||||||
|
|
||||||
|
/* Initialize Coefficient pointer */
|
||||||
|
pb = (pCoeffs);
|
||||||
|
|
||||||
|
i = numTaps;
|
||||||
|
|
||||||
|
/* Perform the multiply-accumulates */
|
||||||
|
do
|
||||||
|
{
|
||||||
|
acc0 += *px++ * *pb++;
|
||||||
|
i--;
|
||||||
|
|
||||||
|
} while(i > 0u);
|
||||||
|
|
||||||
|
/* The result is store in the destination buffer. */
|
||||||
|
*pDst++ = acc0;
|
||||||
|
|
||||||
|
/* Advance state pointer by 1 for the next sample */
|
||||||
|
pState = pState + 1;
|
||||||
|
|
||||||
|
blkCnt--;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Processing is complete.
|
||||||
|
** Now copy the last numTaps - 1 samples to the start of the state buffer.
|
||||||
|
** This prepares the state buffer for the next function call. */
|
||||||
|
|
||||||
|
/* Points to the start of the state buffer */
|
||||||
|
pStateCurnt = S->pState;
|
||||||
|
|
||||||
|
tapCnt = (numTaps - 1u) >> 2u;
|
||||||
|
|
||||||
|
/* copy data */
|
||||||
|
while(tapCnt > 0u)
|
||||||
|
{
|
||||||
|
*pStateCurnt++ = *pState++;
|
||||||
|
*pStateCurnt++ = *pState++;
|
||||||
|
*pStateCurnt++ = *pState++;
|
||||||
|
*pStateCurnt++ = *pState++;
|
||||||
|
|
||||||
|
/* Decrement the loop counter */
|
||||||
|
tapCnt--;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Calculate remaining number of copies */
|
||||||
|
tapCnt = (numTaps - 1u) % 0x4u;
|
||||||
|
|
||||||
|
/* Copy the remaining q31_t data */
|
||||||
|
while(tapCnt > 0u)
|
||||||
|
{
|
||||||
|
*pStateCurnt++ = *pState++;
|
||||||
|
|
||||||
|
/* Decrement the loop counter */
|
||||||
|
tapCnt--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#elif defined(ARM_MATH_CM0_FAMILY)
|
||||||
|
|
||||||
|
void arm_fir_f32(
|
||||||
|
const arm_fir_instance_f32 * S,
|
||||||
|
float32_t * pSrc,
|
||||||
|
float32_t * pDst,
|
||||||
|
uint32_t blockSize)
|
||||||
|
{
|
||||||
|
float32_t *pState = S->pState; /* State pointer */
|
||||||
|
float32_t *pCoeffs = S->pCoeffs; /* Coefficient pointer */
|
||||||
|
float32_t *pStateCurnt; /* Points to the current sample of the state */
|
||||||
|
float32_t *px, *pb; /* Temporary pointers for state and coefficient buffers */
|
||||||
|
uint32_t numTaps = S->numTaps; /* Number of filter coefficients in the filter */
|
||||||
|
uint32_t i, tapCnt, blkCnt; /* Loop counters */
|
||||||
|
|
||||||
|
/* Run the below code for Cortex-M0 */
|
||||||
|
|
||||||
|
float32_t acc;
|
||||||
|
|
||||||
|
/* S->pState points to state array which contains previous frame (numTaps - 1) samples */
|
||||||
|
/* pStateCurnt points to the location where the new input data should be written */
|
||||||
|
pStateCurnt = &(S->pState[(numTaps - 1u)]);
|
||||||
|
|
||||||
|
/* Initialize blkCnt with blockSize */
|
||||||
|
blkCnt = blockSize;
|
||||||
|
|
||||||
|
while(blkCnt > 0u)
|
||||||
|
{
|
||||||
|
/* Copy one sample at a time into state buffer */
|
||||||
|
*pStateCurnt++ = *pSrc++;
|
||||||
|
|
||||||
|
/* Set the accumulator to zero */
|
||||||
|
acc = 0.0f;
|
||||||
|
|
||||||
|
/* Initialize state pointer */
|
||||||
|
px = pState;
|
||||||
|
|
||||||
|
/* Initialize Coefficient pointer */
|
||||||
|
pb = pCoeffs;
|
||||||
|
|
||||||
|
i = numTaps;
|
||||||
|
|
||||||
|
/* Perform the multiply-accumulates */
|
||||||
|
do
|
||||||
|
{
|
||||||
|
/* acc = b[numTaps-1] * x[n-numTaps-1] + b[numTaps-2] * x[n-numTaps-2] + b[numTaps-3] * x[n-numTaps-3] +...+ b[0] * x[0] */
|
||||||
|
acc += *px++ * *pb++;
|
||||||
|
i--;
|
||||||
|
|
||||||
|
} while(i > 0u);
|
||||||
|
|
||||||
|
/* The result is store in the destination buffer. */
|
||||||
|
*pDst++ = acc;
|
||||||
|
|
||||||
|
/* Advance state pointer by 1 for the next sample */
|
||||||
|
pState = pState + 1;
|
||||||
|
|
||||||
|
blkCnt--;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Processing is complete.
|
||||||
|
** Now copy the last numTaps - 1 samples to the starting of the state buffer.
|
||||||
|
** This prepares the state buffer for the next function call. */
|
||||||
|
|
||||||
|
/* Points to the start of the state buffer */
|
||||||
|
pStateCurnt = S->pState;
|
||||||
|
|
||||||
|
/* Copy numTaps number of values */
|
||||||
|
tapCnt = numTaps - 1u;
|
||||||
|
|
||||||
|
/* Copy data */
|
||||||
|
while(tapCnt > 0u)
|
||||||
|
{
|
||||||
|
*pStateCurnt++ = *pState++;
|
||||||
|
|
||||||
|
/* Decrement the loop counter */
|
||||||
|
tapCnt--;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
/* Run the below code for Cortex-M4 and Cortex-M3 */
|
||||||
|
|
||||||
|
void arm_fir_f32(
|
||||||
|
const arm_fir_instance_f32 * S,
|
||||||
|
float32_t * pSrc,
|
||||||
|
float32_t * pDst,
|
||||||
|
uint32_t blockSize)
|
||||||
|
{
|
||||||
|
float32_t *pState = S->pState; /* State pointer */
|
||||||
|
float32_t *pCoeffs = S->pCoeffs; /* Coefficient pointer */
|
||||||
|
float32_t *pStateCurnt; /* Points to the current sample of the state */
|
||||||
|
float32_t *px, *pb; /* Temporary pointers for state and coefficient buffers */
|
||||||
|
float32_t acc0, acc1, acc2, acc3, acc4, acc5, acc6, acc7; /* Accumulators */
|
||||||
|
float32_t x0, x1, x2, x3, x4, x5, x6, x7, c0; /* Temporary variables to hold state and coefficient values */
|
||||||
|
uint32_t numTaps = S->numTaps; /* Number of filter coefficients in the filter */
|
||||||
|
uint32_t i, tapCnt, blkCnt; /* Loop counters */
|
||||||
|
float32_t p0,p1,p2,p3,p4,p5,p6,p7; /* Temporary product values */
|
||||||
|
|
||||||
|
/* S->pState points to state array which contains previous frame (numTaps - 1) samples */
|
||||||
|
/* pStateCurnt points to the location where the new input data should be written */
|
||||||
|
pStateCurnt = &(S->pState[(numTaps - 1u)]);
|
||||||
|
|
||||||
|
/* Apply loop unrolling and compute 8 output values simultaneously.
|
||||||
|
* The variables acc0 ... acc7 hold output values that are being computed:
|
||||||
|
*
|
||||||
|
* acc0 = b[numTaps-1] * x[n-numTaps-1] + b[numTaps-2] * x[n-numTaps-2] + b[numTaps-3] * x[n-numTaps-3] +...+ b[0] * x[0]
|
||||||
|
* acc1 = b[numTaps-1] * x[n-numTaps] + b[numTaps-2] * x[n-numTaps-1] + b[numTaps-3] * x[n-numTaps-2] +...+ b[0] * x[1]
|
||||||
|
* acc2 = b[numTaps-1] * x[n-numTaps+1] + b[numTaps-2] * x[n-numTaps] + b[numTaps-3] * x[n-numTaps-1] +...+ b[0] * x[2]
|
||||||
|
* acc3 = b[numTaps-1] * x[n-numTaps+2] + b[numTaps-2] * x[n-numTaps+1] + b[numTaps-3] * x[n-numTaps] +...+ b[0] * x[3]
|
||||||
|
*/
|
||||||
|
blkCnt = blockSize >> 3;
|
||||||
|
|
||||||
|
/* First part of the processing with loop unrolling. Compute 8 outputs at a time.
|
||||||
|
** a second loop below computes the remaining 1 to 7 samples. */
|
||||||
|
while(blkCnt > 0u)
|
||||||
|
{
|
||||||
|
/* Copy four new input samples into the state buffer */
|
||||||
|
*pStateCurnt++ = *pSrc++;
|
||||||
|
*pStateCurnt++ = *pSrc++;
|
||||||
|
*pStateCurnt++ = *pSrc++;
|
||||||
|
*pStateCurnt++ = *pSrc++;
|
||||||
|
|
||||||
|
/* Set all accumulators to zero */
|
||||||
|
acc0 = 0.0f;
|
||||||
|
acc1 = 0.0f;
|
||||||
|
acc2 = 0.0f;
|
||||||
|
acc3 = 0.0f;
|
||||||
|
acc4 = 0.0f;
|
||||||
|
acc5 = 0.0f;
|
||||||
|
acc6 = 0.0f;
|
||||||
|
acc7 = 0.0f;
|
||||||
|
|
||||||
|
/* Initialize state pointer */
|
||||||
|
px = pState;
|
||||||
|
|
||||||
|
/* Initialize coeff pointer */
|
||||||
|
pb = (pCoeffs);
|
||||||
|
|
||||||
|
/* This is separated from the others to avoid
|
||||||
|
* a call to __aeabi_memmove which would be slower
|
||||||
|
*/
|
||||||
|
*pStateCurnt++ = *pSrc++;
|
||||||
|
*pStateCurnt++ = *pSrc++;
|
||||||
|
*pStateCurnt++ = *pSrc++;
|
||||||
|
*pStateCurnt++ = *pSrc++;
|
||||||
|
|
||||||
|
/* Read the first seven samples from the state buffer: x[n-numTaps], x[n-numTaps-1], x[n-numTaps-2] */
|
||||||
|
x0 = *px++;
|
||||||
|
x1 = *px++;
|
||||||
|
x2 = *px++;
|
||||||
|
x3 = *px++;
|
||||||
|
x4 = *px++;
|
||||||
|
x5 = *px++;
|
||||||
|
x6 = *px++;
|
||||||
|
|
||||||
|
/* Loop unrolling. Process 8 taps at a time. */
|
||||||
|
tapCnt = numTaps >> 3u;
|
||||||
|
|
||||||
|
/* Loop over the number of taps. Unroll by a factor of 8.
|
||||||
|
** Repeat until we've computed numTaps-8 coefficients. */
|
||||||
|
while(tapCnt > 0u)
|
||||||
|
{
|
||||||
|
/* Read the b[numTaps-1] coefficient */
|
||||||
|
c0 = *(pb++);
|
||||||
|
|
||||||
|
/* Read x[n-numTaps-3] sample */
|
||||||
|
x7 = *(px++);
|
||||||
|
|
||||||
|
/* acc0 += b[numTaps-1] * x[n-numTaps] */
|
||||||
|
p0 = x0 * c0;
|
||||||
|
|
||||||
|
/* acc1 += b[numTaps-1] * x[n-numTaps-1] */
|
||||||
|
p1 = x1 * c0;
|
||||||
|
|
||||||
|
/* acc2 += b[numTaps-1] * x[n-numTaps-2] */
|
||||||
|
p2 = x2 * c0;
|
||||||
|
|
||||||
|
/* acc3 += b[numTaps-1] * x[n-numTaps-3] */
|
||||||
|
p3 = x3 * c0;
|
||||||
|
|
||||||
|
/* acc4 += b[numTaps-1] * x[n-numTaps-4] */
|
||||||
|
p4 = x4 * c0;
|
||||||
|
|
||||||
|
/* acc1 += b[numTaps-1] * x[n-numTaps-5] */
|
||||||
|
p5 = x5 * c0;
|
||||||
|
|
||||||
|
/* acc2 += b[numTaps-1] * x[n-numTaps-6] */
|
||||||
|
p6 = x6 * c0;
|
||||||
|
|
||||||
|
/* acc3 += b[numTaps-1] * x[n-numTaps-7] */
|
||||||
|
p7 = x7 * c0;
|
||||||
|
|
||||||
|
/* Read the b[numTaps-2] coefficient */
|
||||||
|
c0 = *(pb++);
|
||||||
|
|
||||||
|
/* Read x[n-numTaps-4] sample */
|
||||||
|
x0 = *(px++);
|
||||||
|
|
||||||
|
acc0 += p0;
|
||||||
|
acc1 += p1;
|
||||||
|
acc2 += p2;
|
||||||
|
acc3 += p3;
|
||||||
|
acc4 += p4;
|
||||||
|
acc5 += p5;
|
||||||
|
acc6 += p6;
|
||||||
|
acc7 += p7;
|
||||||
|
|
||||||
|
|
||||||
|
/* Perform the multiply-accumulate */
|
||||||
|
p0 = x1 * c0;
|
||||||
|
p1 = x2 * c0;
|
||||||
|
p2 = x3 * c0;
|
||||||
|
p3 = x4 * c0;
|
||||||
|
p4 = x5 * c0;
|
||||||
|
p5 = x6 * c0;
|
||||||
|
p6 = x7 * c0;
|
||||||
|
p7 = x0 * c0;
|
||||||
|
|
||||||
|
/* Read the b[numTaps-3] coefficient */
|
||||||
|
c0 = *(pb++);
|
||||||
|
|
||||||
|
/* Read x[n-numTaps-5] sample */
|
||||||
|
x1 = *(px++);
|
||||||
|
|
||||||
|
acc0 += p0;
|
||||||
|
acc1 += p1;
|
||||||
|
acc2 += p2;
|
||||||
|
acc3 += p3;
|
||||||
|
acc4 += p4;
|
||||||
|
acc5 += p5;
|
||||||
|
acc6 += p6;
|
||||||
|
acc7 += p7;
|
||||||
|
|
||||||
|
/* Perform the multiply-accumulates */
|
||||||
|
p0 = x2 * c0;
|
||||||
|
p1 = x3 * c0;
|
||||||
|
p2 = x4 * c0;
|
||||||
|
p3 = x5 * c0;
|
||||||
|
p4 = x6 * c0;
|
||||||
|
p5 = x7 * c0;
|
||||||
|
p6 = x0 * c0;
|
||||||
|
p7 = x1 * c0;
|
||||||
|
|
||||||
|
/* Read the b[numTaps-4] coefficient */
|
||||||
|
c0 = *(pb++);
|
||||||
|
|
||||||
|
/* Read x[n-numTaps-6] sample */
|
||||||
|
x2 = *(px++);
|
||||||
|
|
||||||
|
acc0 += p0;
|
||||||
|
acc1 += p1;
|
||||||
|
acc2 += p2;
|
||||||
|
acc3 += p3;
|
||||||
|
acc4 += p4;
|
||||||
|
acc5 += p5;
|
||||||
|
acc6 += p6;
|
||||||
|
acc7 += p7;
|
||||||
|
|
||||||
|
/* Perform the multiply-accumulates */
|
||||||
|
p0 = x3 * c0;
|
||||||
|
p1 = x4 * c0;
|
||||||
|
p2 = x5 * c0;
|
||||||
|
p3 = x6 * c0;
|
||||||
|
p4 = x7 * c0;
|
||||||
|
p5 = x0 * c0;
|
||||||
|
p6 = x1 * c0;
|
||||||
|
p7 = x2 * c0;
|
||||||
|
|
||||||
|
/* Read the b[numTaps-4] coefficient */
|
||||||
|
c0 = *(pb++);
|
||||||
|
|
||||||
|
/* Read x[n-numTaps-6] sample */
|
||||||
|
x3 = *(px++);
|
||||||
|
|
||||||
|
acc0 += p0;
|
||||||
|
acc1 += p1;
|
||||||
|
acc2 += p2;
|
||||||
|
acc3 += p3;
|
||||||
|
acc4 += p4;
|
||||||
|
acc5 += p5;
|
||||||
|
acc6 += p6;
|
||||||
|
acc7 += p7;
|
||||||
|
|
||||||
|
/* Perform the multiply-accumulates */
|
||||||
|
p0 = x4 * c0;
|
||||||
|
p1 = x5 * c0;
|
||||||
|
p2 = x6 * c0;
|
||||||
|
p3 = x7 * c0;
|
||||||
|
p4 = x0 * c0;
|
||||||
|
p5 = x1 * c0;
|
||||||
|
p6 = x2 * c0;
|
||||||
|
p7 = x3 * c0;
|
||||||
|
|
||||||
|
/* Read the b[numTaps-4] coefficient */
|
||||||
|
c0 = *(pb++);
|
||||||
|
|
||||||
|
/* Read x[n-numTaps-6] sample */
|
||||||
|
x4 = *(px++);
|
||||||
|
|
||||||
|
acc0 += p0;
|
||||||
|
acc1 += p1;
|
||||||
|
acc2 += p2;
|
||||||
|
acc3 += p3;
|
||||||
|
acc4 += p4;
|
||||||
|
acc5 += p5;
|
||||||
|
acc6 += p6;
|
||||||
|
acc7 += p7;
|
||||||
|
|
||||||
|
/* Perform the multiply-accumulates */
|
||||||
|
p0 = x5 * c0;
|
||||||
|
p1 = x6 * c0;
|
||||||
|
p2 = x7 * c0;
|
||||||
|
p3 = x0 * c0;
|
||||||
|
p4 = x1 * c0;
|
||||||
|
p5 = x2 * c0;
|
||||||
|
p6 = x3 * c0;
|
||||||
|
p7 = x4 * c0;
|
||||||
|
|
||||||
|
/* Read the b[numTaps-4] coefficient */
|
||||||
|
c0 = *(pb++);
|
||||||
|
|
||||||
|
/* Read x[n-numTaps-6] sample */
|
||||||
|
x5 = *(px++);
|
||||||
|
|
||||||
|
acc0 += p0;
|
||||||
|
acc1 += p1;
|
||||||
|
acc2 += p2;
|
||||||
|
acc3 += p3;
|
||||||
|
acc4 += p4;
|
||||||
|
acc5 += p5;
|
||||||
|
acc6 += p6;
|
||||||
|
acc7 += p7;
|
||||||
|
|
||||||
|
/* Perform the multiply-accumulates */
|
||||||
|
p0 = x6 * c0;
|
||||||
|
p1 = x7 * c0;
|
||||||
|
p2 = x0 * c0;
|
||||||
|
p3 = x1 * c0;
|
||||||
|
p4 = x2 * c0;
|
||||||
|
p5 = x3 * c0;
|
||||||
|
p6 = x4 * c0;
|
||||||
|
p7 = x5 * c0;
|
||||||
|
|
||||||
|
/* Read the b[numTaps-4] coefficient */
|
||||||
|
c0 = *(pb++);
|
||||||
|
|
||||||
|
/* Read x[n-numTaps-6] sample */
|
||||||
|
x6 = *(px++);
|
||||||
|
|
||||||
|
acc0 += p0;
|
||||||
|
acc1 += p1;
|
||||||
|
acc2 += p2;
|
||||||
|
acc3 += p3;
|
||||||
|
acc4 += p4;
|
||||||
|
acc5 += p5;
|
||||||
|
acc6 += p6;
|
||||||
|
acc7 += p7;
|
||||||
|
|
||||||
|
/* Perform the multiply-accumulates */
|
||||||
|
p0 = x7 * c0;
|
||||||
|
p1 = x0 * c0;
|
||||||
|
p2 = x1 * c0;
|
||||||
|
p3 = x2 * c0;
|
||||||
|
p4 = x3 * c0;
|
||||||
|
p5 = x4 * c0;
|
||||||
|
p6 = x5 * c0;
|
||||||
|
p7 = x6 * c0;
|
||||||
|
|
||||||
|
tapCnt--;
|
||||||
|
|
||||||
|
acc0 += p0;
|
||||||
|
acc1 += p1;
|
||||||
|
acc2 += p2;
|
||||||
|
acc3 += p3;
|
||||||
|
acc4 += p4;
|
||||||
|
acc5 += p5;
|
||||||
|
acc6 += p6;
|
||||||
|
acc7 += p7;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* If the filter length is not a multiple of 8, compute the remaining filter taps */
|
||||||
|
tapCnt = numTaps % 0x8u;
|
||||||
|
|
||||||
|
while(tapCnt > 0u)
|
||||||
|
{
|
||||||
|
/* Read coefficients */
|
||||||
|
c0 = *(pb++);
|
||||||
|
|
||||||
|
/* Fetch 1 state variable */
|
||||||
|
x7 = *(px++);
|
||||||
|
|
||||||
|
/* Perform the multiply-accumulates */
|
||||||
|
p0 = x0 * c0;
|
||||||
|
p1 = x1 * c0;
|
||||||
|
p2 = x2 * c0;
|
||||||
|
p3 = x3 * c0;
|
||||||
|
p4 = x4 * c0;
|
||||||
|
p5 = x5 * c0;
|
||||||
|
p6 = x6 * c0;
|
||||||
|
p7 = x7 * c0;
|
||||||
|
|
||||||
|
/* Reuse the present sample states for next sample */
|
||||||
|
x0 = x1;
|
||||||
|
x1 = x2;
|
||||||
|
x2 = x3;
|
||||||
|
x3 = x4;
|
||||||
|
x4 = x5;
|
||||||
|
x5 = x6;
|
||||||
|
x6 = x7;
|
||||||
|
|
||||||
|
acc0 += p0;
|
||||||
|
acc1 += p1;
|
||||||
|
acc2 += p2;
|
||||||
|
acc3 += p3;
|
||||||
|
acc4 += p4;
|
||||||
|
acc5 += p5;
|
||||||
|
acc6 += p6;
|
||||||
|
acc7 += p7;
|
||||||
|
|
||||||
|
/* Decrement the loop counter */
|
||||||
|
tapCnt--;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Advance the state pointer by 8 to process the next group of 8 samples */
|
||||||
|
pState = pState + 8;
|
||||||
|
|
||||||
|
/* The results in the 8 accumulators, store in the destination buffer. */
|
||||||
|
*pDst++ = acc0;
|
||||||
|
*pDst++ = acc1;
|
||||||
|
*pDst++ = acc2;
|
||||||
|
*pDst++ = acc3;
|
||||||
|
*pDst++ = acc4;
|
||||||
|
*pDst++ = acc5;
|
||||||
|
*pDst++ = acc6;
|
||||||
|
*pDst++ = acc7;
|
||||||
|
|
||||||
|
blkCnt--;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* If the blockSize is not a multiple of 8, compute any remaining output samples here.
|
||||||
|
** No loop unrolling is used. */
|
||||||
|
blkCnt = blockSize % 0x8u;
|
||||||
|
|
||||||
|
while(blkCnt > 0u)
|
||||||
|
{
|
||||||
|
/* Copy one sample at a time into state buffer */
|
||||||
|
*pStateCurnt++ = *pSrc++;
|
||||||
|
|
||||||
|
/* Set the accumulator to zero */
|
||||||
|
acc0 = 0.0f;
|
||||||
|
|
||||||
|
/* Initialize state pointer */
|
||||||
|
px = pState;
|
||||||
|
|
||||||
|
/* Initialize Coefficient pointer */
|
||||||
|
pb = (pCoeffs);
|
||||||
|
|
||||||
|
i = numTaps;
|
||||||
|
|
||||||
|
/* Perform the multiply-accumulates */
|
||||||
|
do
|
||||||
|
{
|
||||||
|
acc0 += *px++ * *pb++;
|
||||||
|
i--;
|
||||||
|
|
||||||
|
} while(i > 0u);
|
||||||
|
|
||||||
|
/* The result is store in the destination buffer. */
|
||||||
|
*pDst++ = acc0;
|
||||||
|
|
||||||
|
/* Advance state pointer by 1 for the next sample */
|
||||||
|
pState = pState + 1;
|
||||||
|
|
||||||
|
blkCnt--;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Processing is complete.
|
||||||
|
** Now copy the last numTaps - 1 samples to the start of the state buffer.
|
||||||
|
** This prepares the state buffer for the next function call. */
|
||||||
|
|
||||||
|
/* Points to the start of the state buffer */
|
||||||
|
pStateCurnt = S->pState;
|
||||||
|
|
||||||
|
tapCnt = (numTaps - 1u) >> 2u;
|
||||||
|
|
||||||
|
/* copy data */
|
||||||
|
while(tapCnt > 0u)
|
||||||
|
{
|
||||||
|
*pStateCurnt++ = *pState++;
|
||||||
|
*pStateCurnt++ = *pState++;
|
||||||
|
*pStateCurnt++ = *pState++;
|
||||||
|
*pStateCurnt++ = *pState++;
|
||||||
|
|
||||||
|
/* Decrement the loop counter */
|
||||||
|
tapCnt--;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Calculate remaining number of copies */
|
||||||
|
tapCnt = (numTaps - 1u) % 0x4u;
|
||||||
|
|
||||||
|
/* Copy the remaining q31_t data */
|
||||||
|
while(tapCnt > 0u)
|
||||||
|
{
|
||||||
|
*pStateCurnt++ = *pState++;
|
||||||
|
|
||||||
|
/* Decrement the loop counter */
|
||||||
|
tapCnt--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @} end of FIR group
|
||||||
|
*/
|
96
src/cmsis/source/arm_fir_init_f32.c
Normal file
96
src/cmsis/source/arm_fir_init_f32.c
Normal file
@ -0,0 +1,96 @@
|
|||||||
|
/*-----------------------------------------------------------------------------
|
||||||
|
* Copyright (C) 2010-2014 ARM Limited. All rights reserved.
|
||||||
|
*
|
||||||
|
* $Date: 19. March 2015
|
||||||
|
* $Revision: V.1.4.5
|
||||||
|
*
|
||||||
|
* Project: CMSIS DSP Library
|
||||||
|
* Title: arm_fir_init_f32.c
|
||||||
|
*
|
||||||
|
* Description: Floating-point FIR filter initialization function.
|
||||||
|
*
|
||||||
|
* Target Processor: Cortex-M4/Cortex-M3/Cortex-M0
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
* ---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "arm_math.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ingroup groupFilters
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @addtogroup FIR
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @details
|
||||||
|
*
|
||||||
|
* @param[in,out] *S points to an instance of the floating-point FIR filter structure.
|
||||||
|
* @param[in] numTaps Number of filter coefficients in the filter.
|
||||||
|
* @param[in] *pCoeffs points to the filter coefficients buffer.
|
||||||
|
* @param[in] *pState points to the state buffer.
|
||||||
|
* @param[in] blockSize number of samples that are processed per call.
|
||||||
|
* @return none.
|
||||||
|
*
|
||||||
|
* <b>Description:</b>
|
||||||
|
* \par
|
||||||
|
* <code>pCoeffs</code> points to the array of filter coefficients stored in time reversed order:
|
||||||
|
* <pre>
|
||||||
|
* {b[numTaps-1], b[numTaps-2], b[N-2], ..., b[1], b[0]}
|
||||||
|
* </pre>
|
||||||
|
* \par
|
||||||
|
* <code>pState</code> points to the array of state variables.
|
||||||
|
* <code>pState</code> is of length <code>numTaps+blockSize-1</code> samples, where <code>blockSize</code> is the number of input samples processed by each call to <code>arm_fir_f32()</code>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
void arm_fir_init_f32(
|
||||||
|
arm_fir_instance_f32 * S,
|
||||||
|
uint16_t numTaps,
|
||||||
|
float32_t * pCoeffs,
|
||||||
|
float32_t * pState,
|
||||||
|
uint32_t blockSize)
|
||||||
|
{
|
||||||
|
/* Assign filter taps */
|
||||||
|
S->numTaps = numTaps;
|
||||||
|
|
||||||
|
/* Assign coefficient pointer */
|
||||||
|
S->pCoeffs = pCoeffs;
|
||||||
|
|
||||||
|
/* Clear state buffer and the size of state buffer is (blockSize + numTaps - 1) */
|
||||||
|
memset(pState, 0, (numTaps + (blockSize - 1u)) * sizeof(float32_t));
|
||||||
|
|
||||||
|
/* Assign state pointer */
|
||||||
|
S->pState = pState;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @} end of FIR group
|
||||||
|
*/
|
204
src/cmsis/source/arm_float_to_q15.c
Normal file
204
src/cmsis/source/arm_float_to_q15.c
Normal file
@ -0,0 +1,204 @@
|
|||||||
|
/* ----------------------------------------------------------------------------
|
||||||
|
* Copyright (C) 2010-2014 ARM Limited. All rights reserved.
|
||||||
|
*
|
||||||
|
* $Date: 19. March 2015
|
||||||
|
* $Revision: V.1.4.5
|
||||||
|
*
|
||||||
|
* Project: CMSIS DSP Library
|
||||||
|
* Title: arm_float_to_q15.c
|
||||||
|
*
|
||||||
|
* Description: Converts the elements of the floating-point vector to Q15 vector.
|
||||||
|
*
|
||||||
|
* Target Processor: Cortex-M4/Cortex-M3/Cortex-M0
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
* ---------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
#include "arm_math.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ingroup groupSupport
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @addtogroup float_to_x
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Converts the elements of the floating-point vector to Q15 vector.
|
||||||
|
* @param[in] *pSrc points to the floating-point input vector
|
||||||
|
* @param[out] *pDst points to the Q15 output vector
|
||||||
|
* @param[in] blockSize length of the input vector
|
||||||
|
* @return none.
|
||||||
|
*
|
||||||
|
* \par Description:
|
||||||
|
* \par
|
||||||
|
* The equation used for the conversion process is:
|
||||||
|
* <pre>
|
||||||
|
* pDst[n] = (q15_t)(pSrc[n] * 32768); 0 <= n < blockSize.
|
||||||
|
* </pre>
|
||||||
|
* \par Scaling and Overflow Behavior:
|
||||||
|
* \par
|
||||||
|
* The function uses saturating arithmetic.
|
||||||
|
* Results outside of the allowable Q15 range [0x8000 0x7FFF] will be saturated.
|
||||||
|
* \note
|
||||||
|
* In order to apply rounding, the library should be rebuilt with the ROUNDING macro
|
||||||
|
* defined in the preprocessor section of project options.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
void arm_float_to_q15(
|
||||||
|
float32_t * pSrc,
|
||||||
|
q15_t * pDst,
|
||||||
|
uint32_t blockSize)
|
||||||
|
{
|
||||||
|
float32_t *pIn = pSrc; /* Src pointer */
|
||||||
|
uint32_t blkCnt; /* loop counter */
|
||||||
|
|
||||||
|
#ifdef ARM_MATH_ROUNDING
|
||||||
|
|
||||||
|
float32_t in;
|
||||||
|
|
||||||
|
#endif /* #ifdef ARM_MATH_ROUNDING */
|
||||||
|
|
||||||
|
#ifndef ARM_MATH_CM0_FAMILY
|
||||||
|
|
||||||
|
/* Run the below code for Cortex-M4 and Cortex-M3 */
|
||||||
|
|
||||||
|
/*loop Unrolling */
|
||||||
|
blkCnt = blockSize >> 2u;
|
||||||
|
|
||||||
|
/* First part of the processing with loop unrolling. Compute 4 outputs at a time.
|
||||||
|
** a second loop below computes the remaining 1 to 3 samples. */
|
||||||
|
while(blkCnt > 0u)
|
||||||
|
{
|
||||||
|
|
||||||
|
#ifdef ARM_MATH_ROUNDING
|
||||||
|
/* C = A * 32768 */
|
||||||
|
/* convert from float to q15 and then store the results in the destination buffer */
|
||||||
|
in = *pIn++;
|
||||||
|
in = (in * 32768.0f);
|
||||||
|
in += in > 0.0f ? 0.5f : -0.5f;
|
||||||
|
*pDst++ = (q15_t) (__SSAT((q31_t) (in), 16));
|
||||||
|
|
||||||
|
in = *pIn++;
|
||||||
|
in = (in * 32768.0f);
|
||||||
|
in += in > 0.0f ? 0.5f : -0.5f;
|
||||||
|
*pDst++ = (q15_t) (__SSAT((q31_t) (in), 16));
|
||||||
|
|
||||||
|
in = *pIn++;
|
||||||
|
in = (in * 32768.0f);
|
||||||
|
in += in > 0.0f ? 0.5f : -0.5f;
|
||||||
|
*pDst++ = (q15_t) (__SSAT((q31_t) (in), 16));
|
||||||
|
|
||||||
|
in = *pIn++;
|
||||||
|
in = (in * 32768.0f);
|
||||||
|
in += in > 0.0f ? 0.5f : -0.5f;
|
||||||
|
*pDst++ = (q15_t) (__SSAT((q31_t) (in), 16));
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
/* C = A * 32768 */
|
||||||
|
/* convert from float to q15 and then store the results in the destination buffer */
|
||||||
|
*pDst++ = (q15_t) __SSAT((q31_t) (*pIn++ * 32768.0f), 16);
|
||||||
|
*pDst++ = (q15_t) __SSAT((q31_t) (*pIn++ * 32768.0f), 16);
|
||||||
|
*pDst++ = (q15_t) __SSAT((q31_t) (*pIn++ * 32768.0f), 16);
|
||||||
|
*pDst++ = (q15_t) __SSAT((q31_t) (*pIn++ * 32768.0f), 16);
|
||||||
|
|
||||||
|
#endif /* #ifdef ARM_MATH_ROUNDING */
|
||||||
|
|
||||||
|
/* Decrement the loop counter */
|
||||||
|
blkCnt--;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* If the blockSize is not a multiple of 4, compute any remaining output samples here.
|
||||||
|
** No loop unrolling is used. */
|
||||||
|
blkCnt = blockSize % 0x4u;
|
||||||
|
|
||||||
|
while(blkCnt > 0u)
|
||||||
|
{
|
||||||
|
|
||||||
|
#ifdef ARM_MATH_ROUNDING
|
||||||
|
/* C = A * 32768 */
|
||||||
|
/* convert from float to q15 and then store the results in the destination buffer */
|
||||||
|
in = *pIn++;
|
||||||
|
in = (in * 32768.0f);
|
||||||
|
in += in > 0.0f ? 0.5f : -0.5f;
|
||||||
|
*pDst++ = (q15_t) (__SSAT((q31_t) (in), 16));
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
/* C = A * 32768 */
|
||||||
|
/* convert from float to q15 and then store the results in the destination buffer */
|
||||||
|
*pDst++ = (q15_t) __SSAT((q31_t) (*pIn++ * 32768.0f), 16);
|
||||||
|
|
||||||
|
#endif /* #ifdef ARM_MATH_ROUNDING */
|
||||||
|
|
||||||
|
/* Decrement the loop counter */
|
||||||
|
blkCnt--;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
/* Run the below code for Cortex-M0 */
|
||||||
|
|
||||||
|
/* Loop over blockSize number of values */
|
||||||
|
blkCnt = blockSize;
|
||||||
|
|
||||||
|
while(blkCnt > 0u)
|
||||||
|
{
|
||||||
|
|
||||||
|
#ifdef ARM_MATH_ROUNDING
|
||||||
|
/* C = A * 32768 */
|
||||||
|
/* convert from float to q15 and then store the results in the destination buffer */
|
||||||
|
in = *pIn++;
|
||||||
|
in = (in * 32768.0f);
|
||||||
|
in += in > 0 ? 0.5f : -0.5f;
|
||||||
|
*pDst++ = (q15_t) (__SSAT((q31_t) (in), 16));
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
/* C = A * 32768 */
|
||||||
|
/* convert from float to q15 and then store the results in the destination buffer */
|
||||||
|
*pDst++ = (q15_t) __SSAT((q31_t) (*pIn++ * 32768.0f), 16);
|
||||||
|
|
||||||
|
#endif /* #ifdef ARM_MATH_ROUNDING */
|
||||||
|
|
||||||
|
/* Decrement the loop counter */
|
||||||
|
blkCnt--;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* #ifndef ARM_MATH_CM0_FAMILY */
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @} end of float_to_x group
|
||||||
|
*/
|
174
src/cmsis/source/arm_mult_f32.c
Normal file
174
src/cmsis/source/arm_mult_f32.c
Normal file
@ -0,0 +1,174 @@
|
|||||||
|
/* ----------------------------------------------------------------------
|
||||||
|
* Copyright (C) 2010-2014 ARM Limited. All rights reserved.
|
||||||
|
*
|
||||||
|
* $Date: 19. March 2015
|
||||||
|
* $Revision: V.1.4.5
|
||||||
|
*
|
||||||
|
* Project: CMSIS DSP Library
|
||||||
|
* Title: arm_mult_f32.c
|
||||||
|
*
|
||||||
|
* Description: Floating-point vector multiplication.
|
||||||
|
*
|
||||||
|
* Target Processor: Cortex-M4/Cortex-M3/Cortex-M0
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
* -------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
#include "arm_math.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ingroup groupMath
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @defgroup BasicMult Vector Multiplication
|
||||||
|
*
|
||||||
|
* Element-by-element multiplication of two vectors.
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
* pDst[n] = pSrcA[n] * pSrcB[n], 0 <= n < blockSize.
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* There are separate functions for floating-point, Q7, Q15, and Q31 data types.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @addtogroup BasicMult
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Floating-point vector multiplication.
|
||||||
|
* @param[in] *pSrcA points to the first input vector
|
||||||
|
* @param[in] *pSrcB points to the second input vector
|
||||||
|
* @param[out] *pDst points to the output vector
|
||||||
|
* @param[in] blockSize number of samples in each vector
|
||||||
|
* @return none.
|
||||||
|
*/
|
||||||
|
|
||||||
|
void arm_mult_f32(
|
||||||
|
float32_t * pSrcA,
|
||||||
|
float32_t * pSrcB,
|
||||||
|
float32_t * pDst,
|
||||||
|
uint32_t blockSize)
|
||||||
|
{
|
||||||
|
uint32_t blkCnt; /* loop counters */
|
||||||
|
#ifndef ARM_MATH_CM0_FAMILY
|
||||||
|
|
||||||
|
/* Run the below code for Cortex-M4 and Cortex-M3 */
|
||||||
|
float32_t inA1, inA2, inA3, inA4; /* temporary input variables */
|
||||||
|
float32_t inB1, inB2, inB3, inB4; /* temporary input variables */
|
||||||
|
float32_t out1, out2, out3, out4; /* temporary output variables */
|
||||||
|
|
||||||
|
/* loop Unrolling */
|
||||||
|
blkCnt = blockSize >> 2u;
|
||||||
|
|
||||||
|
/* First part of the processing with loop unrolling. Compute 4 outputs at a time.
|
||||||
|
** a second loop below computes the remaining 1 to 3 samples. */
|
||||||
|
while(blkCnt > 0u)
|
||||||
|
{
|
||||||
|
/* C = A * B */
|
||||||
|
/* Multiply the inputs and store the results in output buffer */
|
||||||
|
/* read sample from sourceA */
|
||||||
|
inA1 = *pSrcA;
|
||||||
|
/* read sample from sourceB */
|
||||||
|
inB1 = *pSrcB;
|
||||||
|
/* read sample from sourceA */
|
||||||
|
inA2 = *(pSrcA + 1);
|
||||||
|
/* read sample from sourceB */
|
||||||
|
inB2 = *(pSrcB + 1);
|
||||||
|
|
||||||
|
/* out = sourceA * sourceB */
|
||||||
|
out1 = inA1 * inB1;
|
||||||
|
|
||||||
|
/* read sample from sourceA */
|
||||||
|
inA3 = *(pSrcA + 2);
|
||||||
|
/* read sample from sourceB */
|
||||||
|
inB3 = *(pSrcB + 2);
|
||||||
|
|
||||||
|
/* out = sourceA * sourceB */
|
||||||
|
out2 = inA2 * inB2;
|
||||||
|
|
||||||
|
/* read sample from sourceA */
|
||||||
|
inA4 = *(pSrcA + 3);
|
||||||
|
|
||||||
|
/* store result to destination buffer */
|
||||||
|
*pDst = out1;
|
||||||
|
|
||||||
|
/* read sample from sourceB */
|
||||||
|
inB4 = *(pSrcB + 3);
|
||||||
|
|
||||||
|
/* out = sourceA * sourceB */
|
||||||
|
out3 = inA3 * inB3;
|
||||||
|
|
||||||
|
/* store result to destination buffer */
|
||||||
|
*(pDst + 1) = out2;
|
||||||
|
|
||||||
|
/* out = sourceA * sourceB */
|
||||||
|
out4 = inA4 * inB4;
|
||||||
|
/* store result to destination buffer */
|
||||||
|
*(pDst + 2) = out3;
|
||||||
|
/* store result to destination buffer */
|
||||||
|
*(pDst + 3) = out4;
|
||||||
|
|
||||||
|
|
||||||
|
/* update pointers to process next samples */
|
||||||
|
pSrcA += 4u;
|
||||||
|
pSrcB += 4u;
|
||||||
|
pDst += 4u;
|
||||||
|
|
||||||
|
/* Decrement the blockSize loop counter */
|
||||||
|
blkCnt--;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* If the blockSize is not a multiple of 4, compute any remaining output samples here.
|
||||||
|
** No loop unrolling is used. */
|
||||||
|
blkCnt = blockSize % 0x4u;
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
/* Run the below code for Cortex-M0 */
|
||||||
|
|
||||||
|
/* Initialize blkCnt with number of samples */
|
||||||
|
blkCnt = blockSize;
|
||||||
|
|
||||||
|
#endif /* #ifndef ARM_MATH_CM0_FAMILY */
|
||||||
|
|
||||||
|
while(blkCnt > 0u)
|
||||||
|
{
|
||||||
|
/* C = A * B */
|
||||||
|
/* Multiply the inputs and store the results in output buffer */
|
||||||
|
*pDst++ = (*pSrcA++) * (*pSrcB++);
|
||||||
|
|
||||||
|
/* Decrement the blockSize loop counter */
|
||||||
|
blkCnt--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @} end of BasicMult group
|
||||||
|
*/
|
134
src/cmsis/source/arm_q15_to_float.c
Normal file
134
src/cmsis/source/arm_q15_to_float.c
Normal file
@ -0,0 +1,134 @@
|
|||||||
|
/* ----------------------------------------------------------------------------
|
||||||
|
* Copyright (C) 2010-2014 ARM Limited. All rights reserved.
|
||||||
|
*
|
||||||
|
* $Date: 19. March 2015
|
||||||
|
* $Revision: V.1.4.5
|
||||||
|
*
|
||||||
|
* Project: CMSIS DSP Library
|
||||||
|
* Title: arm_q15_to_float.c
|
||||||
|
*
|
||||||
|
* Description: Converts the elements of the Q15 vector to floating-point vector.
|
||||||
|
*
|
||||||
|
* Target Processor: Cortex-M4/Cortex-M3/Cortex-M0
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
* ---------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
#include "arm_math.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ingroup groupSupport
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @defgroup q15_to_x Convert 16-bit Integer value
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @addtogroup q15_to_x
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Converts the elements of the Q15 vector to floating-point vector.
|
||||||
|
* @param[in] *pSrc points to the Q15 input vector
|
||||||
|
* @param[out] *pDst points to the floating-point output vector
|
||||||
|
* @param[in] blockSize length of the input vector
|
||||||
|
* @return none.
|
||||||
|
*
|
||||||
|
* \par Description:
|
||||||
|
*
|
||||||
|
* The equation used for the conversion process is:
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
* pDst[n] = (float32_t) pSrc[n] / 32768; 0 <= n < blockSize.
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
void arm_q15_to_float(
|
||||||
|
q15_t * pSrc,
|
||||||
|
float32_t * pDst,
|
||||||
|
uint32_t blockSize)
|
||||||
|
{
|
||||||
|
q15_t *pIn = pSrc; /* Src pointer */
|
||||||
|
uint32_t blkCnt; /* loop counter */
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef ARM_MATH_CM0_FAMILY
|
||||||
|
|
||||||
|
/* Run the below code for Cortex-M4 and Cortex-M3 */
|
||||||
|
|
||||||
|
/*loop Unrolling */
|
||||||
|
blkCnt = blockSize >> 2u;
|
||||||
|
|
||||||
|
/* First part of the processing with loop unrolling. Compute 4 outputs at a time.
|
||||||
|
** a second loop below computes the remaining 1 to 3 samples. */
|
||||||
|
while(blkCnt > 0u)
|
||||||
|
{
|
||||||
|
/* C = (float32_t) A / 32768 */
|
||||||
|
/* convert from q15 to float and then store the results in the destination buffer */
|
||||||
|
*pDst++ = ((float32_t) * pIn++ / 32768.0f);
|
||||||
|
*pDst++ = ((float32_t) * pIn++ / 32768.0f);
|
||||||
|
*pDst++ = ((float32_t) * pIn++ / 32768.0f);
|
||||||
|
*pDst++ = ((float32_t) * pIn++ / 32768.0f);
|
||||||
|
|
||||||
|
/* Decrement the loop counter */
|
||||||
|
blkCnt--;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* If the blockSize is not a multiple of 4, compute any remaining output samples here.
|
||||||
|
** No loop unrolling is used. */
|
||||||
|
blkCnt = blockSize % 0x4u;
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
/* Run the below code for Cortex-M0 */
|
||||||
|
|
||||||
|
/* Loop over blockSize number of values */
|
||||||
|
blkCnt = blockSize;
|
||||||
|
|
||||||
|
#endif /* #ifndef ARM_MATH_CM0_FAMILY */
|
||||||
|
|
||||||
|
while(blkCnt > 0u)
|
||||||
|
{
|
||||||
|
/* C = (float32_t) A / 32768 */
|
||||||
|
/* convert from q15 to float and then store the results in the destination buffer */
|
||||||
|
*pDst++ = ((float32_t) * pIn++ / 32768.0f);
|
||||||
|
|
||||||
|
/* Decrement the loop counter */
|
||||||
|
blkCnt--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @} end of q15_to_x group
|
||||||
|
*/
|
133
src/cmsis/source/arm_sin_f32.c
Normal file
133
src/cmsis/source/arm_sin_f32.c
Normal file
@ -0,0 +1,133 @@
|
|||||||
|
/* ----------------------------------------------------------------------
|
||||||
|
* Copyright (C) 2010-2014 ARM Limited. All rights reserved.
|
||||||
|
*
|
||||||
|
* $Date: 21. September 2015
|
||||||
|
* $Revision: V.1.4.5 a
|
||||||
|
*
|
||||||
|
* Project: CMSIS DSP Library
|
||||||
|
* Title: arm_sin_f32.c
|
||||||
|
*
|
||||||
|
* Description: Fast sine calculation for floating-point values.
|
||||||
|
*
|
||||||
|
* Target Processor: Cortex-M4/Cortex-M3/Cortex-M0
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
* -------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
#include "arm_math.h"
|
||||||
|
#include "arm_common_tables.h"
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ingroup groupFastMath
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @defgroup sin Sine
|
||||||
|
*
|
||||||
|
* Computes the trigonometric sine function using a combination of table lookup
|
||||||
|
* and linear interpolation. There are separate functions for
|
||||||
|
* Q15, Q31, and floating-point data types.
|
||||||
|
* The input to the floating-point version is in radians while the
|
||||||
|
* fixed-point Q15 and Q31 have a scaled input with the range
|
||||||
|
* [0 +0.9999] mapping to [0 2*pi). The fixed-point range is chosen so that a
|
||||||
|
* value of 2*pi wraps around to 0.
|
||||||
|
*
|
||||||
|
* The implementation is based on table lookup using 256 values together with linear interpolation.
|
||||||
|
* The steps used are:
|
||||||
|
* -# Calculation of the nearest integer table index
|
||||||
|
* -# Compute the fractional portion (fract) of the table index.
|
||||||
|
* -# The final result equals <code>(1.0f-fract)*a + fract*b;</code>
|
||||||
|
*
|
||||||
|
* where
|
||||||
|
* <pre>
|
||||||
|
* b=Table[index+0];
|
||||||
|
* c=Table[index+1];
|
||||||
|
* </pre>
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @addtogroup sin
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Fast approximation to the trigonometric sine function for floating-point data.
|
||||||
|
* @param[in] x input value in radians.
|
||||||
|
* @return sin(x).
|
||||||
|
*/
|
||||||
|
|
||||||
|
float32_t arm_sin_f32(
|
||||||
|
float32_t x)
|
||||||
|
{
|
||||||
|
float32_t sinVal, fract, in; /* Temporary variables for input, output */
|
||||||
|
uint16_t index; /* Index variable */
|
||||||
|
float32_t a, b; /* Two nearest output values */
|
||||||
|
int32_t n;
|
||||||
|
float32_t findex;
|
||||||
|
|
||||||
|
/* input x is in radians */
|
||||||
|
/* Scale the input to [0 1] range from [0 2*PI] , divide input by 2*pi */
|
||||||
|
in = x * 0.159154943092f;
|
||||||
|
|
||||||
|
/* Calculation of floor value of input */
|
||||||
|
n = (int32_t) in;
|
||||||
|
|
||||||
|
/* Make negative values towards -infinity */
|
||||||
|
if(x < 0.0f)
|
||||||
|
{
|
||||||
|
n--;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Map input value to [0 1] */
|
||||||
|
in = in - (float32_t) n;
|
||||||
|
|
||||||
|
/* Calculation of index of the table */
|
||||||
|
findex = (float32_t) FAST_MATH_TABLE_SIZE * in;
|
||||||
|
if (findex >= 512.0f) {
|
||||||
|
findex -= 512.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
index = ((uint16_t)findex) & 0x1ff;
|
||||||
|
|
||||||
|
/* fractional value calculation */
|
||||||
|
fract = findex - (float32_t) index;
|
||||||
|
|
||||||
|
/* Read two nearest values of input value from the sin table */
|
||||||
|
a = sinTable_f32[index];
|
||||||
|
b = sinTable_f32[index+1];
|
||||||
|
|
||||||
|
/* Linear interpolation process */
|
||||||
|
sinVal = (1.0f-fract)*a + fract*b;
|
||||||
|
|
||||||
|
/* Return the output value */
|
||||||
|
return (sinVal);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @} end of sin group
|
||||||
|
*/
|
28
src/cmsis/source/license.txt
Normal file
28
src/cmsis/source/license.txt
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
All files contained in the folders "CMSIS\DSP-Lib\Source" and "CMSIS\DSP-Lib\Examples"
|
||||||
|
are guided by the following license:
|
||||||
|
|
||||||
|
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.
|
65
src/main.c
Normal file
65
src/main.c
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <time.h>
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
|
#include "bpsk.h"
|
||||||
|
|
||||||
|
#define clear() printf("\033[H\033[J")
|
||||||
|
#define gotoxy(x, y) printf("\033[%d;%dH", (y), (x))
|
||||||
|
|
||||||
|
static uint8_t wave_header[44];
|
||||||
|
|
||||||
|
int main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
char *wave_file_name = "modulated.wav";
|
||||||
|
struct stat statbuf;
|
||||||
|
int16_t *wave_buffer;
|
||||||
|
|
||||||
|
if (argc > 1)
|
||||||
|
{
|
||||||
|
wave_file_name = argv[1];
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("Opening %s for demodulation...\n", wave_file_name);
|
||||||
|
int fd = open(wave_file_name, O_RDONLY);
|
||||||
|
if (fd == -1)
|
||||||
|
{
|
||||||
|
perror("unable to open wave file");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (-1 == fstat(fd, &statbuf))
|
||||||
|
{
|
||||||
|
perror("unable to determine size of buffer");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Read the .wav header (44 bytes) into the wave header array.
|
||||||
|
// This effectively discards it.
|
||||||
|
if (read(fd, wave_header, sizeof(wave_header)) != sizeof(wave_header))
|
||||||
|
{
|
||||||
|
fprintf(stderr, "couldn't read wave header");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Allocate a buffer for the remainder of the wave file.
|
||||||
|
int wave_len_bytes = statbuf.st_size - sizeof(wave_header);
|
||||||
|
wave_buffer = malloc(wave_len_bytes);
|
||||||
|
if (read(fd, wave_buffer, wave_len_bytes) != wave_len_bytes)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "short read of wave file\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Perform a BPSK run on it.
|
||||||
|
bpsk_init();
|
||||||
|
bpsk_run(wave_buffer, wave_len_bytes / sizeof(uint16_t));
|
||||||
|
|
||||||
|
printf("\n");
|
||||||
|
return 0;
|
||||||
|
}
|
268
src/varcode.c
Normal file
268
src/varcode.c
Normal file
@ -0,0 +1,268 @@
|
|||||||
|
#include <stdint.h>
|
||||||
|
char varcode_to_char(uint32_t c) {
|
||||||
|
switch (c) {
|
||||||
|
case 683: return '\x00';
|
||||||
|
case 731: return '\x01';
|
||||||
|
case 749: return '\x02';
|
||||||
|
case 887: return '\x03';
|
||||||
|
case 747: return '\x04';
|
||||||
|
case 863: return '\x05';
|
||||||
|
case 751: return '\x06';
|
||||||
|
case 765: return '\x07';
|
||||||
|
case 767: return '\x08';
|
||||||
|
case 239: return '\x09';
|
||||||
|
case 29: return '\x0A';
|
||||||
|
case 879: return '\x0B';
|
||||||
|
case 733: return '\x0C';
|
||||||
|
case 31: return '\x0D';
|
||||||
|
case 885: return '\x0E';
|
||||||
|
case 939: return '\x0F';
|
||||||
|
case 759: return '\x10';
|
||||||
|
case 757: return '\x11';
|
||||||
|
case 941: return '\x12';
|
||||||
|
case 943: return '\x13';
|
||||||
|
case 859: return '\x14';
|
||||||
|
case 875: return '\x15';
|
||||||
|
case 877: return '\x16';
|
||||||
|
case 855: return '\x17';
|
||||||
|
case 891: return '\x18';
|
||||||
|
case 893: return '\x19';
|
||||||
|
case 951: return '\x1A';
|
||||||
|
case 853: return '\x1B';
|
||||||
|
case 861: return '\x1C';
|
||||||
|
case 955: return '\x1D';
|
||||||
|
case 763: return '\x1E';
|
||||||
|
case 895: return '\x1F';
|
||||||
|
case 1: return ' ';
|
||||||
|
case 511: return '!';
|
||||||
|
case 351: return '"';
|
||||||
|
case 501: return '#';
|
||||||
|
case 475: return '$';
|
||||||
|
case 725: return '%';
|
||||||
|
case 699: return '&';
|
||||||
|
case 383: return '\'';
|
||||||
|
case 251: return '(';
|
||||||
|
case 247: return ')';
|
||||||
|
case 367: return '*';
|
||||||
|
case 479: return '+';
|
||||||
|
case 117: return ',';
|
||||||
|
case 53: return '-';
|
||||||
|
case 87: return '.';
|
||||||
|
case 431: return '/';
|
||||||
|
case 183: return '0';
|
||||||
|
case 189: return '1';
|
||||||
|
case 237: return '2';
|
||||||
|
case 255: return '3';
|
||||||
|
case 375: return '4';
|
||||||
|
case 347: return '5';
|
||||||
|
case 363: return '6';
|
||||||
|
case 429: return '7';
|
||||||
|
case 427: return '8';
|
||||||
|
case 439: return '9';
|
||||||
|
case 245: return ':';
|
||||||
|
case 445: return ';';
|
||||||
|
case 493: return '<';
|
||||||
|
case 85: return '=';
|
||||||
|
case 471: return '>';
|
||||||
|
case 687: return '?';
|
||||||
|
case 701: return '@';
|
||||||
|
case 125: return 'A';
|
||||||
|
case 235: return 'B';
|
||||||
|
case 173: return 'C';
|
||||||
|
case 181: return 'D';
|
||||||
|
case 119: return 'E';
|
||||||
|
case 219: return 'F';
|
||||||
|
case 253: return 'G';
|
||||||
|
case 341: return 'H';
|
||||||
|
case 127: return 'I';
|
||||||
|
case 509: return 'J';
|
||||||
|
case 381: return 'K';
|
||||||
|
case 215: return 'L';
|
||||||
|
case 187: return 'M';
|
||||||
|
case 221: return 'N';
|
||||||
|
case 171: return 'O';
|
||||||
|
case 213: return 'P';
|
||||||
|
case 477: return 'Q';
|
||||||
|
case 175: return 'R';
|
||||||
|
case 111: return 'S';
|
||||||
|
case 109: return 'T';
|
||||||
|
case 343: return 'U';
|
||||||
|
case 437: return 'V';
|
||||||
|
case 349: return 'W';
|
||||||
|
case 373: return 'X';
|
||||||
|
case 379: return 'Y';
|
||||||
|
case 685: return 'Z';
|
||||||
|
case 503: return '[';
|
||||||
|
case 495: return '\\';
|
||||||
|
case 507: return ']';
|
||||||
|
case 703: return '^';
|
||||||
|
case 365: return '_';
|
||||||
|
case 735: return '`';
|
||||||
|
case 11: return 'a';
|
||||||
|
case 95: return 'b';
|
||||||
|
case 47: return 'c';
|
||||||
|
case 45: return 'd';
|
||||||
|
case 3: return 'e';
|
||||||
|
case 61: return 'f';
|
||||||
|
case 91: return 'g';
|
||||||
|
case 43: return 'h';
|
||||||
|
case 13: return 'i';
|
||||||
|
case 491: return 'j';
|
||||||
|
case 191: return 'k';
|
||||||
|
case 27: return 'l';
|
||||||
|
case 59: return 'm';
|
||||||
|
case 15: return 'n';
|
||||||
|
case 7: return 'o';
|
||||||
|
case 63: return 'p';
|
||||||
|
case 447: return 'q';
|
||||||
|
case 21: return 'r';
|
||||||
|
case 23: return 's';
|
||||||
|
case 5: return 't';
|
||||||
|
case 55: return 'u';
|
||||||
|
case 123: return 'v';
|
||||||
|
case 107: return 'w';
|
||||||
|
case 223: return 'x';
|
||||||
|
case 93: return 'y';
|
||||||
|
case 469: return 'z';
|
||||||
|
case 695: return '{';
|
||||||
|
case 443: return '|';
|
||||||
|
case 693: return '}';
|
||||||
|
case 727: return '~';
|
||||||
|
case 949: return '\x7F';
|
||||||
|
}
|
||||||
|
return '\0';
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *char_to_varcode(char c) {
|
||||||
|
switch (c) {
|
||||||
|
case '\x00': return "1010101011";
|
||||||
|
case '\x01': return "1011011011";
|
||||||
|
case '\x02': return "1011101101";
|
||||||
|
case '\x03': return "1101110111";
|
||||||
|
case '\x04': return "1011101011";
|
||||||
|
case '\x05': return "1101011111";
|
||||||
|
case '\x06': return "1011101111";
|
||||||
|
case '\x07': return "1011111101";
|
||||||
|
case '\x08': return "1011111111";
|
||||||
|
case '\x09': return "11101111";
|
||||||
|
case '\x0A': return "11101";
|
||||||
|
case '\x0B': return "1101101111";
|
||||||
|
case '\x0C': return "1011011101";
|
||||||
|
case '\x0D': return "11111";
|
||||||
|
case '\x0E': return "1101110101";
|
||||||
|
case '\x0F': return "1110101011";
|
||||||
|
case '\x10': return "1011110111";
|
||||||
|
case '\x11': return "1011110101";
|
||||||
|
case '\x12': return "1110101101";
|
||||||
|
case '\x13': return "1110101111";
|
||||||
|
case '\x14': return "1101011011";
|
||||||
|
case '\x15': return "1101101011";
|
||||||
|
case '\x16': return "1101101101";
|
||||||
|
case '\x17': return "1101010111";
|
||||||
|
case '\x18': return "1101111011";
|
||||||
|
case '\x19': return "1101111101";
|
||||||
|
case '\x1A': return "1110110111";
|
||||||
|
case '\x1B': return "1101010101";
|
||||||
|
case '\x1C': return "1101011101";
|
||||||
|
case '\x1D': return "1110111011";
|
||||||
|
case '\x1E': return "1011111011";
|
||||||
|
case '\x1F': return "1101111111";
|
||||||
|
case ' ': return "1";
|
||||||
|
case '!': return "111111111";
|
||||||
|
case '"': return "101011111";
|
||||||
|
case '#': return "111110101";
|
||||||
|
case '$': return "111011011";
|
||||||
|
case '%': return "1011010101";
|
||||||
|
case '&': return "1010111011";
|
||||||
|
case '\'': return "101111111";
|
||||||
|
case '(': return "11111011";
|
||||||
|
case ')': return "11110111";
|
||||||
|
case '*': return "101101111";
|
||||||
|
case '+': return "111011111";
|
||||||
|
case ',': return "1110101";
|
||||||
|
case '-': return "110101";
|
||||||
|
case '.': return "1010111";
|
||||||
|
case '/': return "110101111";
|
||||||
|
case '0': return "10110111";
|
||||||
|
case '1': return "10111101";
|
||||||
|
case '2': return "11101101";
|
||||||
|
case '3': return "11111111";
|
||||||
|
case '4': return "101110111";
|
||||||
|
case '5': return "101011011";
|
||||||
|
case '6': return "101101011";
|
||||||
|
case '7': return "110101101";
|
||||||
|
case '8': return "110101011";
|
||||||
|
case '9': return "110110111";
|
||||||
|
case ':': return "11110101";
|
||||||
|
case ';': return "110111101";
|
||||||
|
case '<': return "111101101";
|
||||||
|
case '=': return "1010101";
|
||||||
|
case '>': return "111010111";
|
||||||
|
case '?': return "1010101111";
|
||||||
|
case '@': return "1010111101";
|
||||||
|
case 'A': return "1111101";
|
||||||
|
case 'B': return "11101011";
|
||||||
|
case 'C': return "10101101";
|
||||||
|
case 'D': return "10110101";
|
||||||
|
case 'E': return "1110111";
|
||||||
|
case 'F': return "11011011";
|
||||||
|
case 'G': return "11111101";
|
||||||
|
case 'H': return "101010101";
|
||||||
|
case 'I': return "1111111";
|
||||||
|
case 'J': return "111111101";
|
||||||
|
case 'K': return "101111101";
|
||||||
|
case 'L': return "11010111";
|
||||||
|
case 'M': return "10111011";
|
||||||
|
case 'N': return "11011101";
|
||||||
|
case 'O': return "10101011";
|
||||||
|
case 'P': return "11010101";
|
||||||
|
case 'Q': return "111011101";
|
||||||
|
case 'R': return "10101111";
|
||||||
|
case 'S': return "1101111";
|
||||||
|
case 'T': return "1101101";
|
||||||
|
case 'U': return "101010111";
|
||||||
|
case 'V': return "110110101";
|
||||||
|
case 'W': return "101011101";
|
||||||
|
case 'X': return "101110101";
|
||||||
|
case 'Y': return "101111011";
|
||||||
|
case 'Z': return "1010101101";
|
||||||
|
case '[': return "111110111";
|
||||||
|
case '\\': return "111101111";
|
||||||
|
case ']': return "111111011";
|
||||||
|
case '^': return "1010111111";
|
||||||
|
case '_': return "101101101";
|
||||||
|
case '`': return "1011011111";
|
||||||
|
case 'a': return "1011";
|
||||||
|
case 'b': return "1011111";
|
||||||
|
case 'c': return "101111";
|
||||||
|
case 'd': return "101101";
|
||||||
|
case 'e': return "11";
|
||||||
|
case 'f': return "111101";
|
||||||
|
case 'g': return "1011011";
|
||||||
|
case 'h': return "101011";
|
||||||
|
case 'i': return "1101";
|
||||||
|
case 'j': return "111101011";
|
||||||
|
case 'k': return "10111111";
|
||||||
|
case 'l': return "11011";
|
||||||
|
case 'm': return "111011";
|
||||||
|
case 'n': return "1111";
|
||||||
|
case 'o': return "111";
|
||||||
|
case 'p': return "111111";
|
||||||
|
case 'q': return "110111111";
|
||||||
|
case 'r': return "10101";
|
||||||
|
case 's': return "10111";
|
||||||
|
case 't': return "101";
|
||||||
|
case 'u': return "110111";
|
||||||
|
case 'v': return "1111011";
|
||||||
|
case 'w': return "1101011";
|
||||||
|
case 'x': return "11011111";
|
||||||
|
case 'y': return "1011101";
|
||||||
|
case 'z': return "111010101";
|
||||||
|
case '{': return "1010110111";
|
||||||
|
case '|': return "110111011";
|
||||||
|
case '}': return "1010110101";
|
||||||
|
case '~': return "1011010111";
|
||||||
|
case '\x7F': return "1110110101";
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user