mirror of
https://github.com/espressif/openthread.git
synced 2026-08-03 17:37:46 +00:00
[kw41z] move to openthread/ot-kw41z (#6386)
This commit is contained in:
+4
-7
@@ -781,14 +781,14 @@ AC_MSG_CHECKING([whether to build examples])
|
||||
AC_ARG_WITH(examples,
|
||||
[AS_HELP_STRING([--with-examples=TARGET],
|
||||
[Build example applications for one of: simulation, cc1352, cc2538, cc2650, cc2652, efr32mg1, efr32mg12, efr32mg13, efr32mg21,
|
||||
jn5189, k32w061, kw41z, nrf52811, nrf52833, nrf52840 @<:@default=no@:>@.
|
||||
jn5189, k32w061, nrf52811, nrf52833, nrf52840 @<:@default=no@:>@.
|
||||
Note that building example applications also builds the associated OpenThread platform libraries
|
||||
and any third_party libraries needed to support the examples.])],
|
||||
[
|
||||
case "${with_examples}" in
|
||||
no)
|
||||
;;
|
||||
simulation|cc1352|cc2538|cc2650|cc2652|efr32mg1|efr32mg12|efr32mg13|efr32mg21|jn5189|k32w061|kw41z|nrf52811|nrf52833|nrf52840)
|
||||
simulation|cc1352|cc2538|cc2650|cc2652|efr32mg1|efr32mg12|efr32mg13|efr32mg21|jn5189|k32w061|nrf52811|nrf52833|nrf52840)
|
||||
;;
|
||||
*)
|
||||
AC_MSG_RESULT(ERROR)
|
||||
@@ -811,7 +811,6 @@ AM_CONDITIONAL([OPENTHREAD_EXAMPLES_EFR32MG13], [test "${with_examples}" = "efr3
|
||||
AM_CONDITIONAL([OPENTHREAD_EXAMPLES_EFR32MG21], [test "${with_examples}" = "efr32mg21"])
|
||||
AM_CONDITIONAL([OPENTHREAD_EXAMPLES_JN5189], [test "${with_examples}" = "jn5189"])
|
||||
AM_CONDITIONAL([OPENTHREAD_EXAMPLES_K32W061], [test "${with_examples}" = "k32w061"])
|
||||
AM_CONDITIONAL([OPENTHREAD_EXAMPLES_KW41Z], [test "${with_examples}" = "kw41z"])
|
||||
AM_CONDITIONAL([OPENTHREAD_EXAMPLES_NRF52811], [test "${with_examples}" = "nrf52811"])
|
||||
AM_CONDITIONAL([OPENTHREAD_EXAMPLES_NRF52833], [test "${with_examples}" = "nrf52833"])
|
||||
AM_CONDITIONAL([OPENTHREAD_EXAMPLES_NRF52840], [test "${with_examples}" = "nrf52840"])
|
||||
@@ -839,11 +838,11 @@ AC_MSG_CHECKING([whether to build platform libraries])
|
||||
AC_ARG_WITH(platform,
|
||||
[AS_HELP_STRING([--with-platform=TARGET],
|
||||
[Build OpenThread platform libraries for one of: cc1352, cc2538, cc2650, cc2652,
|
||||
efr32mg1, efr32mg12, efr32mg13, efr32mg21, jn5189, kw41z, nrf52811, nrf52833, nrf52840, posix, simulation @<:@default=simulation@:>@.])],
|
||||
efr32mg1, efr32mg12, efr32mg13, efr32mg21, jn5189, nrf52811, nrf52833, nrf52840, posix, simulation @<:@default=simulation@:>@.])],
|
||||
[
|
||||
# Make sure the given target is valid.
|
||||
case "${with_platform}" in
|
||||
no|cc1352|cc2538|cc2650|cc2652|efr32mg1|efr32mg12|efr32mg13|efr32mg21|jn5189|kw41z|nrf52811|nrf52833|nrf52840|posix|simulation)
|
||||
no|cc1352|cc2538|cc2650|cc2652|efr32mg1|efr32mg12|efr32mg13|efr32mg21|jn5189|nrf52811|nrf52833|nrf52840|posix|simulation)
|
||||
;;
|
||||
*)
|
||||
AC_MSG_RESULT(ERROR)
|
||||
@@ -883,7 +882,6 @@ AM_CONDITIONAL([OPENTHREAD_PLATFORM_EFR32MG12], [test "${with_platform}" = "efr3
|
||||
AM_CONDITIONAL([OPENTHREAD_PLATFORM_EFR32MG13], [test "${with_platform}" = "efr32mg13"])
|
||||
AM_CONDITIONAL([OPENTHREAD_PLATFORM_EFR32MG21], [test "${with_platform}" = "efr32mg21"])
|
||||
AM_CONDITIONAL([OPENTHREAD_PLATFORM_JN5189], [test "${with_platform}" = "jn5189"])
|
||||
AM_CONDITIONAL([OPENTHREAD_PLATFORM_KW41Z], [test "${with_platform}" = "kw41z"])
|
||||
AM_CONDITIONAL([OPENTHREAD_PLATFORM_NRF52811], [test "${with_platform}" = "nrf52811"])
|
||||
AM_CONDITIONAL([OPENTHREAD_PLATFORM_NRF52833], [test "${with_platform}" = "nrf52833"])
|
||||
AM_CONDITIONAL([OPENTHREAD_PLATFORM_NRF52840], [test "${with_platform}" = "nrf52840"])
|
||||
@@ -1040,7 +1038,6 @@ examples/platforms/efr32/sleepy-demo/Makefile
|
||||
examples/platforms/efr32/sleepy-demo/sleepy-demo-mtd/Makefile
|
||||
examples/platforms/efr32/sleepy-demo/sleepy-demo-ftd/Makefile
|
||||
examples/platforms/k32w/Makefile
|
||||
examples/platforms/kw41z/Makefile
|
||||
examples/platforms/nrf528xx/Makefile
|
||||
examples/platforms/simulation/Makefile
|
||||
examples/platforms/utils/Makefile
|
||||
|
||||
@@ -1,261 +0,0 @@
|
||||
#
|
||||
# Copyright (c) 2017, The OpenThread Authors.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. 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.
|
||||
# 3. Neither the name of the copyright holder 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 HOLDER 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.
|
||||
#
|
||||
|
||||
.NOTPARALLEL:
|
||||
|
||||
AR = arm-none-eabi-ar
|
||||
CCAS = arm-none-eabi-as
|
||||
CPP = arm-none-eabi-cpp
|
||||
CC = arm-none-eabi-gcc
|
||||
CXX = arm-none-eabi-g++
|
||||
LD = arm-none-eabi-ld
|
||||
STRIP = arm-none-eabi-strip
|
||||
NM = arm-none-eabi-nm
|
||||
RANLIB = arm-none-eabi-ranlib
|
||||
OBJCOPY = arm-none-eabi-objcopy
|
||||
|
||||
BuildJobs ?= 10
|
||||
|
||||
configure_OPTIONS = \
|
||||
--enable-cli \
|
||||
--enable-ftd \
|
||||
--enable-mtd \
|
||||
--enable-ncp \
|
||||
--enable-radio-only \
|
||||
--enable-linker-map \
|
||||
--with-examples=kw41z \
|
||||
$(NULL)
|
||||
|
||||
TopSourceDir := $(dir $(shell readlink $(firstword $(MAKEFILE_LIST))))..
|
||||
AbsTopSourceDir := $(dir $(realpath $(firstword $(MAKEFILE_LIST))))..
|
||||
|
||||
KW41Z_CONFIG_FILE_CPPFLAGS = -DOPENTHREAD_PROJECT_CORE_CONFIG_FILE='\"openthread-core-kw41z-config.h\"'
|
||||
KW41Z_CONFIG_FILE_CPPFLAGS += -DOPENTHREAD_CORE_CONFIG_PLATFORM_CHECK_FILE='\"openthread-core-kw41z-config-check.h\"'
|
||||
KW41Z_CONFIG_FILE_CPPFLAGS += -I$(AbsTopSourceDir)/examples/platforms/kw41z/
|
||||
|
||||
COMMONCFLAGS := \
|
||||
-fdata-sections \
|
||||
-ffunction-sections \
|
||||
-Os \
|
||||
-g \
|
||||
$(KW41Z_CONFIG_FILE_CPPFLAGS) \
|
||||
$(NULL)
|
||||
|
||||
include $(dir $(abspath $(lastword $(MAKEFILE_LIST))))/common-switches.mk
|
||||
|
||||
CPPFLAGS += \
|
||||
$(COMMONCFLAGS) \
|
||||
$(target_CPPFLAGS) \
|
||||
$(NULL)
|
||||
|
||||
CFLAGS += \
|
||||
$(COMMONCFLAGS) \
|
||||
$(target_CFLAGS) \
|
||||
$(NULL)
|
||||
|
||||
CXXFLAGS += \
|
||||
$(COMMONCFLAGS) \
|
||||
$(target_CXXFLAGS) \
|
||||
-fno-exceptions \
|
||||
-fno-rtti \
|
||||
$(NULL)
|
||||
|
||||
LDFLAGS += \
|
||||
$(COMMONCFLAGS) \
|
||||
$(target_LDFLAGS) \
|
||||
-specs=nano.specs \
|
||||
-specs=nosys.specs \
|
||||
-Wl,--gc-sections \
|
||||
$(NULL)
|
||||
|
||||
ECHO := @echo
|
||||
MAKE := make
|
||||
MKDIR_P := mkdir -p
|
||||
LN_S := ln -s
|
||||
RM_F := rm -f
|
||||
|
||||
INSTALL := /usr/bin/install
|
||||
INSTALLFLAGS := -p
|
||||
|
||||
BuildPath = build
|
||||
TopBuildDir = $(BuildPath)
|
||||
AbsTopBuildDir = $(PWD)/$(TopBuildDir)
|
||||
|
||||
ResultPath = output
|
||||
TopResultDir = $(ResultPath)
|
||||
AbsTopResultDir = $(PWD)/$(TopResultDir)
|
||||
|
||||
TargetTuple = kw41z
|
||||
|
||||
ARCHS = cortex-m0plus
|
||||
|
||||
TopTargetLibDir = $(TopResultDir)/$(TargetTuple)/lib
|
||||
|
||||
ifndef BuildJobs
|
||||
BuildJobs := $(shell getconf _NPROCESSORS_ONLN)
|
||||
endif
|
||||
JOBSFLAG := -j$(BuildJobs)
|
||||
|
||||
#
|
||||
# configure-arch <arch>
|
||||
#
|
||||
# Configure OpenThread for the specified architecture.
|
||||
#
|
||||
# arch - The architecture to configure.
|
||||
#
|
||||
define configure-arch
|
||||
$(ECHO) " CONFIG $(TargetTuple)..."
|
||||
(cd $(BuildPath)/$(TargetTuple) && $(AbsTopSourceDir)/configure \
|
||||
INSTALL="$(INSTALL) $(INSTALLFLAGS)" \
|
||||
CPP="$(CPP)" CC="$(CC)" CXX="$(CXX)" OBJC="$(OBJC)" OBJCXX="$(OBJCXX)" AR="$(AR)" RANLIB="$(RANLIB)" NM="$(NM)" STRIP="$(STRIP)" CPPFLAGS="$(CPPFLAGS)" CFLAGS="$(CFLAGS)" CXXFLAGS="$(CXXFLAGS)" LDFLAGS="$(LDFLAGS)" \
|
||||
--host=arm-none-eabi \
|
||||
--prefix=/ \
|
||||
--exec-prefix=/$(TargetTuple) \
|
||||
$(configure_OPTIONS))
|
||||
endef # configure-arch
|
||||
|
||||
#
|
||||
# build-arch <arch>
|
||||
#
|
||||
# Build the OpenThread intermediate build products for the specified
|
||||
# architecture.
|
||||
#
|
||||
# arch - The architecture to build.
|
||||
#
|
||||
define build-arch
|
||||
$(ECHO) " BUILD $(TargetTuple)"
|
||||
$(MAKE) $(JOBSFLAG) -C $(BuildPath)/$(TargetTuple) --no-print-directory \
|
||||
all
|
||||
endef # build-arch
|
||||
|
||||
#
|
||||
# stage-arch <arch>
|
||||
#
|
||||
# Stage (install) the OpenThread final build products for the specified
|
||||
# architecture.
|
||||
#
|
||||
# arch - The architecture to stage.
|
||||
#
|
||||
define stage-arch
|
||||
$(ECHO) " STAGE $(TargetTuple)"
|
||||
$(MAKE) $(JOBSFLAG) -C $(BuildPath)/$(TargetTuple) --no-print-directory \
|
||||
DESTDIR=$(AbsTopResultDir) \
|
||||
install
|
||||
endef # stage-arch
|
||||
|
||||
#
|
||||
# ARCH_template <arch>
|
||||
#
|
||||
# Define macros, targets and rules to configure, build, and stage the
|
||||
# OpenThread for a single architecture.
|
||||
#
|
||||
# arch - The architecture to instantiate the template for.
|
||||
#
|
||||
define ARCH_template
|
||||
CONFIGURE_TARGETS += configure-$(1)
|
||||
BUILD_TARGETS += do-build-$(1)
|
||||
STAGE_TARGETS += stage-$(1)
|
||||
BUILD_DIRS += $(BuildPath)/$(TargetTuple)
|
||||
DIRECTORIES += $(BuildPath)/$(TargetTuple)
|
||||
|
||||
configure-$(1): target_CPPFLAGS=$($(1)_target_CPPFLAGS)
|
||||
configure-$(1): target_CFLAGS=$($(1)_target_CFLAGS)
|
||||
configure-$(1): target_CXXFLAGS=$($(1)_target_CXXFLAGS)
|
||||
configure-$(1): target_LDFLAGS=$($(1)_target_LDFLAGS)
|
||||
|
||||
configure-$(1): $(BuildPath)/$(TargetTuple)/config.status
|
||||
|
||||
$(BuildPath)/$(TargetTuple)/config.status: | $(BuildPath)/$(TargetTuple)
|
||||
$$(call configure-arch,$(1))
|
||||
|
||||
do-build-$(1): configure-$(1)
|
||||
|
||||
do-build-$(1):
|
||||
+$$(call build-arch,$(1))
|
||||
|
||||
stage-$(1): do-build-$(1)
|
||||
|
||||
stage-$(1): | $(TopResultDir)
|
||||
$$(call stage-arch,$(1))
|
||||
|
||||
$(1): stage-$(1)
|
||||
endef # ARCH_template
|
||||
|
||||
.DEFAULT_GOAL := all
|
||||
|
||||
all: stage
|
||||
|
||||
#
|
||||
# cortex-m0plus
|
||||
#
|
||||
|
||||
cortex-m0plus_target_ABI = cortex-m0plus
|
||||
cortex-m0plus_target_CPPFLAGS = -mcpu=cortex-m0plus -mfloat-abi=soft -mthumb
|
||||
cortex-m0plus_target_CFLAGS = -mcpu=cortex-m0plus -mfloat-abi=soft -mthumb
|
||||
cortex-m0plus_target_CXXFLAGS = -mcpu=cortex-m0plus -mfloat-abi=soft -mthumb
|
||||
cortex-m0plus_target_LDFLAGS = -mcpu=cortex-m0plus -mfloat-abi=soft -mthumb
|
||||
|
||||
# Instantiate an architecture-specific build template for each target
|
||||
# architecture.
|
||||
|
||||
$(foreach arch,$(ARCHS),$(eval $(call ARCH_template,$(arch))))
|
||||
|
||||
#
|
||||
# Common / Finalization
|
||||
#
|
||||
|
||||
configure: $(CONFIGURE_TARGETS)
|
||||
|
||||
build: $(BUILD_TARGETS)
|
||||
|
||||
stage: $(STAGE_TARGETS)
|
||||
|
||||
DIRECTORIES = $(TopResultDir) $(TopResultDir)/$(TargetTuple)/lib $(BUILD_DIRS)
|
||||
|
||||
CLEAN_DIRS = $(TopResultDir) $(BUILD_DIRS)
|
||||
|
||||
all: stage
|
||||
|
||||
$(DIRECTORIES):
|
||||
$(ECHO) " MKDIR $@"
|
||||
@$(MKDIR_P) "$@"
|
||||
|
||||
clean:
|
||||
$(ECHO) " CLEAN"
|
||||
@$(RM_F) -r $(CLEAN_DIRS)
|
||||
|
||||
help:
|
||||
$(ECHO) "Simply type 'make -f $(firstword $(MAKEFILE_LIST))' to build OpenThread for the following "
|
||||
$(ECHO) "architectures: "
|
||||
$(ECHO) ""
|
||||
$(ECHO) " $(ARCHS)"
|
||||
$(ECHO) ""
|
||||
$(ECHO) "To build only a particular architecture, specify: "
|
||||
$(ECHO) ""
|
||||
$(ECHO) " make -f $(firstword $(MAKEFILE_LIST)) <architecture>"
|
||||
$(ECHO) ""
|
||||
@@ -30,6 +30,7 @@ include $(abs_top_nlbuild_autotools_dir)/automake/pre.am
|
||||
|
||||
EXTRA_DIST = \
|
||||
gp712 \
|
||||
kw41z \
|
||||
qpg6095 \
|
||||
qpg6100 \
|
||||
qpg7015m \
|
||||
@@ -45,7 +46,6 @@ DIST_SUBDIRS = \
|
||||
cc2652 \
|
||||
efr32 \
|
||||
k32w \
|
||||
kw41z \
|
||||
nrf528xx \
|
||||
simulation \
|
||||
utils \
|
||||
@@ -81,10 +81,6 @@ if OPENTHREAD_PLATFORM_K32W
|
||||
SUBDIRS += k32w
|
||||
endif
|
||||
|
||||
if OPENTHREAD_PLATFORM_KW41Z
|
||||
SUBDIRS += kw41z
|
||||
endif
|
||||
|
||||
if OPENTHREAD_PLATFORM_NRF528XX
|
||||
SUBDIRS += nrf528xx
|
||||
endif
|
||||
|
||||
@@ -69,10 +69,6 @@ if OPENTHREAD_EXAMPLES_K32W061
|
||||
include $(top_srcdir)/examples/platforms/k32w/k32w061/Makefile.platform.am
|
||||
endif
|
||||
|
||||
if OPENTHREAD_EXAMPLES_KW41Z
|
||||
include $(top_srcdir)/examples/platforms/kw41z/Makefile.platform.am
|
||||
endif
|
||||
|
||||
if OPENTHREAD_EXAMPLES_NRF52811
|
||||
include $(top_srcdir)/examples/platforms/nrf528xx/nrf52811/Makefile.platform.am
|
||||
endif
|
||||
|
||||
@@ -1,91 +0,0 @@
|
||||
#
|
||||
# Copyright (c) 2020, The OpenThread Authors.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. 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.
|
||||
# 3. Neither the name of the copyright holder 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 HOLDER 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.
|
||||
#
|
||||
|
||||
set(OT_PLATFORM_LIB "openthread-kw41z" PARENT_SCOPE)
|
||||
|
||||
if(NOT OT_CONFIG)
|
||||
set(OT_CONFIG "openthread-core-kw41z-config.h")
|
||||
set(OT_CONFIG ${OT_CONFIG} PARENT_SCOPE)
|
||||
endif()
|
||||
|
||||
list(APPEND OT_PLATFORM_DEFINES
|
||||
"OPENTHREAD_CORE_CONFIG_PLATFORM_CHECK_FILE=\"openthread-core-kw41z-config-check.h\""
|
||||
)
|
||||
set(OT_PLATFORM_DEFINES ${OT_PLATFORM_DEFINES} PARENT_SCOPE)
|
||||
|
||||
list(APPEND OT_PLATFORM_DEFINES "OPENTHREAD_PROJECT_CORE_CONFIG_FILE=\"${OT_CONFIG}\"")
|
||||
|
||||
add_library(openthread-kw41z
|
||||
alarm.c
|
||||
diag.c
|
||||
entropy.c
|
||||
flash.c
|
||||
logging.c
|
||||
misc.c
|
||||
radio.c
|
||||
system.c
|
||||
uart.c
|
||||
)
|
||||
|
||||
set_target_properties(
|
||||
openthread-kw41z
|
||||
PROPERTIES
|
||||
C_STANDARD 99
|
||||
CXX_STANDARD 11
|
||||
)
|
||||
|
||||
target_link_libraries(openthread-kw41z
|
||||
PRIVATE
|
||||
nxp-kw41z-driver
|
||||
ot-config
|
||||
PUBLIC
|
||||
-T${PROJECT_SOURCE_DIR}/examples/platforms/kw41z/MKW41Z512xxx4.ld
|
||||
-Wl,--gc-sections -Wl,-Map=$<TARGET_PROPERTY:NAME>.map
|
||||
)
|
||||
|
||||
target_compile_definitions(openthread-kw41z
|
||||
PUBLIC
|
||||
${OT_PLATFORM_DEFINES}
|
||||
)
|
||||
|
||||
target_compile_options(openthread-kw41z
|
||||
PRIVATE
|
||||
${OT_CFLAGS}
|
||||
-Wno-unknown-pragmas
|
||||
-Wno-sign-compare
|
||||
-Wno-unused-function
|
||||
-Wno-unused-parameter
|
||||
-Wno-empty-body
|
||||
)
|
||||
|
||||
target_include_directories(openthread-kw41z
|
||||
PRIVATE
|
||||
${OT_PUBLIC_INCLUDES}
|
||||
${PROJECT_SOURCE_DIR}/examples/platforms
|
||||
${PROJECT_SOURCE_DIR}/src/core
|
||||
)
|
||||
@@ -1,242 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2017, The OpenThread Authors.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. 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.
|
||||
* 3. Neither the name of the copyright holder 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 HOLDER 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* GCC linker script for MKW41Z512xxx4.
|
||||
*/
|
||||
|
||||
GROUP (
|
||||
libm.a
|
||||
)
|
||||
|
||||
/* Entry Point */
|
||||
ENTRY(Reset_Handler)
|
||||
|
||||
HEAP_SIZE = DEFINED(__heap_size__) ? __heap_size__ : 0x0400;
|
||||
STACK_SIZE = DEFINED(__stack_size__) ? __stack_size__ : 0x0400;
|
||||
M_VECTOR_RAM_SIZE = DEFINED(__ram_vector_table__) ? 0x0200 : 0x0;
|
||||
|
||||
/* Specify the memory areas */
|
||||
MEMORY
|
||||
{
|
||||
m_interrupts (RX) : ORIGIN = 0x00000000, LENGTH = 0x00000200
|
||||
m_flash_config (RX) : ORIGIN = 0x00000400, LENGTH = 0x00000010
|
||||
m_text (RX) : ORIGIN = 0x00000410, LENGTH = 0x0007FBF0
|
||||
m_data (RW) : ORIGIN = 0x1FFF8000, LENGTH = 0x00020000
|
||||
}
|
||||
|
||||
/* Define output sections */
|
||||
SECTIONS
|
||||
{
|
||||
/* The startup code goes first into internal flash */
|
||||
.interrupts :
|
||||
{
|
||||
__VECTOR_TABLE = .;
|
||||
. = ALIGN(4);
|
||||
KEEP(*(.isr_vector)) /* Startup code */
|
||||
. = ALIGN(4);
|
||||
} > m_interrupts
|
||||
|
||||
.flash_config :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
KEEP(*(.FlashConfig)) /* Flash Configuration Field (FCF) */
|
||||
. = ALIGN(4);
|
||||
} > m_flash_config
|
||||
|
||||
/* The program code and other data goes into internal flash */
|
||||
.text :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
*(.text) /* .text sections (code) */
|
||||
*(.text*) /* .text* sections (code) */
|
||||
*(.rodata) /* .rodata sections (constants, strings, etc.) */
|
||||
*(.rodata*) /* .rodata* sections (constants, strings, etc.) */
|
||||
*(.glue_7) /* glue arm to thumb code */
|
||||
*(.glue_7t) /* glue thumb to arm code */
|
||||
*(.eh_frame)
|
||||
KEEP (*(.init))
|
||||
KEEP (*(.fini))
|
||||
. = ALIGN(4);
|
||||
} > m_text
|
||||
|
||||
.ARM.extab :
|
||||
{
|
||||
*(.ARM.extab* .gnu.linkonce.armextab.*)
|
||||
} > m_text
|
||||
|
||||
.ARM :
|
||||
{
|
||||
__exidx_start = .;
|
||||
*(.ARM.exidx*)
|
||||
__exidx_end = .;
|
||||
} > m_text
|
||||
|
||||
.ctors :
|
||||
{
|
||||
__CTOR_LIST__ = .;
|
||||
/* gcc uses crtbegin.o to find the start of
|
||||
the constructors, so we make sure it is
|
||||
first. Because this is a wildcard, it
|
||||
doesn't matter if the user does not
|
||||
actually link against crtbegin.o; the
|
||||
linker won't look for a file to match a
|
||||
wildcard. The wildcard also means that it
|
||||
doesn't matter which directory crtbegin.o
|
||||
is in. */
|
||||
KEEP (*crtbegin.o(.ctors))
|
||||
KEEP (*crtbegin?.o(.ctors))
|
||||
/* We don't want to include the .ctor section from
|
||||
from the crtend.o file until after the sorted ctors.
|
||||
The .ctor section from the crtend file contains the
|
||||
end of ctors marker and it must be last */
|
||||
KEEP (*(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors))
|
||||
KEEP (*(SORT(.ctors.*)))
|
||||
KEEP (*(.ctors))
|
||||
__CTOR_END__ = .;
|
||||
} > m_text
|
||||
|
||||
.dtors :
|
||||
{
|
||||
__DTOR_LIST__ = .;
|
||||
KEEP (*crtbegin.o(.dtors))
|
||||
KEEP (*crtbegin?.o(.dtors))
|
||||
KEEP (*(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors))
|
||||
KEEP (*(SORT(.dtors.*)))
|
||||
KEEP (*(.dtors))
|
||||
__DTOR_END__ = .;
|
||||
} > m_text
|
||||
|
||||
.preinit_array :
|
||||
{
|
||||
PROVIDE_HIDDEN (__preinit_array_start = .);
|
||||
KEEP (*(.preinit_array*))
|
||||
PROVIDE_HIDDEN (__preinit_array_end = .);
|
||||
} > m_text
|
||||
|
||||
.init_array :
|
||||
{
|
||||
PROVIDE_HIDDEN (__init_array_start = .);
|
||||
KEEP (*(SORT(.init_array.*)))
|
||||
KEEP (*(.init_array*))
|
||||
PROVIDE_HIDDEN (__init_array_end = .);
|
||||
} > m_text
|
||||
|
||||
.fini_array :
|
||||
{
|
||||
PROVIDE_HIDDEN (__fini_array_start = .);
|
||||
KEEP (*(SORT(.fini_array.*)))
|
||||
KEEP (*(.fini_array*))
|
||||
PROVIDE_HIDDEN (__fini_array_end = .);
|
||||
} > m_text
|
||||
|
||||
__etext = .; /* define a global symbol at end of code */
|
||||
__DATA_ROM = .; /* Symbol is used by startup for data initialization */
|
||||
|
||||
/* reserve MTB memory at the beginning of m_data */
|
||||
.mtb : /* MTB buffer address as defined by the hardware */
|
||||
{
|
||||
. = ALIGN(8);
|
||||
_mtb_start = .;
|
||||
KEEP(*(.mtb_buf)) /* need to KEEP Micro Trace Buffer as not referenced by application */
|
||||
. = ALIGN(8);
|
||||
_mtb_end = .;
|
||||
} > m_data
|
||||
|
||||
.interrupts_ram :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
__VECTOR_RAM__ = .;
|
||||
__interrupts_ram_start__ = .; /* Create a global symbol at data start */
|
||||
*(.m_interrupts_ram) /* This is a user defined section */
|
||||
. += M_VECTOR_RAM_SIZE;
|
||||
. = ALIGN(4);
|
||||
__interrupts_ram_end__ = .; /* Define a global symbol at data end */
|
||||
} > m_data
|
||||
|
||||
__VECTOR_RAM = DEFINED(__ram_vector_table__) ? __VECTOR_RAM__ : ORIGIN(m_interrupts);
|
||||
__RAM_VECTOR_TABLE_SIZE_BYTES = DEFINED(__ram_vector_table__) ? (__interrupts_ram_end__ - __interrupts_ram_start__) : 0x0;
|
||||
|
||||
.data : AT(__DATA_ROM)
|
||||
{
|
||||
. = ALIGN(4);
|
||||
__DATA_RAM = .;
|
||||
__data_start__ = .; /* create a global symbol at data start */
|
||||
*(.data) /* .data sections */
|
||||
*(.data*) /* .data* sections */
|
||||
KEEP(*(.jcr*))
|
||||
. = ALIGN(4);
|
||||
__data_end__ = .; /* define a global symbol at data end */
|
||||
} > m_data
|
||||
|
||||
__DATA_END = __DATA_ROM + (__data_end__ - __data_start__);
|
||||
text_end = ORIGIN(m_text) + LENGTH(m_text);
|
||||
ASSERT(__DATA_END <= text_end, "region m_text overflowed with text and data")
|
||||
|
||||
/* Uninitialized data section */
|
||||
.bss :
|
||||
{
|
||||
/* This is used by the startup in order to initialize the .bss section */
|
||||
. = ALIGN(4);
|
||||
__START_BSS = .;
|
||||
__bss_start__ = .;
|
||||
*(.bss)
|
||||
*(.bss*)
|
||||
*(COMMON)
|
||||
. = ALIGN(4);
|
||||
__bss_end__ = .;
|
||||
__END_BSS = .;
|
||||
} > m_data
|
||||
|
||||
.heap :
|
||||
{
|
||||
. = ALIGN(8);
|
||||
__end__ = .;
|
||||
PROVIDE(end = .);
|
||||
__HeapBase = .;
|
||||
. += HEAP_SIZE;
|
||||
__HeapLimit = .;
|
||||
__heap_limit = .; /* Add for _sbrk */
|
||||
} > m_data
|
||||
|
||||
.stack :
|
||||
{
|
||||
. = ALIGN(8);
|
||||
. += STACK_SIZE;
|
||||
} > m_data
|
||||
|
||||
/* Initializes stack on the end of block */
|
||||
__StackTop = ORIGIN(m_data) + LENGTH(m_data);
|
||||
__StackLimit = __StackTop - STACK_SIZE;
|
||||
PROVIDE(__stack = __StackTop);
|
||||
|
||||
.ARM.attributes 0 : { *(.ARM.attributes) }
|
||||
|
||||
ASSERT(__StackLimit >= __HeapLimit, "region m_data overflowed with stack and heap")
|
||||
}
|
||||
@@ -1,110 +0,0 @@
|
||||
#
|
||||
# Copyright (c) 2017, The OpenThread Authors.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. 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.
|
||||
# 3. Neither the name of the copyright holder 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 HOLDER 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 $(abs_top_nlbuild_autotools_dir)/automake/pre.am
|
||||
|
||||
lib_LIBRARIES = libopenthread-kw41z.a
|
||||
|
||||
# Do not enable -Wundef for this platform
|
||||
override CFLAGS := $(filter-out -Wundef,$(CFLAGS))
|
||||
override CXXFLAGS := $(filter-out -Wundef,$(CXXFLAGS))
|
||||
|
||||
# Do not enable -Wcast-align for this platform
|
||||
override CFLAGS := $(filter-out -Wcast-align,$(CFLAGS))
|
||||
override CXXFLAGS := $(filter-out -Wcast-align,$(CXXFLAGS))
|
||||
|
||||
libopenthread_kw41z_a_CPPFLAGS = \
|
||||
-DCPU_MKW41Z512VHT4 \
|
||||
-I$(top_srcdir)/include \
|
||||
-I$(top_srcdir)/examples/platforms \
|
||||
-I$(top_srcdir)/src/core \
|
||||
-I$(top_srcdir)/third_party/nxp \
|
||||
-I$(top_srcdir)/third_party/nxp/CMSIS/Include \
|
||||
-I$(top_srcdir)/third_party/nxp/MKW41Z4 \
|
||||
-I$(top_srcdir)/third_party/nxp/MKW41Z4/drivers \
|
||||
-I$(top_srcdir)/third_party/nxp/MKW41Z4/XCVR \
|
||||
-I$(top_srcdir)/third_party/nxp/MKW41Z4/XCVR/cfgs_kw4x_3x_2x \
|
||||
-Wno-unknown-pragmas \
|
||||
-Wno-sign-compare \
|
||||
-Wno-unused-function \
|
||||
-Wno-unused-parameter \
|
||||
-Wno-empty-body \
|
||||
$(NULL)
|
||||
|
||||
PLATFORM_SOURCES = \
|
||||
alarm.c \
|
||||
diag.c \
|
||||
entropy.c \
|
||||
flash.c \
|
||||
logging.c \
|
||||
misc.c \
|
||||
openthread-core-kw41z-config.h \
|
||||
openthread-core-kw41z-config-check.h \
|
||||
platform-kw41z.h \
|
||||
radio.c \
|
||||
system.c \
|
||||
uart.c \
|
||||
$(NULL)
|
||||
|
||||
libopenthread_kw41z_a_SOURCES = \
|
||||
@top_builddir@/third_party/nxp/MKW41Z4/startup_MKW41Z4.S \
|
||||
@top_builddir@/third_party/nxp/MKW41Z4/clock_config.c \
|
||||
@top_builddir@/third_party/nxp/MKW41Z4/system_MKW41Z4.c \
|
||||
@top_builddir@/third_party/nxp/MKW41Z4/drivers/fsl_clock.c \
|
||||
@top_builddir@/third_party/nxp/MKW41Z4/drivers/fsl_flash.c \
|
||||
@top_builddir@/third_party/nxp/MKW41Z4/drivers/fsl_lpuart.c \
|
||||
@top_builddir@/third_party/nxp/MKW41Z4/drivers/fsl_gpio.c \
|
||||
@top_builddir@/third_party/nxp/MKW41Z4/drivers/fsl_pit.c \
|
||||
@top_builddir@/third_party/nxp/MKW41Z4/drivers/fsl_trng.c \
|
||||
@top_builddir@/third_party/nxp/MKW41Z4/XCVR/dbg_ram_capture.c \
|
||||
@top_builddir@/third_party/nxp/MKW41Z4/XCVR/fsl_xcvr.c \
|
||||
@top_builddir@/third_party/nxp/MKW41Z4/XCVR/fsl_xcvr_trim.c \
|
||||
@top_builddir@/third_party/nxp/MKW41Z4/XCVR/ifr_radio.c \
|
||||
@top_builddir@/third_party/nxp/MKW41Z4/XCVR/cfgs_kw4x_3x_2x/fsl_xcvr_ant_config.c \
|
||||
@top_builddir@/third_party/nxp/MKW41Z4/XCVR/cfgs_kw4x_3x_2x/fsl_xcvr_ble_config.c \
|
||||
@top_builddir@/third_party/nxp/MKW41Z4/XCVR/cfgs_kw4x_3x_2x/fsl_xcvr_common_config.c \
|
||||
@top_builddir@/third_party/nxp/MKW41Z4/XCVR/cfgs_kw4x_3x_2x/fsl_xcvr_gfsk_bt_0p3_h_0p5_config.c \
|
||||
@top_builddir@/third_party/nxp/MKW41Z4/XCVR/cfgs_kw4x_3x_2x/fsl_xcvr_gfsk_bt_0p5_h_0p32_config.c \
|
||||
@top_builddir@/third_party/nxp/MKW41Z4/XCVR/cfgs_kw4x_3x_2x/fsl_xcvr_gfsk_bt_0p5_h_0p5_config.c \
|
||||
@top_builddir@/third_party/nxp/MKW41Z4/XCVR/cfgs_kw4x_3x_2x/fsl_xcvr_gfsk_bt_0p5_h_0p7_config.c \
|
||||
@top_builddir@/third_party/nxp/MKW41Z4/XCVR/cfgs_kw4x_3x_2x/fsl_xcvr_gfsk_bt_0p5_h_1p0_config.c \
|
||||
@top_builddir@/third_party/nxp/MKW41Z4/XCVR/cfgs_kw4x_3x_2x/fsl_xcvr_gfsk_bt_0p7_h_0p5_config.c \
|
||||
@top_builddir@/third_party/nxp/MKW41Z4/XCVR/cfgs_kw4x_3x_2x/fsl_xcvr_mode_datarate_config.c \
|
||||
@top_builddir@/third_party/nxp/MKW41Z4/XCVR/cfgs_kw4x_3x_2x/fsl_xcvr_msk_config.c \
|
||||
@top_builddir@/third_party/nxp/MKW41Z4/XCVR/cfgs_kw4x_3x_2x/fsl_xcvr_zgbe_config.c \
|
||||
$(NULL)
|
||||
|
||||
libopenthread_kw41z_a_SOURCES += \
|
||||
$(PLATFORM_SOURCES) \
|
||||
$(NULL)
|
||||
|
||||
Dash = -
|
||||
libopenthread_kw41z_a_LIBADD = \
|
||||
$(shell find $(top_builddir)/examples/platforms/utils $(Dash)type f $(Dash)name "*.o")
|
||||
|
||||
include $(abs_top_nlbuild_autotools_dir)/automake/post.am
|
||||
@@ -1,39 +0,0 @@
|
||||
#
|
||||
# Copyright (c) 2017, The OpenThread Authors.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. 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.
|
||||
# 3. Neither the name of the copyright holder 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 HOLDER 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.
|
||||
#
|
||||
|
||||
#
|
||||
# kw41z platform-specific Makefile
|
||||
#
|
||||
|
||||
LDADD_COMMON += \
|
||||
$(top_builddir)/examples/platforms/kw41z/libopenthread-kw41z.a \
|
||||
$(NULL)
|
||||
|
||||
LDFLAGS_COMMON += \
|
||||
-T $(top_srcdir)/examples/platforms/kw41z/MKW41Z512xxx4.ld \
|
||||
$(NULL)
|
||||
@@ -1,128 +1 @@
|
||||
# OpenThread on NXP(Freescale) Kinetis MKW41Z512 Example
|
||||
|
||||
This directory contains example platform drivers for the [NXP(Freescale) Kinetis MKW41Z512][mkw41z512] based on [FRDM-KW41Z][frdm-kw41z] hardware platform.
|
||||
|
||||
[mkw41z512]: http://www.nxp.com/products/microcontrollers-and-processors/arm-processors/kinetis-cortex-m-mcus/w-series-wireless-m0-plus-m4/kinetis-kw41z-2.4-ghz-dual-mode-ble-and-802.15.4-wireless-radio-microcontroller-mcu-based-on-arm-cortex-m0-plus-core:KW41Z
|
||||
[frdm-kw41z]: http://www.nxp.com/products/software-and-tools/hardware-development-tools/freedom-development-boards/nxp-freedom-development-kit-for-kinetis-kw41z-31z-21z-mcus:FRDM-KW41Z
|
||||
|
||||
The example platform drivers are intended to present the minimal code necessary to support OpenThread. As a result, the example platform drivers do not necessarily highlight the platform's full capabilities.
|
||||
|
||||
## Toolchain
|
||||
|
||||
Download and install the [GNU toolchain for ARM Cortex-M][gnu-toolchain].
|
||||
|
||||
[gnu-toolchain]: https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/gnu-rm
|
||||
|
||||
In a Bash terminal, follow these instructions to install the GNU toolchain and other dependencies.
|
||||
|
||||
```bash
|
||||
$ cd <path-to-openthread>
|
||||
$ ./script/bootstrap
|
||||
```
|
||||
|
||||
## Build Examples
|
||||
|
||||
```bash
|
||||
$ cd <path-to-openthread>
|
||||
$ ./bootstrap
|
||||
$ make -f examples/Makefile-kw41z
|
||||
```
|
||||
|
||||
After a successful build, the `elf` files are found in `<path-to-openthread>/output/kw41z/bin`. You can convert them to `bin` files using `arm-none-eabi-objcopy`:
|
||||
|
||||
```bash
|
||||
$ arm-none-eabi-objcopy -O binary ot-cli-ftd ot-cli-ftd.bin
|
||||
```
|
||||
|
||||
## Flash Binaries
|
||||
|
||||
Compiled binaries may be flashed onto the MKW41Z512 using drag-and-drop into the board's MSD Bootloader or the [NXP(Freescale) Test Tool][test-tool] or [JTAG interface][jtag]. The [NXP(Freescale) Test Tool][test-tool] provides a convenient method for flashing a MKW41Z512 via the [J-Link][jlink].
|
||||
|
||||
[test-tool]: http://www.nxp.com/webapp/sps/download/license.jsp?colCode=TESTTOOL_SETUP
|
||||
[jtag]: https://en.wikipedia.org/wiki/JTAG
|
||||
[jlink]: https://www.segger.com/jlink-software.html
|
||||
|
||||
## Running the example
|
||||
|
||||
1. Prepare two boards with the flashed `CLI Example` (as shown above).
|
||||
2. The CLI example uses UART connection. To view raw UART output, start a terminal emulator like PuTTY and connect to the used COM port with the following UART settings:
|
||||
|
||||
- Baud rate: 115200
|
||||
- 8 data bits
|
||||
- 1 stop bit
|
||||
- No parity
|
||||
- No flow control
|
||||
|
||||
3. Open a terminal connection on the first board and start a new Thread network.
|
||||
|
||||
```bash
|
||||
> dataset init new
|
||||
Done
|
||||
> dataset
|
||||
Active Timestamp: 1
|
||||
Channel: 13
|
||||
Channel Mask: 0x07fff800
|
||||
Ext PAN ID: d63e8e3e495ebbc3
|
||||
Mesh Local Prefix: fd3d:b50b:f96d:722d::/64
|
||||
Master Key: dfd34f0f05cad978ec4e32b0413038ff
|
||||
Network Name: OpenThread-8f28
|
||||
PAN ID: 0x8f28
|
||||
PSKc: c23a76e98f1a6483639b1ac1271e2e27
|
||||
Security Policy: 0, onrcb
|
||||
Done
|
||||
> dataset commit active
|
||||
Done
|
||||
> ifconfig up
|
||||
Done
|
||||
> thread start
|
||||
Done
|
||||
```
|
||||
|
||||
4. After a couple of seconds the node will become a Leader of the network.
|
||||
|
||||
```bash
|
||||
> state
|
||||
leader
|
||||
```
|
||||
|
||||
5. Open a terminal connection on the second board and attach a node to the network.
|
||||
|
||||
```bash
|
||||
> dataset masterkey dfd34f0f05cad978ec4e32b0413038ff
|
||||
Done
|
||||
> dataset commit active
|
||||
Done
|
||||
> ifconfig up
|
||||
Done
|
||||
> thread start
|
||||
Done
|
||||
```
|
||||
|
||||
6. After a couple of seconds the second node will attach and become a Child.
|
||||
|
||||
```bash
|
||||
> state
|
||||
child
|
||||
```
|
||||
|
||||
7. List all IPv6 addresses of the first board.
|
||||
|
||||
```bash
|
||||
> ipaddr
|
||||
fd3d:b50b:f96d:722d:0:ff:fe00:fc00
|
||||
fd3d:b50b:f96d:722d:0:ff:fe00:c00
|
||||
fd3d:b50b:f96d:722d:7a73:bff6:9093:9117
|
||||
fe80:0:0:0:6c41:9001:f3d6:4148
|
||||
Done
|
||||
```
|
||||
|
||||
8. Choose one of them and send an ICMPv6 ping from the second board.
|
||||
|
||||
```bash
|
||||
> ping fd3d:b50b:f96d:722d:7a73:bff6:9093:9117
|
||||
16 bytes from fd3d:b50b:f96d:722d:558:f56b:d688:799: icmp_seq=1 hlim=64 time=24ms
|
||||
```
|
||||
|
||||
For a list of all available commands, visit [OpenThread CLI Reference README.md][cli].
|
||||
|
||||
[cli]: https://github.com/openthread/openthread/blob/main/src/cli/README.md
|
||||
The OpenThread on KW41Z example has moved to https://github.com/openthread/ot-kw41z
|
||||
|
||||
@@ -1,103 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2017, The OpenThread Authors.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. 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.
|
||||
* 3. Neither the name of the copyright holder 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 HOLDER 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* This file implements the OpenThread platform abstraction for the alarm.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "fsl_clock.h"
|
||||
#include "fsl_device_registers.h"
|
||||
#include "fsl_pit.h"
|
||||
#include <stdint.h>
|
||||
|
||||
#include <openthread/platform/alarm-milli.h>
|
||||
#include <openthread/platform/diag.h>
|
||||
|
||||
static volatile uint32_t sTime = 0;
|
||||
static uint32_t sAlarmTime = 0;
|
||||
|
||||
void kw41zAlarmInit(void)
|
||||
{
|
||||
pit_config_t config;
|
||||
uint32_t count = (CLOCK_GetBusClkFreq() / 1000) - 1;
|
||||
|
||||
PIT_GetDefaultConfig(&config);
|
||||
PIT_Init(PIT, &config);
|
||||
PIT_SetTimerPeriod(PIT, kPIT_Chnl_0, count);
|
||||
PIT_StartTimer(PIT, kPIT_Chnl_0);
|
||||
|
||||
PIT_EnableInterrupts(PIT, kPIT_Chnl_0, kPIT_TimerInterruptEnable);
|
||||
NVIC_ClearPendingIRQ(PIT_IRQn);
|
||||
NVIC_EnableIRQ(PIT_IRQn);
|
||||
}
|
||||
|
||||
void kw41zAlarmProcess(otInstance *aInstance)
|
||||
{
|
||||
if ((sAlarmTime != 0) && (sTime >= sAlarmTime))
|
||||
{
|
||||
sAlarmTime = 0;
|
||||
#if OPENTHREAD_CONFIG_DIAG_ENABLE
|
||||
|
||||
if (otPlatDiagModeGet())
|
||||
{
|
||||
otPlatDiagAlarmFired(aInstance);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
otPlatAlarmMilliFired(aInstance);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void otPlatAlarmMilliStartAt(otInstance *aInstance, uint32_t aT0, uint32_t aDt)
|
||||
{
|
||||
OT_UNUSED_VARIABLE(aInstance);
|
||||
|
||||
sAlarmTime = aT0 + aDt;
|
||||
}
|
||||
|
||||
void otPlatAlarmMilliStop(otInstance *aInstance)
|
||||
{
|
||||
OT_UNUSED_VARIABLE(aInstance);
|
||||
|
||||
sAlarmTime = 0;
|
||||
}
|
||||
|
||||
uint32_t otPlatAlarmMilliGetNow(void)
|
||||
{
|
||||
return sTime;
|
||||
}
|
||||
|
||||
void PIT_IRQHandler(void)
|
||||
{
|
||||
PIT_ClearStatusFlags(PIT, kPIT_Chnl_0, kPIT_TimerFlag);
|
||||
sTime++;
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
#
|
||||
# Copyright (c) 2020, The OpenThread Authors.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. 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.
|
||||
# 3. Neither the name of the copyright holder 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 HOLDER 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.
|
||||
#
|
||||
|
||||
set(CMAKE_SYSTEM_NAME Generic)
|
||||
set(CMAKE_SYSTEM_PROCESSOR ARM)
|
||||
|
||||
set(CMAKE_C_COMPILER arm-none-eabi-gcc)
|
||||
set(CMAKE_CXX_COMPILER arm-none-eabi-g++)
|
||||
set(CMAKE_ASM_COMPILER arm-none-eabi-as)
|
||||
set(CMAKE_RANLIB arm-none-eabi-ranlib)
|
||||
|
||||
set(COMMON_C_FLAGS "-mthumb -fdata-sections -ffunction-sections -mcpu=cortex-m0plus -mfloat-abi=soft")
|
||||
|
||||
set(CMAKE_C_FLAGS_INIT "${COMMON_C_FLAGS} -std=gnu99")
|
||||
set(CMAKE_CXX_FLAGS_INIT "${COMMON_C_FLAGS} -fno-exceptions -fno-rtti")
|
||||
set(CMAKE_ASM_FLAGS_INIT "${COMMON_C_FLAGS}")
|
||||
set(CMAKE_EXE_LINKER_FLAGS_INIT "${COMMON_C_FLAGS} -specs=nano.specs -specs=nosys.specs")
|
||||
@@ -1,84 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2017, The OpenThread Authors.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. 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.
|
||||
* 3. Neither the name of the copyright holder 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 HOLDER 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* This file implements the OpenThread platform abstraction for the diagnostics.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "fsl_device_registers.h"
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <openthread/config.h>
|
||||
#include <openthread/platform/alarm-milli.h>
|
||||
#include <openthread/platform/radio.h>
|
||||
|
||||
#if OPENTHREAD_CONFIG_DIAG_ENABLE
|
||||
|
||||
/**
|
||||
* Diagnostics mode variables.
|
||||
*
|
||||
*/
|
||||
static bool sDiagMode = false;
|
||||
|
||||
void otPlatDiagModeSet(bool aMode)
|
||||
{
|
||||
sDiagMode = aMode;
|
||||
}
|
||||
|
||||
bool otPlatDiagModeGet()
|
||||
{
|
||||
return sDiagMode;
|
||||
}
|
||||
|
||||
void otPlatDiagChannelSet(uint8_t aChannel)
|
||||
{
|
||||
OT_UNUSED_VARIABLE(aChannel);
|
||||
}
|
||||
|
||||
void otPlatDiagTxPowerSet(int8_t aTxPower)
|
||||
{
|
||||
OT_UNUSED_VARIABLE(aTxPower);
|
||||
}
|
||||
|
||||
void otPlatDiagRadioReceived(otInstance *aInstance, otRadioFrame *aFrame, otError aError)
|
||||
{
|
||||
OT_UNUSED_VARIABLE(aInstance);
|
||||
OT_UNUSED_VARIABLE(aFrame);
|
||||
OT_UNUSED_VARIABLE(aError);
|
||||
}
|
||||
|
||||
void otPlatDiagAlarmCallback(otInstance *aInstance)
|
||||
{
|
||||
OT_UNUSED_VARIABLE(aInstance);
|
||||
}
|
||||
|
||||
#endif // OPENTHREAD_CONFIG_DIAG_ENABLE
|
||||
@@ -1,74 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2019, The OpenThread Authors.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. 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.
|
||||
* 3. Neither the name of the copyright holder 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 HOLDER 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* This file implements an entropy source based on TRNG.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <openthread/platform/entropy.h>
|
||||
|
||||
#include "fsl_device_registers.h"
|
||||
#include "fsl_trng.h"
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <utils/code_utils.h>
|
||||
|
||||
void kw41zRandomInit(void)
|
||||
{
|
||||
trng_config_t config;
|
||||
uint32_t seed;
|
||||
|
||||
TRNG_GetDefaultConfig(&config);
|
||||
config.frequencyCountLimit.minimum = 0x00000100;
|
||||
config.frequencyCountLimit.maximum = 0x000F0000;
|
||||
config.ringOscDiv = kTRNG_RingOscDiv0;
|
||||
config.entropyDelay = 1200;
|
||||
|
||||
otEXPECT(TRNG_Init(TRNG0, &config) == kStatus_Success);
|
||||
|
||||
otEXPECT(TRNG_GetRandomData(TRNG0, &seed, sizeof(seed)) == kStatus_Success);
|
||||
|
||||
srand(seed);
|
||||
|
||||
exit:
|
||||
return;
|
||||
}
|
||||
|
||||
otError otPlatEntropyGet(uint8_t *aOutput, uint16_t aOutputLength)
|
||||
{
|
||||
otError status = OT_ERROR_NONE;
|
||||
|
||||
otEXPECT_ACTION((aOutput != NULL), status = OT_ERROR_INVALID_ARGS);
|
||||
|
||||
otEXPECT_ACTION(TRNG_GetRandomData(TRNG0, aOutput, aOutputLength) == kStatus_Success, status = OT_ERROR_FAILED);
|
||||
|
||||
exit:
|
||||
return status;
|
||||
}
|
||||
@@ -1,92 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2017, The OpenThread Authors.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. 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.
|
||||
* 3. Neither the name of the copyright holder 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 HOLDER 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 <stdint.h>
|
||||
|
||||
#include <openthread/instance.h>
|
||||
|
||||
#include "fsl_device_registers.h"
|
||||
#include "fsl_flash.h"
|
||||
|
||||
#define FLASH_BASE_ADDRESS 0x40000
|
||||
#define FLASH_PAGE_SIZE 0x800
|
||||
#define FLASH_PAGE_NUM 2
|
||||
#define FLASH_SWAP_SIZE (FLASH_PAGE_SIZE * (FLASH_PAGE_NUM / 2))
|
||||
|
||||
static flash_config_t sFlashConfig;
|
||||
|
||||
static uint32_t mapAddress(uint8_t aSwapIndex, uint32_t aOffset)
|
||||
{
|
||||
uint32_t address = FLASH_BASE_ADDRESS + aOffset;
|
||||
|
||||
if (aSwapIndex)
|
||||
{
|
||||
address += FLASH_SWAP_SIZE;
|
||||
}
|
||||
|
||||
return address;
|
||||
}
|
||||
|
||||
void otPlatFlashInit(otInstance *aInstance)
|
||||
{
|
||||
OT_UNUSED_VARIABLE(aInstance);
|
||||
|
||||
FLASH_Init(&sFlashConfig);
|
||||
}
|
||||
|
||||
uint32_t otPlatFlashGetSwapSize(otInstance *aInstance)
|
||||
{
|
||||
OT_UNUSED_VARIABLE(aInstance);
|
||||
|
||||
return FLASH_SWAP_SIZE;
|
||||
}
|
||||
|
||||
void otPlatFlashErase(otInstance *aInstance, uint32_t aSwapIndex)
|
||||
{
|
||||
OT_UNUSED_VARIABLE(aInstance);
|
||||
|
||||
FLASH_Erase(&sFlashConfig, mapAddress(aSwapIndex, 0), FSL_FEATURE_FLASH_PFLASH_BLOCK_SECTOR_SIZE,
|
||||
kFLASH_ApiEraseKey);
|
||||
while ((FTFA->FSTAT & FTFA_FSTAT_CCIF_MASK) == 0)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
void otPlatFlashWrite(otInstance *aInstance, uint8_t aSwapIndex, uint32_t aOffset, const void *aData, uint32_t aSize)
|
||||
{
|
||||
OT_UNUSED_VARIABLE(aInstance);
|
||||
|
||||
FLASH_Program(&sFlashConfig, mapAddress(aSwapIndex, aOffset), (uint32_t *)aData, aSize);
|
||||
}
|
||||
|
||||
void otPlatFlashRead(otInstance *aInstance, uint8_t aSwapIndex, uint32_t aOffset, void *aData, uint32_t aSize)
|
||||
{
|
||||
OT_UNUSED_VARIABLE(aInstance);
|
||||
|
||||
memcpy(aData, (void *)mapAddress(aSwapIndex, aOffset), aSize);
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2016, The OpenThread Authors.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. 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.
|
||||
* 3. Neither the name of the copyright holder 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 HOLDER 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file logging.c
|
||||
* Platform abstraction for the logging
|
||||
*
|
||||
*/
|
||||
|
||||
#include <openthread-core-config.h>
|
||||
#include <openthread/config.h>
|
||||
#include <openthread/platform/logging.h>
|
||||
#include <openthread/platform/toolchain.h>
|
||||
|
||||
#if (OPENTHREAD_CONFIG_LOG_OUTPUT == OPENTHREAD_CONFIG_LOG_OUTPUT_PLATFORM_DEFINED)
|
||||
OT_TOOL_WEAK void otPlatLog(otLogLevel aLogLevel, otLogRegion aLogRegion, const char *aFormat, ...)
|
||||
{
|
||||
OT_UNUSED_VARIABLE(aLogLevel);
|
||||
OT_UNUSED_VARIABLE(aLogRegion);
|
||||
OT_UNUSED_VARIABLE(aFormat);
|
||||
}
|
||||
#endif
|
||||
@@ -1,93 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2017, The OpenThread Authors.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. 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.
|
||||
* 3. Neither the name of the copyright holder 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 HOLDER 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 "openthread/platform/misc.h"
|
||||
#include "fsl_device_registers.h"
|
||||
#include <stdint.h>
|
||||
|
||||
void otPlatReset(otInstance *aInstance)
|
||||
{
|
||||
OT_UNUSED_VARIABLE(aInstance);
|
||||
|
||||
NVIC_SystemReset();
|
||||
|
||||
while (1)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
otPlatResetReason otPlatGetResetReason(otInstance *aInstance)
|
||||
{
|
||||
OT_UNUSED_VARIABLE(aInstance);
|
||||
|
||||
otPlatResetReason reason;
|
||||
|
||||
if (RCM->SRS0 & RCM_SRS0_POR_MASK)
|
||||
{
|
||||
reason = OT_PLAT_RESET_REASON_POWER_ON;
|
||||
}
|
||||
else if (RCM->SRS1 & RCM_SRS1_SW_MASK)
|
||||
{
|
||||
reason = OT_PLAT_RESET_REASON_SOFTWARE;
|
||||
}
|
||||
else if (RCM->SRS0 & RCM_SRS0_WDOG_MASK)
|
||||
{
|
||||
reason = OT_PLAT_RESET_REASON_WATCHDOG;
|
||||
}
|
||||
else if (RCM->SRS0 & RCM_SRS0_PIN_MASK)
|
||||
{
|
||||
reason = OT_PLAT_RESET_REASON_EXTERNAL;
|
||||
}
|
||||
else if ((RCM->SRS0 & RCM_SRS0_LOC_MASK) || (RCM->SRS1 & RCM_SRS1_SACKERR_MASK) ||
|
||||
(RCM->SRS1 & RCM_SRS1_LOCKUP_MASK))
|
||||
{
|
||||
reason = OT_PLAT_RESET_REASON_FAULT;
|
||||
}
|
||||
else if ((RCM->SRS0 & RCM_SRS0_WAKEUP_MASK) || (RCM->SRS0 & RCM_SRS0_LVD_MASK) ||
|
||||
(RCM->SRS1 & RCM_SRS1_MDM_AP_MASK))
|
||||
{
|
||||
reason = OT_PLAT_RESET_REASON_ASSERT;
|
||||
}
|
||||
else
|
||||
{
|
||||
reason = OT_PLAT_RESET_REASON_OTHER;
|
||||
}
|
||||
|
||||
return reason;
|
||||
}
|
||||
|
||||
void otPlatAssertFail(const char *aFilename, int aLineNumber)
|
||||
{
|
||||
OT_UNUSED_VARIABLE(aFilename);
|
||||
OT_UNUSED_VARIABLE(aLineNumber);
|
||||
}
|
||||
|
||||
void otPlatWakeHost(void)
|
||||
{
|
||||
// TODO: implement an operation to wake the host from sleep state.
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2019, The OpenThread Authors.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. 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.
|
||||
* 3. Neither the name of the copyright holder 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 HOLDER 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 OPENTHREAD_CORE_KW41Z_CONFIG_CHECK_H_
|
||||
#define OPENTHREAD_CORE_KW41Z_CONFIG_CHECK_H_
|
||||
|
||||
#if OPENTHREAD_CONFIG_RADIO_915MHZ_OQPSK_SUPPORT
|
||||
#error "Platform kw41z doesn't support configuration option: OPENTHREAD_CONFIG_RADIO_915MHZ_OQPSK_SUPPORT"
|
||||
#endif
|
||||
|
||||
#endif /* OPENTHREAD_CORE_KW41Z_CONFIG_CHECK_H_ */
|
||||
@@ -1,105 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2017, The OpenThread Authors.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. 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.
|
||||
* 3. Neither the name of the copyright holder 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 HOLDER 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* This file includes kw41z compile-time configuration constants
|
||||
* for OpenThread.
|
||||
*/
|
||||
|
||||
#ifndef OPENTHREAD_CORE_KW41Z_CONFIG_H_
|
||||
#define OPENTHREAD_CORE_KW41Z_CONFIG_H_
|
||||
|
||||
/**
|
||||
* @def OPENTHREAD_CONFIG_LOG_OUTPUT
|
||||
*
|
||||
* The kw41z platform provides an otPlatLog() function.
|
||||
*/
|
||||
#ifndef OPENTHREAD_CONFIG_LOG_OUTPUT /* allow command line override */
|
||||
#define OPENTHREAD_CONFIG_LOG_OUTPUT OPENTHREAD_CONFIG_LOG_OUTPUT_PLATFORM_DEFINED
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @def OPENTHREAD_CONFIG_PLATFORM_INFO
|
||||
*
|
||||
* The platform-specific string to insert into the OpenThread version string.
|
||||
*
|
||||
*/
|
||||
#define OPENTHREAD_CONFIG_PLATFORM_INFO "KW41Z"
|
||||
|
||||
/**
|
||||
* @def OPENTHREAD_CONFIG_PLATFORM_FLASH_API_ENABLE
|
||||
*
|
||||
* Define to 1 to enable otPlatFlash* APIs to support non-volatile storage.
|
||||
*
|
||||
* When defined to 1, the platform MUST implement the otPlatFlash* APIs instead of the otPlatSettings* APIs.
|
||||
*
|
||||
*/
|
||||
#define OPENTHREAD_CONFIG_PLATFORM_FLASH_API_ENABLE 1
|
||||
|
||||
/**
|
||||
* @def RADIO_CONFIG_SRC_MATCH_ENTRY_NUM
|
||||
*
|
||||
* The number of source address table entries.
|
||||
*
|
||||
*/
|
||||
#define RADIO_CONFIG_SRC_MATCH_ENTRY_NUM 128
|
||||
|
||||
/**
|
||||
* @def OPENTHREAD_CONFIG_MAC_SOFTWARE_RETRANSMIT_ENABLE
|
||||
*
|
||||
* Define to 1 if you want to enable software retransmission logic.
|
||||
*
|
||||
*/
|
||||
#define OPENTHREAD_CONFIG_MAC_SOFTWARE_RETRANSMIT_ENABLE 1
|
||||
|
||||
/**
|
||||
* @def OPENTHREAD_CONFIG_MAC_SOFTWARE_CSMA_BACKOFF_ENABLE
|
||||
*
|
||||
* Define to 1 if you want to enable software CSMA-CA backoff logic.
|
||||
*
|
||||
*/
|
||||
#define OPENTHREAD_CONFIG_MAC_SOFTWARE_CSMA_BACKOFF_ENABLE 1
|
||||
|
||||
/**
|
||||
* @def OPENTHREAD_CONFIG_MAC_SOFTWARE_TX_SECURITY_ENABLE
|
||||
*
|
||||
* Define to 1 if you want to enable software transmission security logic.
|
||||
*
|
||||
*/
|
||||
#define OPENTHREAD_CONFIG_MAC_SOFTWARE_TX_SECURITY_ENABLE 0
|
||||
|
||||
/**
|
||||
* @def OPENTHREAD_CONFIG_NCP_HDLC_ENABLE
|
||||
*
|
||||
* Define to 1 to enable NCP HDLC support.
|
||||
*
|
||||
*/
|
||||
#define OPENTHREAD_CONFIG_NCP_HDLC_ENABLE 1
|
||||
|
||||
#endif // OPENTHREAD_CORE_KW41Z_CONFIG_H_
|
||||
@@ -1,84 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2017, The OpenThread Authors.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. 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.
|
||||
* 3. Neither the name of the copyright holder 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 HOLDER 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* This file includes the platform-specific initializers.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef PLATFORM_KW41Z_H_
|
||||
#define PLATFORM_KW41Z_H_
|
||||
|
||||
#include <openthread-core-config.h>
|
||||
#include <openthread/config.h>
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <openthread/instance.h>
|
||||
|
||||
/**
|
||||
* This function initializes the alarm service used by OpenThread.
|
||||
*
|
||||
*/
|
||||
void kw41zAlarmInit(void);
|
||||
|
||||
/**
|
||||
* This function performs alarm driver processing.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance structure.
|
||||
*
|
||||
*/
|
||||
void kw41zAlarmProcess(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* This function initializes the radio service used by OpenThread.
|
||||
*
|
||||
*/
|
||||
void kw41zRadioInit(void);
|
||||
|
||||
/**
|
||||
* This function performs radio driver processing.
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance structure.
|
||||
*
|
||||
*/
|
||||
void kw41zRadioProcess(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* This function initializes the random number service used by OpenThread.
|
||||
*
|
||||
*/
|
||||
void kw41zRandomInit(void);
|
||||
|
||||
/**
|
||||
* This function performs UART driver processing.
|
||||
*
|
||||
*/
|
||||
void kw41zUartProcess(void);
|
||||
#endif // PLATFORM_KW41Z_H_
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,125 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2017, The OpenThread Authors.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. 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.
|
||||
* 3. Neither the name of the copyright holder 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 HOLDER 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* This file includes the platform-specific initializers.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "clock_config.h"
|
||||
#include "fsl_clock.h"
|
||||
#include "fsl_device_registers.h"
|
||||
#include "fsl_port.h"
|
||||
#include "platform-kw41z.h"
|
||||
#include <stdint.h>
|
||||
|
||||
#include "utils/uart.h"
|
||||
|
||||
otInstance *sInstance;
|
||||
|
||||
void otSysInit(int argc, char *argv[])
|
||||
{
|
||||
OT_UNUSED_VARIABLE(argc);
|
||||
OT_UNUSED_VARIABLE(argv);
|
||||
|
||||
uint32_t temp, tempTrim;
|
||||
uint8_t revId;
|
||||
|
||||
/* enable clock for PORTs */
|
||||
CLOCK_EnableClock(kCLOCK_PortA);
|
||||
CLOCK_EnableClock(kCLOCK_PortB);
|
||||
CLOCK_EnableClock(kCLOCK_PortC);
|
||||
|
||||
SIM->SCGC6 |= (SIM_SCGC6_DMAMUX_MASK); /* Enable clock to DMA_MUX (SIM module) */
|
||||
SIM->SCGC7 |= (SIM_SCGC7_DMA_MASK);
|
||||
|
||||
/* Obtain REV ID from SIM */
|
||||
revId = (uint8_t)((SIM->SDID & SIM_SDID_REVID_MASK) >> SIM_SDID_REVID_SHIFT);
|
||||
|
||||
if (revId == 0)
|
||||
{
|
||||
tempTrim = RSIM->ANA_TRIM;
|
||||
RSIM->ANA_TRIM |= RSIM_ANA_TRIM_BB_LDO_XO_TRIM_MASK; /* max trim for BB LDO for XO */
|
||||
}
|
||||
|
||||
/* Turn on clocks for the XCVR */
|
||||
/* Enable RF OSC in RSIM and wait for ready */
|
||||
temp = RSIM->CONTROL;
|
||||
temp &= ~RSIM_CONTROL_RF_OSC_EN_MASK;
|
||||
RSIM->CONTROL = temp | RSIM_CONTROL_RF_OSC_EN(1);
|
||||
/* Prevent XTAL_OUT_EN from generating XTAL_OUT request */
|
||||
RSIM->RF_OSC_CTRL |= RSIM_RF_OSC_CTRL_RADIO_EXT_OSC_OVRD_EN_MASK;
|
||||
|
||||
/* wait for RF_OSC_READY */
|
||||
while ((RSIM->CONTROL & RSIM_CONTROL_RF_OSC_READY_MASK) == 0)
|
||||
{
|
||||
}
|
||||
|
||||
if (revId == 0)
|
||||
{
|
||||
SIM->SCGC5 |= SIM_SCGC5_PHYDIG_MASK;
|
||||
XCVR_TSM->OVRD0 |= XCVR_TSM_OVRD0_BB_LDO_ADCDAC_EN_OVRD_EN_MASK |
|
||||
XCVR_TSM_OVRD0_BB_LDO_ADCDAC_EN_OVRD_MASK; /* Force ADC DAC LDO on to prevent BGAP failure */
|
||||
/* Reset LDO trim settings */
|
||||
RSIM->ANA_TRIM = tempTrim;
|
||||
} /* Workaround for Rev 1.0 XTAL startup and ADC analog diagnostics circuitry */
|
||||
|
||||
/* Init board clock */
|
||||
BOARD_BootClockRUN();
|
||||
|
||||
kw41zAlarmInit();
|
||||
kw41zRandomInit();
|
||||
kw41zRadioInit();
|
||||
|
||||
otPlatUartEnable();
|
||||
}
|
||||
|
||||
bool otSysPseudoResetWasRequested(void)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
void otSysDeinit(void)
|
||||
{
|
||||
}
|
||||
|
||||
void otSysProcessDrivers(otInstance *aInstance)
|
||||
{
|
||||
sInstance = aInstance;
|
||||
kw41zUartProcess();
|
||||
kw41zRadioProcess(aInstance);
|
||||
kw41zAlarmProcess(aInstance);
|
||||
}
|
||||
|
||||
void NMI_Handler(void)
|
||||
{
|
||||
/* Change NMI Pin MUX */
|
||||
CLOCK_EnableClock(kCLOCK_PortB);
|
||||
PORT_SetPinMux(PORTB, 18, kPORT_MuxAlt2);
|
||||
}
|
||||
@@ -1,206 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2017, The OpenThread Authors.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. 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.
|
||||
* 3. Neither the name of the copyright holder 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 HOLDER 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* This file implements the OpenThread platform abstraction for UART communication.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "fsl_device_registers.h"
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include <utils/code_utils.h>
|
||||
#include <utils/uart.h>
|
||||
|
||||
#include "fsl_clock.h"
|
||||
#include "fsl_lpuart.h"
|
||||
#include "fsl_port.h"
|
||||
|
||||
enum
|
||||
{
|
||||
kPlatformClock = 32000000,
|
||||
kBaudRate = 115200,
|
||||
kReceiveBufferSize = 256,
|
||||
};
|
||||
|
||||
static void processReceive();
|
||||
static void processTransmit();
|
||||
|
||||
static const uint8_t *sTransmitBuffer = NULL;
|
||||
static uint16_t sTransmitLength = 0;
|
||||
static bool sTransmitDone = false;
|
||||
|
||||
typedef struct RecvBuffer
|
||||
{
|
||||
// The data buffer
|
||||
uint8_t mBuffer[kReceiveBufferSize];
|
||||
// The offset of the first item written to the list.
|
||||
uint16_t mHead;
|
||||
// The offset of the next item to be written to the list.
|
||||
uint16_t mTail;
|
||||
} RecvBuffer;
|
||||
|
||||
static RecvBuffer sReceive;
|
||||
|
||||
otError otPlatUartEnable(void)
|
||||
{
|
||||
lpuart_config_t config;
|
||||
|
||||
sReceive.mHead = 0;
|
||||
sReceive.mTail = 0;
|
||||
|
||||
/* Pin MUX */
|
||||
CLOCK_EnableClock(kCLOCK_PortC);
|
||||
PORT_SetPinMux(PORTC, 6, kPORT_MuxAlt4);
|
||||
PORT_SetPinMux(PORTC, 7, kPORT_MuxAlt4);
|
||||
|
||||
/* Set OSCERCLK as LPUART Rx/Tx clock */
|
||||
CLOCK_SetLpuartClock(2);
|
||||
|
||||
LPUART_GetDefaultConfig(&config);
|
||||
config.enableRx = 1;
|
||||
config.enableTx = 1;
|
||||
config.baudRate_Bps = kBaudRate;
|
||||
LPUART_Init(LPUART0, &config, kPlatformClock);
|
||||
LPUART_EnableInterrupts(LPUART0, kLPUART_RxDataRegFullInterruptEnable);
|
||||
|
||||
NVIC_ClearPendingIRQ(LPUART0_IRQn);
|
||||
NVIC_EnableIRQ(LPUART0_IRQn);
|
||||
|
||||
return OT_ERROR_NONE;
|
||||
}
|
||||
|
||||
otError otPlatUartDisable(void)
|
||||
{
|
||||
NVIC_DisableIRQ(LPUART0_IRQn);
|
||||
return OT_ERROR_NONE;
|
||||
}
|
||||
|
||||
otError otPlatUartSend(const uint8_t *aBuf, uint16_t aBufLength)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
|
||||
otEXPECT_ACTION(sTransmitBuffer == NULL, error = OT_ERROR_BUSY);
|
||||
|
||||
sTransmitBuffer = aBuf + 1;
|
||||
sTransmitLength = aBufLength - 1;
|
||||
sTransmitDone = false;
|
||||
LPUART_WriteByte(LPUART0, *aBuf);
|
||||
LPUART_ClearStatusFlags(LPUART0, kLPUART_TxDataRegEmptyFlag);
|
||||
LPUART_EnableInterrupts(LPUART0, kLPUART_TxDataRegEmptyInterruptEnable);
|
||||
|
||||
exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
otError otPlatUartFlush(void)
|
||||
{
|
||||
return OT_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
static void processTransmit(void)
|
||||
{
|
||||
if (sTransmitBuffer && sTransmitDone)
|
||||
{
|
||||
sTransmitDone = false;
|
||||
sTransmitBuffer = NULL;
|
||||
otPlatUartSendDone();
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void kw41zUartProcess(void)
|
||||
{
|
||||
processReceive();
|
||||
processTransmit();
|
||||
}
|
||||
|
||||
static void processReceive(void)
|
||||
{
|
||||
// Copy tail to prevent multiple reads
|
||||
uint16_t tail = sReceive.mTail;
|
||||
|
||||
if (sReceive.mHead > tail)
|
||||
{
|
||||
otPlatUartReceived(sReceive.mBuffer + sReceive.mHead, kReceiveBufferSize - sReceive.mHead);
|
||||
|
||||
// Reset the buffer mHead back to zero
|
||||
sReceive.mHead = 0;
|
||||
}
|
||||
|
||||
if (sReceive.mHead != tail)
|
||||
{
|
||||
otPlatUartReceived(sReceive.mBuffer + sReceive.mHead, tail - sReceive.mHead);
|
||||
|
||||
// Set mHead to the local tail we have cached
|
||||
sReceive.mHead = tail;
|
||||
}
|
||||
}
|
||||
|
||||
void LPUART0_IRQHandler(void)
|
||||
{
|
||||
uint32_t interrupts = LPUART_GetEnabledInterrupts(LPUART0);
|
||||
uint8_t rx_data;
|
||||
|
||||
/* Check if data was received */
|
||||
while (LPUART_GetStatusFlags(LPUART0) & (kLPUART_RxDataRegFullFlag))
|
||||
{
|
||||
rx_data = LPUART_ReadByte(LPUART0);
|
||||
LPUART_ClearStatusFlags(LPUART0, kLPUART_RxDataRegFullFlag);
|
||||
|
||||
if (sReceive.mHead != (sReceive.mTail + 1) % kReceiveBufferSize)
|
||||
{
|
||||
sReceive.mBuffer[sReceive.mTail] = rx_data;
|
||||
sReceive.mTail = (sReceive.mTail + 1) % kReceiveBufferSize;
|
||||
}
|
||||
}
|
||||
|
||||
/* Check if data Tx has end */
|
||||
if ((LPUART_GetStatusFlags(LPUART0) & kLPUART_TxDataRegEmptyFlag) &&
|
||||
(interrupts & kLPUART_TxDataRegEmptyInterruptEnable))
|
||||
{
|
||||
if (sTransmitLength)
|
||||
{
|
||||
sTransmitLength--;
|
||||
LPUART_WriteByte(LPUART0, *sTransmitBuffer++);
|
||||
}
|
||||
else if (!sTransmitDone)
|
||||
{
|
||||
sTransmitDone = true;
|
||||
LPUART_DisableInterrupts(LPUART0, kLPUART_TxDataRegEmptyInterruptEnable);
|
||||
}
|
||||
}
|
||||
|
||||
if (LPUART_GetStatusFlags(LPUART0) & kLPUART_RxOverrunFlag)
|
||||
{
|
||||
LPUART_ClearStatusFlags(LPUART0, kLPUART_RxOverrunFlag);
|
||||
}
|
||||
}
|
||||
@@ -117,21 +117,6 @@ build_k32w061()
|
||||
make -f examples/Makefile-k32w061 "${options[@]}"
|
||||
}
|
||||
|
||||
build_kw41z()
|
||||
{
|
||||
local options=(
|
||||
"COMMISSIONER=1"
|
||||
"DHCP6_CLIENT=1"
|
||||
"DHCP6_SERVER=1"
|
||||
"DNS_CLIENT=1"
|
||||
"JOINER=1"
|
||||
"SLAAC=1"
|
||||
)
|
||||
|
||||
reset_source
|
||||
make -f examples/Makefile-kw41z "${options[@]}"
|
||||
}
|
||||
|
||||
build_nrf52811()
|
||||
{
|
||||
local options=(
|
||||
@@ -263,7 +248,6 @@ main()
|
||||
build_cc2652
|
||||
build_jn5189
|
||||
build_k32w061
|
||||
build_kw41z
|
||||
build_nrf52811
|
||||
build_nrf52833
|
||||
build_nrf52840
|
||||
|
||||
@@ -77,12 +77,6 @@ build_cc2652()
|
||||
"$(dirname "$0")"/cmake-build cc2652 "${OT_COMMON_OPTIONS[@]}" "${OT_BASIC_CHECK_OPTIONS[@]}"
|
||||
}
|
||||
|
||||
build_kw41z()
|
||||
{
|
||||
reset_source
|
||||
"$(dirname "$0")"/cmake-build kw41z "${OT_COMMON_OPTIONS[@]}" "${OT_BASIC_CHECK_OPTIONS[@]}"
|
||||
}
|
||||
|
||||
build_nrf52811()
|
||||
{
|
||||
reset_source
|
||||
@@ -110,7 +104,6 @@ main()
|
||||
build_cc2538
|
||||
build_cc2650
|
||||
build_cc2652
|
||||
build_kw41z
|
||||
# UART transport
|
||||
build_nrf52840 UART_trans
|
||||
# USB transport with bootloader e.g. to support PCA10059 dongle
|
||||
|
||||
+2
-2
@@ -79,7 +79,7 @@ set -euxo pipefail
|
||||
OT_CMAKE_NINJA_TARGET=${OT_CMAKE_NINJA_TARGET:-}
|
||||
|
||||
readonly OT_SRCDIR="$(pwd)"
|
||||
readonly OT_PLATFORMS=(cc1352 cc2538 cc2650 cc2652 efr32mg1 efr32mg12 efr32mg13 efr32mg21 kw41z nrf52811 nrf52833 nrf52840 simulation posix)
|
||||
readonly OT_PLATFORMS=(cc1352 cc2538 cc2650 cc2652 efr32mg1 efr32mg12 efr32mg13 efr32mg21 nrf52811 nrf52833 nrf52840 simulation posix)
|
||||
readonly OT_NRF528XX_BUILD_TYPES=(UART_trans USB_trans_bl SPI_trans_NCP soft_crypto soft_crypto_threading)
|
||||
readonly OT_POSIX_SIM_COMMON_OPTIONS=(
|
||||
"-DOT_BORDER_AGENT=ON"
|
||||
@@ -232,7 +232,7 @@ main()
|
||||
OT_CMAKE_NINJA_TARGET=("ot-cli-mtd" "ot-ncp-mtd")
|
||||
options+=("-DCMAKE_TOOLCHAIN_FILE=examples/platforms/${platform}/arm-none-eabi.cmake" "-DCMAKE_BUILD_TYPE=MinSizeRel")
|
||||
;;
|
||||
cc1352 | cc2538 | cc2652 | kw41z)
|
||||
cc1352 | cc2538 | cc2652)
|
||||
options+=("-DCMAKE_TOOLCHAIN_FILE=examples/platforms/${platform}/arm-none-eabi.cmake" "-DCMAKE_BUILD_TYPE=MinSizeRel")
|
||||
;;
|
||||
efr32*)
|
||||
|
||||
Vendored
+1
-3
@@ -30,9 +30,7 @@ if(NOT OT_EXTERNAL_MBEDTLS)
|
||||
add_subdirectory(mbedtls)
|
||||
endif()
|
||||
|
||||
if(OT_PLATFORM STREQUAL "kw41z")
|
||||
add_subdirectory(nxp)
|
||||
elseif(OT_PLATFORM MATCHES "cc*")
|
||||
if(OT_PLATFORM MATCHES "cc*")
|
||||
add_subdirectory(ti)
|
||||
elseif(OT_PLATFORM MATCHES "^nrf*")
|
||||
add_subdirectory(jlink)
|
||||
|
||||
-136
@@ -1,136 +0,0 @@
|
||||
/* ----------------------------------------------------------------------
|
||||
* 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 */
|
||||
@@ -1,79 +0,0 @@
|
||||
/* ----------------------------------------------------------------------
|
||||
* 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
|
||||
-7154
File diff suppressed because it is too large
Load Diff
-734
@@ -1,734 +0,0 @@
|
||||
/**************************************************************************//**
|
||||
* @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
File diff suppressed because it is too large
Load Diff
-1373
File diff suppressed because it is too large
Load Diff
-798
@@ -1,798 +0,0 @@
|
||||
/**************************************************************************//**
|
||||
* @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
@@ -1,914 +0,0 @@
|
||||
/**************************************************************************//**
|
||||
* @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
File diff suppressed because it is too large
Load Diff
-1937
File diff suppressed because it is too large
Load Diff
-2512
File diff suppressed because it is too large
Load Diff
-87
@@ -1,87 +0,0 @@
|
||||
/**************************************************************************//**
|
||||
* @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
@@ -1,87 +0,0 @@
|
||||
/**************************************************************************//**
|
||||
* @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
@@ -1,96 +0,0 @@
|
||||
/**************************************************************************//**
|
||||
* @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
@@ -1,926 +0,0 @@
|
||||
/**************************************************************************//**
|
||||
* @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
File diff suppressed because it is too large
Load Diff
Vendored
-86
@@ -1,86 +0,0 @@
|
||||
#
|
||||
# Copyright (c) 2020, The OpenThread Authors.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. 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.
|
||||
# 3. Neither the name of the copyright holder 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 HOLDER 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.
|
||||
#
|
||||
|
||||
if(OT_PLATFORM STREQUAL "kw41z")
|
||||
set_property(SOURCE ${PROJECT_SOURCE_DIR}/third_party/nxp/MKW41Z4/startup_MKW41Z4.S PROPERTY LANGUAGE C)
|
||||
|
||||
add_library(nxp-kw41z-driver
|
||||
MKW41Z4/clock_config.c
|
||||
MKW41Z4/drivers/fsl_clock.c
|
||||
MKW41Z4/drivers/fsl_flash.c
|
||||
MKW41Z4/drivers/fsl_lpuart.c
|
||||
MKW41Z4/drivers/fsl_gpio.c
|
||||
MKW41Z4/drivers/fsl_pit.c
|
||||
MKW41Z4/drivers/fsl_trng.c
|
||||
MKW41Z4/startup_MKW41Z4.S
|
||||
MKW41Z4/system_MKW41Z4.c
|
||||
MKW41Z4/XCVR/cfgs_kw4x_3x_2x/fsl_xcvr_ant_config.c
|
||||
MKW41Z4/XCVR/cfgs_kw4x_3x_2x/fsl_xcvr_ble_config.c
|
||||
MKW41Z4/XCVR/cfgs_kw4x_3x_2x/fsl_xcvr_common_config.c
|
||||
MKW41Z4/XCVR/cfgs_kw4x_3x_2x/fsl_xcvr_gfsk_bt_0p3_h_0p5_config.c
|
||||
MKW41Z4/XCVR/cfgs_kw4x_3x_2x/fsl_xcvr_gfsk_bt_0p5_h_0p32_config.c
|
||||
MKW41Z4/XCVR/cfgs_kw4x_3x_2x/fsl_xcvr_gfsk_bt_0p5_h_0p5_config.c
|
||||
MKW41Z4/XCVR/cfgs_kw4x_3x_2x/fsl_xcvr_gfsk_bt_0p5_h_0p7_config.c
|
||||
MKW41Z4/XCVR/cfgs_kw4x_3x_2x/fsl_xcvr_gfsk_bt_0p5_h_1p0_config.c
|
||||
MKW41Z4/XCVR/cfgs_kw4x_3x_2x/fsl_xcvr_gfsk_bt_0p7_h_0p5_config.c
|
||||
MKW41Z4/XCVR/cfgs_kw4x_3x_2x/fsl_xcvr_mode_datarate_config.c
|
||||
MKW41Z4/XCVR/cfgs_kw4x_3x_2x/fsl_xcvr_msk_config.c
|
||||
MKW41Z4/XCVR/cfgs_kw4x_3x_2x/fsl_xcvr_zgbe_config.c
|
||||
MKW41Z4/XCVR/dbg_ram_capture.c
|
||||
MKW41Z4/XCVR/fsl_xcvr.c
|
||||
MKW41Z4/XCVR/fsl_xcvr_trim.c
|
||||
MKW41Z4/XCVR/ifr_radio.c
|
||||
)
|
||||
|
||||
target_compile_definitions(nxp-kw41z-driver
|
||||
PUBLIC
|
||||
${OT_PLATFORM_DEFINES}
|
||||
-DCPU_MKW41Z512VHT4
|
||||
)
|
||||
|
||||
target_compile_options(nxp-kw41z-driver
|
||||
PRIVATE
|
||||
${OT_CFLAGS}
|
||||
-Wno-unknown-pragmas
|
||||
-Wno-sign-compare
|
||||
-Wno-unused-function
|
||||
-Wno-unused-parameter
|
||||
-Wno-empty-body
|
||||
)
|
||||
|
||||
target_include_directories(nxp-kw41z-driver
|
||||
PUBLIC
|
||||
CMSIS/Include
|
||||
MKW41Z4
|
||||
MKW41Z4/drivers
|
||||
MKW41Z4/XCVR
|
||||
MKW41Z4/XCVR/cfgs_kw4x_3x_2x
|
||||
)
|
||||
|
||||
target_link_libraries(nxp-kw41z-driver PRIVATE ot-config)
|
||||
endif()
|
||||
Vendored
-13023
File diff suppressed because it is too large
Load Diff
-2020
File diff suppressed because it is too large
Load Diff
@@ -1,212 +0,0 @@
|
||||
/*!
|
||||
* Copyright 2016-2017 NXP
|
||||
*
|
||||
* \file
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* o Redistributions of source code must retain the above copyright notice, this list
|
||||
* of conditions and the following disclaimer.
|
||||
*
|
||||
* o 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.
|
||||
*
|
||||
* o Neither the name of Freescale Semiconductor, Inc. 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 HOLDER 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 "fsl_xcvr.h"
|
||||
#include "xcvr_test_fsk.h"
|
||||
|
||||
/*! *********************************************************************************
|
||||
*************************************************************************************
|
||||
* Private type definitions
|
||||
*************************************************************************************
|
||||
********************************************************************************** */
|
||||
enum {
|
||||
gDftNormal_c = 0,
|
||||
gDftTxNoMod_Carrier_c = 1,
|
||||
gDftTxPattern_c = 2,
|
||||
gDftTxRandom_c = 3,
|
||||
};
|
||||
|
||||
/*! *********************************************************************************
|
||||
*************************************************************************************
|
||||
* Private memory declarations
|
||||
*************************************************************************************
|
||||
********************************************************************************** */
|
||||
|
||||
/*! *********************************************************************************
|
||||
*************************************************************************************
|
||||
* Public prototypes
|
||||
*************************************************************************************
|
||||
********************************************************************************** */
|
||||
void XcvrFskModTx(void);
|
||||
void XcvrFskNoModTx(void);
|
||||
void XcvrFskIdle(void);
|
||||
void XcvrFskTxRand(void);
|
||||
void XcvrFskLoadPattern(uint32_t u32Pattern);
|
||||
void XcvrFskSetTxPower(uint8_t u8TxPow);
|
||||
void XcvrFskSetTxChannel(uint8_t u8TxChan);
|
||||
void XcvrFskRestoreTXControl(void);
|
||||
uint8_t XcvrFskGetInstantRssi(void);
|
||||
|
||||
/*! *********************************************************************************
|
||||
* XcvrFskModTx
|
||||
***********************************************************************************/
|
||||
void XcvrFskModTx(void)
|
||||
{
|
||||
XcvrFskIdle();
|
||||
XCVR_TX_DIG->CTRL &= ~(XCVR_TX_DIG_CTRL_DFT_CLK_SEL_MASK |
|
||||
XCVR_TX_DIG_CTRL_RADIO_DFT_MODE_MASK);
|
||||
XCVR_TX_DIG->CTRL |= XCVR_TX_DIG_CTRL_RADIO_DFT_MODE(gDftTxPattern_c) |
|
||||
XCVR_TX_DIG_CTRL_TX_DFT_EN_MASK;
|
||||
XCVR_MISC->DTEST_CTRL |= XCVR_CTRL_DTEST_CTRL_DTEST_EN_MASK;
|
||||
XCVR_TSM->CTRL |= XCVR_TSM_CTRL_FORCE_TX_EN_MASK;
|
||||
}
|
||||
|
||||
/*! *********************************************************************************
|
||||
* XcvrFskNoModTx
|
||||
***********************************************************************************/
|
||||
void XcvrFskNoModTx(void)
|
||||
{
|
||||
XcvrFskIdle();
|
||||
XCVR_TX_DIG->CTRL &= ~(XCVR_TX_DIG_CTRL_DFT_CLK_SEL_MASK |
|
||||
XCVR_TX_DIG_CTRL_RADIO_DFT_MODE_MASK);
|
||||
XCVR_TX_DIG->CTRL |= XCVR_TX_DIG_CTRL_RADIO_DFT_MODE(gDftTxNoMod_Carrier_c);
|
||||
XCVR_MISC->DTEST_CTRL |= XCVR_CTRL_DTEST_CTRL_DTEST_EN_MASK;
|
||||
XCVR_TSM->CTRL |= XCVR_TSM_CTRL_FORCE_TX_EN_MASK;
|
||||
}
|
||||
|
||||
/*! *********************************************************************************
|
||||
* XcvrFskIdle
|
||||
***********************************************************************************/
|
||||
void XcvrFskIdle(void)
|
||||
{
|
||||
XCVR_TX_DIG->CTRL &= ~(XCVR_TX_DIG_CTRL_TX_DFT_EN_MASK |
|
||||
XCVR_TX_DIG_CTRL_LFSR_EN_MASK |
|
||||
XCVR_TX_DIG_CTRL_RADIO_DFT_MODE_MASK);
|
||||
XCVR_TSM->CTRL &= ~XCVR_TSM_CTRL_FORCE_TX_EN_MASK;
|
||||
XCVR_MISC->DTEST_CTRL &= ~XCVR_CTRL_DTEST_CTRL_DTEST_EN_MASK;
|
||||
}
|
||||
|
||||
/*! *********************************************************************************
|
||||
* XcvrFskTxRand
|
||||
***********************************************************************************/
|
||||
void XcvrFskTxRand(void)
|
||||
{
|
||||
XcvrFskIdle();
|
||||
XCVR_TX_DIG->CTRL &= ~(XCVR_TX_DIG_CTRL_DFT_CLK_SEL_MASK |
|
||||
XCVR_TX_DIG_CTRL_RADIO_DFT_MODE_MASK |
|
||||
XCVR_TX_DIG_CTRL_LFSR_LENGTH_MASK);
|
||||
XCVR_TX_DIG->CTRL |= XCVR_TX_DIG_CTRL_RADIO_DFT_MODE(gDftTxRandom_c) |
|
||||
XCVR_TX_DIG_CTRL_LFSR_LENGTH(0) | /* length 9 */
|
||||
XCVR_TX_DIG_CTRL_LFSR_EN_MASK;
|
||||
XCVR_MISC->DTEST_CTRL |= XCVR_CTRL_DTEST_CTRL_DTEST_EN_MASK;
|
||||
XCVR_TSM->CTRL |= XCVR_TSM_CTRL_FORCE_TX_EN_MASK;
|
||||
}
|
||||
|
||||
/*! *********************************************************************************
|
||||
* XcvrFskLoadPattern
|
||||
***********************************************************************************/
|
||||
void XcvrFskLoadPattern(uint32_t u32Pattern)
|
||||
{
|
||||
XCVR_TX_DIG->DFT_PATTERN = u32Pattern;
|
||||
}
|
||||
|
||||
/*! *********************************************************************************
|
||||
* XcvrFskGetInstantRssi
|
||||
***********************************************************************************/
|
||||
uint8_t XcvrFskGetInstantRssi(void)
|
||||
{
|
||||
uint8_t u8Rssi;
|
||||
uint32_t t1,t2,t3;
|
||||
t1 = XCVR_RX_DIG->RX_DIG_CTRL;
|
||||
t2 = XCVR_RX_DIG->RSSI_CTRL_0;
|
||||
t3 = XCVR_PHY->CFG1;
|
||||
XCVR_RX_DIG->RX_DIG_CTRL = XCVR_RX_DIG_RX_DIG_CTRL_RX_ADC_NEGEDGE(0) |
|
||||
XCVR_RX_DIG_RX_DIG_CTRL_RX_CH_FILT_BYPASS(1) |
|
||||
XCVR_RX_DIG_RX_DIG_CTRL_RX_ADC_RAW_EN(0) |
|
||||
XCVR_RX_DIG_RX_DIG_CTRL_RX_ADC_POL(0) |
|
||||
XCVR_RX_DIG_RX_DIG_CTRL_RX_DEC_FILT_OSR(1) | /* 1=OSR8, 2=OSR16, 4=OSR32 */
|
||||
XCVR_RX_DIG_RX_DIG_CTRL_RX_FSK_ZB_SEL(0) |
|
||||
XCVR_RX_DIG_RX_DIG_CTRL_RX_NORM_EN(1) |
|
||||
XCVR_RX_DIG_RX_DIG_CTRL_RX_RSSI_EN(1) |
|
||||
XCVR_RX_DIG_RX_DIG_CTRL_RX_AGC_EN(1) |
|
||||
XCVR_RX_DIG_RX_DIG_CTRL_RX_DCOC_EN(1) |
|
||||
XCVR_RX_DIG_RX_DIG_CTRL_RX_DCOC_CAL_EN(1) |
|
||||
XCVR_RX_DIG_RX_DIG_CTRL_RX_IQ_SWAP(0) |
|
||||
XCVR_RX_DIG_RX_DIG_CTRL_RX_DC_RESID_EN(0) |
|
||||
XCVR_RX_DIG_RX_DIG_CTRL_RX_SRC_EN(0) |
|
||||
XCVR_RX_DIG_RX_DIG_CTRL_RX_SRC_RATE(0) | /* Source Rate 0 is default */
|
||||
XCVR_RX_DIG_RX_DIG_CTRL_RX_DMA_DTEST_EN(0) |
|
||||
XCVR_RX_DIG_RX_DIG_CTRL_RX_DEC_FILT_GAIN(22) | /* Dec filt gain for SRC rate == 0 */
|
||||
XCVR_RX_DIG_RX_DIG_CTRL_RX_DEC_FILT_HZD_CORR_DIS(1) ;
|
||||
|
||||
XCVR_RX_DIG->RSSI_CTRL_0 &= ~XCVR_RX_DIG_RSSI_CTRL_0_RSSI_IIR_WEIGHT_MASK;
|
||||
XCVR_RX_DIG->RSSI_CTRL_0 |= XCVR_RX_DIG_RSSI_CTRL_0_RSSI_IIR_WEIGHT(0x5);
|
||||
|
||||
XCVR_RX_DIG->RSSI_CTRL_0 &= ~XCVR_RX_DIG_RSSI_CTRL_0_RSSI_N_WINDOW_AVG_MASK;
|
||||
XCVR_RX_DIG->RSSI_CTRL_0 |= XCVR_RX_DIG_RSSI_CTRL_0_RSSI_N_WINDOW_AVG(0x3);
|
||||
|
||||
uint32_t temp = XCVR_PHY->CFG1;
|
||||
temp &= ~XCVR_PHY_CFG1_CTS_THRESH_MASK;
|
||||
temp |= XCVR_PHY_CFG1_CTS_THRESH(0xFF);
|
||||
XCVR_PHY->CFG1 = temp;
|
||||
|
||||
XCVR_ForceRxWu();
|
||||
for(uint32_t i = 0; i < 10000; i++)
|
||||
{
|
||||
__asm("nop");
|
||||
}
|
||||
u8Rssi = (uint8_t)((XCVR_RX_DIG->RSSI_CTRL_1 &
|
||||
XCVR_RX_DIG_RSSI_CTRL_1_RSSI_OUT_MASK) >>
|
||||
XCVR_RX_DIG_RSSI_CTRL_1_RSSI_OUT_SHIFT);
|
||||
XCVR_ForceRxWd();
|
||||
|
||||
XCVR_RX_DIG->RX_DIG_CTRL = t1;
|
||||
XCVR_RX_DIG->RSSI_CTRL_0 = t2;
|
||||
XCVR_PHY->CFG1 = t3;
|
||||
return u8Rssi;
|
||||
}
|
||||
|
||||
/*! *********************************************************************************
|
||||
* XcvrFskSetTxPower
|
||||
***********************************************************************************/
|
||||
void XcvrFskSetTxPower(uint8_t u8TxPow)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/*! *********************************************************************************
|
||||
* XcvrFskSetTxChannel
|
||||
***********************************************************************************/
|
||||
void XcvrFskSetTxChannel(uint8_t u8TxChan)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/*! *********************************************************************************
|
||||
* XcvrFskRestoreTXControl
|
||||
* After calling this function user should switch to
|
||||
* previous protocol and set the protocol channel to default
|
||||
***********************************************************************************/
|
||||
void XcvrFskRestoreTXControl(void)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1,157 +0,0 @@
|
||||
/*!
|
||||
* Copyright 2016-2017 NXP
|
||||
*
|
||||
* \file
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* o Redistributions of source code must retain the above copyright notice, this list
|
||||
* of conditions and the following disclaimer.
|
||||
*
|
||||
* o 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.
|
||||
*
|
||||
* o Neither the name of Freescale Semiconductor, Inc. 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 HOLDER 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 __XCVR_TEST_FSK_H__
|
||||
#define __XCVR_TEST_FSK_H__
|
||||
|
||||
/*! *********************************************************************************
|
||||
*************************************************************************************
|
||||
* Public type definitions
|
||||
*************************************************************************************
|
||||
********************************************************************************** */
|
||||
|
||||
/*! *********************************************************************************
|
||||
*************************************************************************************
|
||||
* Public prototypes
|
||||
*************************************************************************************
|
||||
********************************************************************************** */
|
||||
/*! *********************************************************************************
|
||||
* \brief This function returns instant RSSI value and returns it as unsigned byte.
|
||||
*
|
||||
* \param[in] None.
|
||||
*
|
||||
* \ingroup TestFunctions
|
||||
*
|
||||
* \details Initialization of the xcvr is necessary prior to calling this function
|
||||
*
|
||||
***********************************************************************************/
|
||||
extern uint8_t XcvrFskGetInstantRssi(void);
|
||||
|
||||
/*! *********************************************************************************
|
||||
* \brief This function sets the transceiver into continuous modulated transmission.
|
||||
*
|
||||
* \param[in] None.
|
||||
*
|
||||
* \ingroup TestFunctions
|
||||
*
|
||||
* \details Initialization of the xcvr and calling XcvrFskLoadPattern are necessary
|
||||
* prior to calling this function
|
||||
*
|
||||
***********************************************************************************/
|
||||
extern void XcvrFskModTx(void);
|
||||
|
||||
/*! *********************************************************************************
|
||||
* \brief This function sets the transceiver into continuous unmodulated transmission.
|
||||
*
|
||||
* \param[in] None.
|
||||
*
|
||||
* \ingroup TestFunctions
|
||||
*
|
||||
* \details
|
||||
*
|
||||
***********************************************************************************/
|
||||
extern void XcvrFskNoModTx(void);
|
||||
|
||||
/*! *********************************************************************************
|
||||
* \brief This function sets the transceiver into idle.
|
||||
*
|
||||
* \param[in] None.
|
||||
*
|
||||
* \ingroup TestFunctions
|
||||
*
|
||||
* \details
|
||||
*
|
||||
***********************************************************************************/
|
||||
extern void XcvrFskIdle(void);
|
||||
|
||||
/*! *********************************************************************************
|
||||
* \brief This function sets the transceiver into continuous modulated transmission.
|
||||
*
|
||||
* \param[in] None.
|
||||
*
|
||||
* \ingroup TestFunctions
|
||||
*
|
||||
* \details The modulation used is a pseudo-random pattern generated using a LFSR.
|
||||
*
|
||||
***********************************************************************************/
|
||||
extern void XcvrFskTxRand(void);
|
||||
|
||||
/*! *********************************************************************************
|
||||
* \brief This function loads a 32 bit value into the pattern register used by XcvrFskModTx.
|
||||
*
|
||||
* \param[in] u32Pattern The pattern to be loaded.
|
||||
*
|
||||
* \ingroup TestFunctions
|
||||
*
|
||||
* \details
|
||||
*
|
||||
***********************************************************************************/
|
||||
extern void XcvrFskLoadPattern(uint32_t u32Pattern);
|
||||
|
||||
/*! *********************************************************************************
|
||||
* \brief This function gives tx power control to xcvr and sets the power to u8TxPow.
|
||||
*
|
||||
* \param[in] u8TxPow Values should be between 0x00 and 0x0F.
|
||||
*
|
||||
* \ingroup TestFunctions
|
||||
*
|
||||
* \details
|
||||
*
|
||||
***********************************************************************************/
|
||||
extern void XcvrFskSetTxPower(uint8_t u8TxPow);
|
||||
|
||||
/*! *********************************************************************************
|
||||
* \brief This function gives tx channel control to xcvr and sets the channel to u8TxChan.
|
||||
*
|
||||
* \param[in] u8TxChan Values should be between 0 and 39.
|
||||
*
|
||||
* \ingroup TestFunctions
|
||||
*
|
||||
* \details
|
||||
*
|
||||
***********************************************************************************/
|
||||
extern void XcvrFskSetTxChannel(uint8_t u8TxChan);
|
||||
|
||||
/*! *********************************************************************************
|
||||
* \brief This function gives tx channel control and power to the upper layer.
|
||||
*
|
||||
* \param[in] None.
|
||||
*
|
||||
* \ingroup TestFunctions
|
||||
*
|
||||
* \details Call this function only if XcvrFskSetTxChannel or XcvrFskSetTxPower were called
|
||||
* previously.
|
||||
*
|
||||
***********************************************************************************/
|
||||
extern void XcvrFskRestoreTXControl(void);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,207 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Freescale Semiconductor, Inc.
|
||||
* Copyright 2016-2017 NXP
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* o Redistributions of source code must retain the above copyright notice, this list
|
||||
* of conditions and the following disclaimer.
|
||||
*
|
||||
* o 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.
|
||||
*
|
||||
* o Neither the name of Freescale Semiconductor, Inc. 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 HOLDER 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 "fsl_xcvr.h"
|
||||
|
||||
/*******************************************************************************
|
||||
* Definitions
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* Prototypes
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* Variables
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* Code
|
||||
******************************************************************************/
|
||||
const xcvr_mode_config_t ant_mode_config =
|
||||
{
|
||||
.radio_mode = ANT_MODE,
|
||||
.scgc5_clock_ena_bits = SIM_SCGC5_PHYDIG_MASK
|
||||
#if !RADIO_IS_GEN_2P1
|
||||
| SIM_SCGC5_ANT_MASK
|
||||
#endif /* !RADIO_IS_GEN_2P1 */
|
||||
,
|
||||
|
||||
/* XCVR_MISC configs */
|
||||
.xcvr_ctrl.mask = XCVR_CTRL_XCVR_CTRL_PROTOCOL_MASK |
|
||||
XCVR_CTRL_XCVR_CTRL_TGT_PWR_SRC_MASK |
|
||||
XCVR_CTRL_XCVR_CTRL_DEMOD_SEL_MASK,
|
||||
.xcvr_ctrl.init = XCVR_CTRL_XCVR_CTRL_PROTOCOL(3) |
|
||||
XCVR_CTRL_XCVR_CTRL_TGT_PWR_SRC(7) |
|
||||
XCVR_CTRL_XCVR_CTRL_DEMOD_SEL(1),
|
||||
|
||||
/* XCVR_PHY configs */
|
||||
.phy_pre_ref0_init = RW0PS(0, 0x1B) |
|
||||
RW0PS(1, 0x1CU) |
|
||||
RW0PS(2, 0x1CU) |
|
||||
RW0PS(3, 0x1CU) |
|
||||
RW0PS(4, 0x1DU) |
|
||||
RW0PS(5, 0x1DU) |
|
||||
RW0PS(6, 0x1EU & 0x3U), /* Phase info #6 overlaps two initialization words - only need two lowest bits*/
|
||||
.phy_pre_ref1_init = (0x1E) >> 2 | /* Phase info #6 overlaps two initialization words - manually compute the shift */
|
||||
RW1PS(7, 0x1EU) |
|
||||
RW1PS(8, 0x1EU) |
|
||||
RW1PS(9, 0x1EU) |
|
||||
RW1PS(10, 0x1EU) |
|
||||
RW1PS(11, 0x1DU) |
|
||||
RW1PS(12, 0x1DU & 0xFU), /* Phase info #12 overlaps two initialization words */
|
||||
.phy_pre_ref2_init = (0x1D) >> 4 | /* Phase info #12 overlaps two initialization words - manually compute the shift */
|
||||
RW2PS(13, 0x1CU) |
|
||||
RW2PS(14, 0x1CU) |
|
||||
RW2PS(15, 0x1CU),
|
||||
|
||||
.phy_cfg1_init = XCVR_PHY_CFG1_AA_PLAYBACK(1) |
|
||||
XCVR_PHY_CFG1_AA_OUTPUT_SEL(1) |
|
||||
XCVR_PHY_CFG1_FSK_BIT_INVERT(0) |
|
||||
XCVR_PHY_CFG1_BSM_EN_BLE(0) |
|
||||
XCVR_PHY_CFG1_DEMOD_CLK_MODE(0) |
|
||||
XCVR_PHY_CFG1_CTS_THRESH(0xF8) |
|
||||
XCVR_PHY_CFG1_FSK_FTS_TIMEOUT(2),
|
||||
|
||||
.phy_el_cfg_init = XCVR_PHY_EL_CFG_EL_ENABLE(1)
|
||||
#if !RADIO_IS_GEN_2P1
|
||||
| XCVR_PHY_EL_CFG_EL_ZB_ENABLE(0)
|
||||
#endif /* !RADIO_IS_GEN_2P1 */
|
||||
,
|
||||
|
||||
/* XCVR_RX_DIG configs */
|
||||
.rx_dig_ctrl_init_26mhz = XCVR_RX_DIG_RX_DIG_CTRL_RX_FSK_ZB_SEL(0) | /* Depends on protocol */
|
||||
XCVR_RX_DIG_RX_DIG_CTRL_RX_DC_RESID_EN(1) | /* Depends on protocol */
|
||||
XCVR_RX_DIG_RX_DIG_CTRL_RX_SRC_RATE(0),
|
||||
|
||||
.rx_dig_ctrl_init_32mhz = XCVR_RX_DIG_RX_DIG_CTRL_RX_FSK_ZB_SEL(0) | /* Depends on protocol */
|
||||
XCVR_RX_DIG_RX_DIG_CTRL_RX_DC_RESID_EN(1), /* Depends on protocol */
|
||||
|
||||
.agc_ctrl_0_init = XCVR_RX_DIG_AGC_CTRL_0_AGC_DOWN_RSSI_THRESH(0xFF),
|
||||
/* XCVR_TSM configs */
|
||||
#if (DATA_PADDING_EN)
|
||||
.tsm_timing_35_init = B0(TX_DIG_EN_ASSERT+TX_DIG_EN_TX_HI_ADJ),
|
||||
#else
|
||||
.tsm_timing_35_init = B0(TX_DIG_EN_ASSERT),
|
||||
#endif /* (DATA_PADDING_EN) */
|
||||
|
||||
/* XCVR_TX_DIG configs */
|
||||
.tx_gfsk_ctrl = XCVR_TX_DIG_GFSK_CTRL_GFSK_MULTIPLY_TABLE_MANUAL(0x4000) |
|
||||
XCVR_TX_DIG_GFSK_CTRL_GFSK_MI(0) |
|
||||
XCVR_TX_DIG_GFSK_CTRL_GFSK_MLD(0) |
|
||||
XCVR_TX_DIG_GFSK_CTRL_GFSK_FLD(0) |
|
||||
XCVR_TX_DIG_GFSK_CTRL_GFSK_MOD_INDEX_SCALING(0) |
|
||||
XCVR_TX_DIG_GFSK_CTRL_TX_IMAGE_FILTER_OVRD_EN(0) |
|
||||
XCVR_TX_DIG_GFSK_CTRL_TX_IMAGE_FILTER_0_OVRD(0) |
|
||||
XCVR_TX_DIG_GFSK_CTRL_TX_IMAGE_FILTER_1_OVRD(0) |
|
||||
XCVR_TX_DIG_GFSK_CTRL_TX_IMAGE_FILTER_2_OVRD(0),
|
||||
.tx_gfsk_coeff1_26mhz = 0,
|
||||
.tx_gfsk_coeff2_26mhz = 0,
|
||||
.tx_gfsk_coeff1_32mhz = 0,
|
||||
.tx_gfsk_coeff2_32mhz = 0,
|
||||
};
|
||||
|
||||
/* MODE & DATA RATE combined configuration */
|
||||
const xcvr_mode_datarate_config_t xcvr_ANT_1mbps_config =
|
||||
{
|
||||
.radio_mode = ANT_MODE,
|
||||
.data_rate = DR_1MBPS,
|
||||
|
||||
.ana_sy_ctrl2.mask = XCVR_ANALOG_SY_CTRL_2_SY_VCO_KVM_MASK,
|
||||
.ana_sy_ctrl2.init = XCVR_ANALOG_SY_CTRL_2_SY_VCO_KVM(0), /* VCO KVM */
|
||||
.ana_rx_bba.mask = XCVR_ANALOG_RX_BBA_RX_BBA_BW_SEL_MASK | XCVR_ANALOG_RX_BBA_RX_BBA2_BW_SEL_MASK,
|
||||
.ana_rx_bba.init = XCVR_ANALOG_RX_BBA_RX_BBA_BW_SEL(5) | XCVR_ANALOG_RX_BBA_RX_BBA2_BW_SEL(5), /* BBA_BW_SEL and BBA2_BW_SEL */
|
||||
.ana_rx_tza.mask = XCVR_ANALOG_RX_TZA_RX_TZA_BW_SEL_MASK,
|
||||
.ana_rx_tza.init = XCVR_ANALOG_RX_TZA_RX_TZA_BW_SEL(5), /* TZA_BW_SEL */
|
||||
|
||||
.phy_cfg2_init = XCVR_PHY_CFG2_PHY_FIFO_PRECHG(8) |
|
||||
XCVR_PHY_CFG2_X2_DEMOD_GAIN(0x6) ,
|
||||
|
||||
/* AGC configs */
|
||||
.agc_ctrl_2_init_26mhz = XCVR_RX_DIG_AGC_CTRL_2_BBA_GAIN_SETTLE_TIME(12) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_BBA_PDET_SEL_LO(5) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_BBA_PDET_SEL_HI(6) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_TZA_PDET_SEL_LO(3) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_TZA_PDET_SEL_HI(7) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_AGC_FAST_EXPIRE(5),
|
||||
.agc_ctrl_2_init_32mhz = XCVR_RX_DIG_AGC_CTRL_2_BBA_GAIN_SETTLE_TIME(14) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_BBA_PDET_SEL_LO(5) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_BBA_PDET_SEL_HI(6) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_TZA_PDET_SEL_LO(3) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_TZA_PDET_SEL_HI(7) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_AGC_FAST_EXPIRE(5),
|
||||
|
||||
/* All constant values are represented as 16 bits, register writes will remove unused bits */
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_0 = 0xFFFB,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_1 = 0xFFF5,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_2 = 0xFFF0,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_3 = 0xFFEC,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_4 = 0xFFEC,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_5 = 0xFFF3,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_6 = 0x0001,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_7 = 0x0016,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_8 = 0x002F,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_9 = 0x0049,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_10 = 0x005D,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_11 = 0x0069,
|
||||
|
||||
/* ANT 32MHz Channel Filter */
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_0 = 0xFFF9,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_1 = 0xFFF4,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_2 = 0xFFED,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_3 = 0xFFE7,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_4 = 0xFFE7,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_5 = 0xFFEE,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_6 = 0xFFFD,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_7 = 0x0015,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_8 = 0x0031,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_9 = 0x004E,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_10 = 0x0066,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_11 = 0x0073,
|
||||
|
||||
.rx_rccal_ctrl_0 = XCVR_RX_DIG_RX_RCCAL_CTRL0_BBA_RCCAL_OFFSET(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_BBA_RCCAL_MANUAL(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_BBA_RCCAL_DIS(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_RCCAL_SMP_DLY(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_RCCAL_COMP_INV(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_TZA_RCCAL_OFFSET(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_TZA_RCCAL_MANUAL(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_TZA_RCCAL_DIS(0) ,
|
||||
.rx_rccal_ctrl_1 = XCVR_RX_DIG_RX_RCCAL_CTRL1_ADC_RCCAL_OFFSET(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL1_ADC_RCCAL_MANUAL(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL1_ADC_RCCAL_DIS(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL1_BBA2_RCCAL_OFFSET(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL1_BBA2_RCCAL_MANUAL(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL1_BBA2_RCCAL_DIS(0) ,
|
||||
|
||||
.tx_fsk_scale_26mhz = XCVR_TX_DIG_FSK_SCALE_FSK_MODULATION_SCALE_0(0x1627) | XCVR_TX_DIG_FSK_SCALE_FSK_MODULATION_SCALE_1(0x09d9),
|
||||
.tx_fsk_scale_32mhz = XCVR_TX_DIG_FSK_SCALE_FSK_MODULATION_SCALE_0(0x1800) | XCVR_TX_DIG_FSK_SCALE_FSK_MODULATION_SCALE_1(0x0800),
|
||||
};
|
||||
|
||||
@@ -1,201 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Freescale Semiconductor, Inc.
|
||||
* Copyright 2016-2017 NXP
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* o Redistributions of source code must retain the above copyright notice, this list
|
||||
* of conditions and the following disclaimer.
|
||||
*
|
||||
* o 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.
|
||||
*
|
||||
* o Neither the name of Freescale Semiconductor, Inc. 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 HOLDER 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 "fsl_xcvr.h"
|
||||
|
||||
/*******************************************************************************
|
||||
* Definitions
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* Prototypes
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* Variables
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* Code
|
||||
******************************************************************************/
|
||||
const xcvr_mode_config_t ble_mode_config =
|
||||
{
|
||||
.radio_mode = BLE_MODE,
|
||||
.scgc5_clock_ena_bits = SIM_SCGC5_PHYDIG_MASK | SIM_SCGC5_BTLL_MASK,
|
||||
|
||||
/* XCVR_MISC configs */
|
||||
.xcvr_ctrl.mask = XCVR_CTRL_XCVR_CTRL_PROTOCOL_MASK |
|
||||
XCVR_CTRL_XCVR_CTRL_TGT_PWR_SRC_MASK |
|
||||
XCVR_CTRL_XCVR_CTRL_DEMOD_SEL_MASK,
|
||||
.xcvr_ctrl.init = XCVR_CTRL_XCVR_CTRL_PROTOCOL(0) |
|
||||
XCVR_CTRL_XCVR_CTRL_TGT_PWR_SRC(7) |
|
||||
XCVR_CTRL_XCVR_CTRL_DEMOD_SEL(1),
|
||||
|
||||
/* XCVR_PHY configs */
|
||||
.phy_pre_ref0_init = RW0PS(0, 0x19) |
|
||||
RW0PS(1, 0x19U) |
|
||||
RW0PS(2, 0x1AU) |
|
||||
RW0PS(3, 0x1BU) |
|
||||
RW0PS(4, 0x1CU) |
|
||||
RW0PS(5, 0x1CU) |
|
||||
RW0PS(6, 0x1DU & 0x3U), /* Phase info #6 overlaps two initialization words */
|
||||
.phy_pre_ref1_init = (0x1D) >> 2 | /* Phase info #6 overlaps two initialization words - manually compute the shift*/
|
||||
RW1PS(7, 0x1EU) |
|
||||
RW1PS(8, 0x1EU) |
|
||||
RW1PS(9, 0x1EU) |
|
||||
RW1PS(10, 0x1DU) |
|
||||
RW1PS(11, 0x1CU) |
|
||||
RW1PS(12, 0x1CU & 0xFU), /* Phase info #12 overlaps two initialization words */
|
||||
.phy_pre_ref2_init = (0x1C) >> 4 | /* Phase info #12 overlaps two initialization words - manually compute the shift*/
|
||||
RW2PS(13, 0x1BU) |
|
||||
RW2PS(14, 0x1AU) |
|
||||
RW2PS(15, 0x19U),
|
||||
|
||||
.phy_cfg1_init = XCVR_PHY_CFG1_AA_PLAYBACK(0) |
|
||||
XCVR_PHY_CFG1_AA_OUTPUT_SEL(1) |
|
||||
XCVR_PHY_CFG1_FSK_BIT_INVERT(0) |
|
||||
XCVR_PHY_CFG1_BSM_EN_BLE(0) |
|
||||
XCVR_PHY_CFG1_DEMOD_CLK_MODE(0) |
|
||||
XCVR_PHY_CFG1_CTS_THRESH(220) |
|
||||
XCVR_PHY_CFG1_FSK_FTS_TIMEOUT(2),
|
||||
|
||||
.phy_el_cfg_init = XCVR_PHY_EL_CFG_EL_ENABLE(1) /* Per SMB */
|
||||
#if !RADIO_IS_GEN_2P1
|
||||
| XCVR_PHY_EL_CFG_EL_ZB_ENABLE(0)
|
||||
#endif /* !RADIO_IS_GEN_2P1 */
|
||||
,
|
||||
|
||||
/* XCVR_RX_DIG configs */
|
||||
.rx_dig_ctrl_init_26mhz = XCVR_RX_DIG_RX_DIG_CTRL_RX_FSK_ZB_SEL(0) | /* Depends on protocol */
|
||||
XCVR_RX_DIG_RX_DIG_CTRL_RX_DC_RESID_EN(1) | /* Depends on protocol */
|
||||
XCVR_RX_DIG_RX_DIG_CTRL_RX_SRC_RATE(0),
|
||||
|
||||
.rx_dig_ctrl_init_32mhz = XCVR_RX_DIG_RX_DIG_CTRL_RX_FSK_ZB_SEL(0) | /* Depends on protocol */
|
||||
XCVR_RX_DIG_RX_DIG_CTRL_RX_DC_RESID_EN(1), /* Depends on protocol */
|
||||
|
||||
.agc_ctrl_0_init = XCVR_RX_DIG_AGC_CTRL_0_AGC_DOWN_RSSI_THRESH(0xFF),
|
||||
/* XCVR_TSM configs */
|
||||
#if (DATA_PADDING_EN)
|
||||
.tsm_timing_35_init = B0(TX_DIG_EN_ASSERT+TX_DIG_EN_TX_HI_ADJ),
|
||||
#else
|
||||
.tsm_timing_35_init = B0(TX_DIG_EN_ASSERT),
|
||||
#endif /* (DATA_PADDING_EN) */
|
||||
|
||||
/* XCVR_TX_DIG configs */
|
||||
.tx_gfsk_ctrl = XCVR_TX_DIG_GFSK_CTRL_GFSK_MULTIPLY_TABLE_MANUAL(0x4000) |
|
||||
XCVR_TX_DIG_GFSK_CTRL_GFSK_MI(1) |
|
||||
XCVR_TX_DIG_GFSK_CTRL_GFSK_MLD(0) |
|
||||
XCVR_TX_DIG_GFSK_CTRL_GFSK_FLD(0) |
|
||||
XCVR_TX_DIG_GFSK_CTRL_GFSK_MOD_INDEX_SCALING(0) |
|
||||
XCVR_TX_DIG_GFSK_CTRL_TX_IMAGE_FILTER_OVRD_EN(0) |
|
||||
XCVR_TX_DIG_GFSK_CTRL_TX_IMAGE_FILTER_0_OVRD(0) |
|
||||
XCVR_TX_DIG_GFSK_CTRL_TX_IMAGE_FILTER_1_OVRD(0) |
|
||||
XCVR_TX_DIG_GFSK_CTRL_TX_IMAGE_FILTER_2_OVRD(0),
|
||||
.tx_gfsk_coeff1_26mhz = 0,
|
||||
.tx_gfsk_coeff2_26mhz = 0,
|
||||
.tx_gfsk_coeff1_32mhz = 0,
|
||||
.tx_gfsk_coeff2_32mhz = 0,
|
||||
};
|
||||
|
||||
/* MODE & DATA RATE combined configuration */
|
||||
const xcvr_mode_datarate_config_t xcvr_BLE_1mbps_config =
|
||||
{
|
||||
.radio_mode = BLE_MODE,
|
||||
.data_rate = DR_1MBPS,
|
||||
|
||||
.ana_sy_ctrl2.mask = XCVR_ANALOG_SY_CTRL_2_SY_VCO_KVM_MASK,
|
||||
.ana_sy_ctrl2.init = XCVR_ANALOG_SY_CTRL_2_SY_VCO_KVM(0), /* VCO KVM */
|
||||
.ana_rx_bba.mask = XCVR_ANALOG_RX_BBA_RX_BBA_BW_SEL_MASK | XCVR_ANALOG_RX_BBA_RX_BBA2_BW_SEL_MASK,
|
||||
.ana_rx_bba.init = XCVR_ANALOG_RX_BBA_RX_BBA_BW_SEL(4) | XCVR_ANALOG_RX_BBA_RX_BBA2_BW_SEL(4), /* BBA_BW_SEL and BBA2_BW_SEL */
|
||||
.ana_rx_tza.mask = XCVR_ANALOG_RX_TZA_RX_TZA_BW_SEL_MASK,
|
||||
.ana_rx_tza.init = XCVR_ANALOG_RX_TZA_RX_TZA_BW_SEL(4), /* TZA_BW_SEL */
|
||||
|
||||
.phy_cfg2_init = XCVR_PHY_CFG2_PHY_FIFO_PRECHG(8) |
|
||||
XCVR_PHY_CFG2_X2_DEMOD_GAIN(0xA) ,
|
||||
|
||||
/* AGC configs */
|
||||
.agc_ctrl_2_init_26mhz = XCVR_RX_DIG_AGC_CTRL_2_BBA_GAIN_SETTLE_TIME(10) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_BBA_PDET_SEL_LO(5) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_BBA_PDET_SEL_HI(6) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_TZA_PDET_SEL_LO(3) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_TZA_PDET_SEL_HI(7) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_AGC_FAST_EXPIRE(5),
|
||||
.agc_ctrl_2_init_32mhz = XCVR_RX_DIG_AGC_CTRL_2_BBA_GAIN_SETTLE_TIME(12) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_BBA_PDET_SEL_LO(5) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_BBA_PDET_SEL_HI(6) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_TZA_PDET_SEL_LO(3) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_TZA_PDET_SEL_HI(7) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_AGC_FAST_EXPIRE(5),
|
||||
|
||||
/* BLE 26MHz Channel Filter */
|
||||
/* All constant values are represented as 16 bits, register writes will remove unused bits */
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_0 = 0xFFFA,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_1 = 0xFFF6,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_2 = 0xFFF1,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_3 = 0xFFEE,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_4 = 0xFFEF,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_5 = 0xFFF6,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_6 = 0x0004,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_7 = 0x0017,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_8 = 0x002F,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_9 = 0x0046,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_10 = 0x0059,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_11 = 0x0063,
|
||||
|
||||
/* BLE 32MHz Channel Filter */
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_0 = 0xFFFA,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_1 = 0xFFF5,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_2 = 0xFFEF,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_3 = 0xFFEB,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_4 = 0xFFEB,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_5 = 0xFFF2,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_6 = 0x0000,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_7 = 0x0015,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_8 = 0x0030,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_9 = 0x004A,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_10 = 0x005F,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_11 = 0x006B,
|
||||
|
||||
.rx_rccal_ctrl_0 = XCVR_RX_DIG_RX_RCCAL_CTRL0_BBA_RCCAL_OFFSET(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_BBA_RCCAL_MANUAL(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_BBA_RCCAL_DIS(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_RCCAL_SMP_DLY(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_RCCAL_COMP_INV(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_TZA_RCCAL_OFFSET(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_TZA_RCCAL_MANUAL(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_TZA_RCCAL_DIS(0) ,
|
||||
.rx_rccal_ctrl_1 = XCVR_RX_DIG_RX_RCCAL_CTRL1_ADC_RCCAL_OFFSET(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL1_ADC_RCCAL_MANUAL(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL1_ADC_RCCAL_DIS(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL1_BBA2_RCCAL_OFFSET(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL1_BBA2_RCCAL_MANUAL(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL1_BBA2_RCCAL_DIS(0) ,
|
||||
};
|
||||
|
||||
@@ -1,623 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Freescale Semiconductor, Inc.
|
||||
* Copyright 2016-2017 NXP
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* o Redistributions of source code must retain the above copyright notice, this list
|
||||
* of conditions and the following disclaimer.
|
||||
*
|
||||
* o 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.
|
||||
*
|
||||
* o Neither the name of Freescale Semiconductor, Inc. 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 HOLDER 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 "fsl_xcvr.h"
|
||||
|
||||
/*******************************************************************************
|
||||
* Definitions
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* Prototypes
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* Variables
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* Code
|
||||
******************************************************************************/
|
||||
const xcvr_common_config_t xcvr_common_config =
|
||||
{
|
||||
/* XCVR_ANA configs */
|
||||
.ana_sy_ctrl1.mask = XCVR_ANALOG_SY_CTRL_1_SY_LPF_FILT_CTRL_MASK,
|
||||
.ana_sy_ctrl1.init = XCVR_ANALOG_SY_CTRL_1_SY_LPF_FILT_CTRL(3), /* PLL Analog Loop Filter */
|
||||
|
||||
#define hpm_vcm_tx 0
|
||||
#define hpm_vcm_cal 1
|
||||
#define hpm_fdb_res_tx 0
|
||||
#define hpm_fdb_res_cal 1
|
||||
#define modulation_word_manual 0
|
||||
#define mod_disable 0
|
||||
#define hpm_mod_manual 0
|
||||
#define hpm_mod_disable 0
|
||||
#define hpm_sdm_out_manual 0
|
||||
#define hpm_sdm_out_disable 0
|
||||
#define channel_num 0
|
||||
#define boc 0
|
||||
#define bmr 1
|
||||
#define zoc 0
|
||||
#define ctune_ldf_lev 8
|
||||
#define ftf_rx_thrsh 33
|
||||
#define ftw_rx 0
|
||||
#define ftf_tx_thrsh 6
|
||||
#define ftw_tx 0
|
||||
#define freq_count_go 0
|
||||
#define freq_count_time 0
|
||||
#define hpm_sdm_in_manual 0
|
||||
#define hpm_sdm_out_invert 0
|
||||
#define hpm_sdm_in_disable 0
|
||||
#define hpm_lfsr_size 4
|
||||
#define hpm_dth_scl 0
|
||||
#define hpm_dth_en 1
|
||||
#define hpm_integer_scale 0
|
||||
#define hpm_integer_invert 0
|
||||
#define hpm_cal_invert 1
|
||||
#define hpm_mod_in_invert 1
|
||||
#define hpm_cal_not_bumped 0
|
||||
#define hpm_cal_count_scale 0
|
||||
#define hp_cal_disable 0
|
||||
#define hpm_cal_factor_manual 0
|
||||
#define hpm_cal_array_size 1
|
||||
#define hpm_cal_time 0
|
||||
#define hpm_sdm_denom 256
|
||||
#define hpm_count_adjust 0
|
||||
#define pll_ld_manual 0
|
||||
#define pll_ld_disable 0
|
||||
#define lpm_sdm_inv 0
|
||||
#define lpm_disable 0
|
||||
#define lpm_dth_scl 8
|
||||
#define lpm_d_ctrl 1
|
||||
#define lpm_d_ovrd 1
|
||||
#define lpm_scale 8
|
||||
#define lpm_sdm_use_neg 0
|
||||
#define hpm_array_bias 0
|
||||
#define lpm_intg 38
|
||||
#define sdm_map_disable 0
|
||||
#define lpm_sdm_delay 4
|
||||
#define hpm_sdm_delay 0
|
||||
#define hpm_integer_delay 0
|
||||
#define ctune_target_manual 0
|
||||
#define ctune_target_disable 0
|
||||
#define ctune_adjust 0
|
||||
#define ctune_manual 0
|
||||
#define ctune_disable 0
|
||||
|
||||
/*-------------------------------------------------------------------------------------------------*/
|
||||
|
||||
.pll_hpm_bump = XCVR_PLL_DIG_HPM_BUMP_HPM_FDB_RES_CAL(hpm_fdb_res_cal) |
|
||||
XCVR_PLL_DIG_HPM_BUMP_HPM_FDB_RES_TX(hpm_fdb_res_tx) |
|
||||
XCVR_PLL_DIG_HPM_BUMP_HPM_VCM_CAL(hpm_vcm_cal) |
|
||||
XCVR_PLL_DIG_HPM_BUMP_HPM_VCM_TX(hpm_vcm_tx),
|
||||
|
||||
/*-------------------------------------------------------------------------------------------------*/
|
||||
|
||||
.pll_mod_ctrl = XCVR_PLL_DIG_MOD_CTRL_HPM_MOD_DISABLE(hpm_mod_disable) |
|
||||
XCVR_PLL_DIG_MOD_CTRL_HPM_MOD_MANUAL(hpm_mod_manual) |
|
||||
XCVR_PLL_DIG_MOD_CTRL_HPM_SDM_OUT_DISABLE(hpm_sdm_out_disable) |
|
||||
XCVR_PLL_DIG_MOD_CTRL_HPM_SDM_OUT_MANUAL(hpm_sdm_out_manual) |
|
||||
XCVR_PLL_DIG_MOD_CTRL_MOD_DISABLE(mod_disable) |
|
||||
XCVR_PLL_DIG_MOD_CTRL_MODULATION_WORD_MANUAL(modulation_word_manual),
|
||||
|
||||
/*-------------------------------------------------------------------------------------------------*/
|
||||
|
||||
.pll_chan_map = XCVR_PLL_DIG_CHAN_MAP_BMR(bmr) |
|
||||
XCVR_PLL_DIG_CHAN_MAP_BOC(boc) |
|
||||
XCVR_PLL_DIG_CHAN_MAP_CHANNEL_NUM(channel_num)
|
||||
#if !RADIO_IS_GEN_2P1
|
||||
| XCVR_PLL_DIG_CHAN_MAP_ZOC(zoc)
|
||||
#endif /* !RADIO_IS_GEN_2P1 */
|
||||
,
|
||||
|
||||
/*-------------------------------------------------------------------------------------------------*/
|
||||
|
||||
.pll_lock_detect = XCVR_PLL_DIG_LOCK_DETECT_CTUNE_LDF_LEV(ctune_ldf_lev) |
|
||||
XCVR_PLL_DIG_LOCK_DETECT_FREQ_COUNT_GO(freq_count_go) |
|
||||
XCVR_PLL_DIG_LOCK_DETECT_FREQ_COUNT_TIME(freq_count_time) |
|
||||
XCVR_PLL_DIG_LOCK_DETECT_FTF_RX_THRSH(ftf_rx_thrsh) |
|
||||
XCVR_PLL_DIG_LOCK_DETECT_FTF_TX_THRSH(ftf_tx_thrsh) |
|
||||
XCVR_PLL_DIG_LOCK_DETECT_FTW_RX(ftw_rx) |
|
||||
XCVR_PLL_DIG_LOCK_DETECT_FTW_TX(ftw_tx),
|
||||
|
||||
/*-------------------------------------------------------------------------------------------------*/
|
||||
|
||||
.pll_hpm_ctrl = XCVR_PLL_DIG_HPM_CTRL_HPM_CAL_INVERT(hpm_cal_invert) |
|
||||
XCVR_PLL_DIG_HPM_CTRL_HPM_DTH_EN(hpm_dth_en) |
|
||||
XCVR_PLL_DIG_HPM_CTRL_HPM_DTH_SCL(hpm_dth_scl) |
|
||||
XCVR_PLL_DIG_HPM_CTRL_HPM_INTEGER_INVERT(hpm_integer_invert) |
|
||||
XCVR_PLL_DIG_HPM_CTRL_HPM_INTEGER_SCALE(hpm_integer_scale) |
|
||||
XCVR_PLL_DIG_HPM_CTRL_HPM_LFSR_SIZE(hpm_lfsr_size) |
|
||||
XCVR_PLL_DIG_HPM_CTRL_HPM_MOD_IN_INVERT(hpm_mod_in_invert) |
|
||||
XCVR_PLL_DIG_HPM_CTRL_HPM_SDM_IN_DISABLE(hpm_sdm_in_disable) |
|
||||
XCVR_PLL_DIG_HPM_CTRL_HPM_SDM_IN_MANUAL(hpm_sdm_in_manual) |
|
||||
XCVR_PLL_DIG_HPM_CTRL_HPM_SDM_OUT_INVERT(hpm_sdm_out_invert),
|
||||
/*-------------------------------------------------------------------------------------------------*/
|
||||
#if !RADIO_IS_GEN_2P1
|
||||
.pll_hpmcal_ctrl = XCVR_PLL_DIG_HPMCAL_CTRL_HP_CAL_DISABLE(hp_cal_disable) |
|
||||
XCVR_PLL_DIG_HPMCAL_CTRL_HPM_CAL_ARRAY_SIZE(hpm_cal_array_size) |
|
||||
XCVR_PLL_DIG_HPMCAL_CTRL_HPM_CAL_COUNT_SCALE(hpm_cal_count_scale) |
|
||||
XCVR_PLL_DIG_HPMCAL_CTRL_HPM_CAL_FACTOR_MANUAL(hpm_cal_factor_manual) |
|
||||
XCVR_PLL_DIG_HPMCAL_CTRL_HPM_CAL_NOT_BUMPED(hpm_cal_not_bumped) |
|
||||
XCVR_PLL_DIG_HPMCAL_CTRL_HPM_CAL_TIME(hpm_cal_time),
|
||||
#endif /* !RADIO_IS_GEN_2P1 */
|
||||
/*-------------------------------------------------------------------------------------------------*/
|
||||
.pll_hpm_sdm_res = XCVR_PLL_DIG_HPM_SDM_RES_HPM_COUNT_ADJUST(hpm_count_adjust) |
|
||||
XCVR_PLL_DIG_HPM_SDM_RES_HPM_DENOM(hpm_sdm_denom),
|
||||
/*-------------------------------------------------------------------------------------------------*/
|
||||
.pll_lpm_ctrl = XCVR_PLL_DIG_LPM_CTRL_LPM_D_CTRL(lpm_d_ctrl) |
|
||||
XCVR_PLL_DIG_LPM_CTRL_LPM_D_OVRD(lpm_d_ovrd) |
|
||||
XCVR_PLL_DIG_LPM_CTRL_LPM_DISABLE(lpm_disable) |
|
||||
XCVR_PLL_DIG_LPM_CTRL_LPM_DTH_SCL(lpm_dth_scl) |
|
||||
XCVR_PLL_DIG_LPM_CTRL_LPM_SCALE(lpm_scale) |
|
||||
XCVR_PLL_DIG_LPM_CTRL_LPM_SDM_INV(lpm_sdm_inv) |
|
||||
XCVR_PLL_DIG_LPM_CTRL_LPM_SDM_USE_NEG(lpm_sdm_use_neg) |
|
||||
XCVR_PLL_DIG_LPM_CTRL_PLL_LD_DISABLE(pll_ld_disable) |
|
||||
XCVR_PLL_DIG_LPM_CTRL_PLL_LD_MANUAL(pll_ld_manual),
|
||||
/*-------------------------------------------------------------------------------------------------*/
|
||||
.pll_lpm_sdm_ctrl1 = XCVR_PLL_DIG_LPM_SDM_CTRL1_HPM_ARRAY_BIAS(hpm_array_bias) |
|
||||
XCVR_PLL_DIG_LPM_SDM_CTRL1_LPM_INTG(lpm_intg) |
|
||||
XCVR_PLL_DIG_LPM_SDM_CTRL1_SDM_MAP_DISABLE(sdm_map_disable),
|
||||
/*-------------------------------------------------------------------------------------------------*/
|
||||
.pll_delay_match = XCVR_PLL_DIG_DELAY_MATCH_HPM_INTEGER_DELAY(hpm_integer_delay) |
|
||||
XCVR_PLL_DIG_DELAY_MATCH_HPM_SDM_DELAY(hpm_sdm_delay) |
|
||||
XCVR_PLL_DIG_DELAY_MATCH_LPM_SDM_DELAY(lpm_sdm_delay),
|
||||
/*-------------------------------------------------------------------------------------------------*/
|
||||
.pll_ctune_ctrl = XCVR_PLL_DIG_CTUNE_CTRL_CTUNE_ADJUST(ctune_adjust) |
|
||||
XCVR_PLL_DIG_CTUNE_CTRL_CTUNE_DISABLE(ctune_disable) |
|
||||
XCVR_PLL_DIG_CTUNE_CTRL_CTUNE_MANUAL(ctune_manual) |
|
||||
XCVR_PLL_DIG_CTUNE_CTRL_CTUNE_TARGET_DISABLE(ctune_target_disable) |
|
||||
XCVR_PLL_DIG_CTUNE_CTRL_CTUNE_TARGET_MANUAL(ctune_target_manual),
|
||||
/*-------------------------------------------------------------------------------------------------*/
|
||||
|
||||
/* XCVR_RX_DIG configs */
|
||||
/* NOTE: Clock specific settings are embedded in the mode dependent configs */
|
||||
.rx_dig_ctrl_init = XCVR_RX_DIG_RX_DIG_CTRL_RX_ADC_NEGEDGE(0) |
|
||||
XCVR_RX_DIG_RX_DIG_CTRL_RX_CH_FILT_BYPASS(0) |
|
||||
#if !RADIO_IS_GEN_2P1
|
||||
XCVR_RX_DIG_RX_DIG_CTRL_RX_ADC_RAW_EN(0) |
|
||||
#endif /* !RADIO_IS_GEN_2P1 */
|
||||
XCVR_RX_DIG_RX_DIG_CTRL_RX_ADC_POL(0) |
|
||||
XCVR_RX_DIG_RX_DIG_CTRL_RX_NORM_EN(1) |
|
||||
XCVR_RX_DIG_RX_DIG_CTRL_RX_RSSI_EN(1) |
|
||||
XCVR_RX_DIG_RX_DIG_CTRL_RX_AGC_EN(1) |
|
||||
XCVR_RX_DIG_RX_DIG_CTRL_RX_DCOC_EN(1) |
|
||||
XCVR_RX_DIG_RX_DIG_CTRL_RX_DCOC_CAL_EN(1) |
|
||||
XCVR_RX_DIG_RX_DIG_CTRL_RX_IQ_SWAP(0) |
|
||||
XCVR_RX_DIG_RX_DIG_CTRL_RX_DMA_DTEST_EN(0) |
|
||||
XCVR_RX_DIG_RX_DIG_CTRL_RX_DEC_FILT_HZD_CORR_DIS(1),
|
||||
|
||||
.agc_ctrl_0_init = XCVR_RX_DIG_AGC_CTRL_0_SLOW_AGC_EN(1) |
|
||||
XCVR_RX_DIG_AGC_CTRL_0_SLOW_AGC_SRC(2) |
|
||||
XCVR_RX_DIG_AGC_CTRL_0_AGC_FREEZE_EN(1) |
|
||||
XCVR_RX_DIG_AGC_CTRL_0_AGC_FREEZE_PRE_OR_AA(0) |
|
||||
XCVR_RX_DIG_AGC_CTRL_0_AGC_UP_EN(1) |
|
||||
XCVR_RX_DIG_AGC_CTRL_0_AGC_UP_SRC(0) |
|
||||
XCVR_RX_DIG_AGC_CTRL_0_AGC_DOWN_BBA_STEP_SZ(2) |
|
||||
XCVR_RX_DIG_AGC_CTRL_0_AGC_DOWN_LNA_STEP_SZ(2) |
|
||||
XCVR_RX_DIG_AGC_CTRL_0_AGC_UP_RSSI_THRESH(0xe7),
|
||||
|
||||
.agc_ctrl_3_init = XCVR_RX_DIG_AGC_CTRL_3_AGC_UNFREEZE_TIME(21) |
|
||||
XCVR_RX_DIG_AGC_CTRL_3_AGC_PDET_LO_DLY(2) |
|
||||
XCVR_RX_DIG_AGC_CTRL_3_AGC_RSSI_DELT_H2S(20) |
|
||||
XCVR_RX_DIG_AGC_CTRL_3_AGC_H2S_STEP_SZ(6) |
|
||||
XCVR_RX_DIG_AGC_CTRL_3_AGC_UP_STEP_SZ(2),
|
||||
|
||||
/* DCOC configs */
|
||||
.dcoc_ctrl_0_init_26mhz = XCVR_RX_DIG_DCOC_CTRL_0_DCOC_CAL_DURATION(16) | /* Only the duration changes between 26MHz and 32MHz ref osc settings */
|
||||
#if (RADIO_IS_GEN_2P1)
|
||||
XCVR_RX_DIG_DCOC_CTRL_0_DCOC_CAL_CHECK_EN(0) |
|
||||
#endif /* (RADIO_IS_GEN_2P1) */
|
||||
XCVR_RX_DIG_DCOC_CTRL_0_TRACK_FROM_ZERO(0) |
|
||||
XCVR_RX_DIG_DCOC_CTRL_0_DCOC_CORRECT_EN(1) |
|
||||
XCVR_RX_DIG_DCOC_CTRL_0_TZA_CORR_POL(0) |
|
||||
XCVR_RX_DIG_DCOC_CTRL_0_BBA_CORR_POL(0) |
|
||||
XCVR_RX_DIG_DCOC_CTRL_0_DCOC_CORRECT_SRC(1),
|
||||
.dcoc_ctrl_0_init_32mhz = XCVR_RX_DIG_DCOC_CTRL_0_DCOC_CAL_DURATION(20) | /* Only the duration changes between 26MHz and 32MHz ref osc settings */
|
||||
#if (RADIO_IS_GEN_2P1)
|
||||
XCVR_RX_DIG_DCOC_CTRL_0_DCOC_CAL_CHECK_EN(0) |
|
||||
#endif /* (RADIO_IS_GEN_2P1) */
|
||||
XCVR_RX_DIG_DCOC_CTRL_0_TRACK_FROM_ZERO(0) |
|
||||
XCVR_RX_DIG_DCOC_CTRL_0_DCOC_CORRECT_EN(1) |
|
||||
XCVR_RX_DIG_DCOC_CTRL_0_TZA_CORR_POL(0) |
|
||||
XCVR_RX_DIG_DCOC_CTRL_0_BBA_CORR_POL(0) |
|
||||
XCVR_RX_DIG_DCOC_CTRL_0_DCOC_CORRECT_SRC(1),
|
||||
|
||||
.dcoc_ctrl_1_init = XCVR_RX_DIG_DCOC_CTRL_1_DCOC_TRK_MIN_AGC_IDX(26),
|
||||
|
||||
.dc_resid_ctrl_init = XCVR_RX_DIG_DC_RESID_CTRL_DC_RESID_ITER_FREEZE(4) |
|
||||
XCVR_RX_DIG_DC_RESID_CTRL_DC_RESID_ALPHA(1) |
|
||||
XCVR_RX_DIG_DC_RESID_CTRL_DC_RESID_EXT_DC_EN(1) |
|
||||
XCVR_RX_DIG_DC_RESID_CTRL_DC_RESID_MIN_AGC_IDX(26),
|
||||
|
||||
.dcoc_cal_gain_init = XCVR_RX_DIG_DCOC_CAL_GAIN_DCOC_BBA_CAL_GAIN1(1) |
|
||||
XCVR_RX_DIG_DCOC_CAL_GAIN_DCOC_LNA_CAL_GAIN1(1) |
|
||||
XCVR_RX_DIG_DCOC_CAL_GAIN_DCOC_BBA_CAL_GAIN2(1) |
|
||||
XCVR_RX_DIG_DCOC_CAL_GAIN_DCOC_LNA_CAL_GAIN2(2) |
|
||||
XCVR_RX_DIG_DCOC_CAL_GAIN_DCOC_BBA_CAL_GAIN3(3) |
|
||||
XCVR_RX_DIG_DCOC_CAL_GAIN_DCOC_LNA_CAL_GAIN3(1) ,
|
||||
|
||||
.dcoc_cal_rcp_init = XCVR_RX_DIG_DCOC_CAL_RCP_ALPHA_CALC_RECIP(1) |
|
||||
XCVR_RX_DIG_DCOC_CAL_RCP_DCOC_TMP_CALC_RECIP(711),
|
||||
|
||||
.lna_gain_val_3_0 = XCVR_RX_DIG_LNA_GAIN_VAL_3_0_LNA_GAIN_VAL_0(0x1DU) |
|
||||
XCVR_RX_DIG_LNA_GAIN_VAL_3_0_LNA_GAIN_VAL_1(0x32U) |
|
||||
XCVR_RX_DIG_LNA_GAIN_VAL_3_0_LNA_GAIN_VAL_2(0x09U) |
|
||||
XCVR_RX_DIG_LNA_GAIN_VAL_3_0_LNA_GAIN_VAL_3(0x38U),
|
||||
|
||||
.lna_gain_val_7_4 = XCVR_RX_DIG_LNA_GAIN_VAL_7_4_LNA_GAIN_VAL_4(0x4FU) |
|
||||
XCVR_RX_DIG_LNA_GAIN_VAL_7_4_LNA_GAIN_VAL_5(0x5BU) |
|
||||
XCVR_RX_DIG_LNA_GAIN_VAL_7_4_LNA_GAIN_VAL_6(0x72U) |
|
||||
XCVR_RX_DIG_LNA_GAIN_VAL_7_4_LNA_GAIN_VAL_7(0x8AU),
|
||||
.lna_gain_val_8 = XCVR_RX_DIG_LNA_GAIN_VAL_8_LNA_GAIN_VAL_8(0xA0U) |
|
||||
XCVR_RX_DIG_LNA_GAIN_VAL_8_LNA_GAIN_VAL_9(0xB6U),
|
||||
|
||||
.bba_res_tune_val_7_0 = XCVR_RX_DIG_BBA_RES_TUNE_VAL_7_0_BBA_RES_TUNE_VAL_0(0x0) |
|
||||
XCVR_RX_DIG_BBA_RES_TUNE_VAL_7_0_BBA_RES_TUNE_VAL_1(0x0) |
|
||||
XCVR_RX_DIG_BBA_RES_TUNE_VAL_7_0_BBA_RES_TUNE_VAL_2(0x0) |
|
||||
XCVR_RX_DIG_BBA_RES_TUNE_VAL_7_0_BBA_RES_TUNE_VAL_3(0x0) |
|
||||
XCVR_RX_DIG_BBA_RES_TUNE_VAL_7_0_BBA_RES_TUNE_VAL_4(0x0) |
|
||||
XCVR_RX_DIG_BBA_RES_TUNE_VAL_7_0_BBA_RES_TUNE_VAL_5(0x0) |
|
||||
XCVR_RX_DIG_BBA_RES_TUNE_VAL_7_0_BBA_RES_TUNE_VAL_6(0x0) |
|
||||
XCVR_RX_DIG_BBA_RES_TUNE_VAL_7_0_BBA_RES_TUNE_VAL_7(0xF),
|
||||
.bba_res_tune_val_10_8 = XCVR_RX_DIG_BBA_RES_TUNE_VAL_10_8_BBA_RES_TUNE_VAL_8(0x0) |
|
||||
XCVR_RX_DIG_BBA_RES_TUNE_VAL_10_8_BBA_RES_TUNE_VAL_9(0x1) |
|
||||
XCVR_RX_DIG_BBA_RES_TUNE_VAL_10_8_BBA_RES_TUNE_VAL_10(0x2),
|
||||
|
||||
.lna_gain_lin_val_2_0_init = XCVR_RX_DIG_LNA_GAIN_LIN_VAL_2_0_LNA_GAIN_LIN_VAL_0(0) |
|
||||
XCVR_RX_DIG_LNA_GAIN_LIN_VAL_2_0_LNA_GAIN_LIN_VAL_1(0) |
|
||||
XCVR_RX_DIG_LNA_GAIN_LIN_VAL_2_0_LNA_GAIN_LIN_VAL_2(1),
|
||||
|
||||
.lna_gain_lin_val_5_3_init = XCVR_RX_DIG_LNA_GAIN_LIN_VAL_5_3_LNA_GAIN_LIN_VAL_3(3) |
|
||||
XCVR_RX_DIG_LNA_GAIN_LIN_VAL_5_3_LNA_GAIN_LIN_VAL_4(5) |
|
||||
XCVR_RX_DIG_LNA_GAIN_LIN_VAL_5_3_LNA_GAIN_LIN_VAL_5(7),
|
||||
|
||||
.lna_gain_lin_val_8_6_init = XCVR_RX_DIG_LNA_GAIN_LIN_VAL_8_6_LNA_GAIN_LIN_VAL_6(14) |
|
||||
XCVR_RX_DIG_LNA_GAIN_LIN_VAL_8_6_LNA_GAIN_LIN_VAL_7(27) |
|
||||
XCVR_RX_DIG_LNA_GAIN_LIN_VAL_8_6_LNA_GAIN_LIN_VAL_8(50),
|
||||
|
||||
.lna_gain_lin_val_9_init = XCVR_RX_DIG_LNA_GAIN_LIN_VAL_9_LNA_GAIN_LIN_VAL_9(91),
|
||||
|
||||
.bba_res_tune_lin_val_3_0_init = XCVR_RX_DIG_BBA_RES_TUNE_LIN_VAL_3_0_BBA_RES_TUNE_LIN_VAL_0(8) |
|
||||
XCVR_RX_DIG_BBA_RES_TUNE_LIN_VAL_3_0_BBA_RES_TUNE_LIN_VAL_1(11) |
|
||||
XCVR_RX_DIG_BBA_RES_TUNE_LIN_VAL_3_0_BBA_RES_TUNE_LIN_VAL_2(16) |
|
||||
XCVR_RX_DIG_BBA_RES_TUNE_LIN_VAL_3_0_BBA_RES_TUNE_LIN_VAL_3(22),
|
||||
|
||||
.bba_res_tune_lin_val_7_4_init = XCVR_RX_DIG_BBA_RES_TUNE_LIN_VAL_7_4_BBA_RES_TUNE_LIN_VAL_4(31) |
|
||||
XCVR_RX_DIG_BBA_RES_TUNE_LIN_VAL_7_4_BBA_RES_TUNE_LIN_VAL_5(44) |
|
||||
XCVR_RX_DIG_BBA_RES_TUNE_LIN_VAL_7_4_BBA_RES_TUNE_LIN_VAL_6(62) |
|
||||
XCVR_RX_DIG_BBA_RES_TUNE_LIN_VAL_7_4_BBA_RES_TUNE_LIN_VAL_7(42), /* Has 2 fractional bits unlike other BBA_RES_TUNE_LIN_VALs */
|
||||
|
||||
.bba_res_tune_lin_val_10_8_init = XCVR_RX_DIG_BBA_RES_TUNE_LIN_VAL_10_8_BBA_RES_TUNE_LIN_VAL_8(128) |
|
||||
XCVR_RX_DIG_BBA_RES_TUNE_LIN_VAL_10_8_BBA_RES_TUNE_LIN_VAL_9(188) |
|
||||
XCVR_RX_DIG_BBA_RES_TUNE_LIN_VAL_10_8_BBA_RES_TUNE_LIN_VAL_10(288),
|
||||
|
||||
.dcoc_bba_step_init = XCVR_RX_DIG_DCOC_BBA_STEP_BBA_DCOC_STEP_RECIP(939) |
|
||||
XCVR_RX_DIG_DCOC_BBA_STEP_BBA_DCOC_STEP(279),
|
||||
|
||||
.dcoc_tza_step_00_init = XCVR_RX_DIG_DCOC_TZA_STEP_0_DCOC_TZA_STEP_GAIN_0(77) |
|
||||
XCVR_RX_DIG_DCOC_TZA_STEP_0_DCOC_TZA_STEP_RCP_0(3404),
|
||||
.dcoc_tza_step_01_init = XCVR_RX_DIG_DCOC_TZA_STEP_1_DCOC_TZA_STEP_GAIN_1(108) |
|
||||
XCVR_RX_DIG_DCOC_TZA_STEP_1_DCOC_TZA_STEP_RCP_1(2439),
|
||||
.dcoc_tza_step_02_init = XCVR_RX_DIG_DCOC_TZA_STEP_2_DCOC_TZA_STEP_GAIN_2(155) |
|
||||
XCVR_RX_DIG_DCOC_TZA_STEP_2_DCOC_TZA_STEP_RCP_2(1691),
|
||||
.dcoc_tza_step_03_init = XCVR_RX_DIG_DCOC_TZA_STEP_3_DCOC_TZA_STEP_GAIN_3(220) |
|
||||
XCVR_RX_DIG_DCOC_TZA_STEP_3_DCOC_TZA_STEP_RCP_3(1192),
|
||||
.dcoc_tza_step_04_init = XCVR_RX_DIG_DCOC_TZA_STEP_4_DCOC_TZA_STEP_GAIN_4(314) |
|
||||
XCVR_RX_DIG_DCOC_TZA_STEP_4_DCOC_TZA_STEP_RCP_4(835),
|
||||
.dcoc_tza_step_05_init = XCVR_RX_DIG_DCOC_TZA_STEP_5_DCOC_TZA_STEP_GAIN_5(436) |
|
||||
XCVR_RX_DIG_DCOC_TZA_STEP_5_DCOC_TZA_STEP_RCP_5(601),
|
||||
.dcoc_tza_step_06_init = XCVR_RX_DIG_DCOC_TZA_STEP_6_DCOC_TZA_STEP_GAIN_6(614) |
|
||||
XCVR_RX_DIG_DCOC_TZA_STEP_6_DCOC_TZA_STEP_RCP_6(427),
|
||||
.dcoc_tza_step_07_init = XCVR_RX_DIG_DCOC_TZA_STEP_7_DCOC_TZA_STEP_GAIN_7(845) |
|
||||
XCVR_RX_DIG_DCOC_TZA_STEP_7_DCOC_TZA_STEP_RCP_7(310),
|
||||
.dcoc_tza_step_08_init = XCVR_RX_DIG_DCOC_TZA_STEP_8_DCOC_TZA_STEP_GAIN_8(1256) |
|
||||
XCVR_RX_DIG_DCOC_TZA_STEP_8_DCOC_TZA_STEP_RCP_8(209),
|
||||
.dcoc_tza_step_09_init = XCVR_RX_DIG_DCOC_TZA_STEP_9_DCOC_TZA_STEP_GAIN_9(1805) |
|
||||
XCVR_RX_DIG_DCOC_TZA_STEP_9_DCOC_TZA_STEP_RCP_9(145),
|
||||
.dcoc_tza_step_10_init = XCVR_RX_DIG_DCOC_TZA_STEP_10_DCOC_TZA_STEP_GAIN_10(2653) |
|
||||
XCVR_RX_DIG_DCOC_TZA_STEP_10_DCOC_TZA_STEP_RCP_10(99),
|
||||
#if (RADIO_IS_GEN_2P1)
|
||||
.dcoc_cal_fail_th_init = XCVR_RX_DIG_DCOC_CAL_FAIL_TH_DCOC_CAL_BETA_F_TH(20) |
|
||||
XCVR_RX_DIG_DCOC_CAL_FAIL_TH_DCOC_CAL_ALPHA_F_TH(10),
|
||||
.dcoc_cal_pass_th_init = XCVR_RX_DIG_DCOC_CAL_PASS_TH_DCOC_CAL_BETA_P_TH(16) |
|
||||
XCVR_RX_DIG_DCOC_CAL_PASS_TH_DCOC_CAL_ALPHA_P_TH(2),
|
||||
#endif /* (RADIO_IS_GEN_2P1) */
|
||||
/* AGC Configs */
|
||||
.agc_gain_tbl_03_00_init = XCVR_RX_DIG_AGC_GAIN_TBL_03_00_LNA_GAIN_00(0) |
|
||||
XCVR_RX_DIG_AGC_GAIN_TBL_03_00_BBA_GAIN_00(0) |
|
||||
XCVR_RX_DIG_AGC_GAIN_TBL_03_00_LNA_GAIN_01(1) |
|
||||
XCVR_RX_DIG_AGC_GAIN_TBL_03_00_BBA_GAIN_01(1) |
|
||||
XCVR_RX_DIG_AGC_GAIN_TBL_03_00_LNA_GAIN_02(2) |
|
||||
XCVR_RX_DIG_AGC_GAIN_TBL_03_00_BBA_GAIN_02(1) |
|
||||
XCVR_RX_DIG_AGC_GAIN_TBL_03_00_LNA_GAIN_03(2) |
|
||||
XCVR_RX_DIG_AGC_GAIN_TBL_03_00_BBA_GAIN_03(2),
|
||||
|
||||
.agc_gain_tbl_07_04_init = XCVR_RX_DIG_AGC_GAIN_TBL_07_04_LNA_GAIN_04(2) |
|
||||
XCVR_RX_DIG_AGC_GAIN_TBL_07_04_BBA_GAIN_04(3) |
|
||||
XCVR_RX_DIG_AGC_GAIN_TBL_07_04_LNA_GAIN_05(3) |
|
||||
XCVR_RX_DIG_AGC_GAIN_TBL_07_04_BBA_GAIN_05(0) |
|
||||
XCVR_RX_DIG_AGC_GAIN_TBL_07_04_LNA_GAIN_06(3) |
|
||||
XCVR_RX_DIG_AGC_GAIN_TBL_07_04_BBA_GAIN_06(1) |
|
||||
XCVR_RX_DIG_AGC_GAIN_TBL_07_04_LNA_GAIN_07(3) |
|
||||
XCVR_RX_DIG_AGC_GAIN_TBL_07_04_BBA_GAIN_07(2),
|
||||
|
||||
.agc_gain_tbl_11_08_init = XCVR_RX_DIG_AGC_GAIN_TBL_11_08_LNA_GAIN_08(3) |
|
||||
XCVR_RX_DIG_AGC_GAIN_TBL_11_08_BBA_GAIN_08(3) |
|
||||
XCVR_RX_DIG_AGC_GAIN_TBL_11_08_LNA_GAIN_09(4) |
|
||||
XCVR_RX_DIG_AGC_GAIN_TBL_11_08_BBA_GAIN_09(2) |
|
||||
XCVR_RX_DIG_AGC_GAIN_TBL_11_08_LNA_GAIN_10(4) |
|
||||
XCVR_RX_DIG_AGC_GAIN_TBL_11_08_BBA_GAIN_10(3) |
|
||||
XCVR_RX_DIG_AGC_GAIN_TBL_11_08_LNA_GAIN_11(4) |
|
||||
XCVR_RX_DIG_AGC_GAIN_TBL_11_08_BBA_GAIN_11(4),
|
||||
|
||||
.agc_gain_tbl_15_12_init = XCVR_RX_DIG_AGC_GAIN_TBL_15_12_LNA_GAIN_12(5) |
|
||||
XCVR_RX_DIG_AGC_GAIN_TBL_15_12_BBA_GAIN_12(4) |
|
||||
XCVR_RX_DIG_AGC_GAIN_TBL_15_12_LNA_GAIN_13(5) |
|
||||
XCVR_RX_DIG_AGC_GAIN_TBL_15_12_BBA_GAIN_13(5) |
|
||||
XCVR_RX_DIG_AGC_GAIN_TBL_15_12_LNA_GAIN_14(6) |
|
||||
XCVR_RX_DIG_AGC_GAIN_TBL_15_12_BBA_GAIN_14(4) |
|
||||
XCVR_RX_DIG_AGC_GAIN_TBL_15_12_LNA_GAIN_15(6) |
|
||||
XCVR_RX_DIG_AGC_GAIN_TBL_15_12_BBA_GAIN_15(5),
|
||||
|
||||
.agc_gain_tbl_19_16_init = XCVR_RX_DIG_AGC_GAIN_TBL_19_16_LNA_GAIN_16(6) |
|
||||
XCVR_RX_DIG_AGC_GAIN_TBL_19_16_BBA_GAIN_16(6) |
|
||||
XCVR_RX_DIG_AGC_GAIN_TBL_19_16_LNA_GAIN_17(6) |
|
||||
XCVR_RX_DIG_AGC_GAIN_TBL_19_16_BBA_GAIN_17(7) |
|
||||
XCVR_RX_DIG_AGC_GAIN_TBL_19_16_LNA_GAIN_18(7) |
|
||||
XCVR_RX_DIG_AGC_GAIN_TBL_19_16_BBA_GAIN_18(6) |
|
||||
XCVR_RX_DIG_AGC_GAIN_TBL_19_16_LNA_GAIN_19(7) |
|
||||
XCVR_RX_DIG_AGC_GAIN_TBL_19_16_BBA_GAIN_19(7),
|
||||
|
||||
.agc_gain_tbl_23_20_init = XCVR_RX_DIG_AGC_GAIN_TBL_23_20_LNA_GAIN_20(8) |
|
||||
XCVR_RX_DIG_AGC_GAIN_TBL_23_20_BBA_GAIN_20(6) |
|
||||
XCVR_RX_DIG_AGC_GAIN_TBL_23_20_LNA_GAIN_21(8) |
|
||||
XCVR_RX_DIG_AGC_GAIN_TBL_23_20_BBA_GAIN_21(7) |
|
||||
XCVR_RX_DIG_AGC_GAIN_TBL_23_20_LNA_GAIN_22(9) |
|
||||
XCVR_RX_DIG_AGC_GAIN_TBL_23_20_BBA_GAIN_22(6) |
|
||||
XCVR_RX_DIG_AGC_GAIN_TBL_23_20_LNA_GAIN_23(9) |
|
||||
XCVR_RX_DIG_AGC_GAIN_TBL_23_20_BBA_GAIN_23(7),
|
||||
|
||||
.agc_gain_tbl_26_24_init = XCVR_RX_DIG_AGC_GAIN_TBL_26_24_LNA_GAIN_24(9) |
|
||||
XCVR_RX_DIG_AGC_GAIN_TBL_26_24_BBA_GAIN_24(8) |
|
||||
XCVR_RX_DIG_AGC_GAIN_TBL_26_24_LNA_GAIN_25(9) |
|
||||
XCVR_RX_DIG_AGC_GAIN_TBL_26_24_BBA_GAIN_25(9) |
|
||||
XCVR_RX_DIG_AGC_GAIN_TBL_26_24_LNA_GAIN_26(9) |
|
||||
XCVR_RX_DIG_AGC_GAIN_TBL_26_24_BBA_GAIN_26(10),
|
||||
|
||||
.rssi_ctrl_0_init = XCVR_RX_DIG_RSSI_CTRL_0_RSSI_USE_VALS(1) |
|
||||
XCVR_RX_DIG_RSSI_CTRL_0_RSSI_HOLD_SRC(0) |
|
||||
XCVR_RX_DIG_RSSI_CTRL_0_RSSI_HOLD_EN(1) |
|
||||
XCVR_RX_DIG_RSSI_CTRL_0_RSSI_IIR_CW_WEIGHT(0) |
|
||||
#if !RADIO_IS_GEN_2P1
|
||||
XCVR_RX_DIG_RSSI_CTRL_0_RSSI_N_WINDOW_AVG(1) |
|
||||
#else
|
||||
XCVR_RX_DIG_RSSI_CTRL_0_RSSI_N_WINDOW_NB(1) |
|
||||
#endif /* !RADIO_IS_GEN_2P1 */
|
||||
XCVR_RX_DIG_RSSI_CTRL_0_RSSI_HOLD_DELAY(4) |
|
||||
XCVR_RX_DIG_RSSI_CTRL_0_RSSI_IIR_WEIGHT(3) |
|
||||
XCVR_RX_DIG_RSSI_CTRL_0_RSSI_VLD_SETTLE(3) |
|
||||
XCVR_RX_DIG_RSSI_CTRL_0_RSSI_ADJ(0xE8) ,
|
||||
|
||||
.cca_ed_lqi_ctrl_0_init = XCVR_RX_DIG_CCA_ED_LQI_CTRL_0_LQI_CORR_THRESH(0) |
|
||||
XCVR_RX_DIG_CCA_ED_LQI_CTRL_0_CORR_CNTR_THRESH(0) |
|
||||
XCVR_RX_DIG_CCA_ED_LQI_CTRL_0_LQI_CNTR(0x1A) |
|
||||
XCVR_RX_DIG_CCA_ED_LQI_CTRL_0_SNR_ADJ(0),
|
||||
|
||||
.cca_ed_lqi_ctrl_1_init = XCVR_RX_DIG_CCA_ED_LQI_CTRL_1_RSSI_NOISE_AVG_DELAY(0) |
|
||||
XCVR_RX_DIG_CCA_ED_LQI_CTRL_1_RSSI_NOISE_AVG_FACTOR(0) |
|
||||
XCVR_RX_DIG_CCA_ED_LQI_CTRL_1_LQI_RSSI_WEIGHT(0x4) |
|
||||
XCVR_RX_DIG_CCA_ED_LQI_CTRL_1_LQI_RSSI_SENS(0x7) |
|
||||
XCVR_RX_DIG_CCA_ED_LQI_CTRL_1_SNR_LQI_DIS(0) |
|
||||
#if !RADIO_IS_GEN_2P1
|
||||
XCVR_RX_DIG_CCA_ED_LQI_CTRL_1_SEL_SNR_MODE(0) |
|
||||
#endif /* !RADIO_IS_GEN_2P1 */
|
||||
XCVR_RX_DIG_CCA_ED_LQI_CTRL_1_MEAS_TRANS_TO_IDLE(0) |
|
||||
XCVR_RX_DIG_CCA_ED_LQI_CTRL_1_CCA1_ED_EN_DIS(0) |
|
||||
XCVR_RX_DIG_CCA_ED_LQI_CTRL_1_MAN_MEAS_COMPLETE(0) |
|
||||
XCVR_RX_DIG_CCA_ED_LQI_CTRL_1_MAN_AA_MATCH(0) |
|
||||
XCVR_RX_DIG_CCA_ED_LQI_CTRL_1_SNR_LQI_WEIGHT(0x5) |
|
||||
XCVR_RX_DIG_CCA_ED_LQI_CTRL_1_LQI_BIAS(0x2),
|
||||
|
||||
/* XCVR_TSM configs */
|
||||
.tsm_ctrl = XCVR_TSM_CTRL_PA_RAMP_SEL(PA_RAMP_SEL) |
|
||||
XCVR_TSM_CTRL_DATA_PADDING_EN(DATA_PADDING_EN) |
|
||||
XCVR_TSM_CTRL_TSM_IRQ0_EN(0) |
|
||||
XCVR_TSM_CTRL_TSM_IRQ1_EN(0) |
|
||||
XCVR_TSM_CTRL_RAMP_DN_DELAY(0x4) |
|
||||
XCVR_TSM_CTRL_TX_ABORT_DIS(0) |
|
||||
XCVR_TSM_CTRL_RX_ABORT_DIS(0) |
|
||||
XCVR_TSM_CTRL_ABORT_ON_CTUNE(0) |
|
||||
XCVR_TSM_CTRL_ABORT_ON_CYCLE_SLIP(0) |
|
||||
XCVR_TSM_CTRL_ABORT_ON_FREQ_TARG(0) |
|
||||
XCVR_TSM_CTRL_BKPT(0xFF) ,
|
||||
|
||||
.tsm_ovrd2_init = XCVR_TSM_OVRD2_FREQ_TARG_LD_EN_OVRD(0) | XCVR_TSM_OVRD2_FREQ_TARG_LD_EN_OVRD_EN_MASK,
|
||||
.end_of_seq_init_26mhz = B3(END_OF_RX_WD_26MHZ) | B2(END_OF_RX_WU_26MHZ) | B1(END_OF_TX_WD) | B0(END_OF_TX_WU),
|
||||
.end_of_seq_init_32mhz = B3(END_OF_RX_WD) | B2(END_OF_RX_WU) | B1(END_OF_TX_WD) | B0(END_OF_TX_WU),
|
||||
|
||||
#if !RADIO_IS_GEN_2P1
|
||||
.lpps_ctrl_init = B3(102) | B2(40) | B1(0) | B0(0),
|
||||
#endif /* !RADIO_IS_GEN_2P1 */
|
||||
|
||||
.tsm_fast_ctrl2_init_26mhz = B3(102 + ADD_FOR_26MHZ) | B2(40 + ADD_FOR_26MHZ) | B1(66) | B0(8),
|
||||
.tsm_fast_ctrl2_init_32mhz = B3(102) | B2(40) | B1(66) | B0(8),
|
||||
|
||||
.pa_ramp_tbl_0_init = XCVR_TSM_PA_RAMP_TBL0_PA_RAMP0(PA_RAMP_0) | XCVR_TSM_PA_RAMP_TBL0_PA_RAMP1(PA_RAMP_1) |
|
||||
XCVR_TSM_PA_RAMP_TBL0_PA_RAMP2(PA_RAMP_2) | XCVR_TSM_PA_RAMP_TBL0_PA_RAMP3(PA_RAMP_3),
|
||||
.pa_ramp_tbl_1_init = XCVR_TSM_PA_RAMP_TBL1_PA_RAMP4(PA_RAMP_4) | XCVR_TSM_PA_RAMP_TBL1_PA_RAMP5(PA_RAMP_5) |
|
||||
XCVR_TSM_PA_RAMP_TBL1_PA_RAMP6(PA_RAMP_6) | XCVR_TSM_PA_RAMP_TBL1_PA_RAMP7(PA_RAMP_7),
|
||||
|
||||
.recycle_count_init_26mhz = B3(0) | B2(0x1C + ADD_FOR_26MHZ) | B1(0x06) | B0(0x66 + ADD_FOR_26MHZ),
|
||||
.recycle_count_init_26mhz = B3(0) | B2(0x1C) | B1(0x06) | B0(0x66),
|
||||
|
||||
.tsm_timing_00_init = B3(END_OF_RX_WD) | B2(0x00) | B1(END_OF_TX_WD) | B0(0x00), /* bb_ldo_hf_en */
|
||||
.tsm_timing_01_init = B3(END_OF_RX_WD) | B2(0x00) | B1(END_OF_TX_WD) | B0(0x00), /* bb_ldo_adcdac_en */
|
||||
.tsm_timing_02_init = B3(END_OF_RX_WD) | B2(0x00) | B1(0xFF) | B0(0xFF), /* bb_ldo_bba_en */
|
||||
.tsm_timing_03_init = B3(END_OF_RX_WD) | B2(0x00) | B1(END_OF_TX_WD) | B0(0x00), /* bb_ldo_pd_en */
|
||||
.tsm_timing_04_init = B3(END_OF_RX_WD) | B2(0x00) | B1(END_OF_TX_WD) | B0(0x00), /* bb_ldo_fdbk_en */
|
||||
.tsm_timing_05_init = B3(END_OF_RX_WD) | B2(0x00) | B1(END_OF_TX_WD) | B0(0x00), /* bb_ldo_vcolo_en */
|
||||
.tsm_timing_06_init = B3(END_OF_RX_WD) | B2(0x00) | B1(END_OF_TX_WD) | B0(0x00), /* bb_ldo_vtref_en */
|
||||
.tsm_timing_07_init = B3(0x05) | B2(0x00) | B1(0x05) | B0(0x00), /* bb_ldo_fdbk_bleed_en */
|
||||
.tsm_timing_08_init = B3(0x03) | B2(0x00) | B1(0x03) | B0(0x00), /* bb_ldo_vcolo_bleed_en */
|
||||
.tsm_timing_09_init = B3(0x03) | B2(0x00) | B1(0x03) | B0(0x00), /* bb_ldo_vcolo_fastcharge_en */
|
||||
|
||||
.tsm_timing_10_init = B3(END_OF_RX_WD) | B2(0x03 + AUX_PLL_DELAY) | B1(END_OF_TX_WD) | B0(0x03), /* bb_xtal_pll_ref_clk_en */
|
||||
.tsm_timing_11_init = B3(0xFF) | B2(0xFF) | B1(END_OF_TX_WD) | B0(0x03), /* bb_xtal_dac_ref_clk_en */
|
||||
.tsm_timing_12_init = B3(END_OF_RX_WD) | B2(0x03 + AUX_PLL_DELAY) | B1(0xFF) | B0(0xFF), /* rxtx_auxpll_vco_ref_clk_en */
|
||||
.tsm_timing_13_init = B3(0x18) | B2(0x00) | B1(0x4C) | B0(0x00), /* sy_vco_autotune_en */
|
||||
.tsm_timing_14_init_26mhz = B3(END_OF_RX_WD_26MHZ) | B2(0x31+ADD_FOR_26MHZ) | B1(END_OF_TX_WU + PD_CYCLE_SLIP_TX_LO_ADJ) | B0(0x63 + PD_CYCLE_SLIP_TX_HI_ADJ), /* sy_pd_cycle_slip_ld_ft_en */
|
||||
.tsm_timing_14_init_32mhz = B3(END_OF_RX_WD) | B2(0x31 + AUX_PLL_DELAY) | B1(END_OF_TX_WU + PD_CYCLE_SLIP_TX_LO_ADJ) | B0(0x63 + PD_CYCLE_SLIP_TX_HI_ADJ),
|
||||
.tsm_timing_15_init = B3(END_OF_RX_WD) | B2(0x03 + AUX_PLL_DELAY) | B1(END_OF_TX_WD) | B0(0x03), /* sy_vco_en */
|
||||
.tsm_timing_16_init_26mhz = B3(END_OF_RX_WD_26MHZ) | B2(0x1C + ADD_FOR_26MHZ) | B1(0xFF) | B0(0xFF), /* sy_lo_rx_buf_en */
|
||||
.tsm_timing_16_init_32mhz = B3(END_OF_RX_WD) | B2(0x1C + AUX_PLL_DELAY) | B1(0xFF) | B0(0xFF),
|
||||
.tsm_timing_17_init = B3(0xFF) | B2(0xFF) | B1(END_OF_TX_WD) | B0(0x55), /* sy_lo_tx_buf_en */
|
||||
.tsm_timing_18_init = B3(END_OF_RX_WD) | B2(0x05 + AUX_PLL_DELAY) | B1(END_OF_TX_WD) | B0(0x05), /* sy_divn_en */
|
||||
.tsm_timing_19_init = B3(0x18+AUX_PLL_DELAY) | B2(0x03 + AUX_PLL_DELAY) | B1(0x4C) | B0(0x03), /* sy_pd_filter_charge_en */
|
||||
|
||||
.tsm_timing_20_init = B3(END_OF_RX_WD) | B2(0x03 + AUX_PLL_DELAY) | B1(END_OF_TX_WD) | B0(0x03), /* sy_pd_en */
|
||||
.tsm_timing_21_init = B3(END_OF_RX_WD) | B2(0x04 + AUX_PLL_DELAY) | B1(END_OF_TX_WD) | B0(0x04), /* sy_lo_divn_en */
|
||||
.tsm_timing_22_init = B3(END_OF_RX_WD) | B2(0x04 + AUX_PLL_DELAY) | B1(0xFF) | B0(0xFF), /* sy_lo_rx_en */
|
||||
.tsm_timing_23_init = B3(0xFF) | B2(0xFF) | B1(END_OF_TX_WD) | B0(0x04), /*sy_lo_tx_en */
|
||||
.tsm_timing_24_init = B3(0x18) | B2(0x00) | B1(0x4C) | B0(0x00), /* sy_divn_cal_en */
|
||||
.tsm_timing_25_init_26mhz = B3(END_OF_RX_WD_26MHZ) | B2(0x1D + ADD_FOR_26MHZ + AUX_PLL_DELAY) | B1(0xFF) | B0(0xFF), /* rx_lna_mixer_en */
|
||||
.tsm_timing_25_init_32mhz = B3(END_OF_RX_WD) | B2(0x1D + AUX_PLL_DELAY) | B1(0xFF) | B0(0xFF),
|
||||
.tsm_timing_26_init = B3(0xFF) | B2(0xFF) | B1(END_OF_TX_WD) | B0(0x58), /* tx_pa_en */
|
||||
.tsm_timing_27_init_26mhz = B3(END_OF_RX_WD_26MHZ) | B2(0x20 + ADD_FOR_26MHZ + AUX_PLL_DELAY) | B1(0xFF) | B0(0xFF), /* rx_adc_i_q_en */
|
||||
.tsm_timing_27_init_32mhz = B3(END_OF_RX_WD) | B2(0x20 + AUX_PLL_DELAY) | B1(0xFF) | B0(0xFF),
|
||||
.tsm_timing_28_init_26mhz = B3(0x21 + ADD_FOR_26MHZ) | B2(0x20 + ADD_FOR_26MHZ + AUX_PLL_DELAY) | B1(0xFF) | B0(0xFF), /* rx_adc_reset_en */
|
||||
.tsm_timing_28_init_32mhz = B3(0x21 + AUX_PLL_DELAY) | B2(0x20 + AUX_PLL_DELAY) | B1(0xFF) | B0(0xFF),
|
||||
.tsm_timing_29_init_26mhz = B3(END_OF_RX_WD_26MHZ) | B2(0x1E + ADD_FOR_26MHZ + AUX_PLL_DELAY) | B1(0xFF) | B0(0xFF), /* rx_bba_i_q_en */
|
||||
.tsm_timing_29_init_32mhz = B3(END_OF_RX_WD) | B2(0x1E + AUX_PLL_DELAY) | B1(0xFF) | B0(0xFF),
|
||||
|
||||
.tsm_timing_30_init_26mhz = B3(END_OF_RX_WD_26MHZ) | B2(0x20 + ADD_FOR_26MHZ + AUX_PLL_DELAY) | B1(0xFF) | B0(0xFF), /* rx_bba_pdet_en */
|
||||
.tsm_timing_30_init_32mhz = B3(END_OF_RX_WD) | B2(0x20 + AUX_PLL_DELAY) | B1(0xFF) | B0(0xFF),
|
||||
.tsm_timing_31_init_26mhz = B3(END_OF_RX_WD_26MHZ) | B2(0x1F + ADD_FOR_26MHZ + AUX_PLL_DELAY) | B1(0xFF) | B0(0xFF), /* rx_bba_tza_dcoc_en */
|
||||
.tsm_timing_31_init_32mhz = B3(END_OF_RX_WD) | B2(0x1F + AUX_PLL_DELAY) | B1(0xFF) | B0(0xFF),
|
||||
.tsm_timing_32_init_26mhz = B3(END_OF_RX_WD_26MHZ) | B2(0x1D + ADD_FOR_26MHZ + AUX_PLL_DELAY) | B1(0xFF) | B0(0xFF), /* rx_tza_i_q_en */
|
||||
.tsm_timing_32_init_32mhz = B3(END_OF_RX_WD) | B2(0x1D + AUX_PLL_DELAY) | B1(0xFF) | B0(0xFF),
|
||||
.tsm_timing_33_init_26mhz = B3(END_OF_RX_WD_26MHZ) | B2(0x20 + ADD_FOR_26MHZ + AUX_PLL_DELAY) | B1(0xFF) | B0(0xFF), /* rx_tza_pdet_en */
|
||||
.tsm_timing_33_init_32mhz = B3(END_OF_RX_WD) | B2(0x20 + AUX_PLL_DELAY) | B1(0xFF) | B0(0xFF),
|
||||
.tsm_timing_34_init = B3(END_OF_RX_WD) | B2(0x07 + AUX_PLL_DELAY) | B1(END_OF_TX_WD) | B0(0x07), /* pll_dig_en */
|
||||
.tsm_timing_35_init = B3(0xFF) | B2(0xFF) | B1(END_OF_TX_WD), /* tx_dig_en - Byte 0 comes from mode specific settings */
|
||||
.tsm_timing_36_init_26mhz = B3(END_OF_RX_WD) | B2(0x66 + ADD_FOR_26MHZ + AUX_PLL_DELAY) | B1(0xFF) | B0(0xFF), /* rx_dig_en */
|
||||
.tsm_timing_36_init_32mhz = B3(END_OF_RX_WD) | B2(0x66 + AUX_PLL_DELAY) | B1(0xFF) | B0(0xFF),
|
||||
.tsm_timing_37_init_26mhz = B3(0x67 + ADD_FOR_26MHZ + AUX_PLL_DELAY) | B2(0x66 + ADD_FOR_26MHZ + AUX_PLL_DELAY) | B1(0xFF) | B0(0xFF), /* rx_init */
|
||||
.tsm_timing_37_init_32mhz = B3(0x67 + AUX_PLL_DELAY) | B2(0x66 + AUX_PLL_DELAY) | B1(0xFF) | B0(0xFF),
|
||||
.tsm_timing_38_init = B3(END_OF_RX_WD) | B2(0x0E + AUX_PLL_DELAY) | B1(END_OF_TX_WD) | B0(0x42), /* sigma_delta_en */
|
||||
.tsm_timing_39_init_26mhz = B3(END_OF_RX_WD_26MHZ) | B2(0x66 + ADD_FOR_26MHZ + AUX_PLL_DELAY) | B1(0xFF) | B0(0xFF), /* rx_phy_en */
|
||||
.tsm_timing_39_init_32mhz = B3(END_OF_RX_WD) | B2(0x66 + AUX_PLL_DELAY) | B1(0xFF) | B0(0xFF),
|
||||
|
||||
.tsm_timing_40_init_26mhz = B3(END_OF_RX_WD_26MHZ) | B2(0x26 + ADD_FOR_26MHZ + AUX_PLL_DELAY) | B1(0xFF) | B0(0xFF), /* dcoc_en */
|
||||
.tsm_timing_40_init_32mhz = B3(END_OF_RX_WD) | B2(0x26 + AUX_PLL_DELAY) | B1(0xFF) | B0(0xFF),
|
||||
.tsm_timing_41_init_26mhz = B3(0x27 + ADD_FOR_26MHZ + AUX_PLL_DELAY) | B2(0x26 + ADD_FOR_26MHZ + AUX_PLL_DELAY) | B1(0xFF) | B0(0xFF), /* dcoc_init */
|
||||
.tsm_timing_41_init_32mhz = B3(0x27 + AUX_PLL_DELAY) | B2(0x26 + AUX_PLL_DELAY) | B1(0xFF) | B0(0xFF),
|
||||
.tsm_timing_51_init = B3(END_OF_RX_WD) | B2(0x03 + AUX_PLL_DELAY) | B1(0xFF) | B0(0xFF), /* rxtx_auxpll_bias_en */
|
||||
.tsm_timing_52_init_26mhz = B3(0x17 + ADD_FOR_26MHZ + AUX_PLL_DELAY) | B2(0x06 + ADD_FOR_26MHZ + AUX_PLL_DELAY) | B1(0xFF) | B0(0xFF), /* rxtx_auxpll_fcal_en */
|
||||
.tsm_timing_52_init_32mhz = B3(0x17 + AUX_PLL_DELAY) | B2(0x06 + AUX_PLL_DELAY) | B1(0xFF) | B0(0xFF),
|
||||
.tsm_timing_53_init = B3(END_OF_RX_WD) | B2(0x03 + AUX_PLL_DELAY) | B1(0xFF) | B0(0xFF), /* rxtx_auxpll_lf_pd_en */
|
||||
.tsm_timing_54_init_26mhz = B3(0x17 + ADD_FOR_26MHZ + AUX_PLL_DELAY) | B2(0x03 + ADD_FOR_26MHZ + AUX_PLL_DELAY) | B1(0xFF) | B0(0xFF), /* rxtx_auxpll_pd_lf_filter_charge_en */
|
||||
.tsm_timing_54_init_32mhz = B3(0x17 + AUX_PLL_DELAY) | B2(0x03 + AUX_PLL_DELAY) | B1(0xFF) | B0(0xFF),
|
||||
.tsm_timing_55_init_26mhz = B3(END_OF_RX_WD_26MHZ) | B2(0x20 + ADD_FOR_26MHZ + AUX_PLL_DELAY) | B1(0xFF) | B0(0xFF), /* rxtx_auxpll_adc_buf_en */
|
||||
.tsm_timing_55_init_32mhz = B3(END_OF_RX_WD) | B2(0x20 + AUX_PLL_DELAY) | B1(0xFF) | B0(0xFF),
|
||||
.tsm_timing_56_init_26mhz = B3(END_OF_RX_WD_26MHZ) | B2(0x20 + ADD_FOR_26MHZ + AUX_PLL_DELAY) | B1(0xFF) | B0(0xFF), /* rxtx_auxpll_dig_buf_en */
|
||||
.tsm_timing_56_init_32mhz = B3(END_OF_RX_WD) | B2(0x20 + AUX_PLL_DELAY) | B1(0xFF) | B0(0xFF),
|
||||
.tsm_timing_57_init = B3(0x1A + AUX_PLL_DELAY) | B2(0x03 + AUX_PLL_DELAY) | B1(0xFF) | B0(0xFF), /*rxtx_rccal_en */
|
||||
.tsm_timing_58_init = B3(0xFF) | B2(0xFF) | B1(END_OF_TX_WD) | B0(0x03), /* tx_hpm_dac_en */
|
||||
|
||||
/* XCVR_TX_DIG configs */
|
||||
#define radio_dft_mode 0
|
||||
#define lfsr_length 4
|
||||
#define lfsr_en 0
|
||||
#define dft_clk_sel 4
|
||||
#define tx_dft_en 0
|
||||
#define soc_test_sel 0
|
||||
#define tx_capture_pol 0
|
||||
#define freq_word_adj 0
|
||||
#define lrm 0
|
||||
#define data_padding_pat_1 0x55
|
||||
#define data_padding_pat_0 0xAA
|
||||
#define gfsk_multiply_table_manual 0
|
||||
#define gfsk_mi 1
|
||||
#define gfsk_mld 0
|
||||
#define gfsk_fld 0
|
||||
#define gfsk_mod_index_scaling 0
|
||||
#define tx_image_filter_ovrd_en 0
|
||||
#define tx_image_filter_0_ovrd 0
|
||||
#define tx_image_filter_1_ovrd 0
|
||||
#define tx_image_filter_2_ovrd 0
|
||||
#define gfsk_filter_coeff_manual2 0xC0630401
|
||||
#define gfsk_filter_coeff_manual1 0xBB29960D
|
||||
#define fsk_modulation_scale_0 0x1800
|
||||
#define fsk_modulation_scale_1 0x0800
|
||||
#define dft_mod_patternval 0
|
||||
#define ctune_bist_go 0
|
||||
#define ctune_bist_thrshld 0
|
||||
#define pa_am_mod_freq 0
|
||||
#define pa_am_mod_entries 0
|
||||
#define pa_am_mod_en 0
|
||||
#define syn_bist_go 0
|
||||
#define syn_bist_all_channels 0
|
||||
#define freq_count_threshold 0
|
||||
#define hpm_inl_bist_go 0
|
||||
#define hpm_dnl_bist_go 0
|
||||
#define dft_max_ram_size 0
|
||||
|
||||
.tx_ctrl = XCVR_TX_DIG_CTRL_RADIO_DFT_MODE(radio_dft_mode) |
|
||||
XCVR_TX_DIG_CTRL_LFSR_LENGTH(lfsr_length) |
|
||||
XCVR_TX_DIG_CTRL_LFSR_EN(lfsr_en) |
|
||||
XCVR_TX_DIG_CTRL_DFT_CLK_SEL(dft_clk_sel) |
|
||||
XCVR_TX_DIG_CTRL_TX_DFT_EN(tx_dft_en) |
|
||||
XCVR_TX_DIG_CTRL_SOC_TEST_SEL(soc_test_sel) |
|
||||
XCVR_TX_DIG_CTRL_TX_CAPTURE_POL(tx_capture_pol) |
|
||||
XCVR_TX_DIG_CTRL_FREQ_WORD_ADJ(freq_word_adj),
|
||||
/*-------------------------------------------------------------------------------------------------*/
|
||||
.tx_data_padding = XCVR_TX_DIG_DATA_PADDING_LRM(lrm) |
|
||||
XCVR_TX_DIG_DATA_PADDING_DATA_PADDING_PAT_1(data_padding_pat_1) |
|
||||
XCVR_TX_DIG_DATA_PADDING_DATA_PADDING_PAT_0(data_padding_pat_0),
|
||||
/*-------------------------------------------------------------------------------------------------*/
|
||||
.tx_dft_pattern = XCVR_TX_DIG_DFT_PATTERN_DFT_MOD_PATTERN(dft_mod_patternval),
|
||||
#if !RADIO_IS_GEN_2P1
|
||||
/*-------------------------------------------------------------------------------------------------*/
|
||||
.rf_dft_bist_1 = XCVR_TX_DIG_RF_DFT_BIST_1_CTUNE_BIST_GO(ctune_bist_go) |
|
||||
XCVR_TX_DIG_RF_DFT_BIST_1_CTUNE_BIST_THRSHLD(ctune_bist_thrshld) |
|
||||
XCVR_TX_DIG_RF_DFT_BIST_1_PA_AM_MOD_FREQ(pa_am_mod_freq) |
|
||||
XCVR_TX_DIG_RF_DFT_BIST_1_PA_AM_MOD_ENTRIES(pa_am_mod_entries) |
|
||||
XCVR_TX_DIG_RF_DFT_BIST_1_PA_AM_MOD_EN(pa_am_mod_en),
|
||||
/*-------------------------------------------------------------------------------------------------*/
|
||||
.rf_dft_bist_2 = XCVR_TX_DIG_RF_DFT_BIST_2_SYN_BIST_GO(syn_bist_go) |
|
||||
XCVR_TX_DIG_RF_DFT_BIST_2_SYN_BIST_ALL_CHANNELS(syn_bist_all_channels) |
|
||||
XCVR_TX_DIG_RF_DFT_BIST_2_FREQ_COUNT_THRESHOLD(freq_count_threshold) |
|
||||
XCVR_TX_DIG_RF_DFT_BIST_2_HPM_INL_BIST_GO(hpm_inl_bist_go) |
|
||||
XCVR_TX_DIG_RF_DFT_BIST_2_HPM_DNL_BIST_GO(hpm_dnl_bist_go) |
|
||||
XCVR_TX_DIG_RF_DFT_BIST_2_DFT_MAX_RAM_SIZE(dft_max_ram_size),
|
||||
#endif /* !RADIO_IS_GEN_2P1 */
|
||||
};
|
||||
|
||||
-353
@@ -1,353 +0,0 @@
|
||||
/*
|
||||
* Copyright 2016-2017 NXP
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* o Redistributions of source code must retain the above copyright notice, this list
|
||||
* of conditions and the following disclaimer.
|
||||
*
|
||||
* o 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.
|
||||
*
|
||||
* o Neither the name of Freescale Semiconductor, Inc. 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 HOLDER 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 "fsl_xcvr.h"
|
||||
|
||||
/*******************************************************************************
|
||||
* Definitions
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* Prototypes
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* Variables
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* Code
|
||||
******************************************************************************/
|
||||
/* MODE only configuration */
|
||||
const xcvr_mode_config_t gfsk_bt_0p3_h_0p5_mode_config =
|
||||
{
|
||||
.radio_mode = GFSK_BT_0p3_h_0p5,
|
||||
.scgc5_clock_ena_bits = SIM_SCGC5_PHYDIG_MASK | SIM_SCGC5_GEN_FSK_MASK,
|
||||
|
||||
/* XCVR_MISC configs */
|
||||
.xcvr_ctrl.mask = XCVR_CTRL_XCVR_CTRL_PROTOCOL_MASK |
|
||||
XCVR_CTRL_XCVR_CTRL_TGT_PWR_SRC_MASK |
|
||||
XCVR_CTRL_XCVR_CTRL_DEMOD_SEL_MASK,
|
||||
.xcvr_ctrl.init = XCVR_CTRL_XCVR_CTRL_PROTOCOL(8) |
|
||||
XCVR_CTRL_XCVR_CTRL_TGT_PWR_SRC(7) |
|
||||
XCVR_CTRL_XCVR_CTRL_DEMOD_SEL(1),
|
||||
|
||||
/* XCVR_PHY configs */
|
||||
.phy_pre_ref0_init = 0x7BCDEB39,
|
||||
.phy_pre_ref1_init = 0xCEF7DEF7,
|
||||
.phy_pre_ref2_init = 0x0000CEB7,
|
||||
|
||||
.phy_cfg1_init = XCVR_PHY_CFG1_AA_PLAYBACK(1) |
|
||||
XCVR_PHY_CFG1_AA_OUTPUT_SEL(1) |
|
||||
XCVR_PHY_CFG1_FSK_BIT_INVERT(0) |
|
||||
XCVR_PHY_CFG1_BSM_EN_BLE(0) |
|
||||
XCVR_PHY_CFG1_DEMOD_CLK_MODE(0) |
|
||||
XCVR_PHY_CFG1_CTS_THRESH(0xda) |
|
||||
XCVR_PHY_CFG1_FSK_FTS_TIMEOUT(2),
|
||||
|
||||
.phy_el_cfg_init = XCVR_PHY_EL_CFG_EL_ENABLE(1)
|
||||
#if !RADIO_IS_GEN_2P1
|
||||
| XCVR_PHY_EL_CFG_EL_ZB_ENABLE(0)
|
||||
#endif /* !RADIO_IS_GEN_2P1 */
|
||||
,
|
||||
|
||||
/* XCVR_RX_DIG configs */
|
||||
.rx_dig_ctrl_init_26mhz = XCVR_RX_DIG_RX_DIG_CTRL_RX_FSK_ZB_SEL(0) | /* Depends on protocol */
|
||||
XCVR_RX_DIG_RX_DIG_CTRL_RX_DC_RESID_EN(1) | /* Depends on protocol */
|
||||
XCVR_RX_DIG_RX_DIG_CTRL_RX_SRC_RATE(0),
|
||||
|
||||
.rx_dig_ctrl_init_32mhz = XCVR_RX_DIG_RX_DIG_CTRL_RX_FSK_ZB_SEL(0) | /* Depends on protocol */
|
||||
XCVR_RX_DIG_RX_DIG_CTRL_RX_DC_RESID_EN(1), /* Depends on protocol */
|
||||
|
||||
.agc_ctrl_0_init = XCVR_RX_DIG_AGC_CTRL_0_AGC_DOWN_RSSI_THRESH(0xFF),
|
||||
|
||||
/* XCVR_TSM configs */
|
||||
#if (DATA_PADDING_EN)
|
||||
.tsm_timing_35_init = B0(TX_DIG_EN_ASSERT+TX_DIG_EN_TX_HI_ADJ),
|
||||
#else
|
||||
.tsm_timing_35_init = B0(TX_DIG_EN_ASSERT),
|
||||
#endif /* (DATA_PADDING_EN) */
|
||||
|
||||
/* XCVR_TX_DIG configs */
|
||||
.tx_gfsk_ctrl = XCVR_TX_DIG_GFSK_CTRL_GFSK_MULTIPLY_TABLE_MANUAL(0x4000) |
|
||||
XCVR_TX_DIG_GFSK_CTRL_GFSK_MI(1) |
|
||||
XCVR_TX_DIG_GFSK_CTRL_GFSK_MLD(0) |
|
||||
XCVR_TX_DIG_GFSK_CTRL_GFSK_FLD(1) | /* Use GFSK Manual Filter Coeffs */
|
||||
XCVR_TX_DIG_GFSK_CTRL_GFSK_MOD_INDEX_SCALING(0) |
|
||||
XCVR_TX_DIG_GFSK_CTRL_TX_IMAGE_FILTER_OVRD_EN(0) |
|
||||
XCVR_TX_DIG_GFSK_CTRL_TX_IMAGE_FILTER_0_OVRD(0) |
|
||||
XCVR_TX_DIG_GFSK_CTRL_TX_IMAGE_FILTER_1_OVRD(0) |
|
||||
XCVR_TX_DIG_GFSK_CTRL_TX_IMAGE_FILTER_2_OVRD(0),
|
||||
.tx_gfsk_coeff1_26mhz = (107U) << 0 | /* coeff 2/13 */
|
||||
(164U) << 7 | /* coeff 6/9 */
|
||||
(125U) << 16 | /* coef 3/12 */
|
||||
(169U) << 23, /* coeff 7/8 */
|
||||
.tx_gfsk_coeff2_26mhz = (72U) << 0 | /* coeff 0/15 */
|
||||
(90U) << 8 | /* coeff 1/14 */
|
||||
(141U) << 16 | /* coeff 4/11 */
|
||||
(155U) << 24, /* coeff 5/10 */
|
||||
.tx_gfsk_coeff1_32mhz = (70U) << 0 | /* coeff 2/13 */
|
||||
(216U) << 7 | /* coeff 6/9 */
|
||||
(105U) << 16 | /* coef 3/12 */
|
||||
(233U) << 23, /* coeff 7/8 */
|
||||
.tx_gfsk_coeff2_32mhz = (25U) << 0 | /* coeff 0/15 */
|
||||
(44U) << 8 | /* coeff 1/14 */
|
||||
(145U) << 16 | /* coeff 4/11 */
|
||||
(184U) << 24, /* coeff 5/10 */
|
||||
};
|
||||
|
||||
/* MODE & DATA RATE combined configuration */
|
||||
const xcvr_mode_datarate_config_t xcvr_GFSK_BT_0p3_h_0p5_1mbps_config =
|
||||
{
|
||||
.radio_mode = GFSK_BT_0p3_h_0p5,
|
||||
.data_rate = DR_1MBPS,
|
||||
|
||||
.ana_sy_ctrl2.mask = XCVR_ANALOG_SY_CTRL_2_SY_VCO_KVM_MASK,
|
||||
.ana_sy_ctrl2.init = XCVR_ANALOG_SY_CTRL_2_SY_VCO_KVM(0), /* VCO KVM */
|
||||
.ana_rx_bba.mask = XCVR_ANALOG_RX_BBA_RX_BBA_BW_SEL_MASK | XCVR_ANALOG_RX_BBA_RX_BBA2_BW_SEL_MASK,
|
||||
.ana_rx_bba.init = XCVR_ANALOG_RX_BBA_RX_BBA_BW_SEL(4) | XCVR_ANALOG_RX_BBA_RX_BBA2_BW_SEL(4), /* BBA_BW_SEL and BBA2_BW_SEL */
|
||||
.ana_rx_tza.mask = XCVR_ANALOG_RX_TZA_RX_TZA_BW_SEL_MASK,
|
||||
.ana_rx_tza.init = XCVR_ANALOG_RX_TZA_RX_TZA_BW_SEL(4), /*TZA_BW_SEL */
|
||||
|
||||
.phy_cfg2_init = XCVR_PHY_CFG2_PHY_FIFO_PRECHG(8) |
|
||||
XCVR_PHY_CFG2_X2_DEMOD_GAIN(0xA) ,
|
||||
|
||||
/* AGC configs */
|
||||
.agc_ctrl_2_init_26mhz = XCVR_RX_DIG_AGC_CTRL_2_BBA_GAIN_SETTLE_TIME(11) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_BBA_PDET_SEL_LO(5) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_BBA_PDET_SEL_HI(6) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_TZA_PDET_SEL_LO(3) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_TZA_PDET_SEL_HI(7) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_AGC_FAST_EXPIRE(5),
|
||||
.agc_ctrl_2_init_32mhz = XCVR_RX_DIG_AGC_CTRL_2_BBA_GAIN_SETTLE_TIME(12) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_BBA_PDET_SEL_LO(5) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_BBA_PDET_SEL_HI(6) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_TZA_PDET_SEL_LO(3) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_TZA_PDET_SEL_HI(7) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_AGC_FAST_EXPIRE(5),
|
||||
|
||||
/* All constant values are represented as 16 bits, register writes will remove unused bits */
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_0 = 0xFFFF,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_1 = 0xFFFD,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_2 = 0xFFF9,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_3 = 0xFFF4,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_4 = 0xFFF2,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_5 = 0xFFF5,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_6 = 0x0000,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_7 = 0x0011,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_8 = 0x0028,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_9 = 0x0041,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_10 = 0x0055,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_11 = 0x0061,
|
||||
|
||||
/* 32MHz Channel Filter */
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_0 = 0x0001,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_1 = 0xFFFF,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_2 = 0xFFFA,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_3 = 0xFFF4,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_4 = 0xFFF0,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_5 = 0xFFF0,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_6 = 0xFFF9,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_7 = 0x000B,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_8 = 0x0025,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_9 = 0x0043,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_10 = 0x005C,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_11 = 0x006A,
|
||||
|
||||
.rx_rccal_ctrl_0 = XCVR_RX_DIG_RX_RCCAL_CTRL0_BBA_RCCAL_OFFSET(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_BBA_RCCAL_MANUAL(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_BBA_RCCAL_DIS(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_RCCAL_SMP_DLY(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_RCCAL_COMP_INV(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_TZA_RCCAL_OFFSET(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_TZA_RCCAL_MANUAL(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_TZA_RCCAL_DIS(0) ,
|
||||
.rx_rccal_ctrl_1 = XCVR_RX_DIG_RX_RCCAL_CTRL1_ADC_RCCAL_OFFSET(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL1_ADC_RCCAL_MANUAL(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL1_ADC_RCCAL_DIS(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL1_BBA2_RCCAL_OFFSET(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL1_BBA2_RCCAL_MANUAL(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL1_BBA2_RCCAL_DIS(0) ,
|
||||
|
||||
.tx_fsk_scale_26mhz = XCVR_TX_DIG_FSK_SCALE_FSK_MODULATION_SCALE_0(0x1627) | XCVR_TX_DIG_FSK_SCALE_FSK_MODULATION_SCALE_1(0x09d9),
|
||||
.tx_fsk_scale_32mhz = XCVR_TX_DIG_FSK_SCALE_FSK_MODULATION_SCALE_0(0x1800) | XCVR_TX_DIG_FSK_SCALE_FSK_MODULATION_SCALE_1(0x0800),
|
||||
};
|
||||
|
||||
const xcvr_mode_datarate_config_t xcvr_GFSK_BT_0p3_h_0p5_500kbps_config =
|
||||
{
|
||||
.radio_mode = GFSK_BT_0p3_h_0p5,
|
||||
.data_rate = DR_500KBPS,
|
||||
|
||||
.ana_sy_ctrl2.mask = XCVR_ANALOG_SY_CTRL_2_SY_VCO_KVM_MASK,
|
||||
.ana_sy_ctrl2.init = XCVR_ANALOG_SY_CTRL_2_SY_VCO_KVM(0), /* VCO KVM */
|
||||
.ana_rx_bba.mask = XCVR_ANALOG_RX_BBA_RX_BBA_BW_SEL_MASK | XCVR_ANALOG_RX_BBA_RX_BBA2_BW_SEL_MASK,
|
||||
.ana_rx_bba.init = XCVR_ANALOG_RX_BBA_RX_BBA_BW_SEL(5) | XCVR_ANALOG_RX_BBA_RX_BBA2_BW_SEL(5), /* BBA_BW_SEL and BBA2_BW_SEL */
|
||||
.ana_rx_tza.mask = XCVR_ANALOG_RX_TZA_RX_TZA_BW_SEL_MASK,
|
||||
.ana_rx_tza.init = XCVR_ANALOG_RX_TZA_RX_TZA_BW_SEL(5), /* TZA_BW_SEL */
|
||||
|
||||
.phy_cfg2_init = XCVR_PHY_CFG2_PHY_FIFO_PRECHG(8) |
|
||||
XCVR_PHY_CFG2_X2_DEMOD_GAIN(0x8) ,
|
||||
|
||||
/* AGC configs */
|
||||
.agc_ctrl_2_init_26mhz = XCVR_RX_DIG_AGC_CTRL_2_BBA_GAIN_SETTLE_TIME(15) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_BBA_PDET_SEL_LO(5) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_BBA_PDET_SEL_HI(6) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_TZA_PDET_SEL_LO(3) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_TZA_PDET_SEL_HI(7) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_AGC_FAST_EXPIRE(5),
|
||||
.agc_ctrl_2_init_32mhz = XCVR_RX_DIG_AGC_CTRL_2_BBA_GAIN_SETTLE_TIME(18) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_BBA_PDET_SEL_LO(5) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_BBA_PDET_SEL_HI(6) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_TZA_PDET_SEL_LO(3) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_TZA_PDET_SEL_HI(7) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_AGC_FAST_EXPIRE(5),
|
||||
|
||||
/* All constant values are represented as 16 bits, register writes will remove unused bits */
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_0 = 0x0001,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_1 = 0x0000,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_2 = 0xFFFC,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_3 = 0xFFF7,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_4 = 0xFFF3,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_5 = 0xFFF2,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_6 = 0xFFF9,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_7 = 0x000A,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_8 = 0x0023,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_9 = 0x0040,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_10 = 0x0059,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_11 = 0x0068,
|
||||
|
||||
/* 32MHz Channel Filter */
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_0 = 0x0001,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_1 = 0x0001,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_2 = 0xFFFF,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_3 = 0xFFFA,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_4 = 0xFFF3,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_5 = 0xFFEF,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_6 = 0xFFF3,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_7 = 0x0001,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_8 = 0x001D,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_9 = 0x003F,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_10 = 0x005F,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_11 = 0x0072,
|
||||
|
||||
.rx_rccal_ctrl_0 = XCVR_RX_DIG_RX_RCCAL_CTRL0_BBA_RCCAL_OFFSET(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_BBA_RCCAL_MANUAL(31) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_BBA_RCCAL_DIS(1) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_RCCAL_SMP_DLY(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_RCCAL_COMP_INV(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_TZA_RCCAL_OFFSET(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_TZA_RCCAL_MANUAL(31) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_TZA_RCCAL_DIS(1) ,
|
||||
.rx_rccal_ctrl_1 = XCVR_RX_DIG_RX_RCCAL_CTRL1_ADC_RCCAL_OFFSET(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL1_ADC_RCCAL_MANUAL(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL1_ADC_RCCAL_DIS(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL1_BBA2_RCCAL_OFFSET(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL1_BBA2_RCCAL_MANUAL(31) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL1_BBA2_RCCAL_DIS(1) ,
|
||||
|
||||
.tx_fsk_scale_26mhz = XCVR_TX_DIG_FSK_SCALE_FSK_MODULATION_SCALE_0(0x1627) | XCVR_TX_DIG_FSK_SCALE_FSK_MODULATION_SCALE_1(0x09d9),
|
||||
.tx_fsk_scale_32mhz = XCVR_TX_DIG_FSK_SCALE_FSK_MODULATION_SCALE_0(0x1800) | XCVR_TX_DIG_FSK_SCALE_FSK_MODULATION_SCALE_1(0x0800),
|
||||
};
|
||||
|
||||
const xcvr_mode_datarate_config_t xcvr_GFSK_BT_0p3_h_0p5_250kbps_config =
|
||||
{
|
||||
.radio_mode = GFSK_BT_0p3_h_0p5,
|
||||
.data_rate = DR_250KBPS,
|
||||
|
||||
.ana_sy_ctrl2.mask = XCVR_ANALOG_SY_CTRL_2_SY_VCO_KVM_MASK,
|
||||
.ana_sy_ctrl2.init = XCVR_ANALOG_SY_CTRL_2_SY_VCO_KVM(0), /* VCO KVM */
|
||||
.ana_rx_bba.mask = XCVR_ANALOG_RX_BBA_RX_BBA_BW_SEL_MASK | XCVR_ANALOG_RX_BBA_RX_BBA2_BW_SEL_MASK,
|
||||
.ana_rx_bba.init = XCVR_ANALOG_RX_BBA_RX_BBA_BW_SEL(5) | XCVR_ANALOG_RX_BBA_RX_BBA2_BW_SEL(5), /* BBA_BW_SEL and BBA2_BW_SEL */
|
||||
.ana_rx_tza.mask = XCVR_ANALOG_RX_TZA_RX_TZA_BW_SEL_MASK,
|
||||
.ana_rx_tza.init = XCVR_ANALOG_RX_TZA_RX_TZA_BW_SEL(5), /* TZA_BW_SEL */
|
||||
|
||||
.phy_cfg2_init = XCVR_PHY_CFG2_PHY_FIFO_PRECHG(8) |
|
||||
XCVR_PHY_CFG2_X2_DEMOD_GAIN(0x6) ,
|
||||
|
||||
/* AGC configs */
|
||||
.agc_ctrl_2_init_26mhz = XCVR_RX_DIG_AGC_CTRL_2_BBA_GAIN_SETTLE_TIME(18) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_BBA_PDET_SEL_LO(5) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_BBA_PDET_SEL_HI(2) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_TZA_PDET_SEL_LO(3) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_TZA_PDET_SEL_HI(7) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_AGC_FAST_EXPIRE(5),
|
||||
.agc_ctrl_2_init_32mhz = XCVR_RX_DIG_AGC_CTRL_2_BBA_GAIN_SETTLE_TIME(22) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_BBA_PDET_SEL_LO(5) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_BBA_PDET_SEL_HI(6) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_TZA_PDET_SEL_LO(3) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_TZA_PDET_SEL_HI(7) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_AGC_FAST_EXPIRE(5),
|
||||
|
||||
/* All constant values are represented as 16 bits, register writes will remove unused bits */
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_0 = 0x0001,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_1 = 0x0003,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_2 = 0x0003,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_3 = 0xFFFF,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_4 = 0xFFF7,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_5 = 0xFFEE,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_6 = 0xFFEC,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_7 = 0xFFF7,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_8 = 0x0014,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_9 = 0x003C,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_10 = 0x0064,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_11 = 0x007D,
|
||||
|
||||
/* 32MHz Channel Filter */
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_0 = 0x0001,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_1 = 0x0003,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_2 = 0x0005,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_3 = 0x0003,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_4 = 0xFFFC,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_5 = 0xFFF0,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_6 = 0xFFE8,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_7 = 0xFFEF,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_8 = 0x000B,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_9 = 0x0038,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_10 = 0x0068,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_11 = 0x0086,
|
||||
|
||||
.rx_rccal_ctrl_0 = XCVR_RX_DIG_RX_RCCAL_CTRL0_BBA_RCCAL_OFFSET(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_BBA_RCCAL_MANUAL(31) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_BBA_RCCAL_DIS(1) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_RCCAL_SMP_DLY(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_RCCAL_COMP_INV(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_TZA_RCCAL_OFFSET(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_TZA_RCCAL_MANUAL(31) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_TZA_RCCAL_DIS(1) ,
|
||||
.rx_rccal_ctrl_1 = XCVR_RX_DIG_RX_RCCAL_CTRL1_ADC_RCCAL_OFFSET(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL1_ADC_RCCAL_MANUAL(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL1_ADC_RCCAL_DIS(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL1_BBA2_RCCAL_OFFSET(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL1_BBA2_RCCAL_MANUAL(31) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL1_BBA2_RCCAL_DIS(1),
|
||||
|
||||
.tx_fsk_scale_26mhz = XCVR_TX_DIG_FSK_SCALE_FSK_MODULATION_SCALE_0(0x1627) | XCVR_TX_DIG_FSK_SCALE_FSK_MODULATION_SCALE_1(0x09d9),
|
||||
.tx_fsk_scale_32mhz = XCVR_TX_DIG_FSK_SCALE_FSK_MODULATION_SCALE_0(0x1800) | XCVR_TX_DIG_FSK_SCALE_FSK_MODULATION_SCALE_1(0x0800),
|
||||
};
|
||||
|
||||
-341
@@ -1,341 +0,0 @@
|
||||
/*
|
||||
* Copyright 2016-2017 NXP
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* o Redistributions of source code must retain the above copyright notice, this list
|
||||
* of conditions and the following disclaimer.
|
||||
*
|
||||
* o 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.
|
||||
*
|
||||
* o Neither the name of Freescale Semiconductor, Inc. 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 HOLDER 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 "fsl_xcvr.h"
|
||||
|
||||
/*******************************************************************************
|
||||
* Definitions
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* Prototypes
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* Variables
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* Code
|
||||
******************************************************************************/
|
||||
/* MODE only configuration */
|
||||
const xcvr_mode_config_t gfsk_bt_0p5_h_0p32_mode_config =
|
||||
{
|
||||
.radio_mode = GFSK_BT_0p5_h_0p32,
|
||||
.scgc5_clock_ena_bits = SIM_SCGC5_PHYDIG_MASK | SIM_SCGC5_GEN_FSK_MASK,
|
||||
|
||||
/* XCVR_MISC configs */
|
||||
.xcvr_ctrl.mask = XCVR_CTRL_XCVR_CTRL_PROTOCOL_MASK |
|
||||
XCVR_CTRL_XCVR_CTRL_TGT_PWR_SRC_MASK |
|
||||
XCVR_CTRL_XCVR_CTRL_DEMOD_SEL_MASK,
|
||||
.xcvr_ctrl.init = XCVR_CTRL_XCVR_CTRL_PROTOCOL(8) |
|
||||
XCVR_CTRL_XCVR_CTRL_TGT_PWR_SRC(7) |
|
||||
XCVR_CTRL_XCVR_CTRL_DEMOD_SEL(1),
|
||||
|
||||
/* XCVR_PHY configs */
|
||||
.phy_pre_ref0_init = 0xBBDE739B,
|
||||
.phy_pre_ref1_init = 0xDEFBDEF7,
|
||||
.phy_pre_ref2_init = 0x0000E739,
|
||||
|
||||
.phy_cfg1_init = XCVR_PHY_CFG1_AA_PLAYBACK(1) |
|
||||
XCVR_PHY_CFG1_AA_OUTPUT_SEL(1) |
|
||||
XCVR_PHY_CFG1_FSK_BIT_INVERT(0) |
|
||||
XCVR_PHY_CFG1_BSM_EN_BLE(0) |
|
||||
XCVR_PHY_CFG1_DEMOD_CLK_MODE(0) |
|
||||
XCVR_PHY_CFG1_CTS_THRESH(0xF0) |
|
||||
XCVR_PHY_CFG1_FSK_FTS_TIMEOUT(2),
|
||||
|
||||
.phy_el_cfg_init = XCVR_PHY_EL_CFG_EL_ENABLE(1)
|
||||
#if !RADIO_IS_GEN_2P1
|
||||
| XCVR_PHY_EL_CFG_EL_ZB_ENABLE(0)
|
||||
#endif /* !RADIO_IS_GEN_2P1 */
|
||||
,
|
||||
|
||||
/* XCVR_RX_DIG configs */
|
||||
.rx_dig_ctrl_init_26mhz = XCVR_RX_DIG_RX_DIG_CTRL_RX_FSK_ZB_SEL(0) | /* Depends on protocol */
|
||||
XCVR_RX_DIG_RX_DIG_CTRL_RX_DC_RESID_EN(1) | /* Depends on protocol */
|
||||
XCVR_RX_DIG_RX_DIG_CTRL_RX_SRC_RATE(0),
|
||||
|
||||
.rx_dig_ctrl_init_32mhz = XCVR_RX_DIG_RX_DIG_CTRL_RX_FSK_ZB_SEL(0) | /* Depends on protocol */
|
||||
XCVR_RX_DIG_RX_DIG_CTRL_RX_DC_RESID_EN(1), /* Depends on protocol */
|
||||
|
||||
.agc_ctrl_0_init = XCVR_RX_DIG_AGC_CTRL_0_AGC_DOWN_RSSI_THRESH(0xFF),
|
||||
|
||||
/* XCVR_TSM configs */
|
||||
#if (DATA_PADDING_EN)
|
||||
.tsm_timing_35_init = B0(TX_DIG_EN_ASSERT+TX_DIG_EN_TX_HI_ADJ),
|
||||
#else
|
||||
.tsm_timing_35_init = B0(TX_DIG_EN_ASSERT),
|
||||
#endif /* (DATA_PADDING_EN) */
|
||||
|
||||
/* XCVR_TX_DIG configs */
|
||||
.tx_gfsk_ctrl = XCVR_TX_DIG_GFSK_CTRL_GFSK_MULTIPLY_TABLE_MANUAL(0x4000) |
|
||||
XCVR_TX_DIG_GFSK_CTRL_GFSK_MI(0) |
|
||||
XCVR_TX_DIG_GFSK_CTRL_GFSK_MLD(0) |
|
||||
XCVR_TX_DIG_GFSK_CTRL_GFSK_FLD(0) |
|
||||
XCVR_TX_DIG_GFSK_CTRL_GFSK_MOD_INDEX_SCALING(0) |
|
||||
XCVR_TX_DIG_GFSK_CTRL_TX_IMAGE_FILTER_OVRD_EN(0) |
|
||||
XCVR_TX_DIG_GFSK_CTRL_TX_IMAGE_FILTER_0_OVRD(0) |
|
||||
XCVR_TX_DIG_GFSK_CTRL_TX_IMAGE_FILTER_1_OVRD(0) |
|
||||
XCVR_TX_DIG_GFSK_CTRL_TX_IMAGE_FILTER_2_OVRD(0),
|
||||
.tx_gfsk_coeff1_26mhz = 0,
|
||||
.tx_gfsk_coeff2_26mhz = 0,
|
||||
.tx_gfsk_coeff1_32mhz = 0,
|
||||
.tx_gfsk_coeff2_32mhz = 0,
|
||||
};
|
||||
|
||||
/* MODE & DATA RATE combined configuration */
|
||||
const xcvr_mode_datarate_config_t xcvr_GFSK_BT_0p5_h_0p32_1mbps_config =
|
||||
{
|
||||
.radio_mode = GFSK_BT_0p5_h_0p32,
|
||||
.data_rate = DR_1MBPS,
|
||||
|
||||
.ana_sy_ctrl2.mask = XCVR_ANALOG_SY_CTRL_2_SY_VCO_KVM_MASK,
|
||||
.ana_sy_ctrl2.init = XCVR_ANALOG_SY_CTRL_2_SY_VCO_KVM(0), /* VCO KVM */
|
||||
.ana_rx_bba.mask = XCVR_ANALOG_RX_BBA_RX_BBA_BW_SEL_MASK | XCVR_ANALOG_RX_BBA_RX_BBA2_BW_SEL_MASK,
|
||||
.ana_rx_bba.init = XCVR_ANALOG_RX_BBA_RX_BBA_BW_SEL(5) | XCVR_ANALOG_RX_BBA_RX_BBA2_BW_SEL(5), /* BBA_BW_SEL and BBA2_BW_SEL */
|
||||
.ana_rx_tza.mask = XCVR_ANALOG_RX_TZA_RX_TZA_BW_SEL_MASK,
|
||||
.ana_rx_tza.init = XCVR_ANALOG_RX_TZA_RX_TZA_BW_SEL(5), /* TZA_BW_SEL */
|
||||
|
||||
.phy_cfg2_init = XCVR_PHY_CFG2_PHY_FIFO_PRECHG(8) |
|
||||
XCVR_PHY_CFG2_X2_DEMOD_GAIN(0x4) ,
|
||||
|
||||
/* AGC configs */
|
||||
.agc_ctrl_2_init_26mhz = XCVR_RX_DIG_AGC_CTRL_2_BBA_GAIN_SETTLE_TIME(12) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_BBA_PDET_SEL_LO(5) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_BBA_PDET_SEL_HI(6) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_TZA_PDET_SEL_LO(3) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_TZA_PDET_SEL_HI(7) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_AGC_FAST_EXPIRE(5),
|
||||
.agc_ctrl_2_init_32mhz = XCVR_RX_DIG_AGC_CTRL_2_BBA_GAIN_SETTLE_TIME(14) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_BBA_PDET_SEL_LO(5) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_BBA_PDET_SEL_HI(6) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_TZA_PDET_SEL_LO(3) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_TZA_PDET_SEL_HI(7) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_AGC_FAST_EXPIRE(5),
|
||||
|
||||
/* All constant values are represented as 16 bits, register writes will remove unused bits */
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_0 = 0xFFFB,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_1 = 0xFFF5,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_2 = 0xFFF0,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_3 = 0xFFEC,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_4 = 0xFFEC,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_5 = 0xFFF3,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_6 = 0x0001,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_7 = 0x0016,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_8 = 0x002F,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_9 = 0x0049,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_10 = 0x005D,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_11 = 0x0069,
|
||||
|
||||
/* 32MHz Channel Filter */
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_0 = 0xFFF9,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_1 = 0xFFF4,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_2 = 0xFFED,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_3 = 0xFFE7,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_4 = 0xFFE7,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_5 = 0xFFEE,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_6 = 0xFFFD,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_7 = 0x0015,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_8 = 0x0031,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_9 = 0x004E,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_10 = 0x0066,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_11 = 0x0073,
|
||||
|
||||
.rx_rccal_ctrl_0 = XCVR_RX_DIG_RX_RCCAL_CTRL0_BBA_RCCAL_OFFSET(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_BBA_RCCAL_MANUAL(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_BBA_RCCAL_DIS(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_RCCAL_SMP_DLY(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_RCCAL_COMP_INV(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_TZA_RCCAL_OFFSET(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_TZA_RCCAL_MANUAL(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_TZA_RCCAL_DIS(0) ,
|
||||
.rx_rccal_ctrl_1 = XCVR_RX_DIG_RX_RCCAL_CTRL1_ADC_RCCAL_OFFSET(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL1_ADC_RCCAL_MANUAL(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL1_ADC_RCCAL_DIS(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL1_BBA2_RCCAL_OFFSET(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL1_BBA2_RCCAL_MANUAL(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL1_BBA2_RCCAL_DIS(0) ,
|
||||
|
||||
.tx_fsk_scale_26mhz = XCVR_TX_DIG_FSK_SCALE_FSK_MODULATION_SCALE_0(0x1627) | XCVR_TX_DIG_FSK_SCALE_FSK_MODULATION_SCALE_1(0x09d9),
|
||||
.tx_fsk_scale_32mhz = XCVR_TX_DIG_FSK_SCALE_FSK_MODULATION_SCALE_0(0x1800) | XCVR_TX_DIG_FSK_SCALE_FSK_MODULATION_SCALE_1(0x0800),
|
||||
};
|
||||
|
||||
const xcvr_mode_datarate_config_t xcvr_GFSK_BT_0p5_h_0p32_500kbps_config =
|
||||
{
|
||||
.radio_mode = GFSK_BT_0p5_h_0p32,
|
||||
.data_rate = DR_500KBPS,
|
||||
|
||||
.ana_sy_ctrl2.mask = XCVR_ANALOG_SY_CTRL_2_SY_VCO_KVM_MASK,
|
||||
.ana_sy_ctrl2.init = XCVR_ANALOG_SY_CTRL_2_SY_VCO_KVM(0), /* VCO KVM */
|
||||
.ana_rx_bba.mask = XCVR_ANALOG_RX_BBA_RX_BBA_BW_SEL_MASK | XCVR_ANALOG_RX_BBA_RX_BBA2_BW_SEL_MASK,
|
||||
.ana_rx_bba.init = XCVR_ANALOG_RX_BBA_RX_BBA_BW_SEL(5) | XCVR_ANALOG_RX_BBA_RX_BBA2_BW_SEL(5), /* BBA_BW_SEL and BBA2_BW_SEL */
|
||||
.ana_rx_tza.mask = XCVR_ANALOG_RX_TZA_RX_TZA_BW_SEL_MASK,
|
||||
.ana_rx_tza.init = XCVR_ANALOG_RX_TZA_RX_TZA_BW_SEL(5), /* TZA_BW_SEL */
|
||||
|
||||
.phy_cfg2_init = XCVR_PHY_CFG2_PHY_FIFO_PRECHG(8) |
|
||||
XCVR_PHY_CFG2_X2_DEMOD_GAIN(0x4) ,
|
||||
|
||||
/* AGC configs */
|
||||
.agc_ctrl_2_init_26mhz = XCVR_RX_DIG_AGC_CTRL_2_BBA_GAIN_SETTLE_TIME(15) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_BBA_PDET_SEL_LO(5) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_BBA_PDET_SEL_HI(6) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_TZA_PDET_SEL_LO(3) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_TZA_PDET_SEL_HI(7) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_AGC_FAST_EXPIRE(5),
|
||||
.agc_ctrl_2_init_32mhz = XCVR_RX_DIG_AGC_CTRL_2_BBA_GAIN_SETTLE_TIME(18) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_BBA_PDET_SEL_LO(5) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_BBA_PDET_SEL_HI(6) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_TZA_PDET_SEL_LO(3) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_TZA_PDET_SEL_HI(7) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_AGC_FAST_EXPIRE(5),
|
||||
|
||||
/* All constant values are represented as 16 bits, register writes will remove unused bits */
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_0 = 0x0001,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_1 = 0x0000,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_2 = 0xFFFA,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_3 = 0xFFF3,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_4 = 0xFFEE,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_5 = 0xFFEF,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_6 = 0xFFF8,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_7 = 0x000A,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_8 = 0x0025,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_9 = 0x0043,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_10 = 0x005D,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_11 = 0x006B,
|
||||
|
||||
/* 32MHz Channel Filter */
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_0 = 0x0004,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_1 = 0x0003,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_2 = 0xFFFE,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_3 = 0xFFF6,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_4 = 0xFFED,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_5 = 0xFFE9,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_6 = 0xFFEF,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_7 = 0x0001,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_8 = 0x0020,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_9 = 0x0044,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_10 = 0x0064,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_11 = 0x0077,
|
||||
|
||||
.rx_rccal_ctrl_0 = XCVR_RX_DIG_RX_RCCAL_CTRL0_BBA_RCCAL_OFFSET(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_BBA_RCCAL_MANUAL(31) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_BBA_RCCAL_DIS(1) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_RCCAL_SMP_DLY(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_RCCAL_COMP_INV(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_TZA_RCCAL_OFFSET(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_TZA_RCCAL_MANUAL(31) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_TZA_RCCAL_DIS(1) ,
|
||||
.rx_rccal_ctrl_1 = XCVR_RX_DIG_RX_RCCAL_CTRL1_ADC_RCCAL_OFFSET(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL1_ADC_RCCAL_MANUAL(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL1_ADC_RCCAL_DIS(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL1_BBA2_RCCAL_OFFSET(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL1_BBA2_RCCAL_MANUAL(31) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL1_BBA2_RCCAL_DIS(1) ,
|
||||
|
||||
.tx_fsk_scale_26mhz = XCVR_TX_DIG_FSK_SCALE_FSK_MODULATION_SCALE_0(0x1627) | XCVR_TX_DIG_FSK_SCALE_FSK_MODULATION_SCALE_1(0x09d9),
|
||||
.tx_fsk_scale_32mhz = XCVR_TX_DIG_FSK_SCALE_FSK_MODULATION_SCALE_0(0x1800) | XCVR_TX_DIG_FSK_SCALE_FSK_MODULATION_SCALE_1(0x0800),
|
||||
};
|
||||
|
||||
const xcvr_mode_datarate_config_t xcvr_GFSK_BT_0p5_h_0p32_250kbps_config =
|
||||
{
|
||||
.radio_mode = GFSK_BT_0p5_h_0p32,
|
||||
.data_rate = DR_250KBPS,
|
||||
|
||||
.ana_sy_ctrl2.mask = XCVR_ANALOG_SY_CTRL_2_SY_VCO_KVM_MASK,
|
||||
.ana_sy_ctrl2.init = XCVR_ANALOG_SY_CTRL_2_SY_VCO_KVM(0), /* VCO KVM */
|
||||
.ana_rx_bba.mask = XCVR_ANALOG_RX_BBA_RX_BBA_BW_SEL_MASK | XCVR_ANALOG_RX_BBA_RX_BBA2_BW_SEL_MASK,
|
||||
.ana_rx_bba.init = XCVR_ANALOG_RX_BBA_RX_BBA_BW_SEL(5) | XCVR_ANALOG_RX_BBA_RX_BBA2_BW_SEL(5), /* BBA_BW_SEL and BBA2_BW_SEL */
|
||||
.ana_rx_tza.mask = XCVR_ANALOG_RX_TZA_RX_TZA_BW_SEL_MASK,
|
||||
.ana_rx_tza.init = XCVR_ANALOG_RX_TZA_RX_TZA_BW_SEL(5), /* TZA_BW_SEL */
|
||||
|
||||
.phy_cfg2_init = XCVR_PHY_CFG2_PHY_FIFO_PRECHG(8) |
|
||||
XCVR_PHY_CFG2_X2_DEMOD_GAIN(0x4) ,
|
||||
|
||||
/* AGC configs */
|
||||
.agc_ctrl_2_init_26mhz = XCVR_RX_DIG_AGC_CTRL_2_BBA_GAIN_SETTLE_TIME(18) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_BBA_PDET_SEL_LO(5) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_BBA_PDET_SEL_HI(6) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_TZA_PDET_SEL_LO(3) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_TZA_PDET_SEL_HI(7) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_AGC_FAST_EXPIRE(5),
|
||||
.agc_ctrl_2_init_32mhz = XCVR_RX_DIG_AGC_CTRL_2_BBA_GAIN_SETTLE_TIME(22) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_BBA_PDET_SEL_LO(5) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_BBA_PDET_SEL_HI(2) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_TZA_PDET_SEL_LO(3) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_TZA_PDET_SEL_HI(7) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_AGC_FAST_EXPIRE(5),
|
||||
|
||||
/* All constant values are represented as 16 bits, register writes will remove unused bits */
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_0 = 0x0002,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_1 = 0xFFFD,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_2 = 0xFFF8,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_3 = 0xFFF1,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_4 = 0xFFEC,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_5 = 0xFFED,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_6 = 0xFFF7,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_7 = 0x000B,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_8 = 0x0027,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_9 = 0x0046,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_10 = 0x0060,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_11 = 0x0070,
|
||||
|
||||
/* 32MHz Channel Filter */
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_0 = 0x0001,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_1 = 0x0003,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_2 = 0x0005,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_3 = 0x0003,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_4 = 0xFFFC,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_5 = 0xFFF0,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_6 = 0xFFE8,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_7 = 0xFFEF,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_8 = 0x000B,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_9 = 0x0038,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_10 = 0x0068,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_11 = 0x0086,
|
||||
|
||||
.rx_rccal_ctrl_0 = XCVR_RX_DIG_RX_RCCAL_CTRL0_BBA_RCCAL_OFFSET(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_BBA_RCCAL_MANUAL(31) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_BBA_RCCAL_DIS(1) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_RCCAL_SMP_DLY(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_RCCAL_COMP_INV(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_TZA_RCCAL_OFFSET(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_TZA_RCCAL_MANUAL(31) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_TZA_RCCAL_DIS(1) ,
|
||||
.rx_rccal_ctrl_1 = XCVR_RX_DIG_RX_RCCAL_CTRL1_ADC_RCCAL_OFFSET(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL1_ADC_RCCAL_MANUAL(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL1_ADC_RCCAL_DIS(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL1_BBA2_RCCAL_OFFSET(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL1_BBA2_RCCAL_MANUAL(31) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL1_BBA2_RCCAL_DIS(1) ,
|
||||
|
||||
.tx_fsk_scale_26mhz = XCVR_TX_DIG_FSK_SCALE_FSK_MODULATION_SCALE_0(0x1627) | XCVR_TX_DIG_FSK_SCALE_FSK_MODULATION_SCALE_1(0x09d9),
|
||||
.tx_fsk_scale_32mhz = XCVR_TX_DIG_FSK_SCALE_FSK_MODULATION_SCALE_0(0x1800) | XCVR_TX_DIG_FSK_SCALE_FSK_MODULATION_SCALE_1(0x0800),
|
||||
};
|
||||
|
||||
-356
@@ -1,356 +0,0 @@
|
||||
/*
|
||||
* Copyright 2016-2017 NXP
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* o Redistributions of source code must retain the above copyright notice, this list
|
||||
* of conditions and the following disclaimer.
|
||||
*
|
||||
* o 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.
|
||||
*
|
||||
* o Neither the name of Freescale Semiconductor, Inc. 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 HOLDER 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 "fsl_xcvr.h"
|
||||
|
||||
/*******************************************************************************
|
||||
* Definitions
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* Prototypes
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* Variables
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* Code
|
||||
******************************************************************************/
|
||||
/* MODE only configuration */
|
||||
const xcvr_mode_config_t gfsk_bt_0p5_h_0p5_mode_config =
|
||||
{
|
||||
.radio_mode = GFSK_BT_0p5_h_0p5,
|
||||
.scgc5_clock_ena_bits = SIM_SCGC5_PHYDIG_MASK | SIM_SCGC5_GEN_FSK_MASK,
|
||||
|
||||
/* XCVR_MISC configs */
|
||||
.xcvr_ctrl.mask = XCVR_CTRL_XCVR_CTRL_PROTOCOL_MASK |
|
||||
XCVR_CTRL_XCVR_CTRL_TGT_PWR_SRC_MASK |
|
||||
XCVR_CTRL_XCVR_CTRL_DEMOD_SEL_MASK,
|
||||
.xcvr_ctrl.init = XCVR_CTRL_XCVR_CTRL_PROTOCOL(8) |
|
||||
XCVR_CTRL_XCVR_CTRL_TGT_PWR_SRC(7) |
|
||||
XCVR_CTRL_XCVR_CTRL_DEMOD_SEL(1),
|
||||
|
||||
.phy_pre_ref0_init = RW0PS(0, 0x19) |
|
||||
RW0PS(1, 0x19U) |
|
||||
RW0PS(2, 0x1AU) |
|
||||
RW0PS(3, 0x1BU) |
|
||||
RW0PS(4, 0x1CU) |
|
||||
RW0PS(5, 0x1CU) |
|
||||
RW0PS(6, 0x1DU & 0x3U), /* Phase info #6 overlaps two initialization words */
|
||||
.phy_pre_ref1_init = (0x1D) >> 2 | /* Phase info #6 overlaps two initialization words - manually compute the shift*/
|
||||
RW1PS(7, 0x1EU) |
|
||||
RW1PS(8, 0x1EU) |
|
||||
RW1PS(9, 0x1EU) |
|
||||
RW1PS(10, 0x1DU) |
|
||||
RW1PS(11, 0x1CU) |
|
||||
RW1PS(12, 0x1CU & 0xFU), /* Phase info #12 overlaps two initialization words */
|
||||
.phy_pre_ref2_init = (0x1C) >> 4 | /* Phase info #12 overlaps two initialization words - manually compute the shift*/
|
||||
RW2PS(13, 0x1BU) |
|
||||
RW2PS(14, 0x1AU) |
|
||||
RW2PS(15, 0x19U),
|
||||
|
||||
.phy_cfg1_init = XCVR_PHY_CFG1_AA_PLAYBACK(1) |
|
||||
XCVR_PHY_CFG1_AA_OUTPUT_SEL(1) |
|
||||
XCVR_PHY_CFG1_FSK_BIT_INVERT(0) |
|
||||
XCVR_PHY_CFG1_BSM_EN_BLE(0) |
|
||||
XCVR_PHY_CFG1_DEMOD_CLK_MODE(0) |
|
||||
XCVR_PHY_CFG1_CTS_THRESH(205) |
|
||||
XCVR_PHY_CFG1_FSK_FTS_TIMEOUT(2),
|
||||
|
||||
.phy_el_cfg_init = XCVR_PHY_EL_CFG_EL_ENABLE(1)
|
||||
#if !RADIO_IS_GEN_2P1
|
||||
| XCVR_PHY_EL_CFG_EL_ZB_ENABLE(0)
|
||||
#endif /* !RADIO_IS_GEN_2P1 */
|
||||
,
|
||||
/* XCVR_RX_DIG configs */
|
||||
.rx_dig_ctrl_init_26mhz = XCVR_RX_DIG_RX_DIG_CTRL_RX_FSK_ZB_SEL(0) | /* Depends on protocol */
|
||||
XCVR_RX_DIG_RX_DIG_CTRL_RX_DC_RESID_EN(1) | /* Depends on protocol */
|
||||
XCVR_RX_DIG_RX_DIG_CTRL_RX_SRC_RATE(0),
|
||||
|
||||
.rx_dig_ctrl_init_32mhz = XCVR_RX_DIG_RX_DIG_CTRL_RX_FSK_ZB_SEL(0) | /* Depends on protocol */
|
||||
XCVR_RX_DIG_RX_DIG_CTRL_RX_DC_RESID_EN(1), /* Depends on protocol */
|
||||
|
||||
.agc_ctrl_0_init = XCVR_RX_DIG_AGC_CTRL_0_AGC_DOWN_RSSI_THRESH(0xFF),
|
||||
|
||||
/* XCVR_TSM configs */
|
||||
#if (DATA_PADDING_EN)
|
||||
.tsm_timing_35_init = B0(TX_DIG_EN_ASSERT+TX_DIG_EN_TX_HI_ADJ),
|
||||
#else
|
||||
.tsm_timing_35_init = B0(TX_DIG_EN_ASSERT),
|
||||
#endif /* (DATA_PADDING_EN) */
|
||||
|
||||
/* XCVR_TX_DIG configs */
|
||||
.tx_gfsk_ctrl = XCVR_TX_DIG_GFSK_CTRL_GFSK_MULTIPLY_TABLE_MANUAL(0x4000) |
|
||||
XCVR_TX_DIG_GFSK_CTRL_GFSK_MI(1) |
|
||||
XCVR_TX_DIG_GFSK_CTRL_GFSK_MLD(0) |
|
||||
XCVR_TX_DIG_GFSK_CTRL_GFSK_FLD(0) |
|
||||
XCVR_TX_DIG_GFSK_CTRL_GFSK_MOD_INDEX_SCALING(0) |
|
||||
XCVR_TX_DIG_GFSK_CTRL_TX_IMAGE_FILTER_OVRD_EN(0) |
|
||||
XCVR_TX_DIG_GFSK_CTRL_TX_IMAGE_FILTER_0_OVRD(0) |
|
||||
XCVR_TX_DIG_GFSK_CTRL_TX_IMAGE_FILTER_1_OVRD(0) |
|
||||
XCVR_TX_DIG_GFSK_CTRL_TX_IMAGE_FILTER_2_OVRD(0),
|
||||
.tx_gfsk_coeff1_26mhz = 0,
|
||||
.tx_gfsk_coeff2_26mhz = 0,
|
||||
.tx_gfsk_coeff1_32mhz = 0,
|
||||
.tx_gfsk_coeff2_32mhz = 0,
|
||||
};
|
||||
|
||||
/* MODE & DATA RATE combined configuration */
|
||||
|
||||
const xcvr_mode_datarate_config_t xcvr_GFSK_BT_0p5_h_0p5_1mbps_config =
|
||||
{
|
||||
.radio_mode = GFSK_BT_0p5_h_0p5,
|
||||
.data_rate = DR_1MBPS,
|
||||
|
||||
.ana_sy_ctrl2.mask = XCVR_ANALOG_SY_CTRL_2_SY_VCO_KVM_MASK,
|
||||
.ana_sy_ctrl2.init = XCVR_ANALOG_SY_CTRL_2_SY_VCO_KVM(0), /* VCO KVM */
|
||||
.ana_rx_bba.mask = XCVR_ANALOG_RX_BBA_RX_BBA_BW_SEL_MASK | XCVR_ANALOG_RX_BBA_RX_BBA2_BW_SEL_MASK,
|
||||
.ana_rx_bba.init = XCVR_ANALOG_RX_BBA_RX_BBA_BW_SEL(4) | XCVR_ANALOG_RX_BBA_RX_BBA2_BW_SEL(4), /* BBA_BW_SEL and BBA2_BW_SEL */
|
||||
.ana_rx_tza.mask = XCVR_ANALOG_RX_TZA_RX_TZA_BW_SEL_MASK,
|
||||
.ana_rx_tza.init = XCVR_ANALOG_RX_TZA_RX_TZA_BW_SEL(4), /*TZA_BW_SEL */
|
||||
|
||||
.phy_cfg2_init = XCVR_PHY_CFG2_PHY_FIFO_PRECHG(8) |
|
||||
XCVR_PHY_CFG2_X2_DEMOD_GAIN(0xA) ,
|
||||
|
||||
/* AGC configs */
|
||||
.agc_ctrl_2_init_26mhz = XCVR_RX_DIG_AGC_CTRL_2_BBA_GAIN_SETTLE_TIME(10) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_BBA_PDET_SEL_LO(5) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_BBA_PDET_SEL_HI(6) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_TZA_PDET_SEL_LO(3) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_TZA_PDET_SEL_HI(7) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_AGC_FAST_EXPIRE(5),
|
||||
.agc_ctrl_2_init_32mhz = XCVR_RX_DIG_AGC_CTRL_2_BBA_GAIN_SETTLE_TIME(12) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_BBA_PDET_SEL_LO(5) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_BBA_PDET_SEL_HI(6) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_TZA_PDET_SEL_LO(3) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_TZA_PDET_SEL_HI(7) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_AGC_FAST_EXPIRE(5),
|
||||
|
||||
/* BLE 26MHz Channel Filter */
|
||||
/* All constant values are represented as 16 bits, register writes will remove unused bits */
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_0 = 0xFFFA,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_1 = 0xFFF6,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_2 = 0xFFF1,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_3 = 0xFFEE,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_4 = 0xFFEF,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_5 = 0xFFF6,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_6 = 0x0004,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_7 = 0x0017,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_8 = 0x002F,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_9 = 0x0046,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_10 = 0x0059,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_11 = 0x0063,
|
||||
|
||||
/* BLE 32MHz Channel Filter */
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_0 = 0xFFFA,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_1 = 0xFFF5,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_2 = 0xFFEF,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_3 = 0xFFEB,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_4 = 0xFFEB,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_5 = 0xFFF2,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_6 = 0x0000,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_7 = 0x0015,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_8 = 0x0030,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_9 = 0x004A,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_10 = 0x005F,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_11 = 0x006B,
|
||||
|
||||
.rx_rccal_ctrl_0 = XCVR_RX_DIG_RX_RCCAL_CTRL0_BBA_RCCAL_OFFSET(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_BBA_RCCAL_MANUAL(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_BBA_RCCAL_DIS(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_RCCAL_SMP_DLY(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_RCCAL_COMP_INV(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_TZA_RCCAL_OFFSET(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_TZA_RCCAL_MANUAL(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_TZA_RCCAL_DIS(0) ,
|
||||
.rx_rccal_ctrl_1 = XCVR_RX_DIG_RX_RCCAL_CTRL1_ADC_RCCAL_OFFSET(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL1_ADC_RCCAL_MANUAL(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL1_ADC_RCCAL_DIS(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL1_BBA2_RCCAL_OFFSET(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL1_BBA2_RCCAL_MANUAL(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL1_BBA2_RCCAL_DIS(0) ,
|
||||
|
||||
.tx_fsk_scale_26mhz = XCVR_TX_DIG_FSK_SCALE_FSK_MODULATION_SCALE_0(0x1627) | XCVR_TX_DIG_FSK_SCALE_FSK_MODULATION_SCALE_1(0x09d9),
|
||||
.tx_fsk_scale_32mhz = XCVR_TX_DIG_FSK_SCALE_FSK_MODULATION_SCALE_0(0x1800) | XCVR_TX_DIG_FSK_SCALE_FSK_MODULATION_SCALE_1(0x0800),
|
||||
};
|
||||
|
||||
const xcvr_mode_datarate_config_t xcvr_GFSK_BT_0p5_h_0p5_500kbps_config =
|
||||
{
|
||||
.radio_mode = GFSK_BT_0p5_h_0p5,
|
||||
.data_rate = DR_500KBPS,
|
||||
|
||||
.ana_sy_ctrl2.mask = XCVR_ANALOG_SY_CTRL_2_SY_VCO_KVM_MASK,
|
||||
.ana_sy_ctrl2.init = XCVR_ANALOG_SY_CTRL_2_SY_VCO_KVM(0), /* VCO KVM */
|
||||
.ana_rx_bba.mask = XCVR_ANALOG_RX_BBA_RX_BBA_BW_SEL_MASK | XCVR_ANALOG_RX_BBA_RX_BBA2_BW_SEL_MASK,
|
||||
.ana_rx_bba.init = XCVR_ANALOG_RX_BBA_RX_BBA_BW_SEL(5) | XCVR_ANALOG_RX_BBA_RX_BBA2_BW_SEL(5), /* BBA_BW_SEL and BBA2_BW_SEL */
|
||||
.ana_rx_tza.mask = XCVR_ANALOG_RX_TZA_RX_TZA_BW_SEL_MASK,
|
||||
.ana_rx_tza.init = XCVR_ANALOG_RX_TZA_RX_TZA_BW_SEL(5), /* TZA_BW_SEL */
|
||||
|
||||
.phy_cfg2_init = XCVR_PHY_CFG2_PHY_FIFO_PRECHG(8) |
|
||||
XCVR_PHY_CFG2_X2_DEMOD_GAIN(0x8) ,
|
||||
|
||||
/* AGC configs */
|
||||
.agc_ctrl_2_init_26mhz = XCVR_RX_DIG_AGC_CTRL_2_BBA_GAIN_SETTLE_TIME(15) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_BBA_PDET_SEL_LO(5) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_BBA_PDET_SEL_HI(6) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_TZA_PDET_SEL_LO(3) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_TZA_PDET_SEL_HI(7) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_AGC_FAST_EXPIRE(5),
|
||||
.agc_ctrl_2_init_32mhz = XCVR_RX_DIG_AGC_CTRL_2_BBA_GAIN_SETTLE_TIME(18) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_BBA_PDET_SEL_LO(5) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_BBA_PDET_SEL_HI(6) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_TZA_PDET_SEL_LO(3) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_TZA_PDET_SEL_HI(7) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_AGC_FAST_EXPIRE(5),
|
||||
|
||||
/* All constant values are represented as 16 bits, register writes will remove unused bits */
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_0 = 0x0004,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_1 = 0x0003,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_2 = 0xFFFE,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_3 = 0xFFF5,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_4 = 0xFFEC,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_5 = 0xFFE8,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_6 = 0xFFEE,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_7 = 0x0001,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_8 = 0x0020,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_9 = 0x0045,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_10 = 0x0065,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_11 = 0x0079,
|
||||
|
||||
/* 32MHz */
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_0 = 0x0005,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_1 = 0x0006,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_2 = 0x0003,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_3 = 0xFFFA,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_4 = 0xFFEF,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_5 = 0xFFE6,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_6 = 0xFFE7,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_7 = 0xFFF8,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_8 = 0x0019,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_9 = 0x0042,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_10 = 0x0069,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_11 = 0x0080,
|
||||
|
||||
.rx_rccal_ctrl_0 = XCVR_RX_DIG_RX_RCCAL_CTRL0_BBA_RCCAL_OFFSET(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_BBA_RCCAL_MANUAL(31) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_BBA_RCCAL_DIS(1) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_RCCAL_SMP_DLY(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_RCCAL_COMP_INV(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_TZA_RCCAL_OFFSET(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_TZA_RCCAL_MANUAL(31) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_TZA_RCCAL_DIS(1) ,
|
||||
.rx_rccal_ctrl_1 = XCVR_RX_DIG_RX_RCCAL_CTRL1_ADC_RCCAL_OFFSET(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL1_ADC_RCCAL_MANUAL(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL1_ADC_RCCAL_DIS(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL1_BBA2_RCCAL_OFFSET(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL1_BBA2_RCCAL_MANUAL(31) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL1_BBA2_RCCAL_DIS(1) ,
|
||||
|
||||
.tx_fsk_scale_26mhz = XCVR_TX_DIG_FSK_SCALE_FSK_MODULATION_SCALE_0(0x1627) | XCVR_TX_DIG_FSK_SCALE_FSK_MODULATION_SCALE_1(0x09d9),
|
||||
.tx_fsk_scale_32mhz = XCVR_TX_DIG_FSK_SCALE_FSK_MODULATION_SCALE_0(0x1800) | XCVR_TX_DIG_FSK_SCALE_FSK_MODULATION_SCALE_1(0x0800),
|
||||
};
|
||||
|
||||
const xcvr_mode_datarate_config_t xcvr_GFSK_BT_0p5_h_0p5_250kbps_config =
|
||||
{
|
||||
.radio_mode = GFSK_BT_0p5_h_0p5,
|
||||
.data_rate = DR_250KBPS,
|
||||
|
||||
.ana_sy_ctrl2.mask = XCVR_ANALOG_SY_CTRL_2_SY_VCO_KVM_MASK,
|
||||
.ana_sy_ctrl2.init = XCVR_ANALOG_SY_CTRL_2_SY_VCO_KVM(0), /* VCO KVM */
|
||||
.ana_rx_bba.mask = XCVR_ANALOG_RX_BBA_RX_BBA_BW_SEL_MASK | XCVR_ANALOG_RX_BBA_RX_BBA2_BW_SEL_MASK,
|
||||
.ana_rx_bba.init = XCVR_ANALOG_RX_BBA_RX_BBA_BW_SEL(5) | XCVR_ANALOG_RX_BBA_RX_BBA2_BW_SEL(5), /* BBA_BW_SEL and BBA2_BW_SEL */
|
||||
.ana_rx_tza.mask = XCVR_ANALOG_RX_TZA_RX_TZA_BW_SEL_MASK,
|
||||
.ana_rx_tza.init = XCVR_ANALOG_RX_TZA_RX_TZA_BW_SEL(5), /* TZA_BW_SEL */
|
||||
|
||||
.phy_cfg2_init = XCVR_PHY_CFG2_PHY_FIFO_PRECHG(8) |
|
||||
XCVR_PHY_CFG2_X2_DEMOD_GAIN(0x6) ,
|
||||
|
||||
/* AGC configs */
|
||||
.agc_ctrl_2_init_26mhz = XCVR_RX_DIG_AGC_CTRL_2_BBA_GAIN_SETTLE_TIME(18) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_BBA_PDET_SEL_LO(5) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_BBA_PDET_SEL_HI(6) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_TZA_PDET_SEL_LO(3) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_TZA_PDET_SEL_HI(7) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_AGC_FAST_EXPIRE(5),
|
||||
.agc_ctrl_2_init_32mhz = XCVR_RX_DIG_AGC_CTRL_2_BBA_GAIN_SETTLE_TIME(22) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_BBA_PDET_SEL_LO(5) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_BBA_PDET_SEL_HI(2) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_TZA_PDET_SEL_LO(3) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_TZA_PDET_SEL_HI(7) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_AGC_FAST_EXPIRE(5),
|
||||
|
||||
/* All constant values are represented as 16 bits, register writes will remove unused bits */
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_0 = 0x0002,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_1 = 0xFFFD,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_2 = 0xFFF8,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_3 = 0xFFF1,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_4 = 0xFFEC,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_5 = 0xFFED,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_6 = 0xFFF7,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_7 = 0x000B,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_8 = 0x0027,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_9 = 0x0046,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_10 = 0x0060,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_11 = 0x0070,
|
||||
|
||||
/* 32MHz Channel Filter */
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_0 = 0x0002,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_1 = 0xFFFD,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_2 = 0xFFF8,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_3 = 0xFFF1,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_4 = 0xFFEC,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_5 = 0xFFED,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_6 = 0xFFF6,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_7 = 0x000A,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_8 = 0x0027,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_9 = 0x0046,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_10 = 0x0061,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_11 = 0x0071,
|
||||
|
||||
.rx_rccal_ctrl_0 = XCVR_RX_DIG_RX_RCCAL_CTRL0_BBA_RCCAL_OFFSET(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_BBA_RCCAL_MANUAL(31) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_BBA_RCCAL_DIS(1) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_RCCAL_SMP_DLY(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_RCCAL_COMP_INV(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_TZA_RCCAL_OFFSET(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_TZA_RCCAL_MANUAL(31) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_TZA_RCCAL_DIS(1) ,
|
||||
.rx_rccal_ctrl_1 = XCVR_RX_DIG_RX_RCCAL_CTRL1_ADC_RCCAL_OFFSET(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL1_ADC_RCCAL_MANUAL(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL1_ADC_RCCAL_DIS(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL1_BBA2_RCCAL_OFFSET(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL1_BBA2_RCCAL_MANUAL(31) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL1_BBA2_RCCAL_DIS(1) ,
|
||||
|
||||
.tx_fsk_scale_26mhz = XCVR_TX_DIG_FSK_SCALE_FSK_MODULATION_SCALE_0(0x1627) | XCVR_TX_DIG_FSK_SCALE_FSK_MODULATION_SCALE_1(0x09d9),
|
||||
.tx_fsk_scale_32mhz = XCVR_TX_DIG_FSK_SCALE_FSK_MODULATION_SCALE_0(0x1800) | XCVR_TX_DIG_FSK_SCALE_FSK_MODULATION_SCALE_1(0x0800),
|
||||
};
|
||||
|
||||
-341
@@ -1,341 +0,0 @@
|
||||
/*
|
||||
* Copyright 2016-2017 NXP
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* o Redistributions of source code must retain the above copyright notice, this list
|
||||
* of conditions and the following disclaimer.
|
||||
*
|
||||
* o 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.
|
||||
*
|
||||
* o Neither the name of Freescale Semiconductor, Inc. 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 HOLDER 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 "fsl_xcvr.h"
|
||||
|
||||
/*******************************************************************************
|
||||
* Definitions
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* Prototypes
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* Variables
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* Code
|
||||
******************************************************************************/
|
||||
/* MODE only configuration */
|
||||
const xcvr_mode_config_t gfsk_bt_0p5_h_0p7_mode_config =
|
||||
{
|
||||
.radio_mode = GFSK_BT_0p5_h_0p7,
|
||||
.scgc5_clock_ena_bits = SIM_SCGC5_PHYDIG_MASK | SIM_SCGC5_GEN_FSK_MASK,
|
||||
|
||||
/* XCVR_MISC configs */
|
||||
.xcvr_ctrl.mask = XCVR_CTRL_XCVR_CTRL_PROTOCOL_MASK |
|
||||
XCVR_CTRL_XCVR_CTRL_TGT_PWR_SRC_MASK |
|
||||
XCVR_CTRL_XCVR_CTRL_DEMOD_SEL_MASK,
|
||||
.xcvr_ctrl.init = XCVR_CTRL_XCVR_CTRL_PROTOCOL(8) |
|
||||
XCVR_CTRL_XCVR_CTRL_TGT_PWR_SRC(7) |
|
||||
XCVR_CTRL_XCVR_CTRL_DEMOD_SEL(1),
|
||||
|
||||
/* XCVR_PHY configs */
|
||||
.phy_pre_ref0_init = 0x37ACE2F7,
|
||||
.phy_pre_ref1_init = 0xADF3BDEF,
|
||||
.phy_pre_ref2_init = 0x0000BE33,
|
||||
|
||||
.phy_cfg1_init = XCVR_PHY_CFG1_AA_PLAYBACK(1) |
|
||||
XCVR_PHY_CFG1_AA_OUTPUT_SEL(1) |
|
||||
XCVR_PHY_CFG1_FSK_BIT_INVERT(0) |
|
||||
XCVR_PHY_CFG1_BSM_EN_BLE(0) |
|
||||
XCVR_PHY_CFG1_DEMOD_CLK_MODE(0) |
|
||||
XCVR_PHY_CFG1_CTS_THRESH(0xCD) |
|
||||
XCVR_PHY_CFG1_FSK_FTS_TIMEOUT(2),
|
||||
|
||||
.phy_el_cfg_init = XCVR_PHY_EL_CFG_EL_ENABLE(1)
|
||||
#if !RADIO_IS_GEN_2P1
|
||||
| XCVR_PHY_EL_CFG_EL_ZB_ENABLE(0)
|
||||
#endif /* !RADIO_IS_GEN_2P1 */
|
||||
,
|
||||
|
||||
/* XCVR_RX_DIG configs */
|
||||
.rx_dig_ctrl_init_26mhz = XCVR_RX_DIG_RX_DIG_CTRL_RX_FSK_ZB_SEL(0) | /* Depends on protocol */
|
||||
XCVR_RX_DIG_RX_DIG_CTRL_RX_DC_RESID_EN(1) | /* Depends on protocol */
|
||||
XCVR_RX_DIG_RX_DIG_CTRL_RX_SRC_RATE(0),
|
||||
|
||||
.rx_dig_ctrl_init_32mhz = XCVR_RX_DIG_RX_DIG_CTRL_RX_FSK_ZB_SEL(0) | /* Depends on protocol */
|
||||
XCVR_RX_DIG_RX_DIG_CTRL_RX_DC_RESID_EN(1), /* Depends on protocol */
|
||||
|
||||
.agc_ctrl_0_init = XCVR_RX_DIG_AGC_CTRL_0_AGC_DOWN_RSSI_THRESH(0xFF),
|
||||
|
||||
/* XCVR_TSM configs */
|
||||
#if (DATA_PADDING_EN)
|
||||
.tsm_timing_35_init = B0(TX_DIG_EN_ASSERT + TX_DIG_EN_TX_HI_ADJ),
|
||||
#else
|
||||
.tsm_timing_35_init = B0(TX_DIG_EN_ASSERT),
|
||||
#endif /* (DATA_PADDING_EN) */
|
||||
|
||||
/* XCVR_TX_DIG configs */
|
||||
.tx_gfsk_ctrl = XCVR_TX_DIG_GFSK_CTRL_GFSK_MULTIPLY_TABLE_MANUAL(0x4000) |
|
||||
XCVR_TX_DIG_GFSK_CTRL_GFSK_MI(2) |
|
||||
XCVR_TX_DIG_GFSK_CTRL_GFSK_MLD(0) |
|
||||
XCVR_TX_DIG_GFSK_CTRL_GFSK_FLD(0) |
|
||||
XCVR_TX_DIG_GFSK_CTRL_GFSK_MOD_INDEX_SCALING(0) |
|
||||
XCVR_TX_DIG_GFSK_CTRL_TX_IMAGE_FILTER_OVRD_EN(0) |
|
||||
XCVR_TX_DIG_GFSK_CTRL_TX_IMAGE_FILTER_0_OVRD(0) |
|
||||
XCVR_TX_DIG_GFSK_CTRL_TX_IMAGE_FILTER_1_OVRD(0) |
|
||||
XCVR_TX_DIG_GFSK_CTRL_TX_IMAGE_FILTER_2_OVRD(0),
|
||||
.tx_gfsk_coeff1_26mhz = 0,
|
||||
.tx_gfsk_coeff2_26mhz = 0,
|
||||
.tx_gfsk_coeff1_32mhz = 0,
|
||||
.tx_gfsk_coeff2_32mhz = 0,
|
||||
};
|
||||
|
||||
/* MODE & DATA RATE combined configuration */
|
||||
const xcvr_mode_datarate_config_t xcvr_GFSK_BT_0p5_h_0p7_1mbps_config =
|
||||
{
|
||||
.radio_mode = GFSK_BT_0p5_h_0p7,
|
||||
.data_rate = DR_1MBPS,
|
||||
|
||||
.ana_sy_ctrl2.mask = XCVR_ANALOG_SY_CTRL_2_SY_VCO_KVM_MASK,
|
||||
.ana_sy_ctrl2.init = XCVR_ANALOG_SY_CTRL_2_SY_VCO_KVM(1), /* VCO KVM */
|
||||
.ana_rx_bba.mask = XCVR_ANALOG_RX_BBA_RX_BBA_BW_SEL_MASK | XCVR_ANALOG_RX_BBA_RX_BBA2_BW_SEL_MASK,
|
||||
.ana_rx_bba.init = XCVR_ANALOG_RX_BBA_RX_BBA_BW_SEL(3) | XCVR_ANALOG_RX_BBA_RX_BBA2_BW_SEL(3), /* BBA_BW_SEL and BBA2_BW_SEL */
|
||||
.ana_rx_tza.mask = XCVR_ANALOG_RX_TZA_RX_TZA_BW_SEL_MASK,
|
||||
.ana_rx_tza.init = XCVR_ANALOG_RX_TZA_RX_TZA_BW_SEL(3), /* TZA_BW_SEL */
|
||||
|
||||
.phy_cfg2_init = XCVR_PHY_CFG2_PHY_FIFO_PRECHG(8) |
|
||||
XCVR_PHY_CFG2_X2_DEMOD_GAIN(0xA) ,
|
||||
|
||||
/* AGC configs */
|
||||
.agc_ctrl_2_init_26mhz = XCVR_RX_DIG_AGC_CTRL_2_BBA_GAIN_SETTLE_TIME(11) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_BBA_PDET_SEL_LO(5) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_BBA_PDET_SEL_HI(6) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_TZA_PDET_SEL_LO(3) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_TZA_PDET_SEL_HI(7) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_AGC_FAST_EXPIRE(5),
|
||||
.agc_ctrl_2_init_32mhz = XCVR_RX_DIG_AGC_CTRL_2_BBA_GAIN_SETTLE_TIME(12) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_BBA_PDET_SEL_LO(5) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_BBA_PDET_SEL_HI(6) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_TZA_PDET_SEL_LO(3) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_TZA_PDET_SEL_HI(7) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_AGC_FAST_EXPIRE(5),
|
||||
|
||||
/* All constant values are represented as 16 bits, register writes will remove unused bits */
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_0 = 0x0002,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_1 = 0x0002,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_2 = 0x0000,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_3 = 0xFFF9,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_4 = 0xFFF0,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_5 = 0xFFEA,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_6 = 0xFFEC,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_7 = 0xFFFC,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_8 = 0x001B,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_9 = 0x0042,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_10 = 0x0066,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_11 = 0x007C,
|
||||
|
||||
/* 32MHz Channel Filter */
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_0 = 0x0002,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_1 = 0x0003,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_2 = 0x0002,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_3 = 0xFFFC,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_4 = 0xFFF2,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_5 = 0xFFE9,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_6 = 0xFFE9,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_7 = 0xFFF7,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_8 = 0x0016,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_9 = 0x0040,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_10 = 0x0069,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_11 = 0x0082,
|
||||
|
||||
.rx_rccal_ctrl_0 = XCVR_RX_DIG_RX_RCCAL_CTRL0_BBA_RCCAL_OFFSET(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_BBA_RCCAL_MANUAL(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_BBA_RCCAL_DIS(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_RCCAL_SMP_DLY(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_RCCAL_COMP_INV(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_TZA_RCCAL_OFFSET(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_TZA_RCCAL_MANUAL(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_TZA_RCCAL_DIS(0) ,
|
||||
.rx_rccal_ctrl_1 = XCVR_RX_DIG_RX_RCCAL_CTRL1_ADC_RCCAL_OFFSET(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL1_ADC_RCCAL_MANUAL(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL1_ADC_RCCAL_DIS(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL1_BBA2_RCCAL_OFFSET(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL1_BBA2_RCCAL_MANUAL(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL1_BBA2_RCCAL_DIS(0) ,
|
||||
|
||||
.tx_fsk_scale_26mhz = XCVR_TX_DIG_FSK_SCALE_FSK_MODULATION_SCALE_0(0x1627) | XCVR_TX_DIG_FSK_SCALE_FSK_MODULATION_SCALE_1(0x09d9),
|
||||
.tx_fsk_scale_32mhz = XCVR_TX_DIG_FSK_SCALE_FSK_MODULATION_SCALE_0(0x1800) | XCVR_TX_DIG_FSK_SCALE_FSK_MODULATION_SCALE_1(0x0800),
|
||||
};
|
||||
|
||||
const xcvr_mode_datarate_config_t xcvr_GFSK_BT_0p5_h_0p7_500kbps_config =
|
||||
{
|
||||
.radio_mode = GFSK_BT_0p5_h_0p7,
|
||||
.data_rate = DR_500KBPS,
|
||||
|
||||
.ana_sy_ctrl2.mask = XCVR_ANALOG_SY_CTRL_2_SY_VCO_KVM_MASK,
|
||||
.ana_sy_ctrl2.init = XCVR_ANALOG_SY_CTRL_2_SY_VCO_KVM(0), /* VCO KVM */
|
||||
.ana_rx_bba.mask = XCVR_ANALOG_RX_BBA_RX_BBA_BW_SEL_MASK | XCVR_ANALOG_RX_BBA_RX_BBA2_BW_SEL_MASK,
|
||||
.ana_rx_bba.init = XCVR_ANALOG_RX_BBA_RX_BBA_BW_SEL(5) | XCVR_ANALOG_RX_BBA_RX_BBA2_BW_SEL(5), /* BBA_BW_SEL and BBA2_BW_SEL */
|
||||
.ana_rx_tza.mask = XCVR_ANALOG_RX_TZA_RX_TZA_BW_SEL_MASK,
|
||||
.ana_rx_tza.init = XCVR_ANALOG_RX_TZA_RX_TZA_BW_SEL(5), /* TZA_BW_SEL */
|
||||
|
||||
.phy_cfg2_init = XCVR_PHY_CFG2_PHY_FIFO_PRECHG(8) |
|
||||
XCVR_PHY_CFG2_X2_DEMOD_GAIN(0x8) ,
|
||||
|
||||
/* AGC configs */
|
||||
.agc_ctrl_2_init_26mhz = XCVR_RX_DIG_AGC_CTRL_2_BBA_GAIN_SETTLE_TIME(15) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_BBA_PDET_SEL_LO(5) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_BBA_PDET_SEL_HI(6) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_TZA_PDET_SEL_LO(3) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_TZA_PDET_SEL_HI(7) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_AGC_FAST_EXPIRE(5),
|
||||
.agc_ctrl_2_init_32mhz = XCVR_RX_DIG_AGC_CTRL_2_BBA_GAIN_SETTLE_TIME(18) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_BBA_PDET_SEL_LO(5) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_BBA_PDET_SEL_HI(6) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_TZA_PDET_SEL_LO(3) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_TZA_PDET_SEL_HI(7) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_AGC_FAST_EXPIRE(5),
|
||||
|
||||
/* All constant values are represented as 16 bits, register writes will remove unused bits */
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_0 = 0x0002,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_1 = 0x0004,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_2 = 0x0005,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_3 = 0x0001,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_4 = 0xFFF6,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_5 = 0xFFE8,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_6 = 0xFFE2,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_7 = 0xFFEC,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_8 = 0x000C,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_9 = 0x003D,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_10 = 0x006F,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_11 = 0x008F,
|
||||
|
||||
/* 32MHz Channel Filter */
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_0 = 0x0001,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_1 = 0x0004,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_2 = 0x0007,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_3 = 0x0006,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_4 = 0xFFFC,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_5 = 0xFFEC,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_6 = 0xFFDF,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_7 = 0xFFE3,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_8 = 0x0002,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_9 = 0x0038,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_10 = 0x0072,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_11 = 0x0098,
|
||||
|
||||
.rx_rccal_ctrl_0 = XCVR_RX_DIG_RX_RCCAL_CTRL0_BBA_RCCAL_OFFSET(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_BBA_RCCAL_MANUAL(31) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_BBA_RCCAL_DIS(1) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_RCCAL_SMP_DLY(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_RCCAL_COMP_INV(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_TZA_RCCAL_OFFSET(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_TZA_RCCAL_MANUAL(31) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_TZA_RCCAL_DIS(1) ,
|
||||
.rx_rccal_ctrl_1 = XCVR_RX_DIG_RX_RCCAL_CTRL1_ADC_RCCAL_OFFSET(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL1_ADC_RCCAL_MANUAL(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL1_ADC_RCCAL_DIS(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL1_BBA2_RCCAL_OFFSET(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL1_BBA2_RCCAL_MANUAL(31) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL1_BBA2_RCCAL_DIS(1) ,
|
||||
|
||||
.tx_fsk_scale_26mhz = XCVR_TX_DIG_FSK_SCALE_FSK_MODULATION_SCALE_0(0x1627) | XCVR_TX_DIG_FSK_SCALE_FSK_MODULATION_SCALE_1(0x09d9),
|
||||
.tx_fsk_scale_32mhz = XCVR_TX_DIG_FSK_SCALE_FSK_MODULATION_SCALE_0(0x1800) | XCVR_TX_DIG_FSK_SCALE_FSK_MODULATION_SCALE_1(0x0800),
|
||||
};
|
||||
|
||||
const xcvr_mode_datarate_config_t xcvr_GFSK_BT_0p5_h_0p7_250kbps_config =
|
||||
{
|
||||
.radio_mode = GFSK_BT_0p5_h_0p7,
|
||||
.data_rate = DR_250KBPS,
|
||||
|
||||
.ana_sy_ctrl2.mask = XCVR_ANALOG_SY_CTRL_2_SY_VCO_KVM_MASK,
|
||||
.ana_sy_ctrl2.init = XCVR_ANALOG_SY_CTRL_2_SY_VCO_KVM(0), /* VCO KVM */
|
||||
.ana_rx_bba.mask = XCVR_ANALOG_RX_BBA_RX_BBA_BW_SEL_MASK | XCVR_ANALOG_RX_BBA_RX_BBA2_BW_SEL_MASK,
|
||||
.ana_rx_bba.init = XCVR_ANALOG_RX_BBA_RX_BBA_BW_SEL(5) | XCVR_ANALOG_RX_BBA_RX_BBA2_BW_SEL(5), /* BBA_BW_SEL and BBA2_BW_SEL */
|
||||
.ana_rx_tza.mask = XCVR_ANALOG_RX_TZA_RX_TZA_BW_SEL_MASK,
|
||||
.ana_rx_tza.init = XCVR_ANALOG_RX_TZA_RX_TZA_BW_SEL(5), /* TZA_BW_SEL */
|
||||
|
||||
.phy_cfg2_init = XCVR_PHY_CFG2_PHY_FIFO_PRECHG(8) |
|
||||
XCVR_PHY_CFG2_X2_DEMOD_GAIN(0x6) ,
|
||||
|
||||
/* AGC configs */
|
||||
.agc_ctrl_2_init_26mhz = XCVR_RX_DIG_AGC_CTRL_2_BBA_GAIN_SETTLE_TIME(18) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_BBA_PDET_SEL_LO(5) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_BBA_PDET_SEL_HI(6) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_TZA_PDET_SEL_LO(3) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_TZA_PDET_SEL_HI(7) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_AGC_FAST_EXPIRE(5),
|
||||
.agc_ctrl_2_init_32mhz = XCVR_RX_DIG_AGC_CTRL_2_BBA_GAIN_SETTLE_TIME(22) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_BBA_PDET_SEL_LO(5) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_BBA_PDET_SEL_HI(2) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_TZA_PDET_SEL_LO(3) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_TZA_PDET_SEL_HI(7) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_AGC_FAST_EXPIRE(5),
|
||||
|
||||
/* All constant values are represented as 16 bits, register writes will remove unused bits */
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_0 = 0x0000,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_1 = 0x0003,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_2 = 0x0006,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_3 = 0x0005,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_4 = 0xFFFE,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_5 = 0xFFF1,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_6 = 0xFFE6,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_7 = 0xFFEA,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_8 = 0x0005,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_9 = 0x0036,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_10 = 0x006B,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_11 = 0x008D,
|
||||
|
||||
/* 32MHz Channel Filter */
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_0 = 0xFFFF,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_1 = 0x0000,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_2 = 0x0004,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_3 = 0x0008,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_4 = 0x0004,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_5 = 0xFFF8,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_6 = 0xFFE6,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_7 = 0xFFE2,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_8 = 0xFFFA,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_9 = 0x002E,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_10 = 0x006D,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_11 = 0x0098,
|
||||
|
||||
.rx_rccal_ctrl_0 = XCVR_RX_DIG_RX_RCCAL_CTRL0_BBA_RCCAL_OFFSET(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_BBA_RCCAL_MANUAL(31) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_BBA_RCCAL_DIS(1) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_RCCAL_SMP_DLY(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_RCCAL_COMP_INV(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_TZA_RCCAL_OFFSET(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_TZA_RCCAL_MANUAL(31) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_TZA_RCCAL_DIS(1) ,
|
||||
.rx_rccal_ctrl_1 = XCVR_RX_DIG_RX_RCCAL_CTRL1_ADC_RCCAL_OFFSET(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL1_ADC_RCCAL_MANUAL(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL1_ADC_RCCAL_DIS(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL1_BBA2_RCCAL_OFFSET(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL1_BBA2_RCCAL_MANUAL(31) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL1_BBA2_RCCAL_DIS(1) ,
|
||||
|
||||
.tx_fsk_scale_26mhz = XCVR_TX_DIG_FSK_SCALE_FSK_MODULATION_SCALE_0(0x1627) | XCVR_TX_DIG_FSK_SCALE_FSK_MODULATION_SCALE_1(0x09d9),
|
||||
.tx_fsk_scale_32mhz = XCVR_TX_DIG_FSK_SCALE_FSK_MODULATION_SCALE_0(0x1800) | XCVR_TX_DIG_FSK_SCALE_FSK_MODULATION_SCALE_1(0x0800),
|
||||
};
|
||||
|
||||
-340
@@ -1,340 +0,0 @@
|
||||
/*
|
||||
* Copyright 2016-2017 NXP
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* o Redistributions of source code must retain the above copyright notice, this list
|
||||
* of conditions and the following disclaimer.
|
||||
*
|
||||
* o 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.
|
||||
*
|
||||
* o Neither the name of Freescale Semiconductor, Inc. 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 HOLDER 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 "fsl_xcvr.h"
|
||||
|
||||
/*******************************************************************************
|
||||
* Definitions
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* Prototypes
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* Variables
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* Code
|
||||
******************************************************************************/
|
||||
/* MODE only configuration */
|
||||
const xcvr_mode_config_t gfsk_bt_0p5_h_1p0_mode_config =
|
||||
{
|
||||
.radio_mode = GFSK_BT_0p5_h_1p0,
|
||||
.scgc5_clock_ena_bits = SIM_SCGC5_PHYDIG_MASK | SIM_SCGC5_GEN_FSK_MASK,
|
||||
|
||||
/* XCVR_MISC configs */
|
||||
.xcvr_ctrl.mask = XCVR_CTRL_XCVR_CTRL_PROTOCOL_MASK |
|
||||
XCVR_CTRL_XCVR_CTRL_TGT_PWR_SRC_MASK |
|
||||
XCVR_CTRL_XCVR_CTRL_DEMOD_SEL_MASK,
|
||||
.xcvr_ctrl.init = XCVR_CTRL_XCVR_CTRL_PROTOCOL(8) |
|
||||
XCVR_CTRL_XCVR_CTRL_TGT_PWR_SRC(7) |
|
||||
XCVR_CTRL_XCVR_CTRL_DEMOD_SEL(1),
|
||||
|
||||
/* XCVR_PHY configs */
|
||||
.phy_pre_ref0_init = 0xF38B5273,
|
||||
.phy_pre_ref1_init = 0x8CEF9CE6,
|
||||
.phy_pre_ref2_init = 0x00009D2D,
|
||||
|
||||
.phy_cfg1_init = XCVR_PHY_CFG1_AA_PLAYBACK(1) |
|
||||
XCVR_PHY_CFG1_AA_OUTPUT_SEL(1) |
|
||||
XCVR_PHY_CFG1_FSK_BIT_INVERT(0) |
|
||||
XCVR_PHY_CFG1_BSM_EN_BLE(0) |
|
||||
XCVR_PHY_CFG1_DEMOD_CLK_MODE(0) |
|
||||
XCVR_PHY_CFG1_CTS_THRESH(0xb0) |
|
||||
XCVR_PHY_CFG1_FSK_FTS_TIMEOUT(2),
|
||||
|
||||
.phy_el_cfg_init = XCVR_PHY_EL_CFG_EL_ENABLE(1)
|
||||
#if !RADIO_IS_GEN_2P1
|
||||
| XCVR_PHY_EL_CFG_EL_ZB_ENABLE(0)
|
||||
#endif /* !RADIO_IS_GEN_2P1 */
|
||||
,
|
||||
/* XCVR_RX_DIG configs */
|
||||
.rx_dig_ctrl_init_26mhz = XCVR_RX_DIG_RX_DIG_CTRL_RX_FSK_ZB_SEL(0) | /* Depends on protocol */
|
||||
XCVR_RX_DIG_RX_DIG_CTRL_RX_DC_RESID_EN(1) | /* Depends on protocol */
|
||||
XCVR_RX_DIG_RX_DIG_CTRL_RX_SRC_RATE(0),
|
||||
|
||||
.rx_dig_ctrl_init_32mhz = XCVR_RX_DIG_RX_DIG_CTRL_RX_FSK_ZB_SEL(0) | /* Depends on protocol */
|
||||
XCVR_RX_DIG_RX_DIG_CTRL_RX_DC_RESID_EN(1), /* Depends on protocol */
|
||||
|
||||
.agc_ctrl_0_init = XCVR_RX_DIG_AGC_CTRL_0_AGC_DOWN_RSSI_THRESH(0xFF),
|
||||
|
||||
/* XCVR_TSM configs */
|
||||
#if (DATA_PADDING_EN)
|
||||
.tsm_timing_35_init = B0(TX_DIG_EN_ASSERT + TX_DIG_EN_TX_HI_ADJ),
|
||||
#else
|
||||
.tsm_timing_35_init = B0(TX_DIG_EN_ASSERT),
|
||||
#endif /* (DATA_PADDING_EN) */
|
||||
|
||||
/* XCVR_TX_DIG configs */
|
||||
.tx_gfsk_ctrl = XCVR_TX_DIG_GFSK_CTRL_GFSK_MULTIPLY_TABLE_MANUAL(0x4000) |
|
||||
XCVR_TX_DIG_GFSK_CTRL_GFSK_MI(3) |
|
||||
XCVR_TX_DIG_GFSK_CTRL_GFSK_MLD(0) |
|
||||
XCVR_TX_DIG_GFSK_CTRL_GFSK_FLD(0) |
|
||||
XCVR_TX_DIG_GFSK_CTRL_GFSK_MOD_INDEX_SCALING(0) |
|
||||
XCVR_TX_DIG_GFSK_CTRL_TX_IMAGE_FILTER_OVRD_EN(0) |
|
||||
XCVR_TX_DIG_GFSK_CTRL_TX_IMAGE_FILTER_0_OVRD(0) |
|
||||
XCVR_TX_DIG_GFSK_CTRL_TX_IMAGE_FILTER_1_OVRD(0) |
|
||||
XCVR_TX_DIG_GFSK_CTRL_TX_IMAGE_FILTER_2_OVRD(0),
|
||||
.tx_gfsk_coeff1_26mhz = 0,
|
||||
.tx_gfsk_coeff2_26mhz = 0,
|
||||
.tx_gfsk_coeff1_32mhz = 0,
|
||||
.tx_gfsk_coeff2_32mhz = 0,
|
||||
};
|
||||
|
||||
/* MODE & DATA RATE combined configuration */
|
||||
const xcvr_mode_datarate_config_t xcvr_GFSK_BT_0p5_h_1p0_1mbps_config =
|
||||
{
|
||||
.radio_mode = GFSK_BT_0p5_h_1p0,
|
||||
.data_rate = DR_1MBPS,
|
||||
|
||||
.ana_sy_ctrl2.mask = XCVR_ANALOG_SY_CTRL_2_SY_VCO_KVM_MASK,
|
||||
.ana_sy_ctrl2.init = XCVR_ANALOG_SY_CTRL_2_SY_VCO_KVM(1), /* VCO KVM */
|
||||
.ana_rx_bba.mask = XCVR_ANALOG_RX_BBA_RX_BBA_BW_SEL_MASK | XCVR_ANALOG_RX_BBA_RX_BBA2_BW_SEL_MASK,
|
||||
.ana_rx_bba.init = XCVR_ANALOG_RX_BBA_RX_BBA_BW_SEL(3) | XCVR_ANALOG_RX_BBA_RX_BBA2_BW_SEL(3), /* BBA_BW_SEL and BBA2_BW_SEL */
|
||||
.ana_rx_tza.mask = XCVR_ANALOG_RX_TZA_RX_TZA_BW_SEL_MASK,
|
||||
.ana_rx_tza.init = XCVR_ANALOG_RX_TZA_RX_TZA_BW_SEL(3), /* TZA_BW_SEL */
|
||||
|
||||
.phy_cfg2_init = XCVR_PHY_CFG2_PHY_FIFO_PRECHG(8) |
|
||||
XCVR_PHY_CFG2_X2_DEMOD_GAIN(0xA) ,
|
||||
|
||||
/* AGC configs */
|
||||
.agc_ctrl_2_init_26mhz = XCVR_RX_DIG_AGC_CTRL_2_BBA_GAIN_SETTLE_TIME(11) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_BBA_PDET_SEL_LO(5) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_BBA_PDET_SEL_HI(6) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_TZA_PDET_SEL_LO(3) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_TZA_PDET_SEL_HI(7) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_AGC_FAST_EXPIRE(5),
|
||||
.agc_ctrl_2_init_32mhz = XCVR_RX_DIG_AGC_CTRL_2_BBA_GAIN_SETTLE_TIME(12) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_BBA_PDET_SEL_LO(5) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_BBA_PDET_SEL_HI(6) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_TZA_PDET_SEL_LO(3) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_TZA_PDET_SEL_HI(7) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_AGC_FAST_EXPIRE(5),
|
||||
|
||||
/* All constant values are represented as 16 bits, register writes will remove unused bits */
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_0 = 0x0001,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_1 = 0x0004,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_2 = 0x0006,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_3 = 0x0003,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_4 = 0xFFF9,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_5 = 0xFFEB,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_6 = 0xFFE2,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_7 = 0xFFE9,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_8 = 0x0008,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_9 = 0x003A,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_10 = 0x006F,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_11 = 0x0090,
|
||||
|
||||
/* 32MHz Channel Filter */
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_0 = 0x0000,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_1 = 0x0003,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_2 = 0x0007,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_3 = 0x0008,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_4 = 0x0000,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_5 = 0xFFF0,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_6 = 0xFFE0,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_7 = 0xFFE1,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_8 = 0xFFFD,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_9 = 0x0034,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_10 = 0x0072,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_11 = 0x009A,
|
||||
|
||||
.rx_rccal_ctrl_0 = XCVR_RX_DIG_RX_RCCAL_CTRL0_BBA_RCCAL_OFFSET(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_BBA_RCCAL_MANUAL(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_BBA_RCCAL_DIS(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_RCCAL_SMP_DLY(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_RCCAL_COMP_INV(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_TZA_RCCAL_OFFSET(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_TZA_RCCAL_MANUAL(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_TZA_RCCAL_DIS(0) ,
|
||||
.rx_rccal_ctrl_1 = XCVR_RX_DIG_RX_RCCAL_CTRL1_ADC_RCCAL_OFFSET(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL1_ADC_RCCAL_MANUAL(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL1_ADC_RCCAL_DIS(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL1_BBA2_RCCAL_OFFSET(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL1_BBA2_RCCAL_MANUAL(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL1_BBA2_RCCAL_DIS(0) ,
|
||||
|
||||
.tx_fsk_scale_26mhz = XCVR_TX_DIG_FSK_SCALE_FSK_MODULATION_SCALE_0(0x1627) | XCVR_TX_DIG_FSK_SCALE_FSK_MODULATION_SCALE_1(0x09d9),
|
||||
.tx_fsk_scale_32mhz = XCVR_TX_DIG_FSK_SCALE_FSK_MODULATION_SCALE_0(0x1800) | XCVR_TX_DIG_FSK_SCALE_FSK_MODULATION_SCALE_1(0x0800),
|
||||
};
|
||||
|
||||
const xcvr_mode_datarate_config_t xcvr_GFSK_BT_0p5_h_1p0_500kbps_config =
|
||||
{
|
||||
.radio_mode = GFSK_BT_0p5_h_1p0,
|
||||
.data_rate = DR_500KBPS,
|
||||
|
||||
.ana_sy_ctrl2.mask = XCVR_ANALOG_SY_CTRL_2_SY_VCO_KVM_MASK,
|
||||
.ana_sy_ctrl2.init = XCVR_ANALOG_SY_CTRL_2_SY_VCO_KVM(0), /* VCO KVM */
|
||||
.ana_rx_bba.mask = XCVR_ANALOG_RX_BBA_RX_BBA_BW_SEL_MASK | XCVR_ANALOG_RX_BBA_RX_BBA2_BW_SEL_MASK,
|
||||
.ana_rx_bba.init = XCVR_ANALOG_RX_BBA_RX_BBA_BW_SEL(5) | XCVR_ANALOG_RX_BBA_RX_BBA2_BW_SEL(5), /* BBA_BW_SEL and BBA2_BW_SEL */
|
||||
.ana_rx_tza.mask = XCVR_ANALOG_RX_TZA_RX_TZA_BW_SEL_MASK,
|
||||
.ana_rx_tza.init = XCVR_ANALOG_RX_TZA_RX_TZA_BW_SEL(5), /* TZA_BW_SEL */
|
||||
|
||||
.phy_cfg2_init = XCVR_PHY_CFG2_PHY_FIFO_PRECHG(8) |
|
||||
XCVR_PHY_CFG2_X2_DEMOD_GAIN(0x8) ,
|
||||
|
||||
/* AGC configs */
|
||||
.agc_ctrl_2_init_26mhz = XCVR_RX_DIG_AGC_CTRL_2_BBA_GAIN_SETTLE_TIME(15) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_BBA_PDET_SEL_LO(5) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_BBA_PDET_SEL_HI(6) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_TZA_PDET_SEL_LO(3) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_TZA_PDET_SEL_HI(7) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_AGC_FAST_EXPIRE(5),
|
||||
.agc_ctrl_2_init_32mhz = XCVR_RX_DIG_AGC_CTRL_2_BBA_GAIN_SETTLE_TIME(18) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_BBA_PDET_SEL_LO(5) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_BBA_PDET_SEL_HI(6) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_TZA_PDET_SEL_LO(3) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_TZA_PDET_SEL_HI(7) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_AGC_FAST_EXPIRE(5),
|
||||
|
||||
/* All constant values are represented as 16 bits, register writes will remove unused bits */
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_0 = 0xFFFD,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_1 = 0xFFEA,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_2 = 0xFFF3,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_3 = 0x0021,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_4 = 0x0013,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_5 = 0xFFC9,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_6 = 0xFFEE,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_7 = 0x005E,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_8 = 0x0004,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_9 = 0xFF4E,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_10 = 0xFFFC,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_11 = 0x018F,
|
||||
|
||||
/* 32MHz Channel Filter */
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_0 = 0x0012,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_1 = 0x0011,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_2 = 0xFFE1,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_3 = 0xFFEE,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_4 = 0x0034,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_5 = 0xFFFD,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_6 = 0xFFB7,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_7 = 0x003B,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_8 = 0x004F,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_9 = 0xFF5B,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_10 = 0xFFB5,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_11 = 0x018B,
|
||||
|
||||
.rx_rccal_ctrl_0 = XCVR_RX_DIG_RX_RCCAL_CTRL0_BBA_RCCAL_OFFSET(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_BBA_RCCAL_MANUAL(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_BBA_RCCAL_DIS(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_RCCAL_SMP_DLY(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_RCCAL_COMP_INV(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_TZA_RCCAL_OFFSET(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_TZA_RCCAL_MANUAL(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_TZA_RCCAL_DIS(0) ,
|
||||
.rx_rccal_ctrl_1 = XCVR_RX_DIG_RX_RCCAL_CTRL1_ADC_RCCAL_OFFSET(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL1_ADC_RCCAL_MANUAL(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL1_ADC_RCCAL_DIS(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL1_BBA2_RCCAL_OFFSET(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL1_BBA2_RCCAL_MANUAL(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL1_BBA2_RCCAL_DIS(0) ,
|
||||
|
||||
.tx_fsk_scale_26mhz = XCVR_TX_DIG_FSK_SCALE_FSK_MODULATION_SCALE_0(0x1627) | XCVR_TX_DIG_FSK_SCALE_FSK_MODULATION_SCALE_1(0x09d9),
|
||||
.tx_fsk_scale_32mhz = XCVR_TX_DIG_FSK_SCALE_FSK_MODULATION_SCALE_0(0x1800) | XCVR_TX_DIG_FSK_SCALE_FSK_MODULATION_SCALE_1(0x0800),
|
||||
};
|
||||
|
||||
const xcvr_mode_datarate_config_t xcvr_GFSK_BT_0p5_h_1p0_250kbps_config =
|
||||
{
|
||||
.radio_mode = GFSK_BT_0p5_h_1p0,
|
||||
.data_rate = DR_250KBPS,
|
||||
|
||||
.ana_sy_ctrl2.mask = XCVR_ANALOG_SY_CTRL_2_SY_VCO_KVM_MASK,
|
||||
.ana_sy_ctrl2.init = XCVR_ANALOG_SY_CTRL_2_SY_VCO_KVM(0), /* VCO KVM */
|
||||
.ana_rx_bba.mask = XCVR_ANALOG_RX_BBA_RX_BBA_BW_SEL_MASK | XCVR_ANALOG_RX_BBA_RX_BBA2_BW_SEL_MASK,
|
||||
.ana_rx_bba.init = XCVR_ANALOG_RX_BBA_RX_BBA_BW_SEL(5) | XCVR_ANALOG_RX_BBA_RX_BBA2_BW_SEL(5), /* BBA_BW_SEL and BBA2_BW_SEL */
|
||||
.ana_rx_tza.mask = XCVR_ANALOG_RX_TZA_RX_TZA_BW_SEL_MASK,
|
||||
.ana_rx_tza.init = XCVR_ANALOG_RX_TZA_RX_TZA_BW_SEL(5), /* TZA_BW_SEL */
|
||||
|
||||
.phy_cfg2_init = XCVR_PHY_CFG2_PHY_FIFO_PRECHG(8) |
|
||||
XCVR_PHY_CFG2_X2_DEMOD_GAIN(0x6) ,
|
||||
|
||||
/* AGC configs */
|
||||
.agc_ctrl_2_init_26mhz = XCVR_RX_DIG_AGC_CTRL_2_BBA_GAIN_SETTLE_TIME(18) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_BBA_PDET_SEL_LO(5) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_BBA_PDET_SEL_HI(2) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_TZA_PDET_SEL_LO(3) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_TZA_PDET_SEL_HI(7) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_AGC_FAST_EXPIRE(5),
|
||||
.agc_ctrl_2_init_32mhz = XCVR_RX_DIG_AGC_CTRL_2_BBA_GAIN_SETTLE_TIME(22) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_BBA_PDET_SEL_LO(5) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_BBA_PDET_SEL_HI(6) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_TZA_PDET_SEL_LO(3) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_TZA_PDET_SEL_HI(7) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_AGC_FAST_EXPIRE(5),
|
||||
|
||||
/* All constant values are represented as 16 bits, register writes will remove unused bits */
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_0 = 0xFFFE,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_1 = 0x0004,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_2 = 0x000C,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_3 = 0x0011,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_4 = 0x000B,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_5 = 0xFFF8,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_6 = 0xFFE0,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_7 = 0xFFD7,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_8 = 0xFFF0,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_9 = 0x002A,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_10 = 0x006F,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_11 = 0x009E,
|
||||
|
||||
/* 32MHz Channel Filter */
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_0 = 0xFFFA,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_1 = 0xFFF9,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_2 = 0x0000,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_3 = 0x000F,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_4 = 0x0019,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_5 = 0x000C,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_6 = 0xFFEB,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_7 = 0xFFCD,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_8 = 0xFFD7,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_9 = 0x0017,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_10 = 0x0075,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_11 = 0x00BB,
|
||||
|
||||
.rx_rccal_ctrl_0 = XCVR_RX_DIG_RX_RCCAL_CTRL0_BBA_RCCAL_OFFSET(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_BBA_RCCAL_MANUAL(31) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_BBA_RCCAL_DIS(1) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_RCCAL_SMP_DLY(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_RCCAL_COMP_INV(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_TZA_RCCAL_OFFSET(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_TZA_RCCAL_MANUAL(31) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_TZA_RCCAL_DIS(1) ,
|
||||
.rx_rccal_ctrl_1 = XCVR_RX_DIG_RX_RCCAL_CTRL1_ADC_RCCAL_OFFSET(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL1_ADC_RCCAL_MANUAL(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL1_ADC_RCCAL_DIS(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL1_BBA2_RCCAL_OFFSET(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL1_BBA2_RCCAL_MANUAL(31) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL1_BBA2_RCCAL_DIS(1) ,
|
||||
|
||||
.tx_fsk_scale_26mhz = XCVR_TX_DIG_FSK_SCALE_FSK_MODULATION_SCALE_0(0x1627) | XCVR_TX_DIG_FSK_SCALE_FSK_MODULATION_SCALE_1(0x09d9),
|
||||
.tx_fsk_scale_32mhz = XCVR_TX_DIG_FSK_SCALE_FSK_MODULATION_SCALE_0(0x1800) | XCVR_TX_DIG_FSK_SCALE_FSK_MODULATION_SCALE_1(0x0800),
|
||||
};
|
||||
|
||||
-353
@@ -1,353 +0,0 @@
|
||||
/*
|
||||
* Copyright 2016-2017 NXP
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* o Redistributions of source code must retain the above copyright notice, this list
|
||||
* of conditions and the following disclaimer.
|
||||
*
|
||||
* o 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.
|
||||
*
|
||||
* o Neither the name of Freescale Semiconductor, Inc. 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 HOLDER 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 "fsl_xcvr.h"
|
||||
|
||||
/*******************************************************************************
|
||||
* Definitions
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* Prototypes
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* Variables
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* Code
|
||||
******************************************************************************/
|
||||
/* MODE only configuration */
|
||||
const xcvr_mode_config_t gfsk_bt_0p7_h_0p5_mode_config =
|
||||
{
|
||||
.radio_mode = GFSK_BT_0p7_h_0p5,
|
||||
.scgc5_clock_ena_bits = SIM_SCGC5_PHYDIG_MASK | SIM_SCGC5_GEN_FSK_MASK,
|
||||
|
||||
/* XCVR_MISC configs */
|
||||
.xcvr_ctrl.mask = XCVR_CTRL_XCVR_CTRL_PROTOCOL_MASK |
|
||||
XCVR_CTRL_XCVR_CTRL_TGT_PWR_SRC_MASK |
|
||||
XCVR_CTRL_XCVR_CTRL_DEMOD_SEL_MASK,
|
||||
.xcvr_ctrl.init = XCVR_CTRL_XCVR_CTRL_PROTOCOL(8) |
|
||||
XCVR_CTRL_XCVR_CTRL_TGT_PWR_SRC(7) |
|
||||
XCVR_CTRL_XCVR_CTRL_DEMOD_SEL(1),
|
||||
|
||||
/* XCVR_PHY configs */
|
||||
.phy_pre_ref0_init = 0x79CDEB39,
|
||||
.phy_pre_ref1_init = 0xCE77DEF7,
|
||||
.phy_pre_ref2_init = 0x0000CEB7,
|
||||
|
||||
.phy_cfg1_init = XCVR_PHY_CFG1_AA_PLAYBACK(1) |
|
||||
XCVR_PHY_CFG1_AA_OUTPUT_SEL(1) |
|
||||
XCVR_PHY_CFG1_FSK_BIT_INVERT(0) |
|
||||
XCVR_PHY_CFG1_BSM_EN_BLE(0) |
|
||||
XCVR_PHY_CFG1_DEMOD_CLK_MODE(0) |
|
||||
XCVR_PHY_CFG1_CTS_THRESH(0xb0) |
|
||||
XCVR_PHY_CFG1_FSK_FTS_TIMEOUT(2),
|
||||
|
||||
.phy_el_cfg_init = XCVR_PHY_EL_CFG_EL_ENABLE(1)
|
||||
#if !RADIO_IS_GEN_2P1
|
||||
| XCVR_PHY_EL_CFG_EL_ZB_ENABLE(0)
|
||||
#endif /* !RADIO_IS_GEN_2P1 */
|
||||
,
|
||||
|
||||
/* XCVR_RX_DIG configs */
|
||||
.rx_dig_ctrl_init_26mhz = XCVR_RX_DIG_RX_DIG_CTRL_RX_FSK_ZB_SEL(0) | /* Depends on protocol */
|
||||
XCVR_RX_DIG_RX_DIG_CTRL_RX_DC_RESID_EN(1), /* Depends on protocol */
|
||||
XCVR_RX_DIG_RX_DIG_CTRL_RX_SRC_RATE(0),
|
||||
|
||||
.rx_dig_ctrl_init_32mhz = XCVR_RX_DIG_RX_DIG_CTRL_RX_FSK_ZB_SEL(0) | /* Depends on protocol */
|
||||
XCVR_RX_DIG_RX_DIG_CTRL_RX_DC_RESID_EN(1), /* Depends on protocol */
|
||||
|
||||
.agc_ctrl_0_init = XCVR_RX_DIG_AGC_CTRL_0_AGC_DOWN_RSSI_THRESH(0xFF),
|
||||
|
||||
/* XCVR_TSM configs */
|
||||
#if (DATA_PADDING_EN)
|
||||
.tsm_timing_35_init = B0(TX_DIG_EN_ASSERT+TX_DIG_EN_TX_HI_ADJ),
|
||||
#else
|
||||
.tsm_timing_35_init = B0(TX_DIG_EN_ASSERT),
|
||||
#endif /* (DATA_PADDING_EN) */
|
||||
|
||||
/* XCVR_TX_DIG configs */
|
||||
.tx_gfsk_ctrl = XCVR_TX_DIG_GFSK_CTRL_GFSK_MULTIPLY_TABLE_MANUAL(0x4000) |
|
||||
XCVR_TX_DIG_GFSK_CTRL_GFSK_MI(1) |
|
||||
XCVR_TX_DIG_GFSK_CTRL_GFSK_MLD(0) |
|
||||
XCVR_TX_DIG_GFSK_CTRL_GFSK_FLD(1) | /* Use GFSK Manual Filter Coeffs */
|
||||
XCVR_TX_DIG_GFSK_CTRL_GFSK_MOD_INDEX_SCALING(0) |
|
||||
XCVR_TX_DIG_GFSK_CTRL_TX_IMAGE_FILTER_OVRD_EN(0) |
|
||||
XCVR_TX_DIG_GFSK_CTRL_TX_IMAGE_FILTER_0_OVRD(0) |
|
||||
XCVR_TX_DIG_GFSK_CTRL_TX_IMAGE_FILTER_1_OVRD(0) |
|
||||
XCVR_TX_DIG_GFSK_CTRL_TX_IMAGE_FILTER_2_OVRD(0),
|
||||
.tx_gfsk_coeff1_26mhz = (27U) << 0 | /* Coeff 2/13 */
|
||||
(276U) << 7 | /* Coeff 6/9 */
|
||||
(62U) << 16 | /* Coef 3/12 */
|
||||
(326U) << 23, /* Coeff 7/8 */
|
||||
.tx_gfsk_coeff2_26mhz = (3U) << 0 | /* Coeff 0/15 */
|
||||
(10U) << 8 | /* Coeff 1/14 */
|
||||
(121U) << 16 | /* Coeff 4/11 */
|
||||
(198U) << 24, /* Coeff 5/10 */
|
||||
.tx_gfsk_coeff1_32mhz = (1U) << 0 | /* Coeff 2/13 */
|
||||
(330U) << 7 | /* Coeff 6/9 */
|
||||
(7U) << 16 | /* Coef 3/12 */
|
||||
(510U) << 23, /* Coeff 7/8 */
|
||||
.tx_gfsk_coeff2_32mhz = (0U) << 0 | /* Coeff 0/15 */
|
||||
(0U) << 8 | /* Coeff 1/14 */
|
||||
(37U) << 16 | /* Coeff 4/11 */
|
||||
(138U) << 24, /* Coeff 5/10 */
|
||||
};
|
||||
|
||||
/* MODE & DATA RATE combined configuration */
|
||||
const xcvr_mode_datarate_config_t xcvr_GFSK_BT_0p7_h_0p5_1mbps_config =
|
||||
{
|
||||
.radio_mode = GFSK_BT_0p7_h_0p5,
|
||||
.data_rate = DR_1MBPS,
|
||||
|
||||
.ana_sy_ctrl2.mask = XCVR_ANALOG_SY_CTRL_2_SY_VCO_KVM_MASK,
|
||||
.ana_sy_ctrl2.init = XCVR_ANALOG_SY_CTRL_2_SY_VCO_KVM(0), /* VCO KVM */
|
||||
.ana_rx_bba.mask = XCVR_ANALOG_RX_BBA_RX_BBA_BW_SEL_MASK | XCVR_ANALOG_RX_BBA_RX_BBA2_BW_SEL_MASK,
|
||||
.ana_rx_bba.init = XCVR_ANALOG_RX_BBA_RX_BBA_BW_SEL(3) | XCVR_ANALOG_RX_BBA_RX_BBA2_BW_SEL(3), /* BBA_BW_SEL and BBA2_BW_SEL */
|
||||
.ana_rx_tza.mask = XCVR_ANALOG_RX_TZA_RX_TZA_BW_SEL_MASK,
|
||||
.ana_rx_tza.init = XCVR_ANALOG_RX_TZA_RX_TZA_BW_SEL(3), /*TZA_BW_SEL */
|
||||
|
||||
.phy_cfg2_init = XCVR_PHY_CFG2_PHY_FIFO_PRECHG(8) |
|
||||
XCVR_PHY_CFG2_X2_DEMOD_GAIN(0xA) ,
|
||||
|
||||
/* AGC configs */
|
||||
.agc_ctrl_2_init_26mhz = XCVR_RX_DIG_AGC_CTRL_2_BBA_GAIN_SETTLE_TIME(11) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_BBA_PDET_SEL_LO(5) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_BBA_PDET_SEL_HI(6) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_TZA_PDET_SEL_LO(3) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_TZA_PDET_SEL_HI(7) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_AGC_FAST_EXPIRE(5),
|
||||
.agc_ctrl_2_init_32mhz = XCVR_RX_DIG_AGC_CTRL_2_BBA_GAIN_SETTLE_TIME(12) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_BBA_PDET_SEL_LO(5) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_BBA_PDET_SEL_HI(6) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_TZA_PDET_SEL_LO(3) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_TZA_PDET_SEL_HI(7) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_AGC_FAST_EXPIRE(5),
|
||||
|
||||
/* All constant values are represented as 16 bits, register writes will remove unused bits */
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_0 = 0x0001,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_1 = 0x0000,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_2 = 0xFFFE,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_3 = 0xFFF8,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_4 = 0xFFF1,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_5 = 0xFFEF,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_6 = 0xFFF4,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_7 = 0x0004,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_8 = 0x0020,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_9 = 0x0041,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_10 = 0x005E,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_11 = 0x0070,
|
||||
|
||||
/* 32MHz Channel Filter */
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_0 = 0x0002,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_1 = 0x0002,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_2 = 0x0000,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_3 = 0xFFFA,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_4 = 0xFFF2,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_5 = 0xFFEB,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_6 = 0xFFED,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_7 = 0xFFFD,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_8 = 0x001B,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_9 = 0x0041,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_10 = 0x0065,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_11 = 0x007A,
|
||||
|
||||
.rx_rccal_ctrl_0 = XCVR_RX_DIG_RX_RCCAL_CTRL0_BBA_RCCAL_OFFSET(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_BBA_RCCAL_MANUAL(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_BBA_RCCAL_DIS(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_RCCAL_SMP_DLY(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_RCCAL_COMP_INV(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_TZA_RCCAL_OFFSET(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_TZA_RCCAL_MANUAL(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_TZA_RCCAL_DIS(0) ,
|
||||
.rx_rccal_ctrl_1 = XCVR_RX_DIG_RX_RCCAL_CTRL1_ADC_RCCAL_OFFSET(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL1_ADC_RCCAL_MANUAL(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL1_ADC_RCCAL_DIS(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL1_BBA2_RCCAL_OFFSET(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL1_BBA2_RCCAL_MANUAL(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL1_BBA2_RCCAL_DIS(0) ,
|
||||
|
||||
.tx_fsk_scale_26mhz = XCVR_TX_DIG_FSK_SCALE_FSK_MODULATION_SCALE_0(0x1627) | XCVR_TX_DIG_FSK_SCALE_FSK_MODULATION_SCALE_1(0x09d9),
|
||||
.tx_fsk_scale_32mhz = XCVR_TX_DIG_FSK_SCALE_FSK_MODULATION_SCALE_0(0x1800) | XCVR_TX_DIG_FSK_SCALE_FSK_MODULATION_SCALE_1(0x0800),
|
||||
};
|
||||
|
||||
const xcvr_mode_datarate_config_t xcvr_GFSK_BT_0p7_h_0p5_500kbps_config =
|
||||
{
|
||||
.radio_mode = GFSK_BT_0p7_h_0p5,
|
||||
.data_rate = DR_500KBPS,
|
||||
|
||||
.ana_sy_ctrl2.mask = XCVR_ANALOG_SY_CTRL_2_SY_VCO_KVM_MASK,
|
||||
.ana_sy_ctrl2.init = XCVR_ANALOG_SY_CTRL_2_SY_VCO_KVM(0), /* VCO KVM */
|
||||
.ana_rx_bba.mask = XCVR_ANALOG_RX_BBA_RX_BBA_BW_SEL_MASK | XCVR_ANALOG_RX_BBA_RX_BBA2_BW_SEL_MASK,
|
||||
.ana_rx_bba.init = XCVR_ANALOG_RX_BBA_RX_BBA_BW_SEL(5) | XCVR_ANALOG_RX_BBA_RX_BBA2_BW_SEL(5), /* BBA_BW_SEL and BBA2_BW_SEL */
|
||||
.ana_rx_tza.mask = XCVR_ANALOG_RX_TZA_RX_TZA_BW_SEL_MASK,
|
||||
.ana_rx_tza.init = XCVR_ANALOG_RX_TZA_RX_TZA_BW_SEL(5), /* TZA_BW_SEL */
|
||||
|
||||
.phy_cfg2_init = XCVR_PHY_CFG2_PHY_FIFO_PRECHG(8) |
|
||||
XCVR_PHY_CFG2_X2_DEMOD_GAIN(0x8) ,
|
||||
|
||||
/* AGC configs */
|
||||
.agc_ctrl_2_init_26mhz = XCVR_RX_DIG_AGC_CTRL_2_BBA_GAIN_SETTLE_TIME(15) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_BBA_PDET_SEL_LO(5) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_BBA_PDET_SEL_HI(6) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_TZA_PDET_SEL_LO(3) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_TZA_PDET_SEL_HI(7) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_AGC_FAST_EXPIRE(5),
|
||||
.agc_ctrl_2_init_32mhz = XCVR_RX_DIG_AGC_CTRL_2_BBA_GAIN_SETTLE_TIME(18) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_BBA_PDET_SEL_LO(5) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_BBA_PDET_SEL_HI(6) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_TZA_PDET_SEL_LO(3) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_TZA_PDET_SEL_HI(7) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_AGC_FAST_EXPIRE(5),
|
||||
|
||||
/* All constant values are represented as 16 bits, register writes will remove unused bits */
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_0 = 0x0002,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_1 = 0xFFFF,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_2 = 0xFFF8,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_3 = 0xFFFA,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_4 = 0x000A,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_5 = 0x0019,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_6 = 0x0009,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_7 = 0xFFDB,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_8 = 0xFFC1,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_9 = 0xFFF6,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_10 = 0x0072,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_11 = 0x00DD,
|
||||
|
||||
/* 32MHz Channel Filter */
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_0 = 0x0002,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_1 = 0x0003,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_2 = 0xFFFC,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_3 = 0xFFF4,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_4 = 0xFFFD,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_5 = 0x0016,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_6 = 0x001A,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_7 = 0xFFEC,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_8 = 0xFFBC,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_9 = 0xFFE0,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_10 = 0x0069,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_11 = 0x00ED,
|
||||
|
||||
.rx_rccal_ctrl_0 = XCVR_RX_DIG_RX_RCCAL_CTRL0_BBA_RCCAL_OFFSET(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_BBA_RCCAL_MANUAL(31) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_BBA_RCCAL_DIS(1) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_RCCAL_SMP_DLY(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_RCCAL_COMP_INV(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_TZA_RCCAL_OFFSET(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_TZA_RCCAL_MANUAL(31) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_TZA_RCCAL_DIS(1) ,
|
||||
.rx_rccal_ctrl_1 = XCVR_RX_DIG_RX_RCCAL_CTRL1_ADC_RCCAL_OFFSET(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL1_ADC_RCCAL_MANUAL(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL1_ADC_RCCAL_DIS(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL1_BBA2_RCCAL_OFFSET(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL1_BBA2_RCCAL_MANUAL(31) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL1_BBA2_RCCAL_DIS(1) ,
|
||||
|
||||
.tx_fsk_scale_26mhz = XCVR_TX_DIG_FSK_SCALE_FSK_MODULATION_SCALE_0(0x1627) | XCVR_TX_DIG_FSK_SCALE_FSK_MODULATION_SCALE_1(0x09d9),
|
||||
.tx_fsk_scale_32mhz = XCVR_TX_DIG_FSK_SCALE_FSK_MODULATION_SCALE_0(0x1800) | XCVR_TX_DIG_FSK_SCALE_FSK_MODULATION_SCALE_1(0x0800),
|
||||
};
|
||||
|
||||
const xcvr_mode_datarate_config_t xcvr_GFSK_BT_0p7_h_0p5_250kbps_config =
|
||||
{
|
||||
.radio_mode = GFSK_BT_0p7_h_0p5,
|
||||
.data_rate = DR_250KBPS,
|
||||
|
||||
.ana_sy_ctrl2.mask = XCVR_ANALOG_SY_CTRL_2_SY_VCO_KVM_MASK,
|
||||
.ana_sy_ctrl2.init = XCVR_ANALOG_SY_CTRL_2_SY_VCO_KVM(0), /* VCO KVM */
|
||||
.ana_rx_bba.mask = XCVR_ANALOG_RX_BBA_RX_BBA_BW_SEL_MASK | XCVR_ANALOG_RX_BBA_RX_BBA2_BW_SEL_MASK,
|
||||
.ana_rx_bba.init = XCVR_ANALOG_RX_BBA_RX_BBA_BW_SEL(5) | XCVR_ANALOG_RX_BBA_RX_BBA2_BW_SEL(5), /* BBA_BW_SEL and BBA2_BW_SEL */
|
||||
.ana_rx_tza.mask = XCVR_ANALOG_RX_TZA_RX_TZA_BW_SEL_MASK,
|
||||
.ana_rx_tza.init = XCVR_ANALOG_RX_TZA_RX_TZA_BW_SEL(5), /* TZA_BW_SEL */
|
||||
|
||||
.phy_cfg2_init = XCVR_PHY_CFG2_PHY_FIFO_PRECHG(8) |
|
||||
XCVR_PHY_CFG2_X2_DEMOD_GAIN(0x6) ,
|
||||
|
||||
/* AGC configs */
|
||||
.agc_ctrl_2_init_26mhz = XCVR_RX_DIG_AGC_CTRL_2_BBA_GAIN_SETTLE_TIME(18) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_BBA_PDET_SEL_LO(5) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_BBA_PDET_SEL_HI(6) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_TZA_PDET_SEL_LO(3) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_TZA_PDET_SEL_HI(7) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_AGC_FAST_EXPIRE(5),
|
||||
.agc_ctrl_2_init_32mhz = XCVR_RX_DIG_AGC_CTRL_2_BBA_GAIN_SETTLE_TIME(22) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_BBA_PDET_SEL_LO(5) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_BBA_PDET_SEL_HI(2) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_TZA_PDET_SEL_LO(3) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_TZA_PDET_SEL_HI(7) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_AGC_FAST_EXPIRE(5),
|
||||
|
||||
/* All constant values are represented as 16 bits, register writes will remove unused bits */
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_0 = 0x0000,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_1 = 0x0003,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_2 = 0x0006,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_3 = 0x0005,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_4 = 0xFFFE,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_5 = 0xFFF1,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_6 = 0xFFE6,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_7 = 0xFFEA,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_8 = 0x0005,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_9 = 0x0036,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_10 = 0x006B,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_11 = 0x008D,
|
||||
|
||||
/* 32MHz Channel Filter */
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_0 = 0xFFFF,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_1 = 0x0000,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_2 = 0x0004,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_3 = 0x0008,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_4 = 0x0004,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_5 = 0xFFF8,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_6 = 0xFFE6,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_7 = 0xFFE2,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_8 = 0xFFFA,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_9 = 0x002E,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_10 = 0x006D,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_11 = 0x0098,
|
||||
|
||||
.rx_rccal_ctrl_0 = XCVR_RX_DIG_RX_RCCAL_CTRL0_BBA_RCCAL_OFFSET(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_BBA_RCCAL_MANUAL(31) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_BBA_RCCAL_DIS(1) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_RCCAL_SMP_DLY(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_RCCAL_COMP_INV(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_TZA_RCCAL_OFFSET(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_TZA_RCCAL_MANUAL(31) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_TZA_RCCAL_DIS(1) ,
|
||||
.rx_rccal_ctrl_1 = XCVR_RX_DIG_RX_RCCAL_CTRL1_ADC_RCCAL_OFFSET(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL1_ADC_RCCAL_MANUAL(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL1_ADC_RCCAL_DIS(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL1_BBA2_RCCAL_OFFSET(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL1_BBA2_RCCAL_MANUAL(31) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL1_BBA2_RCCAL_DIS(1) ,
|
||||
|
||||
.tx_fsk_scale_26mhz = XCVR_TX_DIG_FSK_SCALE_FSK_MODULATION_SCALE_0(0x1627) | XCVR_TX_DIG_FSK_SCALE_FSK_MODULATION_SCALE_1(0x09d9),
|
||||
.tx_fsk_scale_32mhz = XCVR_TX_DIG_FSK_SCALE_FSK_MODULATION_SCALE_0(0x1800) | XCVR_TX_DIG_FSK_SCALE_FSK_MODULATION_SCALE_1(0x0800),
|
||||
};
|
||||
|
||||
-212
@@ -1,212 +0,0 @@
|
||||
/*
|
||||
* Copyright 2016-2017 NXP
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* o Redistributions of source code must retain the above copyright notice, this list
|
||||
* of conditions and the following disclaimer.
|
||||
*
|
||||
* o 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.
|
||||
*
|
||||
* o Neither the name of Freescale Semiconductor, Inc. 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 HOLDER 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 "fsl_xcvr.h"
|
||||
|
||||
/*******************************************************************************
|
||||
* Definitions
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* Prototypes
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* Variables
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* Code
|
||||
******************************************************************************/
|
||||
/* ========================= DATA RATE ONLY settings ===============*/
|
||||
/*!
|
||||
* @brief XCVR 1Mbps DATA RATE specific configure structure
|
||||
*/
|
||||
const xcvr_datarate_config_t xcvr_1mbps_config =
|
||||
{
|
||||
.data_rate = DR_1MBPS,
|
||||
.phy_el_cfg_init = XCVR_PHY_EL_CFG_EL_WIN_SIZE(0xF) |
|
||||
#if !RADIO_IS_GEN_2P1
|
||||
XCVR_PHY_EL_CFG_EL_ZB_WIN_SIZE(0) |
|
||||
#endif /* !RADIO_IS_GEN_2P1 */
|
||||
XCVR_PHY_EL_CFG_EL_INTERVAL(0x20) ,
|
||||
.rx_dig_ctrl_init_26mhz = XCVR_RX_DIG_RX_DIG_CTRL_RX_DEC_FILT_OSR(0) |
|
||||
XCVR_RX_DIG_RX_DIG_CTRL_RX_DEC_FILT_GAIN(16),
|
||||
.rx_dig_ctrl_init_32mhz = XCVR_RX_DIG_RX_DIG_CTRL_RX_DEC_FILT_OSR(1) |
|
||||
XCVR_RX_DIG_RX_DIG_CTRL_RX_DEC_FILT_GAIN(16),
|
||||
|
||||
.agc_ctrl_1_init_26mhz = XCVR_RX_DIG_AGC_CTRL_1_LNA_GAIN_SETTLE_TIME(10) |
|
||||
XCVR_RX_DIG_AGC_CTRL_1_PRESLOW_EN(PRESLOW_ENA),
|
||||
.agc_ctrl_1_init_32mhz = XCVR_RX_DIG_AGC_CTRL_1_LNA_GAIN_SETTLE_TIME(12) |
|
||||
XCVR_RX_DIG_AGC_CTRL_1_PRESLOW_EN(PRESLOW_ENA),
|
||||
|
||||
.dcoc_ctrl_0_init_26mhz = XCVR_RX_DIG_DCOC_CTRL_0_DCOC_CORR_DLY(10) |
|
||||
XCVR_RX_DIG_DCOC_CTRL_0_DCOC_CORR_HOLD_TIME(21),
|
||||
.dcoc_ctrl_0_init_32mhz = XCVR_RX_DIG_DCOC_CTRL_0_DCOC_CORR_DLY(12) |
|
||||
XCVR_RX_DIG_DCOC_CTRL_0_DCOC_CORR_HOLD_TIME(26),
|
||||
|
||||
.dcoc_ctrl_1_init_26mhz = XCVR_RX_DIG_DCOC_CTRL_1_DCOC_SIGN_SCALE_IDX(1) |
|
||||
XCVR_RX_DIG_DCOC_CTRL_1_DCOC_ALPHAC_SCALE_IDX(3) |
|
||||
XCVR_RX_DIG_DCOC_CTRL_1_DCOC_ALPHA_RADIUS_IDX(3) |
|
||||
XCVR_RX_DIG_DCOC_CTRL_1_DCOC_TRK_EST_GS_CNT(0) |
|
||||
XCVR_RX_DIG_DCOC_CTRL_1_DCOC_SIGN_SCALE_GS_IDX(1) |
|
||||
XCVR_RX_DIG_DCOC_CTRL_1_DCOC_ALPHAC_SCALE_GS_IDX(3) |
|
||||
XCVR_RX_DIG_DCOC_CTRL_1_DCOC_ALPHA_RADIUS_GS_IDX(3),
|
||||
|
||||
.dcoc_ctrl_1_init_32mhz = XCVR_RX_DIG_DCOC_CTRL_1_DCOC_SIGN_SCALE_IDX(1) |
|
||||
XCVR_RX_DIG_DCOC_CTRL_1_DCOC_ALPHAC_SCALE_IDX(3) |
|
||||
XCVR_RX_DIG_DCOC_CTRL_1_DCOC_ALPHA_RADIUS_IDX(3) |
|
||||
XCVR_RX_DIG_DCOC_CTRL_1_DCOC_TRK_EST_GS_CNT(0) |
|
||||
XCVR_RX_DIG_DCOC_CTRL_1_DCOC_SIGN_SCALE_GS_IDX(1) |
|
||||
XCVR_RX_DIG_DCOC_CTRL_1_DCOC_ALPHAC_SCALE_GS_IDX(3) |
|
||||
XCVR_RX_DIG_DCOC_CTRL_1_DCOC_ALPHA_RADIUS_GS_IDX(3),
|
||||
|
||||
.dcoc_cal_iir_init_26mhz = XCVR_RX_DIG_DCOC_CAL_IIR_DCOC_CAL_IIR3A_IDX(2) |
|
||||
XCVR_RX_DIG_DCOC_CAL_IIR_DCOC_CAL_IIR2A_IDX(2) |
|
||||
XCVR_RX_DIG_DCOC_CAL_IIR_DCOC_CAL_IIR1A_IDX(2),
|
||||
.dcoc_cal_iir_init_32mhz = XCVR_RX_DIG_DCOC_CAL_IIR_DCOC_CAL_IIR3A_IDX(2) |
|
||||
XCVR_RX_DIG_DCOC_CAL_IIR_DCOC_CAL_IIR2A_IDX(3) |
|
||||
XCVR_RX_DIG_DCOC_CAL_IIR_DCOC_CAL_IIR1A_IDX(2),
|
||||
|
||||
.dc_resid_ctrl_26mhz = XCVR_RX_DIG_DC_RESID_CTRL_DC_RESID_NWIN(33) |
|
||||
XCVR_RX_DIG_DC_RESID_CTRL_DC_RESID_DLY(6),
|
||||
.dc_resid_ctrl_32mhz = XCVR_RX_DIG_DC_RESID_CTRL_DC_RESID_NWIN(40) |
|
||||
XCVR_RX_DIG_DC_RESID_CTRL_DC_RESID_DLY(7),
|
||||
};
|
||||
|
||||
/*!
|
||||
* @brief XCVR 500K bps DATA RATE specific configure structure
|
||||
*/
|
||||
const xcvr_datarate_config_t xcvr_500kbps_config =
|
||||
{
|
||||
.data_rate = DR_500KBPS,
|
||||
.phy_el_cfg_init = XCVR_PHY_EL_CFG_EL_WIN_SIZE(0x8) |
|
||||
#if !RADIO_IS_GEN_2P1
|
||||
XCVR_PHY_EL_CFG_EL_ZB_WIN_SIZE(0) |
|
||||
#endif /* !RADIO_IS_GEN_2P1 */
|
||||
XCVR_PHY_EL_CFG_EL_INTERVAL(0x10),
|
||||
.rx_dig_ctrl_init_26mhz = XCVR_RX_DIG_RX_DIG_CTRL_RX_DEC_FILT_OSR(1) |
|
||||
XCVR_RX_DIG_RX_DIG_CTRL_RX_DEC_FILT_GAIN(16),
|
||||
.rx_dig_ctrl_init_32mhz = XCVR_RX_DIG_RX_DIG_CTRL_RX_DEC_FILT_OSR(2) |
|
||||
XCVR_RX_DIG_RX_DIG_CTRL_RX_DEC_FILT_GAIN(16),
|
||||
|
||||
.agc_ctrl_1_init_26mhz = XCVR_RX_DIG_AGC_CTRL_1_LNA_GAIN_SETTLE_TIME(15) |
|
||||
XCVR_RX_DIG_AGC_CTRL_1_PRESLOW_EN(PRESLOW_ENA),
|
||||
.agc_ctrl_1_init_32mhz = XCVR_RX_DIG_AGC_CTRL_1_LNA_GAIN_SETTLE_TIME(18) |
|
||||
XCVR_RX_DIG_AGC_CTRL_1_PRESLOW_EN(PRESLOW_ENA),
|
||||
|
||||
.dcoc_ctrl_0_init_26mhz = XCVR_RX_DIG_DCOC_CTRL_0_DCOC_CORR_DLY(13) |
|
||||
XCVR_RX_DIG_DCOC_CTRL_0_DCOC_CORR_HOLD_TIME(29),
|
||||
.dcoc_ctrl_0_init_32mhz = XCVR_RX_DIG_DCOC_CTRL_0_DCOC_CORR_DLY(16) |
|
||||
XCVR_RX_DIG_DCOC_CTRL_0_DCOC_CORR_HOLD_TIME(36),
|
||||
|
||||
.dcoc_ctrl_1_init_26mhz = XCVR_RX_DIG_DCOC_CTRL_1_DCOC_SIGN_SCALE_IDX(1) |
|
||||
XCVR_RX_DIG_DCOC_CTRL_1_DCOC_ALPHAC_SCALE_IDX(3) |
|
||||
XCVR_RX_DIG_DCOC_CTRL_1_DCOC_ALPHA_RADIUS_IDX(2) |
|
||||
XCVR_RX_DIG_DCOC_CTRL_1_DCOC_TRK_EST_GS_CNT(0) |
|
||||
XCVR_RX_DIG_DCOC_CTRL_1_DCOC_SIGN_SCALE_GS_IDX(1) |
|
||||
XCVR_RX_DIG_DCOC_CTRL_1_DCOC_ALPHAC_SCALE_GS_IDX(3) |
|
||||
XCVR_RX_DIG_DCOC_CTRL_1_DCOC_ALPHA_RADIUS_GS_IDX(2),
|
||||
|
||||
.dcoc_ctrl_1_init_32mhz = XCVR_RX_DIG_DCOC_CTRL_1_DCOC_SIGN_SCALE_IDX(1) |
|
||||
XCVR_RX_DIG_DCOC_CTRL_1_DCOC_ALPHAC_SCALE_IDX(3) |
|
||||
XCVR_RX_DIG_DCOC_CTRL_1_DCOC_ALPHA_RADIUS_IDX(2) |
|
||||
XCVR_RX_DIG_DCOC_CTRL_1_DCOC_TRK_EST_GS_CNT(0) |
|
||||
XCVR_RX_DIG_DCOC_CTRL_1_DCOC_SIGN_SCALE_GS_IDX(1) |
|
||||
XCVR_RX_DIG_DCOC_CTRL_1_DCOC_ALPHAC_SCALE_GS_IDX(3) |
|
||||
XCVR_RX_DIG_DCOC_CTRL_1_DCOC_ALPHA_RADIUS_GS_IDX(2),
|
||||
|
||||
.dcoc_cal_iir_init_26mhz = XCVR_RX_DIG_DCOC_CAL_IIR_DCOC_CAL_IIR3A_IDX(2) |
|
||||
XCVR_RX_DIG_DCOC_CAL_IIR_DCOC_CAL_IIR2A_IDX(2) |
|
||||
XCVR_RX_DIG_DCOC_CAL_IIR_DCOC_CAL_IIR1A_IDX(2),
|
||||
.dcoc_cal_iir_init_32mhz = XCVR_RX_DIG_DCOC_CAL_IIR_DCOC_CAL_IIR3A_IDX(2) |
|
||||
XCVR_RX_DIG_DCOC_CAL_IIR_DCOC_CAL_IIR2A_IDX(2) |
|
||||
XCVR_RX_DIG_DCOC_CAL_IIR_DCOC_CAL_IIR1A_IDX(2),
|
||||
|
||||
.dc_resid_ctrl_26mhz = XCVR_RX_DIG_DC_RESID_CTRL_DC_RESID_NWIN(26) |
|
||||
XCVR_RX_DIG_DC_RESID_CTRL_DC_RESID_DLY(4),
|
||||
.dc_resid_ctrl_32mhz = XCVR_RX_DIG_DC_RESID_CTRL_DC_RESID_NWIN(32) |
|
||||
XCVR_RX_DIG_DC_RESID_CTRL_DC_RESID_DLY(4),
|
||||
};
|
||||
|
||||
/*!
|
||||
* @brief XCVR 250K bps DATA RATE specific configure structure
|
||||
*/
|
||||
const xcvr_datarate_config_t xcvr_250kbps_config =
|
||||
{
|
||||
.data_rate = DR_250KBPS,
|
||||
.phy_el_cfg_init = XCVR_PHY_EL_CFG_EL_WIN_SIZE(0x4) |
|
||||
#if !RADIO_IS_GEN_2P1
|
||||
XCVR_PHY_EL_CFG_EL_ZB_WIN_SIZE(0) |
|
||||
#endif /* !RADIO_IS_GEN_2P1 */
|
||||
XCVR_PHY_EL_CFG_EL_INTERVAL(0x8) ,
|
||||
.rx_dig_ctrl_init_26mhz = XCVR_RX_DIG_RX_DIG_CTRL_RX_DEC_FILT_OSR(2) |
|
||||
XCVR_RX_DIG_RX_DIG_CTRL_RX_DEC_FILT_GAIN(16),
|
||||
.rx_dig_ctrl_init_32mhz = XCVR_RX_DIG_RX_DIG_CTRL_RX_DEC_FILT_OSR(4) |
|
||||
XCVR_RX_DIG_RX_DIG_CTRL_RX_DEC_FILT_GAIN(16),
|
||||
|
||||
.agc_ctrl_1_init_26mhz = XCVR_RX_DIG_AGC_CTRL_1_LNA_GAIN_SETTLE_TIME(18) |
|
||||
XCVR_RX_DIG_AGC_CTRL_1_PRESLOW_EN(PRESLOW_ENA),
|
||||
.agc_ctrl_1_init_32mhz = XCVR_RX_DIG_AGC_CTRL_1_LNA_GAIN_SETTLE_TIME(22) |
|
||||
XCVR_RX_DIG_AGC_CTRL_1_PRESLOW_EN(PRESLOW_ENA),
|
||||
|
||||
.dcoc_ctrl_0_init_26mhz = XCVR_RX_DIG_DCOC_CTRL_0_DCOC_CORR_DLY(16) |
|
||||
XCVR_RX_DIG_DCOC_CTRL_0_DCOC_CORR_HOLD_TIME(34),
|
||||
.dcoc_ctrl_0_init_32mhz = XCVR_RX_DIG_DCOC_CTRL_0_DCOC_CORR_DLY(20) |
|
||||
XCVR_RX_DIG_DCOC_CTRL_0_DCOC_CORR_HOLD_TIME(42),
|
||||
|
||||
.dcoc_ctrl_1_init_26mhz = XCVR_RX_DIG_DCOC_CTRL_1_DCOC_SIGN_SCALE_IDX(1) |
|
||||
XCVR_RX_DIG_DCOC_CTRL_1_DCOC_ALPHAC_SCALE_IDX(3) |
|
||||
XCVR_RX_DIG_DCOC_CTRL_1_DCOC_ALPHA_RADIUS_IDX(1) |
|
||||
XCVR_RX_DIG_DCOC_CTRL_1_DCOC_TRK_EST_GS_CNT(0) |
|
||||
XCVR_RX_DIG_DCOC_CTRL_1_DCOC_SIGN_SCALE_GS_IDX(1) |
|
||||
XCVR_RX_DIG_DCOC_CTRL_1_DCOC_ALPHAC_SCALE_GS_IDX(3) |
|
||||
XCVR_RX_DIG_DCOC_CTRL_1_DCOC_ALPHA_RADIUS_GS_IDX(2),
|
||||
|
||||
.dcoc_ctrl_1_init_32mhz = XCVR_RX_DIG_DCOC_CTRL_1_DCOC_SIGN_SCALE_IDX(1) |
|
||||
XCVR_RX_DIG_DCOC_CTRL_1_DCOC_ALPHAC_SCALE_IDX(3) |
|
||||
XCVR_RX_DIG_DCOC_CTRL_1_DCOC_ALPHA_RADIUS_IDX(1) |
|
||||
XCVR_RX_DIG_DCOC_CTRL_1_DCOC_TRK_EST_GS_CNT(0) |
|
||||
XCVR_RX_DIG_DCOC_CTRL_1_DCOC_SIGN_SCALE_GS_IDX(1) |
|
||||
XCVR_RX_DIG_DCOC_CTRL_1_DCOC_ALPHAC_SCALE_GS_IDX(3) |
|
||||
XCVR_RX_DIG_DCOC_CTRL_1_DCOC_ALPHA_RADIUS_GS_IDX(2),
|
||||
|
||||
.dcoc_cal_iir_init_26mhz = XCVR_RX_DIG_DCOC_CAL_IIR_DCOC_CAL_IIR3A_IDX(0) |
|
||||
XCVR_RX_DIG_DCOC_CAL_IIR_DCOC_CAL_IIR2A_IDX(1) |
|
||||
XCVR_RX_DIG_DCOC_CAL_IIR_DCOC_CAL_IIR1A_IDX(1),
|
||||
.dcoc_cal_iir_init_32mhz = XCVR_RX_DIG_DCOC_CAL_IIR_DCOC_CAL_IIR3A_IDX(0) |
|
||||
XCVR_RX_DIG_DCOC_CAL_IIR_DCOC_CAL_IIR2A_IDX(1) |
|
||||
XCVR_RX_DIG_DCOC_CAL_IIR_DCOC_CAL_IIR1A_IDX(1),
|
||||
|
||||
.dc_resid_ctrl_26mhz = XCVR_RX_DIG_DC_RESID_CTRL_DC_RESID_NWIN(13) |
|
||||
XCVR_RX_DIG_DC_RESID_CTRL_DC_RESID_DLY(4),
|
||||
.dc_resid_ctrl_32mhz = XCVR_RX_DIG_DC_RESID_CTRL_DC_RESID_NWIN(16) |
|
||||
XCVR_RX_DIG_DC_RESID_CTRL_DC_RESID_DLY(4),
|
||||
};
|
||||
|
||||
@@ -1,343 +0,0 @@
|
||||
/*
|
||||
* Copyright 2016-2017 NXP
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* o Redistributions of source code must retain the above copyright notice, this list
|
||||
* of conditions and the following disclaimer.
|
||||
*
|
||||
* o 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.
|
||||
*
|
||||
* o Neither the name of Freescale Semiconductor, Inc. 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 HOLDER 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 "fsl_xcvr.h"
|
||||
|
||||
/*******************************************************************************
|
||||
* Definitions
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* Prototypes
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* Variables
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* Code
|
||||
******************************************************************************/
|
||||
/* MODE only configuration */
|
||||
const xcvr_mode_config_t msk_mode_config =
|
||||
{
|
||||
.radio_mode = MSK,
|
||||
.scgc5_clock_ena_bits = SIM_SCGC5_PHYDIG_MASK | SIM_SCGC5_GEN_FSK_MASK,
|
||||
|
||||
/* XCVR_MISC configs */
|
||||
.xcvr_ctrl.mask = XCVR_CTRL_XCVR_CTRL_PROTOCOL_MASK |
|
||||
XCVR_CTRL_XCVR_CTRL_TGT_PWR_SRC_MASK |
|
||||
XCVR_CTRL_XCVR_CTRL_DEMOD_SEL_MASK,
|
||||
.xcvr_ctrl.init = XCVR_CTRL_XCVR_CTRL_PROTOCOL(9) |
|
||||
XCVR_CTRL_XCVR_CTRL_TGT_PWR_SRC(4) |
|
||||
XCVR_CTRL_XCVR_CTRL_DEMOD_SEL(1),
|
||||
|
||||
/* XCVR_PHY configs */
|
||||
.phy_pre_ref0_init = 0x79CDEB38,
|
||||
.phy_pre_ref1_init = 0xCE77DFF7,
|
||||
.phy_pre_ref2_init = 0x0000CEB7,
|
||||
|
||||
.phy_cfg1_init = XCVR_PHY_CFG1_AA_PLAYBACK(0) |
|
||||
XCVR_PHY_CFG1_AA_OUTPUT_SEL(1) |
|
||||
XCVR_PHY_CFG1_FSK_BIT_INVERT(0) |
|
||||
XCVR_PHY_CFG1_BSM_EN_BLE(0) |
|
||||
XCVR_PHY_CFG1_DEMOD_CLK_MODE(0) |
|
||||
XCVR_PHY_CFG1_CTS_THRESH(208U) |
|
||||
XCVR_PHY_CFG1_FSK_FTS_TIMEOUT(2),
|
||||
|
||||
.phy_el_cfg_init = XCVR_PHY_EL_CFG_EL_ENABLE(1)
|
||||
#if !RADIO_IS_GEN_2P1
|
||||
| XCVR_PHY_EL_CFG_EL_ZB_ENABLE(0)
|
||||
#endif /* !RADIO_IS_GEN_2P1 */
|
||||
,
|
||||
|
||||
/* XCVR_RX_DIG configs */
|
||||
.rx_dig_ctrl_init_26mhz = XCVR_RX_DIG_RX_DIG_CTRL_RX_FSK_ZB_SEL(0) | /* Depends on protocol */
|
||||
XCVR_RX_DIG_RX_DIG_CTRL_RX_DC_RESID_EN(1) | /* Depends on protocol */
|
||||
XCVR_RX_DIG_RX_DIG_CTRL_RX_SRC_RATE(0),
|
||||
|
||||
.rx_dig_ctrl_init_32mhz = XCVR_RX_DIG_RX_DIG_CTRL_RX_FSK_ZB_SEL(0) | /* Depends on protocol */
|
||||
XCVR_RX_DIG_RX_DIG_CTRL_RX_DC_RESID_EN(1), /* Depends on protocol */
|
||||
|
||||
.agc_ctrl_0_init = XCVR_RX_DIG_AGC_CTRL_0_AGC_DOWN_RSSI_THRESH(0xFF),
|
||||
|
||||
/* XCVR_TSM configs */
|
||||
#if (DATA_PADDING_EN)
|
||||
.tsm_timing_35_init = B0(TX_DIG_EN_ASSERT+TX_DIG_EN_TX_HI_ADJ),
|
||||
#else
|
||||
.tsm_timing_35_init = B0(TX_DIG_EN_ASSERT),
|
||||
#endif /* (DATA_PADDING_EN) */
|
||||
|
||||
/* XCVR_TX_DIG configs */
|
||||
.tx_gfsk_ctrl = XCVR_TX_DIG_GFSK_CTRL_GFSK_MULTIPLY_TABLE_MANUAL(0x4000) |
|
||||
XCVR_TX_DIG_GFSK_CTRL_GFSK_MI(0) |
|
||||
XCVR_TX_DIG_GFSK_CTRL_GFSK_MLD(0) |
|
||||
XCVR_TX_DIG_GFSK_CTRL_GFSK_FLD(0) |
|
||||
XCVR_TX_DIG_GFSK_CTRL_GFSK_MOD_INDEX_SCALING(0) |
|
||||
XCVR_TX_DIG_GFSK_CTRL_TX_IMAGE_FILTER_OVRD_EN(0) |
|
||||
XCVR_TX_DIG_GFSK_CTRL_TX_IMAGE_FILTER_0_OVRD(0) |
|
||||
XCVR_TX_DIG_GFSK_CTRL_TX_IMAGE_FILTER_1_OVRD(0) |
|
||||
XCVR_TX_DIG_GFSK_CTRL_TX_IMAGE_FILTER_2_OVRD(0),
|
||||
.tx_gfsk_coeff1_26mhz = 0,
|
||||
.tx_gfsk_coeff2_26mhz = 0,
|
||||
.tx_gfsk_coeff1_32mhz = 0,
|
||||
.tx_gfsk_coeff2_32mhz = 0,
|
||||
};
|
||||
|
||||
/* MODE & DATA RATE combined configuration */
|
||||
const xcvr_mode_datarate_config_t xcvr_MSK_1mbps_config =
|
||||
{
|
||||
.radio_mode = MSK,
|
||||
.data_rate = DR_1MBPS,
|
||||
|
||||
.ana_sy_ctrl2.mask = XCVR_ANALOG_SY_CTRL_2_SY_VCO_KVM_MASK,
|
||||
.ana_sy_ctrl2.init = XCVR_ANALOG_SY_CTRL_2_SY_VCO_KVM(0), /* VCO KVM */
|
||||
.ana_rx_bba.mask = XCVR_ANALOG_RX_BBA_RX_BBA_BW_SEL_MASK | XCVR_ANALOG_RX_BBA_RX_BBA2_BW_SEL_MASK,
|
||||
.ana_rx_bba.init = XCVR_ANALOG_RX_BBA_RX_BBA_BW_SEL(3) | XCVR_ANALOG_RX_BBA_RX_BBA2_BW_SEL(3), /* BBA_BW_SEL and BBA2_BW_SEL */
|
||||
.ana_rx_tza.mask = XCVR_ANALOG_RX_TZA_RX_TZA_BW_SEL_MASK,
|
||||
.ana_rx_tza.init = XCVR_ANALOG_RX_TZA_RX_TZA_BW_SEL(3), /*TZA_BW_SEL */
|
||||
|
||||
.phy_cfg2_init = XCVR_PHY_CFG2_PHY_FIFO_PRECHG(8) |
|
||||
XCVR_PHY_CFG2_X2_DEMOD_GAIN(0xA) ,
|
||||
|
||||
/* AGC configs */
|
||||
.agc_ctrl_2_init_26mhz = XCVR_RX_DIG_AGC_CTRL_2_BBA_GAIN_SETTLE_TIME(11) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_BBA_PDET_SEL_LO(5) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_BBA_PDET_SEL_HI(6) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_TZA_PDET_SEL_LO(3) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_TZA_PDET_SEL_HI(7) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_AGC_FAST_EXPIRE(5),
|
||||
.agc_ctrl_2_init_32mhz = XCVR_RX_DIG_AGC_CTRL_2_BBA_GAIN_SETTLE_TIME(12) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_BBA_PDET_SEL_LO(5) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_BBA_PDET_SEL_HI(6) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_TZA_PDET_SEL_LO(3) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_TZA_PDET_SEL_HI(7) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_AGC_FAST_EXPIRE(5),
|
||||
|
||||
/* All constant values are represented as 16 bits, register writes will remove unused bits */
|
||||
/* MSK 1MBPS channel filter @ 26MHz RF OSC */
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_0 = 0x0002,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_1 = 0x0002,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_2 = 0x0000,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_3 = 0xFFF9,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_4 = 0xFFF0,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_5 = 0xFFEA,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_6 = 0xFFEC,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_7 = 0xFFFC,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_8 = 0x001B,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_9 = 0x0042,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_10 = 0x0066,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_11 = 0x007C,
|
||||
|
||||
/* MSK 1MBPS channel filter @ 32MHz RF OSC */
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_0 = 0x0002,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_1 = 0x0003,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_2 = 0x0002,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_3 = 0xFFFC,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_4 = 0xFFF2,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_5 = 0xFFE9,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_6 = 0xFFE9,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_7 = 0xFFF7,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_8 = 0x0016,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_9 = 0x0040,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_10 = 0x0069,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_11 = 0x0082,
|
||||
|
||||
.rx_rccal_ctrl_0 = XCVR_RX_DIG_RX_RCCAL_CTRL0_BBA_RCCAL_OFFSET(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_BBA_RCCAL_MANUAL(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_BBA_RCCAL_DIS(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_RCCAL_SMP_DLY(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_RCCAL_COMP_INV(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_TZA_RCCAL_OFFSET(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_TZA_RCCAL_MANUAL(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_TZA_RCCAL_DIS(0) ,
|
||||
.rx_rccal_ctrl_1 = XCVR_RX_DIG_RX_RCCAL_CTRL1_ADC_RCCAL_OFFSET(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL1_ADC_RCCAL_MANUAL(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL1_ADC_RCCAL_DIS(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL1_BBA2_RCCAL_OFFSET(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL1_BBA2_RCCAL_MANUAL(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL1_BBA2_RCCAL_DIS(0) ,
|
||||
|
||||
.tx_fsk_scale_26mhz = XCVR_TX_DIG_FSK_SCALE_FSK_MODULATION_SCALE_0(0x1627) | XCVR_TX_DIG_FSK_SCALE_FSK_MODULATION_SCALE_1(0x09d9),
|
||||
.tx_fsk_scale_32mhz = XCVR_TX_DIG_FSK_SCALE_FSK_MODULATION_SCALE_0(0x1800) | XCVR_TX_DIG_FSK_SCALE_FSK_MODULATION_SCALE_1(0x0800),
|
||||
};
|
||||
|
||||
const xcvr_mode_datarate_config_t xcvr_MSK_500kbps_config =
|
||||
{
|
||||
.radio_mode = MSK,
|
||||
.data_rate = DR_500KBPS,
|
||||
|
||||
.ana_sy_ctrl2.mask = XCVR_ANALOG_SY_CTRL_2_SY_VCO_KVM_MASK,
|
||||
.ana_sy_ctrl2.init = XCVR_ANALOG_SY_CTRL_2_SY_VCO_KVM(0), /* VCO KVM */
|
||||
.ana_rx_bba.mask = XCVR_ANALOG_RX_BBA_RX_BBA_BW_SEL_MASK | XCVR_ANALOG_RX_BBA_RX_BBA2_BW_SEL_MASK,
|
||||
.ana_rx_bba.init = XCVR_ANALOG_RX_BBA_RX_BBA_BW_SEL(5) | XCVR_ANALOG_RX_BBA_RX_BBA2_BW_SEL(5), /* BBA_BW_SEL and BBA2_BW_SEL */
|
||||
.ana_rx_tza.mask = XCVR_ANALOG_RX_TZA_RX_TZA_BW_SEL_MASK,
|
||||
.ana_rx_tza.init = XCVR_ANALOG_RX_TZA_RX_TZA_BW_SEL(5), /* TZA_BW_SEL */
|
||||
|
||||
.phy_cfg2_init = XCVR_PHY_CFG2_PHY_FIFO_PRECHG(8) |
|
||||
XCVR_PHY_CFG2_X2_DEMOD_GAIN(0xa) ,
|
||||
|
||||
/* AGC configs */
|
||||
.agc_ctrl_2_init_26mhz = XCVR_RX_DIG_AGC_CTRL_2_BBA_GAIN_SETTLE_TIME(15) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_BBA_PDET_SEL_LO(5) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_BBA_PDET_SEL_HI(6) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_TZA_PDET_SEL_LO(3) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_TZA_PDET_SEL_HI(7) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_AGC_FAST_EXPIRE(5),
|
||||
.agc_ctrl_2_init_32mhz = XCVR_RX_DIG_AGC_CTRL_2_BBA_GAIN_SETTLE_TIME(18) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_BBA_PDET_SEL_LO(5) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_BBA_PDET_SEL_HI(6) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_TZA_PDET_SEL_LO(3) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_TZA_PDET_SEL_HI(7) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_AGC_FAST_EXPIRE(5),
|
||||
|
||||
/* All constant values are represented as 16 bits, register writes will remove unused bits */
|
||||
/* MSK 500KBPS channel filter @ 26MHz RF OSC */
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_0 = 0x0001,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_1 = 0x0004,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_2 = 0x0006,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_3 = 0x0005,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_4 = 0xFFFC,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_5 = 0xFFED,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_6 = 0xFFE2,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_7 = 0xFFE7,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_8 = 0x0005,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_9 = 0x0038,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_10 = 0x006F,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_11 = 0x0092,
|
||||
|
||||
/* MSK 500KBPS channel filter @ 32MHz RF OSC */
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_0 = 0xFFFF,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_1 = 0x0002,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_2 = 0x0006,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_3 = 0x0009,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_4 = 0x0003,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_5 = 0xFFF3,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_6 = 0xFFE2,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_7 = 0xFFE0,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_8 = 0xFFFA,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_9 = 0x0031,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_10 = 0x0071,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_11 = 0x009C,
|
||||
|
||||
.rx_rccal_ctrl_0 = XCVR_RX_DIG_RX_RCCAL_CTRL0_BBA_RCCAL_OFFSET(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_BBA_RCCAL_MANUAL(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_BBA_RCCAL_DIS(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_RCCAL_SMP_DLY(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_RCCAL_COMP_INV(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_TZA_RCCAL_OFFSET(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_TZA_RCCAL_MANUAL(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_TZA_RCCAL_DIS(0) ,
|
||||
.rx_rccal_ctrl_1 = XCVR_RX_DIG_RX_RCCAL_CTRL1_ADC_RCCAL_OFFSET(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL1_ADC_RCCAL_MANUAL(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL1_ADC_RCCAL_DIS(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL1_BBA2_RCCAL_OFFSET(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL1_BBA2_RCCAL_MANUAL(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL1_BBA2_RCCAL_DIS(0) ,
|
||||
|
||||
.tx_fsk_scale_26mhz = XCVR_TX_DIG_FSK_SCALE_FSK_MODULATION_SCALE_0(0x1627) | XCVR_TX_DIG_FSK_SCALE_FSK_MODULATION_SCALE_1(0x09d9),
|
||||
.tx_fsk_scale_32mhz = XCVR_TX_DIG_FSK_SCALE_FSK_MODULATION_SCALE_0(0x1800) | XCVR_TX_DIG_FSK_SCALE_FSK_MODULATION_SCALE_1(0x0800),
|
||||
};
|
||||
|
||||
const xcvr_mode_datarate_config_t xcvr_MSK_250kbps_config =
|
||||
{
|
||||
.radio_mode = MSK,
|
||||
.data_rate = DR_250KBPS,
|
||||
|
||||
.ana_sy_ctrl2.mask = XCVR_ANALOG_SY_CTRL_2_SY_VCO_KVM_MASK,
|
||||
.ana_sy_ctrl2.init = XCVR_ANALOG_SY_CTRL_2_SY_VCO_KVM(0), /* VCO KVM */
|
||||
.ana_rx_bba.mask = XCVR_ANALOG_RX_BBA_RX_BBA_BW_SEL_MASK | XCVR_ANALOG_RX_BBA_RX_BBA2_BW_SEL_MASK,
|
||||
.ana_rx_bba.init = XCVR_ANALOG_RX_BBA_RX_BBA_BW_SEL(5) | XCVR_ANALOG_RX_BBA_RX_BBA2_BW_SEL(5), /* BBA_BW_SEL and BBA2_BW_SEL */
|
||||
.ana_rx_tza.mask = XCVR_ANALOG_RX_TZA_RX_TZA_BW_SEL_MASK,
|
||||
.ana_rx_tza.init = XCVR_ANALOG_RX_TZA_RX_TZA_BW_SEL(5), /* TZA_BW_SEL */
|
||||
|
||||
.phy_cfg2_init = XCVR_PHY_CFG2_PHY_FIFO_PRECHG(8) |
|
||||
XCVR_PHY_CFG2_X2_DEMOD_GAIN(0x8) ,
|
||||
|
||||
/* AGC configs */
|
||||
.agc_ctrl_2_init_26mhz = XCVR_RX_DIG_AGC_CTRL_2_BBA_GAIN_SETTLE_TIME(18) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_BBA_PDET_SEL_LO(5) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_BBA_PDET_SEL_HI(2) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_TZA_PDET_SEL_LO(3) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_TZA_PDET_SEL_HI(7) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_AGC_FAST_EXPIRE(5),
|
||||
.agc_ctrl_2_init_32mhz = XCVR_RX_DIG_AGC_CTRL_2_BBA_GAIN_SETTLE_TIME(22) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_BBA_PDET_SEL_LO(5) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_BBA_PDET_SEL_HI(6) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_TZA_PDET_SEL_LO(3) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_TZA_PDET_SEL_HI(7) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_AGC_FAST_EXPIRE(5),
|
||||
|
||||
/* All constant values are represented as 16 bits, register writes will remove unused bits */
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_0 = 0x0002,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_1 = 0xFFFF,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_2 = 0xFFF8,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_3 = 0xFFFA,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_4 = 0x000A,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_5 = 0x0019,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_6 = 0x0009,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_7 = 0xFFDB,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_8 = 0xFFC1,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_9 = 0xFFF6,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_10 = 0x0072,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_11 = 0x00DD,
|
||||
|
||||
/* MSK 250KBPS channel filter @ 32MHz RF OSC */
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_0 = 0x0002,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_1 = 0x0003,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_2 = 0xFFFC,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_3 = 0xFFF4,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_4 = 0xFFFD,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_5 = 0x0016,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_6 = 0x001A,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_7 = 0xFFEC,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_8 = 0xFFBC,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_9 = 0xFFE0,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_10 = 0x0069,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_11 = 0x00ED,
|
||||
|
||||
.rx_rccal_ctrl_0 = XCVR_RX_DIG_RX_RCCAL_CTRL0_BBA_RCCAL_OFFSET(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_BBA_RCCAL_MANUAL(31) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_BBA_RCCAL_DIS(1) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_RCCAL_SMP_DLY(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_RCCAL_COMP_INV(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_TZA_RCCAL_OFFSET(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_TZA_RCCAL_MANUAL(31) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_TZA_RCCAL_DIS(1) ,
|
||||
.rx_rccal_ctrl_1 = XCVR_RX_DIG_RX_RCCAL_CTRL1_ADC_RCCAL_OFFSET(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL1_ADC_RCCAL_MANUAL(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL1_ADC_RCCAL_DIS(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL1_BBA2_RCCAL_OFFSET(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL1_BBA2_RCCAL_MANUAL(31) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL1_BBA2_RCCAL_DIS(1) ,
|
||||
|
||||
.tx_fsk_scale_26mhz = XCVR_TX_DIG_FSK_SCALE_FSK_MODULATION_SCALE_0(0x1627) | XCVR_TX_DIG_FSK_SCALE_FSK_MODULATION_SCALE_1(0x09d9),
|
||||
.tx_fsk_scale_32mhz = XCVR_TX_DIG_FSK_SCALE_FSK_MODULATION_SCALE_0(0x1800) | XCVR_TX_DIG_FSK_SCALE_FSK_MODULATION_SCALE_1(0x0800),
|
||||
};
|
||||
|
||||
@@ -1,244 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Freescale Semiconductor, Inc.
|
||||
* Copyright 2016-2017 NXP
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* o Redistributions of source code must retain the above copyright notice, this list
|
||||
* of conditions and the following disclaimer.
|
||||
*
|
||||
* o 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.
|
||||
*
|
||||
* o Neither the name of Freescale Semiconductor, Inc. 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 HOLDER 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 "fsl_xcvr.h"
|
||||
|
||||
/*******************************************************************************
|
||||
* Definitions
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* Prototypes
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* Variables
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* Code
|
||||
******************************************************************************/
|
||||
const xcvr_mode_config_t zgbe_mode_config =
|
||||
{
|
||||
.radio_mode = ZIGBEE_MODE,
|
||||
.scgc5_clock_ena_bits = SIM_SCGC5_PHYDIG_MASK | SIM_SCGC5_ZigBee_MASK,
|
||||
|
||||
/* XCVR_MISC configs */
|
||||
.xcvr_ctrl.mask = XCVR_CTRL_XCVR_CTRL_PROTOCOL_MASK |
|
||||
XCVR_CTRL_XCVR_CTRL_TGT_PWR_SRC_MASK |
|
||||
XCVR_CTRL_XCVR_CTRL_DEMOD_SEL_MASK,
|
||||
.xcvr_ctrl.init = XCVR_CTRL_XCVR_CTRL_PROTOCOL(4) |
|
||||
XCVR_CTRL_XCVR_CTRL_TGT_PWR_SRC(7) |
|
||||
XCVR_CTRL_XCVR_CTRL_DEMOD_SEL(2),
|
||||
|
||||
/* XCVR_PHY configs */
|
||||
.phy_pre_ref0_init = 0x0, /* Not used in Zigbee */
|
||||
.phy_pre_ref1_init = 0x0, /* Not used in Zigbee */
|
||||
.phy_pre_ref2_init = 0x0, /* Not used in Zigbee */
|
||||
|
||||
.phy_cfg1_init = XCVR_PHY_CFG1_AA_PLAYBACK(0) |
|
||||
XCVR_PHY_CFG1_AA_OUTPUT_SEL(1) |
|
||||
XCVR_PHY_CFG1_FSK_BIT_INVERT(0) |
|
||||
XCVR_PHY_CFG1_BSM_EN_BLE(0) |
|
||||
XCVR_PHY_CFG1_DEMOD_CLK_MODE(0) |
|
||||
XCVR_PHY_CFG1_CTS_THRESH(0xC0) |
|
||||
XCVR_PHY_CFG1_FSK_FTS_TIMEOUT(2),
|
||||
|
||||
.phy_el_cfg_init = XCVR_PHY_EL_CFG_EL_ENABLE(1)
|
||||
#if !RADIO_IS_GEN_2P1
|
||||
| XCVR_PHY_EL_CFG_EL_ZB_ENABLE(0)
|
||||
#endif /* !RADIO_IS_GEN_2P1 */
|
||||
,
|
||||
|
||||
/* XCVR_PLL_DIG configs */
|
||||
|
||||
/* XCVR_RX_DIG configs */
|
||||
.rx_dig_ctrl_init_26mhz = XCVR_RX_DIG_RX_DIG_CTRL_RX_FSK_ZB_SEL(1) | /* Depends on protocol */
|
||||
XCVR_RX_DIG_RX_DIG_CTRL_RX_DC_RESID_EN(1) | /* Depends on protocol */
|
||||
XCVR_RX_DIG_RX_DIG_CTRL_RX_SRC_RATE(0),
|
||||
|
||||
.rx_dig_ctrl_init_32mhz = XCVR_RX_DIG_RX_DIG_CTRL_RX_FSK_ZB_SEL(1) | /* Depends on protocol */
|
||||
XCVR_RX_DIG_RX_DIG_CTRL_RX_DC_RESID_EN(1), /* Depends on protocol */
|
||||
|
||||
.agc_ctrl_0_init = XCVR_RX_DIG_AGC_CTRL_0_AGC_DOWN_RSSI_THRESH(0xFF),
|
||||
/* XCVR_TSM configs */
|
||||
#if (DATA_PADDING_EN)
|
||||
.tsm_timing_35_init = B0(TX_DIG_EN_ASSERT+ZGBE_TX_DIG_EN_TX_HI_ADJ), /* DATA_PADDING adjustments are specified relative to the non-Zigbee base timing */
|
||||
#else
|
||||
.tsm_timing_35_init = B0(ZGBE_TX_DIG_EN_ASSERT),
|
||||
#endif /* (DATA_PADDING_EN) */
|
||||
|
||||
/* XCVR_TX_DIG configs */
|
||||
.tx_gfsk_ctrl = XCVR_TX_DIG_GFSK_CTRL_GFSK_MULTIPLY_TABLE_MANUAL(0x4000) |
|
||||
XCVR_TX_DIG_GFSK_CTRL_GFSK_MI(1) |
|
||||
XCVR_TX_DIG_GFSK_CTRL_GFSK_MLD(0) |
|
||||
XCVR_TX_DIG_GFSK_CTRL_GFSK_FLD(0) |
|
||||
XCVR_TX_DIG_GFSK_CTRL_GFSK_MOD_INDEX_SCALING(0) |
|
||||
XCVR_TX_DIG_GFSK_CTRL_TX_IMAGE_FILTER_OVRD_EN(0) |
|
||||
XCVR_TX_DIG_GFSK_CTRL_TX_IMAGE_FILTER_0_OVRD(0) |
|
||||
XCVR_TX_DIG_GFSK_CTRL_TX_IMAGE_FILTER_1_OVRD(0) |
|
||||
XCVR_TX_DIG_GFSK_CTRL_TX_IMAGE_FILTER_2_OVRD(0) ,
|
||||
.tx_gfsk_coeff1_26mhz = 0,
|
||||
.tx_gfsk_coeff2_26mhz = 0,
|
||||
.tx_gfsk_coeff1_32mhz = 0,
|
||||
.tx_gfsk_coeff2_32mhz = 0,
|
||||
};
|
||||
|
||||
const xcvr_mode_datarate_config_t xcvr_ZIGBEE_500kbps_config =
|
||||
{
|
||||
.radio_mode = ZIGBEE_MODE,
|
||||
.data_rate = DR_500KBPS,
|
||||
|
||||
.ana_sy_ctrl2.mask = XCVR_ANALOG_SY_CTRL_2_SY_VCO_KVM_MASK,
|
||||
.ana_sy_ctrl2.init = XCVR_ANALOG_SY_CTRL_2_SY_VCO_KVM(1), /* VCO KVM */
|
||||
|
||||
.ana_rx_bba.mask = XCVR_ANALOG_RX_BBA_RX_BBA_BW_SEL_MASK | XCVR_ANALOG_RX_BBA_RX_BBA2_BW_SEL_MASK,
|
||||
.ana_rx_bba.init = XCVR_ANALOG_RX_BBA_RX_BBA_BW_SEL(1) | XCVR_ANALOG_RX_BBA_RX_BBA2_BW_SEL(1), /* BBA_BW_SEL and BBA2_BW_SEL */
|
||||
.ana_rx_tza.mask = XCVR_ANALOG_RX_TZA_RX_TZA_BW_SEL_MASK,
|
||||
.ana_rx_tza.init = XCVR_ANALOG_RX_TZA_RX_TZA_BW_SEL(1), /*TZA_BW_SEL */
|
||||
|
||||
.phy_cfg2_init = XCVR_PHY_CFG2_PHY_FIFO_PRECHG(8) |
|
||||
XCVR_PHY_CFG2_X2_DEMOD_GAIN(0xA) ,
|
||||
|
||||
/* AGC configs */
|
||||
.agc_ctrl_2_init_26mhz = XCVR_RX_DIG_AGC_CTRL_2_BBA_GAIN_SETTLE_TIME(8) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_BBA_PDET_SEL_LO(5) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_BBA_PDET_SEL_HI(6) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_TZA_PDET_SEL_LO(3) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_TZA_PDET_SEL_HI(5) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_AGC_FAST_EXPIRE(5),
|
||||
.agc_ctrl_2_init_32mhz = XCVR_RX_DIG_AGC_CTRL_2_BBA_GAIN_SETTLE_TIME(10) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_BBA_PDET_SEL_LO(5) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_BBA_PDET_SEL_HI(6) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_TZA_PDET_SEL_LO(3) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_TZA_PDET_SEL_HI(5) |
|
||||
XCVR_RX_DIG_AGC_CTRL_2_AGC_FAST_EXPIRE(5),
|
||||
|
||||
/* All constant values are represented as 16 bits, register writes will remove unused bits */
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_0 = 0xFFFF,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_1 = 0xFFFF,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_2 = 0x0002,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_3 = 0x0008,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_4 = 0x000A,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_5 = 0x0000,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_6 = 0xFFE8,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_7 = 0xFFD7,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_8 = 0xFFE6,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_9 = 0x0022,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_10 = 0x0075,
|
||||
.rx_chf_coeffs_26mhz.rx_chf_coef_11 = 0x00B2,
|
||||
|
||||
/* IEEE 802.15.4 32MHz Channel Filter -- 1.55/1.25/5/0.97/B5 */
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_0 = 0xFFFF,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_1 = 0xFFFF,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_2 = 0x0005,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_3 = 0x0004,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_4 = 0xFFF2,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_5 = 0xFFF2,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_6 = 0x001D,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_7 = 0x0025,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_8 = 0xFFCE,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_9 = 0xFFA1,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_10 = 0x0040,
|
||||
.rx_chf_coeffs_32mhz.rx_chf_coef_11 = 0x0124,
|
||||
|
||||
.rx_rccal_ctrl_0 = XCVR_RX_DIG_RX_RCCAL_CTRL0_BBA_RCCAL_OFFSET(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_BBA_RCCAL_MANUAL(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_BBA_RCCAL_DIS(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_RCCAL_SMP_DLY(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_RCCAL_COMP_INV(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_TZA_RCCAL_OFFSET(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_TZA_RCCAL_MANUAL(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL0_TZA_RCCAL_DIS(0) ,
|
||||
.rx_rccal_ctrl_1 = XCVR_RX_DIG_RX_RCCAL_CTRL1_ADC_RCCAL_OFFSET(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL1_ADC_RCCAL_MANUAL(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL1_ADC_RCCAL_DIS(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL1_BBA2_RCCAL_OFFSET(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL1_BBA2_RCCAL_MANUAL(0) |
|
||||
XCVR_RX_DIG_RX_RCCAL_CTRL1_BBA2_RCCAL_DIS(0) ,
|
||||
|
||||
.tx_fsk_scale_26mhz = XCVR_TX_DIG_FSK_SCALE_FSK_MODULATION_SCALE_0(0x1627) | XCVR_TX_DIG_FSK_SCALE_FSK_MODULATION_SCALE_1(0x09d9),
|
||||
.tx_fsk_scale_32mhz = XCVR_TX_DIG_FSK_SCALE_FSK_MODULATION_SCALE_0(0x1800) | XCVR_TX_DIG_FSK_SCALE_FSK_MODULATION_SCALE_1(0x0800),
|
||||
};
|
||||
|
||||
/* CUSTOM datarate dependent config structure for ONLY 802.15.4 */
|
||||
/*!
|
||||
* @brief XCVR 500K bps DATA RATE specific configure structure
|
||||
*/
|
||||
const xcvr_datarate_config_t xcvr_802_15_4_500kbps_config =
|
||||
{
|
||||
.data_rate = DR_500KBPS,
|
||||
.phy_el_cfg_init = XCVR_PHY_EL_CFG_EL_ZB_WIN_SIZE(0) |
|
||||
XCVR_PHY_EL_CFG_EL_WIN_SIZE(0x8) |
|
||||
XCVR_PHY_EL_CFG_EL_INTERVAL(0x10) ,
|
||||
.rx_dig_ctrl_init_26mhz = XCVR_RX_DIG_RX_DIG_CTRL_RX_DEC_FILT_OSR(1) |
|
||||
XCVR_RX_DIG_RX_DIG_CTRL_RX_DEC_FILT_GAIN(16),
|
||||
.rx_dig_ctrl_init_32mhz = XCVR_RX_DIG_RX_DIG_CTRL_RX_DEC_FILT_OSR(2) |
|
||||
XCVR_RX_DIG_RX_DIG_CTRL_RX_DEC_FILT_GAIN(16),
|
||||
|
||||
.agc_ctrl_1_init_26mhz = XCVR_RX_DIG_AGC_CTRL_1_LNA_GAIN_SETTLE_TIME(13) |
|
||||
XCVR_RX_DIG_AGC_CTRL_1_PRESLOW_EN(PRESLOW_ENA),
|
||||
.agc_ctrl_1_init_32mhz = XCVR_RX_DIG_AGC_CTRL_1_LNA_GAIN_SETTLE_TIME(10) |
|
||||
XCVR_RX_DIG_AGC_CTRL_1_PRESLOW_EN(PRESLOW_ENA),
|
||||
|
||||
.dcoc_ctrl_0_init_26mhz = XCVR_RX_DIG_DCOC_CTRL_0_DCOC_CORR_DLY(13) |
|
||||
XCVR_RX_DIG_DCOC_CTRL_0_DCOC_CORR_HOLD_TIME(29),
|
||||
.dcoc_ctrl_0_init_32mhz = XCVR_RX_DIG_DCOC_CTRL_0_DCOC_CORR_DLY(21) |
|
||||
XCVR_RX_DIG_DCOC_CTRL_0_DCOC_CORR_HOLD_TIME(47),
|
||||
|
||||
.dcoc_ctrl_1_init_26mhz = XCVR_RX_DIG_DCOC_CTRL_1_DCOC_SIGN_SCALE_IDX(1) |
|
||||
XCVR_RX_DIG_DCOC_CTRL_1_DCOC_ALPHAC_SCALE_IDX(3) |
|
||||
XCVR_RX_DIG_DCOC_CTRL_1_DCOC_ALPHA_RADIUS_IDX(2) |
|
||||
XCVR_RX_DIG_DCOC_CTRL_1_DCOC_TRK_EST_GS_CNT(0) |
|
||||
XCVR_RX_DIG_DCOC_CTRL_1_DCOC_SIGN_SCALE_GS_IDX(1) |
|
||||
XCVR_RX_DIG_DCOC_CTRL_1_DCOC_ALPHAC_SCALE_GS_IDX(3) |
|
||||
XCVR_RX_DIG_DCOC_CTRL_1_DCOC_ALPHA_RADIUS_GS_IDX(2),
|
||||
|
||||
.dcoc_ctrl_1_init_32mhz = XCVR_RX_DIG_DCOC_CTRL_1_DCOC_SIGN_SCALE_IDX(1) |
|
||||
XCVR_RX_DIG_DCOC_CTRL_1_DCOC_ALPHAC_SCALE_IDX(3) |
|
||||
XCVR_RX_DIG_DCOC_CTRL_1_DCOC_ALPHA_RADIUS_IDX(2) |
|
||||
XCVR_RX_DIG_DCOC_CTRL_1_DCOC_TRK_EST_GS_CNT(0) |
|
||||
XCVR_RX_DIG_DCOC_CTRL_1_DCOC_SIGN_SCALE_GS_IDX(1) |
|
||||
XCVR_RX_DIG_DCOC_CTRL_1_DCOC_ALPHAC_SCALE_GS_IDX(3) |
|
||||
XCVR_RX_DIG_DCOC_CTRL_1_DCOC_ALPHA_RADIUS_GS_IDX(2),
|
||||
|
||||
.dcoc_cal_iir_init_26mhz = XCVR_RX_DIG_DCOC_CAL_IIR_DCOC_CAL_IIR3A_IDX(2) |
|
||||
XCVR_RX_DIG_DCOC_CAL_IIR_DCOC_CAL_IIR2A_IDX(2) |
|
||||
XCVR_RX_DIG_DCOC_CAL_IIR_DCOC_CAL_IIR1A_IDX(2),
|
||||
.dcoc_cal_iir_init_32mhz = XCVR_RX_DIG_DCOC_CAL_IIR_DCOC_CAL_IIR3A_IDX(1) |
|
||||
XCVR_RX_DIG_DCOC_CAL_IIR_DCOC_CAL_IIR2A_IDX(2) |
|
||||
XCVR_RX_DIG_DCOC_CAL_IIR_DCOC_CAL_IIR1A_IDX(1),
|
||||
|
||||
.dc_resid_ctrl_26mhz = XCVR_RX_DIG_DC_RESID_CTRL_DC_RESID_NWIN(26) |
|
||||
XCVR_RX_DIG_DC_RESID_CTRL_DC_RESID_DLY(4),
|
||||
.dc_resid_ctrl_32mhz = XCVR_RX_DIG_DC_RESID_CTRL_DC_RESID_NWIN(48) |
|
||||
XCVR_RX_DIG_DC_RESID_CTRL_DC_RESID_DLY(0),
|
||||
};
|
||||
|
||||
-160
@@ -1,160 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Freescale Semiconductor, Inc.
|
||||
* Copyright 2016-2017 NXP
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* o Redistributions of source code must retain the above copyright notice, this list
|
||||
* of conditions and the following disclaimer.
|
||||
*
|
||||
* o 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.
|
||||
*
|
||||
* o Neither the name of Freescale Semiconductor, Inc. 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 HOLDER 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 "fsl_device_registers.h"
|
||||
#include "fsl_xcvr.h"
|
||||
#include "dbg_ram_capture.h"
|
||||
|
||||
/*******************************************************************************
|
||||
* Definitions
|
||||
******************************************************************************/
|
||||
#if RADIO_IS_GEN_3P0
|
||||
#define PKT_RAM_SIZE_16B_WORDS (1152) /* Number of 16bit entries in each Packet RAM bank */
|
||||
#else
|
||||
#define PKT_RAM_SIZE_16B_WORDS (544) /* Number of 16bit entries in each Packet RAM bank */
|
||||
#endif /* RADIO_IS_GEN_3P0 */
|
||||
#define SIGN_EXTND_12_16(x) ((x) | (((x) & 0x800) ? 0xF000 : 0x0))
|
||||
#define SIGN_EXTND_5_8(x) ((x) | (((x) & 0x10) ? 0xE0 : 0x0))
|
||||
|
||||
/*******************************************************************************
|
||||
* Prototypes
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* Variables
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* Code
|
||||
******************************************************************************/
|
||||
void dbg_ram_init(void)
|
||||
{
|
||||
XCVR_RX_DIG->RX_DIG_CTRL |= XCVR_RX_DIG_RX_DIG_CTRL_RX_DMA_DTEST_EN_MASK; /* Turns on clocking to DMA/DBG blocks */
|
||||
XCVR_MISC->PACKET_RAM_CTRL |= XCVR_CTRL_PACKET_RAM_CTRL_XCVR_RAM_ALLOW_MASK; /* Make PKT RAM available to just XCVR */
|
||||
|
||||
/* Some external code must perform the RX warmup request. */
|
||||
}
|
||||
|
||||
|
||||
dbgRamStatus_t dbg_ram_capture(uint8_t dbg_page, uint16_t buffer_sz_bytes, void * result_buffer)
|
||||
{
|
||||
dbgRamStatus_t status = DBG_RAM_SUCCESS;
|
||||
uint32_t temp;
|
||||
volatile uint8_t *pkt_ram_ptr0, *pkt_ram_ptr1;
|
||||
uint8_t * output_ptr;
|
||||
uint16_t i;
|
||||
|
||||
/* Some external code must perform the RX warmup request after the dbg_ram_init() call */
|
||||
|
||||
if (result_buffer == NULL)
|
||||
{
|
||||
status = DBG_RAM_FAIL_NULL_POINTER;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (buffer_sz_bytes > (544*2*2))
|
||||
{
|
||||
status = DBG_RAM_FAIL_SAMPLE_NUM_LIMIT;
|
||||
}
|
||||
else
|
||||
{
|
||||
temp = XCVR_MISC->PACKET_RAM_CTRL & ~XCVR_CTRL_PACKET_RAM_CTRL_DBG_PAGE_MASK;
|
||||
switch (dbg_page)
|
||||
{
|
||||
case DBG_PAGE_RXDIGIQ:
|
||||
case DBG_PAGE_RAWADCIQ:
|
||||
case DBG_PAGE_DCESTIQ:
|
||||
XCVR_MISC->PACKET_RAM_CTRL = temp | XCVR_CTRL_PACKET_RAM_CTRL_DBG_PAGE(dbg_page);
|
||||
|
||||
while (!(XCVR_MISC->PACKET_RAM_CTRL & XCVR_CTRL_PACKET_RAM_CTRL_DBG_RAM_FULL(2)))
|
||||
{
|
||||
/* Waiting for PKT_RAM to fill, wait for PKT_RAM_1 full to ensure complete memory is filled. */
|
||||
}
|
||||
/* Copy to output by bytes to avoid any access size problems in 16 bit packet RAM. */
|
||||
output_ptr = result_buffer;
|
||||
#if !RADIO_IS_GEN_2P1
|
||||
pkt_ram_ptr0 = (volatile uint8_t *)&(XCVR_PKT_RAM->PACKET_RAM_0[0]);
|
||||
pkt_ram_ptr1 = (volatile uint8_t *)&(XCVR_PKT_RAM->PACKET_RAM_1[0]);
|
||||
#else
|
||||
pkt_ram_ptr0 = (volatile uint8_t *)&(XCVR_PKT_RAM->PACKET_RAM[0]);
|
||||
pkt_ram_ptr1 = (volatile uint8_t *)&(XCVR_PKT_RAM->PACKET_RAM[XCVR_PKT_RAM_PACKET_RAM_COUNT>>1]); /* Second packet RAM starts halfway through */
|
||||
#endif /* !RADIO_IS_GEN_2P1 */
|
||||
/* For *IQ pages I and Q are stored alternately in packet ram 0 & 1 */
|
||||
for (i = 0; i < buffer_sz_bytes / 4; i++)
|
||||
{
|
||||
*output_ptr++ = *pkt_ram_ptr0++;
|
||||
*output_ptr++ = *pkt_ram_ptr0++;
|
||||
*output_ptr++ = *pkt_ram_ptr1++;
|
||||
*output_ptr++ = *pkt_ram_ptr1++;
|
||||
}
|
||||
|
||||
break;
|
||||
case DBG_PAGE_RXINPH:
|
||||
case DBG_PAGE_DEMOD_HARD:
|
||||
case DBG_PAGE_DEMOD_SOFT:
|
||||
case DBG_PAGE_DEMOD_DATA:
|
||||
case DBG_PAGE_DEMOD_CFO_PH:
|
||||
XCVR_MISC->PACKET_RAM_CTRL = temp | XCVR_CTRL_PACKET_RAM_CTRL_DBG_PAGE(dbg_page);
|
||||
while (!(XCVR_MISC->PACKET_RAM_CTRL & XCVR_CTRL_PACKET_RAM_CTRL_DBG_RAM_FULL(2)))
|
||||
{
|
||||
/* Waiting for PKT_RAM to fill, wait for PKT_RAM_1 full to ensure complete memory is filled. */
|
||||
}
|
||||
/* Copy to output by bytes to avoid any access size problems in 16 bit packet RAM. */
|
||||
output_ptr = result_buffer;
|
||||
#if !RADIO_IS_GEN_2P1
|
||||
pkt_ram_ptr0 = (volatile uint8_t *)&(XCVR_PKT_RAM->PACKET_RAM_0[0]);
|
||||
#else
|
||||
pkt_ram_ptr0 = (volatile uint8_t *)&(XCVR_PKT_RAM->PACKET_RAM[0]);
|
||||
#endif /* !RADIO_IS_GEN_2P1 */
|
||||
/* This is for non I/Q */
|
||||
for (i = 0; i < buffer_sz_bytes; i++)
|
||||
{
|
||||
*output_ptr = *pkt_ram_ptr0;
|
||||
pkt_ram_ptr0++;
|
||||
output_ptr++;
|
||||
}
|
||||
break;
|
||||
case DBG_PAGE_IDLE:
|
||||
default:
|
||||
status = DBG_RAM_FAIL_PAGE_ERROR; /* Illegal capture page request. */
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
XCVR_MISC->PACKET_RAM_CTRL &= ~XCVR_CTRL_PACKET_RAM_CTRL_DBG_PAGE_MASK; /* Clear DBG_PAGE to terminate the acquisition */
|
||||
|
||||
/* Process the samples and copy to output pointer */
|
||||
|
||||
XCVR_MISC->PACKET_RAM_CTRL &= ~XCVR_CTRL_PACKET_RAM_CTRL_XCVR_RAM_ALLOW_MASK; /* Make PKT RAM available to protocol blocks */
|
||||
XCVR_RX_DIG->RX_DIG_CTRL &= ~XCVR_RX_DIG_RX_DIG_CTRL_RX_DMA_DTEST_EN_MASK; /* Turns off clocking to DMA/DBG blocks */
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
-206
@@ -1,206 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Freescale Semiconductor, Inc.
|
||||
* Copyright 2016-2017 NXP
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* o Redistributions of source code must retain the above copyright notice, this list
|
||||
* of conditions and the following disclaimer.
|
||||
*
|
||||
* o 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.
|
||||
*
|
||||
* o Neither the name of Freescale Semiconductor, Inc. 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 HOLDER 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 _DBG_RAM_CAPTURE_H_
|
||||
/* clang-format off */
|
||||
#define _DBG_RAM_CAPTURE_H_
|
||||
/* clang-format on */
|
||||
|
||||
#include "fsl_common.h"
|
||||
#include "fsl_device_registers.h"
|
||||
|
||||
/*!
|
||||
* @addtogroup xcvr
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*! @file*/
|
||||
|
||||
/*******************************************************************************
|
||||
* Definitions
|
||||
******************************************************************************/
|
||||
/* Page definitions */
|
||||
#define DBG_PAGE_IDLE (0x00)
|
||||
#define DBG_PAGE_RXDIGIQ (0x01)
|
||||
#define DBG_PAGE_RAWADCIQ (0x04)
|
||||
#define DBG_PAGE_DCESTIQ (0x07)
|
||||
#define DBG_PAGE_RXINPH (0x0A)
|
||||
#define DBG_PAGE_DEMOD_HARD (0x0B)
|
||||
#define DBG_PAGE_DEMOD_SOFT (0x0C)
|
||||
#define DBG_PAGE_DEMOD_DATA (0x0D)
|
||||
#define DBG_PAGE_DEMOD_CFO_PH (0x0E)
|
||||
|
||||
typedef enum _dbgRamStatus
|
||||
{
|
||||
DBG_RAM_SUCCESS = 0,
|
||||
DBG_RAM_FAIL_SAMPLE_NUM_LIMIT = 1,
|
||||
DBG_RAM_FAIL_PAGE_ERROR = 2,
|
||||
DBG_RAM_FAIL_NULL_POINTER = 3,
|
||||
DBG_RAM_INVALID_TRIG_SETTING = 4,
|
||||
DBG_RAM_FAIL_NOT_ENOUGH_SAMPLES = 5,
|
||||
DBG_RAM_CAPTURE_NOT_COMPLETE = 6, /* Not an error response, but an indication that capture isn't complete for status polling */
|
||||
} dbgRamStatus_t;
|
||||
|
||||
#if RADIO_IS_GEN_3P0
|
||||
typedef enum _dbgRamStartTriggerType
|
||||
{
|
||||
NO_START_TRIG = 0,
|
||||
START_ON_FSK_PREAMBLE_FOUND = 1,
|
||||
START_ON_FSK_AA_MATCH = 2,
|
||||
START_ON_ZBDEMOD_PREAMBLE_FOUND = 3,
|
||||
START_ON_ZBDEMOD_SFD_MATCH = 4,
|
||||
START_ON_AGC_DCOC_GAIN_CHG = 5,
|
||||
START_ON_TSM_RX_DIG_EN = 6,
|
||||
START_ON_TSM_SPARE2_EN = 7,
|
||||
INVALID_START_TRIG = 8
|
||||
} dbgRamStartTriggerType;
|
||||
|
||||
typedef enum _dbgRamStopTriggerType
|
||||
{
|
||||
NO_STOP_TRIG = 0,
|
||||
STOP_ON_FSK_PREAMBLE_FOUND = 1,
|
||||
STOP_ON_FSK_AA_MATCH = 2,
|
||||
STOP_ON_ZBDEMOD_PREAMBLE_FOUND = 3,
|
||||
STOP_ON_ZBDEMOD_SFD_MATCH = 4,
|
||||
STOP_ON_AGC_DCOC_GAIN_CHG = 5,
|
||||
STOP_ON_TSM_RX_DIG_EN = 6,
|
||||
STOP_ON_TSM_SPARE3_EN = 7,
|
||||
STOP_ON_TSM_PLL_UNLOCK = 8,
|
||||
STOP_ON_BLE_CRC_ERROR_INC = 9,
|
||||
STOP_ON_CRC_FAIL_ZGBE_GENFSK = 10,
|
||||
STOP_ON_GENFSK_HEADER_FAIL = 11,
|
||||
INVALID_STOP_TRIG = 12
|
||||
} dbgRamStopTriggerType;
|
||||
#endif /* RADIO_IS_GEN_3P0 */
|
||||
|
||||
/*! *********************************************************************************
|
||||
* \brief This function prepares for sample capture to packet RAM.
|
||||
*
|
||||
* \return None.
|
||||
*
|
||||
* \details
|
||||
* This routine assumes that some other functions in the calling routine both set
|
||||
* the channel and force RX warmup before calling ::dbg_ram_capture().
|
||||
***********************************************************************************/
|
||||
void dbg_ram_init(void);
|
||||
|
||||
/*! *********************************************************************************
|
||||
* \brief This function performs any state restoration at the completion of PKT RAM capture.
|
||||
*
|
||||
* \details
|
||||
* Any clocks enabled to the packet RAM capture circuitry are disabled.
|
||||
***********************************************************************************/
|
||||
void dbg_ram_release(void);
|
||||
|
||||
#if RADIO_IS_GEN_3P0
|
||||
/*! *********************************************************************************
|
||||
* \brief This function initiates the capture of transceiver data to the transceiver packet RAM.
|
||||
*
|
||||
* \param[in] dbg_page - The page selector (DBG_PAGE).
|
||||
* \param[in] dbg_start_trigger - The trigger to start acquisition (must be "no trigger" if a stop trigger is enabled).
|
||||
* \param[in] dbg_stop_trigger - The trigger to stop acquisition (must be "no trigger" if a start trigger is enabled).
|
||||
*
|
||||
* \return Status of the request.
|
||||
*
|
||||
* \details
|
||||
* This function starts the process of capturing data to the packet RAM. Depending upon the start and stop trigger
|
||||
* settings, the actual capture process can take an indeterminate amount of time. Other APIs are provided to
|
||||
* perform a blocking wait for completion or allow polling for completion of the capture.
|
||||
* After any capture has completed, a separate routine must be called to postprocess the capture and copy all
|
||||
* data out of the packet RAM into a normal RAM buffer.
|
||||
***********************************************************************************/
|
||||
dbgRamStatus_t dbg_ram_start_capture(uint8_t dbg_page, dbgRamStartTriggerType start_trig, dbgRamStopTriggerType stop_trig);
|
||||
|
||||
/*! *********************************************************************************
|
||||
* \brief This function performs a blocking wait for completion of the capture of transceiver data to the transceiver packet RAM.
|
||||
*
|
||||
* \return Status of the request, DBG_RAM_SUCCESS if capture is complete.
|
||||
*
|
||||
* \details
|
||||
* This function performs a wait loop for capture completion and may take an indeterminate amount of time for
|
||||
* some capture trigger types.
|
||||
***********************************************************************************/
|
||||
dbgRamStatus_t dbg_ram_wait_for_complete(void); /* Blocking wait for capture completion, no matter what trigger type */
|
||||
|
||||
/*! *********************************************************************************
|
||||
* \brief This function polls the state of the capture of transceiver data to the transceiver packet RAM.
|
||||
*
|
||||
* \return Status of the request, DBG_RAM_SUCCESS if capture is complete, DBG_RAM_CAPTURE_NOT_COMPLETE if not complete.
|
||||
*
|
||||
***********************************************************************************/
|
||||
dbgRamStatus_t dbg_ram_poll_capture_status(void); /* Non-blocking completion check, just reads the current status of the capure */
|
||||
|
||||
/*! *********************************************************************************
|
||||
* \brief This function processes the captured data into a usable order and copies from packet RAM to normal RAM.
|
||||
*
|
||||
* \param[in] dbg_page - The page selector (DBG_PAGE).
|
||||
* \param[in] buffer_sz_bytes - The size of the output buffer (in bytes)
|
||||
* \param[in] result_buffer - The pointer to the output buffer of a size large enough for the samples.
|
||||
*
|
||||
* \return None.
|
||||
*
|
||||
* \details
|
||||
* Data is copied from packet RAM in bytes to ensure no access problems. Data is unpacked from packet RAM
|
||||
* (either sequentially captured or simultaneously captured) into a linear RAM buffer in system RAM.
|
||||
* If a start trigger is enabled then the first buffer_sz_bytes that are captured are copied out.
|
||||
* If a stop trigger is enabled then the last buffer_sz_bytes that are captured are copied out.
|
||||
***********************************************************************************/
|
||||
dbgRamStatus_t dbg_ram_postproc_capture(uint8_t dbg_page, uint16_t buffer_sz_bytes, void * result_buffer); /* postprocess a capture to unpack data */
|
||||
|
||||
#else
|
||||
/*! *********************************************************************************
|
||||
* \brief This function captures transceiver data to the transceiver packet RAM.
|
||||
*
|
||||
* \param[in] dbg_page - The page selector (DBG_PAGE).
|
||||
* \param[in] buffer_sz_bytes - The size of the output buffer (in bytes)
|
||||
* \param[in] result_buffer - The pointer to the output buffer of a size large enough for the samples.
|
||||
*
|
||||
* \return None.
|
||||
*
|
||||
* \details
|
||||
* The capture to packet RAM always captures a full PKT_RAM worth of samples. The samples will be
|
||||
* copied to the buffer pointed to by result_buffer parameter until buffer_sz_bytes worth of data have
|
||||
* been copied. Data will be copied
|
||||
* NOTE: This routine has a slight hazard of getting stuck waiting for debug RAM to fill up when RX has
|
||||
* not been enabled or RX ends before the RAM fills up (such as when capturing packet data ). It is
|
||||
* intended to be used with manually triggered RX where RX data will continue as long as needed.
|
||||
***********************************************************************************/
|
||||
dbgRamStatus_t dbg_ram_capture(uint8_t dbg_page, uint16_t buffer_sz_bytes, void * result_buffer);
|
||||
#endif /* RADIO_IS_GEN_3P0 */
|
||||
|
||||
/* @} */
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
/*! @}*/
|
||||
|
||||
#endif /* _DBG_RAM_CAPTURE_H_ */
|
||||
|
||||
-273
@@ -1,273 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Freescale Semiconductor, Inc.
|
||||
* Copyright 2016-2017 NXP
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* o Redistributions of source code must retain the above copyright notice, this list
|
||||
* of conditions and the following disclaimer.
|
||||
*
|
||||
* o 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.
|
||||
*
|
||||
* o Neither the name of Freescale Semiconductor, Inc. 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 HOLDER 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 "MKW41Z4.h"
|
||||
#include "fsl_xcvr.h"
|
||||
#include "fsl_edma.h"
|
||||
#include "fsl_dmamux.h"
|
||||
#include "dma_capture.h"
|
||||
|
||||
/*******************************************************************************
|
||||
* Definitions
|
||||
******************************************************************************/
|
||||
#define PKT_RAM_SIZE_16B_WORDS (544) /* Number of 16bit entries in each Packet RAM */
|
||||
#define SIGN_EXTND_12_16(x) ((x) | (((x) & 0x800) ? 0xF000 : 0x0))
|
||||
#define SIGN_EXTND_5_8(x) ((x) | (((x) & 0x10) ? 0xE0 : 0x0))
|
||||
|
||||
const dma_capture_lut_t dma_table [DMA_PAGE_MAX] =
|
||||
{
|
||||
/* DMA_PAGE OSR */
|
||||
{DMA_PAGE_IDLE, 0xF},
|
||||
{DMA_PAGE_RXDIGIQ, 0x4},
|
||||
{DMA_PAGE_RXDIGI, 0x2},
|
||||
{DMA_PAGE_RXDIGQ, 0x2},
|
||||
{DMA_PAGE_RAWADCIQ, 0x2},
|
||||
{DMA_PAGE_RAWADCI, 0x1},
|
||||
{DMA_PAGE_RAWADCQ, 0x1},
|
||||
{DMA_PAGE_DCESTIQ, 0x4},
|
||||
{DMA_PAGE_DCESTI, 0x2},
|
||||
{DMA_PAGE_DCESTQ, 0x2},
|
||||
{DMA_PAGE_RXINPH, 0x1},
|
||||
{DMA_PAGE_DEMOD_HARD, 0xF},
|
||||
{DMA_PAGE_DEMOD_SOFT, 0xF},
|
||||
{DMA_PAGE_DEMOD_DATA, 0xF},
|
||||
{DMA_PAGE_DEMOD_CFO_PH, 0xF},
|
||||
};
|
||||
|
||||
/*******************************************************************************
|
||||
* Variables
|
||||
******************************************************************************/
|
||||
|
||||
/* Initialize to an invalid value. */
|
||||
uint8_t osr_temp = 0xF;
|
||||
edma_handle_t g_EDMA_Handle;
|
||||
volatile bool g_Transfer_Done = false;
|
||||
|
||||
/*******************************************************************************
|
||||
* Prototypes
|
||||
******************************************************************************/
|
||||
|
||||
/* User callback function for EDMA transfer. */
|
||||
void EDMA_Callback(edma_handle_t *handle, void *param, bool transferDone, uint32_t tcds)
|
||||
{
|
||||
if (transferDone)
|
||||
{
|
||||
g_Transfer_Done = true;
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
* Code
|
||||
******************************************************************************/
|
||||
void dma_init(void)
|
||||
{
|
||||
edma_config_t dmaConfig;
|
||||
|
||||
/* Configure DMAMUX */
|
||||
DMAMUX_Init(DMAMUX0);
|
||||
DMAMUX_SetSource(DMAMUX0, 0, 11);
|
||||
DMAMUX_EnableChannel(DMAMUX0, 0);
|
||||
|
||||
/* Configure EDMA transfer */
|
||||
EDMA_GetDefaultConfig(&dmaConfig);
|
||||
EDMA_Init(DMA0, &dmaConfig);
|
||||
EDMA_CreateHandle(&g_EDMA_Handle, DMA0, 0);
|
||||
EDMA_SetCallback(&g_EDMA_Handle, EDMA_Callback, NULL);
|
||||
|
||||
/* Turns on clocking to DMA/DBG blocks */
|
||||
XCVR_RX_DIG->RX_DIG_CTRL |= XCVR_RX_DIG_RX_DIG_CTRL_RX_DMA_DTEST_EN_MASK;
|
||||
/* Save current osr config */
|
||||
osr_temp = (XCVR_RX_DIG->RX_DIG_CTRL & XCVR_RX_DIG_RX_DIG_CTRL_RX_DEC_FILT_OSR_MASK) >> XCVR_RX_DIG_RX_DIG_CTRL_RX_DEC_FILT_OSR_SHIFT;
|
||||
|
||||
/* Some external code must perform the RX warmup request */
|
||||
}
|
||||
|
||||
dmaStatus_t dma_wait_for_complete(void)
|
||||
{
|
||||
dmaStatus_t status = DMA_SUCCESS;
|
||||
|
||||
/* Wait for EDMA transfer finish */
|
||||
while (g_Transfer_Done != true)
|
||||
{
|
||||
/* Timeout */
|
||||
if (XCVR_MISC->DMA_CTRL & XCVR_CTRL_DMA_CTRL_DMA_TIMED_OUT_MASK)
|
||||
{
|
||||
/* Clear flag */
|
||||
XCVR_MISC->DMA_CTRL |= XCVR_CTRL_DMA_CTRL_DMA_TIMED_OUT_MASK;
|
||||
|
||||
/* Capture error */
|
||||
status = DMA_CAPTURE_NOT_COMPLETE;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Release DMA module */
|
||||
dma_release();
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
dmaStatus_t dma_poll_capture_status(void)
|
||||
{
|
||||
dmaStatus_t status = DMA_SUCCESS;
|
||||
|
||||
if (g_Transfer_Done != true)
|
||||
{
|
||||
/* Timeout */
|
||||
if (XCVR_MISC->DMA_CTRL & XCVR_CTRL_DMA_CTRL_DMA_TIMED_OUT_MASK)
|
||||
{
|
||||
/* Clear flag */
|
||||
XCVR_MISC->DMA_CTRL |= XCVR_CTRL_DMA_CTRL_DMA_TIMED_OUT_MASK;
|
||||
/* Release DMA module */
|
||||
dma_release();
|
||||
/* Capture error */
|
||||
status = DMA_CAPTURE_NOT_COMPLETE;
|
||||
}
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
void dma_release(void)
|
||||
{
|
||||
/* Restart flag */
|
||||
g_Transfer_Done = false;
|
||||
|
||||
/* Disable DMA */
|
||||
XCVR_MISC->DMA_CTRL &= ~XCVR_CTRL_DMA_CTRL_DMA_PAGE_MASK;
|
||||
|
||||
/* Gasket bypass disable */
|
||||
RSIM->CONTROL &= ~(RSIM_CONTROL_RADIO_GASKET_BYPASS_OVRD_EN_MASK |
|
||||
RSIM_CONTROL_RADIO_GASKET_BYPASS_OVRD_MASK);
|
||||
|
||||
/* Restore previous osr config (if any) */
|
||||
if (osr_temp != 0xF)
|
||||
{
|
||||
XCVR_RX_DIG->RX_DIG_CTRL &= ~XCVR_RX_DIG_RX_DIG_CTRL_RX_DEC_FILT_OSR_MASK;
|
||||
XCVR_RX_DIG->RX_DIG_CTRL |= XCVR_RX_DIG_RX_DIG_CTRL_RX_DEC_FILT_OSR(osr_temp);
|
||||
osr_temp = 0xF;
|
||||
}
|
||||
}
|
||||
|
||||
#if RADIO_IS_GEN_3P0
|
||||
dmaStatus_t dma_start_capture(uint8_t dbg_page, uint16_t buffer_sz_bytes, void * result_buffer, dmaStartTriggerType start_trig)
|
||||
{
|
||||
|
||||
}
|
||||
#else
|
||||
dmaStatus_t dma_capture(uint8_t dma_page, uint16_t buffer_sz_bytes, uint32_t * result_buffer)
|
||||
{
|
||||
dmaStatus_t status = DMA_SUCCESS;
|
||||
|
||||
/* Some external code must perform the RX warmup request after the d_init() call. */
|
||||
if (result_buffer == NULL)
|
||||
{
|
||||
status = DMA_FAIL_NULL_POINTER;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (buffer_sz_bytes > (4096))
|
||||
{
|
||||
status = DMA_FAIL_SAMPLE_NUM_LIMIT;
|
||||
}
|
||||
else
|
||||
{
|
||||
uint32_t temp = XCVR_MISC->DMA_CTRL & ~XCVR_CTRL_DMA_CTRL_DMA_PAGE_MASK;
|
||||
edma_transfer_config_t transferConfig;
|
||||
|
||||
/* Wait for Network Address Match to start capturing */
|
||||
// while (!((XCVR_MISC->DMA_CTRL & XCVR_CTRL_D MA_CTRL_DMA_TRIGGERRED_MASK)));
|
||||
|
||||
switch (dma_page)
|
||||
{
|
||||
case DMA_PAGE_RXDIGIQ:
|
||||
case DMA_PAGE_RAWADCIQ:
|
||||
case DMA_PAGE_DCESTIQ:
|
||||
case DMA_PAGE_RXINPH:
|
||||
case DMA_PAGE_DEMOD_CFO_PH:
|
||||
|
||||
/* Set OSR */
|
||||
XCVR_RX_DIG->RX_DIG_CTRL &= ~XCVR_RX_DIG_RX_DIG_CTRL_RX_DEC_FILT_OSR_MASK;
|
||||
XCVR_RX_DIG->RX_DIG_CTRL |= XCVR_RX_DIG_RX_DIG_CTRL_RX_DEC_FILT_OSR(dma_table[dma_page].osr);
|
||||
|
||||
/* Single request mode */
|
||||
XCVR_MISC->DMA_CTRL |= XCVR_CTRL_DMA_CTRL_SINGLE_REQ_MODE_MASK;
|
||||
XCVR_MISC->DMA_CTRL &= ~XCVR_CTRL_DMA_CTRL_BYPASS_DMA_SYNC_MASK;
|
||||
|
||||
/* Gasket bypass disable */
|
||||
RSIM->CONTROL &= ~(RSIM_CONTROL_RADIO_GASKET_BYPASS_OVRD_EN_MASK |
|
||||
RSIM_CONTROL_RADIO_GASKET_BYPASS_OVRD_MASK);
|
||||
break;
|
||||
|
||||
case DMA_PAGE_DEMOD_HARD:
|
||||
case DMA_PAGE_DEMOD_SOFT:
|
||||
case DMA_PAGE_DEMOD_DATA:
|
||||
/* Data rate is too low to use Single Req mode */
|
||||
|
||||
/* Request per sample mode */
|
||||
XCVR_MISC->DMA_CTRL &= XCVR_CTRL_DMA_CTRL_SINGLE_REQ_MODE_MASK;
|
||||
XCVR_MISC->DMA_CTRL |= XCVR_CTRL_DMA_CTRL_BYPASS_DMA_SYNC_MASK;
|
||||
|
||||
/* Gasket bypass enable */
|
||||
RSIM->CONTROL |= (RSIM_CONTROL_RADIO_GASKET_BYPASS_OVRD_EN_MASK |
|
||||
RSIM_CONTROL_RADIO_GASKET_BYPASS_OVRD_MASK);
|
||||
break;
|
||||
|
||||
case DMA_PAGE_IDLE:
|
||||
default:
|
||||
/* Illegal capture page request */
|
||||
status = DMA_FAIL_PAGE_ERROR;
|
||||
break;
|
||||
}
|
||||
|
||||
if (status == DMA_SUCCESS)
|
||||
{
|
||||
/* Select DMA_page */
|
||||
XCVR_MISC->DMA_CTRL = temp | XCVR_CTRL_DMA_CTRL_DMA_PAGE(dma_page);
|
||||
|
||||
/* EDMA transfer config */
|
||||
EDMA_PrepareTransfer(&transferConfig, /* Config */
|
||||
(uint32_t *)&XCVR_MISC->DMA_DATA, /* Source address */
|
||||
sizeof(uint32_t), /* Source address width(bytes) */
|
||||
result_buffer, /* Destination address */
|
||||
sizeof(*result_buffer), /* Destination address width */
|
||||
sizeof(uint32_t), /* Transfer bytes per channel request */
|
||||
buffer_sz_bytes, /* Bytes to be transferred */
|
||||
kEDMA_PeripheralToMemory); /* Transfer type */
|
||||
|
||||
EDMA_SubmitTransfer(&g_EDMA_Handle, &transferConfig);
|
||||
EDMA_StartTransfer(&g_EDMA_Handle);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
#endif /* RADIO_IS_GEN_3P0 */
|
||||
-194
@@ -1,194 +0,0 @@
|
||||
/*
|
||||
* Copyright 2016-2017 NXP
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* o Redistributions of source code must retain the above copyright notice, this list
|
||||
* of conditions and the following disclaimer.
|
||||
*
|
||||
* o 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.
|
||||
*
|
||||
* o Neither the name of Freescale Semiconductor, Inc. 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 HOLDER 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 _DMA_CAPTURE_H_
|
||||
#define _DMA_CAPTURE_H_
|
||||
|
||||
#include "fsl_common.h"
|
||||
|
||||
#if RADIO_IS_GEN_3P0
|
||||
#include "K32W042S1M2_M0P.h"
|
||||
#else
|
||||
#include "fsl_device_registers.h"
|
||||
#endif /* RADIO_IS_GEN_3P0 */
|
||||
|
||||
/*!
|
||||
* @addtogroup xcvr
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*! @file*/
|
||||
|
||||
/*******************************************************************************
|
||||
* Definitions
|
||||
******************************************************************************/
|
||||
/* Page definitions */
|
||||
#define DMA_PAGE_IDLE (0x00)
|
||||
#define DMA_PAGE_RXDIGIQ (0x01)
|
||||
#define DMA_PAGE_RXDIGI (0x02)
|
||||
#define DMA_PAGE_RXDIGQ (0x03)
|
||||
#define DMA_PAGE_RAWADCIQ (0x04)
|
||||
#define DMA_PAGE_RAWADCI (0x05)
|
||||
#define DMA_PAGE_RAWADCQ (0x06)
|
||||
#define DMA_PAGE_DCESTIQ (0x07)
|
||||
#define DMA_PAGE_DCESTI (0x08)
|
||||
#define DMA_PAGE_DCESTQ (0x09)
|
||||
#define DMA_PAGE_RXINPH (0x0A)
|
||||
#define DMA_PAGE_DEMOD_HARD (0x0B)
|
||||
#define DMA_PAGE_DEMOD_SOFT (0x0C)
|
||||
#define DMA_PAGE_DEMOD_DATA (0x0D)
|
||||
#define DMA_PAGE_DEMOD_CFO_PH (0x0E)
|
||||
|
||||
#define DMA_PAGE_MAX (0x0F)
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t dma_page;
|
||||
uint8_t osr;
|
||||
} dma_capture_lut_t;
|
||||
|
||||
typedef enum _dmaStatus
|
||||
{
|
||||
DMA_SUCCESS = 0,
|
||||
DMA_FAIL_SAMPLE_NUM_LIMIT = 1,
|
||||
DMA_FAIL_PAGE_ERROR = 2,
|
||||
DMA_FAIL_NULL_POINTER = 3,
|
||||
DMA_INVALID_TRIG_SETTING = 4,
|
||||
DMA_FAIL_NOT_ENOUGH_SAMPLES = 5,
|
||||
DMA_CAPTURE_NOT_COMPLETE = 6, /* Not an error response, but an indication that capture isn't complete for status polling. */
|
||||
} dmaStatus_t;
|
||||
|
||||
#if RADIO_IS_GEN_3P0
|
||||
typedef enum dmaStartTriggerType
|
||||
{
|
||||
NO_DMA_START_TRIG = 0,
|
||||
START_DMA_ON_FSK_PREAMBLE_FOUND = 1,
|
||||
START_DMA_ON_FSK_AA_MATCH = 2,
|
||||
START_DMA_ON_ZBDEMOD_PREAMBLE_FOUND = 3,
|
||||
START_DMA_ON_ZBDEMOD_SFD_MATCH = 4,
|
||||
START_DMA_ON_AGC_DCOC_GAIN_CHG = 5,
|
||||
START_DMA_ON_TSM_RX_DIG_EN = 6,
|
||||
START_ODMA_N_TSM_SPARE2_EN = 7,
|
||||
INVALID_DMA_START_TRIG = 8
|
||||
} dmaStartTriggerType;
|
||||
#endif /* RADIO_IS_GEN_3P0 */
|
||||
|
||||
/*! *********************************************************************************
|
||||
* \brief This function prepares for sample capture to system RAM using DMA.
|
||||
*
|
||||
* \return None.
|
||||
*
|
||||
* \details
|
||||
* This routine assumes that some other functions in the calling routine both set
|
||||
* the channel and force RX warmup before calling the appropriate capture routine.
|
||||
* This routine may corrupt the OSR value of the system but restores it in the ::dma_release() routine.
|
||||
***********************************************************************************/
|
||||
void dma_init(void);
|
||||
|
||||
/*! *********************************************************************************
|
||||
* \brief This function performs a blocking wait for completion of the capture of transceiver data to the system RAM.
|
||||
*
|
||||
* \return Status of the request, DMA_SUCCESS if capture is complete.
|
||||
*
|
||||
* \details
|
||||
* This function performs a wait loop for capture completion and may take an indeterminate amount of time for
|
||||
* some capture trigger types.
|
||||
* Blocking wait for capture completion, no matter what trigger type.
|
||||
***********************************************************************************/
|
||||
dmaStatus_t dma_wait_for_complete(void);
|
||||
|
||||
/*! *********************************************************************************
|
||||
* \brief This function polls the state of the capture of transceiver data to the transceiver packet RAM.
|
||||
*
|
||||
* \return Status of the request, DMA_SUCCESS if capture is complete, DMA_CAPTURE_NOT_COMPLETE if not complete.
|
||||
*
|
||||
* \details
|
||||
* Non-blocking completion check, just reads the current status of the capure.
|
||||
***********************************************************************************/
|
||||
dmaStatus_t dma_poll_capture_status(void);
|
||||
|
||||
/*! *********************************************************************************
|
||||
* \brief This function performs any state restoration at the completion of DMA capture to system RAM.
|
||||
*
|
||||
* \details
|
||||
* Because DMA capture only works at specific OSR values the DMA capture routines must force the OSR to the
|
||||
* supported value when capturing data. This forced OSR value must be restored after DMA operations are complete.
|
||||
***********************************************************************************/
|
||||
void dma_release(void);
|
||||
|
||||
#if RADIO_IS_GEN_3P0
|
||||
/*! *********************************************************************************
|
||||
* \brief This function initiates the capture of transceiver data to the system RAM.
|
||||
*
|
||||
* \param[in] dbg_page - The page selector (DBG_PAGE).
|
||||
* \param[in] buffer_sz_bytes - The size of the output buffer (in bytes)
|
||||
* \param[in] result_buffer - The pointer to the output buffer of a size large enough for the samples.
|
||||
* \param[in] dbg_start_trigger - The trigger to start acquisition (must be "no trigger" if a stop trigger is enabled).
|
||||
*
|
||||
* \return Status of the request.
|
||||
*
|
||||
* \details
|
||||
* This function starts the process of capturing data to the system RAM. Depending upon the start trigger
|
||||
* settings, the actual capture process can take an indeterminate amount of time. Other APIs are provided to
|
||||
* perform a blocking wait for completion or allow polling for completion of the capture.
|
||||
* After any capture has completed, data will be left in system RAM.
|
||||
***********************************************************************************/
|
||||
dmaStatus_t dma_start_capture(uint8_t dbg_page, uint16_t buffer_sz_bytes, void * result_buffer, dmaStartTriggerType start_trig);
|
||||
|
||||
#else /* Gen 2.0 version */
|
||||
/*! *********************************************************************************
|
||||
* \brief This function captures transceiver data to the transceiver packet RAM.
|
||||
*
|
||||
* \param[in] dma_page - The page selector (DBG_PAGE).
|
||||
* \param[in] buffer_sz_bytes - The size of the output buffer (in bytes)
|
||||
* \param[in] result_buffer - The pointer to the output buffer of a size large enough for the samples.
|
||||
*
|
||||
* \return None.
|
||||
*
|
||||
* \details
|
||||
* The capture to system RAM . The samples will be
|
||||
* copied to the buffer pointed to by result_buffer parameter until buffer_sz_bytes worth of data have
|
||||
* been copied. Data will be copied
|
||||
* NOTE: This routine has a slight hazard of getting stuck waiting for the specified number of butes when RX has
|
||||
* not been enabled or RX ends before the specified byte count is achieved (such as when capturing packet data ). It is
|
||||
* intended to be used with manually triggered RX where RX data will continue as long as needed.
|
||||
***********************************************************************************/
|
||||
dmaStatus_t dma_capture(uint8_t dma_page, uint16_t buffer_sz_bytes, uint32_t * result_buffer);
|
||||
#endif /* RADIO_IS_GEN_3P0 */
|
||||
|
||||
/* @} */
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
/*! @}*/
|
||||
|
||||
#endif /* _DMA_CAPTURE_H_ */
|
||||
|
||||
|
||||
-2132
File diff suppressed because it is too large
Load Diff
-1236
File diff suppressed because it is too large
Load Diff
-995
@@ -1,995 +0,0 @@
|
||||
/*
|
||||
* Copyright 2016-2017 NXP
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* o Redistributions of source code must retain the above copyright notice, this list
|
||||
* of conditions and the following disclaimer.
|
||||
*
|
||||
* o 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.
|
||||
*
|
||||
* o Neither the name of Freescale Semiconductor, Inc. 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 HOLDER 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 "fsl_device_registers.h"
|
||||
#include "fsl_common.h"
|
||||
#include "fsl_xcvr.h"
|
||||
#include "fsl_xcvr_trim.h"
|
||||
#include "dbg_ram_capture.h"
|
||||
#include "math.h"
|
||||
|
||||
/*******************************************************************************
|
||||
* Definitions
|
||||
******************************************************************************/
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
* Prototypes
|
||||
******************************************************************************/
|
||||
void DC_Measure_short(IQ_t chan, DAC_SWEEP_STEP2_t dcoc_init_val);
|
||||
float calc_dcoc_dac_step(GAIN_CALC_TBL_ENTRY2_T * meas_ptr, GAIN_CALC_TBL_ENTRY2_T * baseline_meas_ptr );
|
||||
extern float roundf (float);
|
||||
|
||||
/*******************************************************************************
|
||||
* Variables
|
||||
******************************************************************************/
|
||||
const int8_t TsettleCal = 10;
|
||||
static GAIN_CALC_TBL_ENTRY2_T measurement_tbl2[NUM_I_Q_CHAN][NUM_SWEEP_STEP_ENTRIES2];
|
||||
static const int8_t sweep_step_values2[NUM_SWEEP_STEP_ENTRIES2] =
|
||||
{
|
||||
0, /* Baseline entry is first and not used in this table */
|
||||
-16,
|
||||
+16,
|
||||
-4,
|
||||
-4,
|
||||
-4,
|
||||
-4,
|
||||
-4,
|
||||
-4,
|
||||
-4,
|
||||
-4,
|
||||
-4,
|
||||
-4,
|
||||
-4,
|
||||
+4,
|
||||
+4,
|
||||
+4,
|
||||
+4,
|
||||
+4,
|
||||
+4,
|
||||
+4,
|
||||
+4,
|
||||
+4,
|
||||
+4,
|
||||
+4
|
||||
};
|
||||
|
||||
/*******************************************************************************
|
||||
* Macros
|
||||
******************************************************************************/
|
||||
#define ISIGN(x) !((uint16_t)x & 0x8000)
|
||||
#define ABS(x) ((x) > 0 ? (x) : -(x))
|
||||
|
||||
/*******************************************************************************
|
||||
* Code
|
||||
******************************************************************************/
|
||||
/*! *********************************************************************************
|
||||
* \brief This function performs a trim of the BBA DCOC DAC on the DUT
|
||||
*
|
||||
* \return status - 1 if passed, 0 if failed.
|
||||
*
|
||||
* \ingroup PublicAPIs
|
||||
*
|
||||
* \details
|
||||
* Requires the RX to be warmed up before this function is called.
|
||||
*
|
||||
***********************************************************************************/
|
||||
uint8_t rx_bba_dcoc_dac_trim_shortIQ(void)
|
||||
{
|
||||
uint8_t i;
|
||||
float temp_mi = 0;
|
||||
float temp_mq = 0;
|
||||
float temp_pi = 0;
|
||||
float temp_pq = 0;
|
||||
float temp_step = 0;
|
||||
uint8_t bbf_dacinit_i, bbf_dacinit_q;
|
||||
|
||||
uint32_t dcoc_init_reg_value_dcgain = 0x80802020; /* Used in 2nd & 3rd Generation DCOC Trims only. */
|
||||
uint32_t bbf_dcoc_step;
|
||||
uint32_t bbf_dcoc_step_rcp;
|
||||
TZAdcocstep_t tza_dcoc_step[11];
|
||||
uint8_t status = 0;
|
||||
|
||||
/* Save register values. */
|
||||
uint32_t dcoc_ctrl_0_stack;
|
||||
uint32_t dcoc_ctrl_1_stack;
|
||||
uint32_t agc_ctrl_1_stack;
|
||||
uint32_t rx_dig_ctrl_stack;
|
||||
uint32_t dcoc_cal_gain_state;
|
||||
|
||||
XcvrCalDelay(1000);
|
||||
dcoc_ctrl_0_stack = XCVR_RX_DIG->DCOC_CTRL_0; /* Save state of DCOC_CTRL_0 for later restore. */
|
||||
dcoc_ctrl_1_stack = XCVR_RX_DIG->DCOC_CTRL_1; /* Save state of DCOC_CTRL_1 for later restore. */
|
||||
rx_dig_ctrl_stack = XCVR_RX_DIG->RX_DIG_CTRL; /* Save state of RX_DIG_CTRL for later restore. */
|
||||
agc_ctrl_1_stack = XCVR_RX_DIG->AGC_CTRL_1; /* Save state of RX_DIG_CTRL for later restore. */
|
||||
dcoc_cal_gain_state = XCVR_RX_DIG->DCOC_CAL_GAIN; /* Save state of DCOC_CAL_GAIN for later restore. */
|
||||
|
||||
/* Ensure AGC, DCOC and RX_DIG_CTRL is in correct mode. */
|
||||
XCVR_RX_DIG->RX_DIG_CTRL = (XCVR_RX_DIG->RX_DIG_CTRL & ~XCVR_RX_DIG_RX_DIG_CTRL_RX_AGC_EN_MASK) | XCVR_RX_DIG_RX_DIG_CTRL_RX_AGC_EN(0); /* Turn OFF AGC */
|
||||
|
||||
XCVR_RX_DIG->AGC_CTRL_1 = (XCVR_RX_DIG->AGC_CTRL_1 & ~XCVR_RX_DIG_AGC_CTRL_1_USER_LNA_GAIN_EN_MASK) | XCVR_RX_DIG_AGC_CTRL_1_USER_LNA_GAIN_EN(1) ; /* Set LNA Manual Gain */
|
||||
XCVR_RX_DIG->AGC_CTRL_1 = (XCVR_RX_DIG->AGC_CTRL_1 & ~XCVR_RX_DIG_AGC_CTRL_1_USER_BBA_GAIN_EN_MASK) | XCVR_RX_DIG_AGC_CTRL_1_USER_BBA_GAIN_EN(1) ; /* Set BBA Manual Gain */
|
||||
|
||||
XCVR_RX_DIG->RX_DIG_CTRL = (XCVR_RX_DIG->RX_DIG_CTRL & ~XCVR_RX_DIG_RX_DIG_CTRL_RX_DCOC_CAL_EN_MASK) | XCVR_RX_DIG_RX_DIG_CTRL_RX_DCOC_CAL_EN(0); /* Enable HW DC Calibration -- Disable for SW-DCOC */
|
||||
XCVR_RX_DIG->DCOC_CTRL_0 = (XCVR_RX_DIG->DCOC_CTRL_0 & ~XCVR_RX_DIG_DCOC_CTRL_0_DCOC_MAN_MASK) | XCVR_RX_DIG_DCOC_CTRL_0_DCOC_MAN(1); /* Enable Manual DCOC */
|
||||
/* DCOC_CTRL_0 @ 4005_C02C -- Define default DCOC DAC settings in manual mode. */
|
||||
XCVR_RX_DIG->DCOC_DAC_INIT = XCVR_RX_DIG_DCOC_DAC_INIT_BBA_DCOC_INIT_I(0x20) | XCVR_RX_DIG_DCOC_DAC_INIT_BBA_DCOC_INIT_Q(0x20) | XCVR_RX_DIG_DCOC_DAC_INIT_TZA_DCOC_INIT_I(0x80) | XCVR_RX_DIG_DCOC_DAC_INIT_TZA_DCOC_INIT_Q(0x80);
|
||||
/* Set DCOC Tracking State. */
|
||||
XCVR_RX_DIG->DCOC_CTRL_0 = (XCVR_RX_DIG->DCOC_CTRL_0 & ~XCVR_RX_DIG_DCOC_CTRL_0_DCOC_CORRECT_SRC_MASK) | XCVR_RX_DIG_DCOC_CTRL_0_DCOC_CORRECT_SRC(0); /* Disables DCOC Tracking when set to 0 */
|
||||
/* Apply Manual Gain. */
|
||||
XCVR_RX_DIG->AGC_CTRL_1 = XCVR_RX_DIG_AGC_CTRL_1_USER_LNA_GAIN_EN(1) | XCVR_RX_DIG_AGC_CTRL_1_USER_BBA_GAIN_EN(1) | XCVR_RX_DIG_AGC_CTRL_1_LNA_USER_GAIN(0x02) | XCVR_RX_DIG_AGC_CTRL_1_BBA_USER_GAIN(0x00) ;
|
||||
XcvrCalDelay(TsettleCal);
|
||||
|
||||
dcoc_init_reg_value_dcgain = XCVR_RX_DIG->DCOC_DAC_INIT; /* Capture DC null setting. */
|
||||
|
||||
bbf_dacinit_i = (dcoc_init_reg_value_dcgain & 0x000000FFU);
|
||||
bbf_dacinit_q = (dcoc_init_reg_value_dcgain & 0x0000FF00U) >> 8;
|
||||
|
||||
DC_Measure_short(I_CHANNEL, NOMINAL2);
|
||||
DC_Measure_short(Q_CHANNEL, NOMINAL2);
|
||||
|
||||
/* SWEEP Q CHANNEL */
|
||||
/* BBF NEG STEP */
|
||||
XCVR_RX_DIG->DCOC_DAC_INIT = (XCVR_RX_DIG->DCOC_DAC_INIT & ~XCVR_RX_DIG_DCOC_DAC_INIT_BBA_DCOC_INIT_Q_MASK) | XCVR_RX_DIG_DCOC_DAC_INIT_BBA_DCOC_INIT_Q(bbf_dacinit_q - 16);
|
||||
XcvrCalDelay(TsettleCal);
|
||||
DC_Measure_short(Q_CHANNEL, BBF_NEG);
|
||||
|
||||
/* BBF POS STEP */
|
||||
XCVR_RX_DIG->DCOC_DAC_INIT = (XCVR_RX_DIG->DCOC_DAC_INIT & ~XCVR_RX_DIG_DCOC_DAC_INIT_BBA_DCOC_INIT_Q_MASK) | XCVR_RX_DIG_DCOC_DAC_INIT_BBA_DCOC_INIT_Q(bbf_dacinit_q + 16);
|
||||
XcvrCalDelay(TsettleCal);
|
||||
DC_Measure_short(Q_CHANNEL, BBF_POS);
|
||||
|
||||
XCVR_RX_DIG->DCOC_DAC_INIT = dcoc_init_reg_value_dcgain; /* Return DAC setting to initial. */
|
||||
XcvrCalDelay(TsettleCal);
|
||||
|
||||
/* SWEEP I CHANNEL */
|
||||
/* BBF NEG STEP */
|
||||
XCVR_RX_DIG->DCOC_DAC_INIT = (XCVR_RX_DIG->DCOC_DAC_INIT & ~XCVR_RX_DIG_DCOC_DAC_INIT_BBA_DCOC_INIT_I_MASK) | XCVR_RX_DIG_DCOC_DAC_INIT_BBA_DCOC_INIT_I(bbf_dacinit_i - 16);
|
||||
XcvrCalDelay(TsettleCal);
|
||||
DC_Measure_short(I_CHANNEL, BBF_NEG);
|
||||
/* BBF POS STEP */
|
||||
XCVR_RX_DIG->DCOC_DAC_INIT = (XCVR_RX_DIG->DCOC_DAC_INIT & ~XCVR_RX_DIG_DCOC_DAC_INIT_BBA_DCOC_INIT_I_MASK) | XCVR_RX_DIG_DCOC_DAC_INIT_BBA_DCOC_INIT_I(bbf_dacinit_i + 16);
|
||||
XcvrCalDelay(TsettleCal);
|
||||
DC_Measure_short(I_CHANNEL, BBF_POS);
|
||||
|
||||
XCVR_RX_DIG->DCOC_DAC_INIT = dcoc_init_reg_value_dcgain; /* Return DACs to initial. */
|
||||
XcvrCalDelay(TsettleCal);
|
||||
|
||||
/* Calculate BBF DCOC STEPS, RECIPROCALS */
|
||||
temp_mi = calc_dcoc_dac_step(&measurement_tbl2[I_CHANNEL][BBF_NEG], &measurement_tbl2[I_CHANNEL][NOMINAL2]);
|
||||
temp_mq = calc_dcoc_dac_step(&measurement_tbl2[Q_CHANNEL][BBF_NEG], &measurement_tbl2[Q_CHANNEL][NOMINAL2]);
|
||||
temp_pi = calc_dcoc_dac_step(&measurement_tbl2[I_CHANNEL][BBF_POS], &measurement_tbl2[I_CHANNEL][NOMINAL2]);
|
||||
temp_pq = calc_dcoc_dac_step(&measurement_tbl2[Q_CHANNEL][BBF_POS], &measurement_tbl2[Q_CHANNEL][NOMINAL2]);
|
||||
|
||||
temp_step = (temp_mi+temp_pi + temp_mq+temp_pq) / 4;
|
||||
|
||||
bbf_dcoc_step = (uint32_t)roundf(temp_step * 8U);
|
||||
|
||||
if ((bbf_dcoc_step > 265) & (bbf_dcoc_step < 305))
|
||||
{
|
||||
bbf_dcoc_step_rcp = (uint32_t)roundf((float)0x8000U / temp_step);
|
||||
|
||||
/* Calculate TZA DCOC STEPS & RECIPROCALS and IQ_DC_GAIN_MISMATCH. */
|
||||
for (i = TZA_STEP_N0; i <= TZA_STEP_N10; i++) /* Relying on enumeration ordering. */
|
||||
{
|
||||
/* Calculate TZA DCOC STEPSIZE & its RECIPROCAL. */
|
||||
switch(i){
|
||||
case TZA_STEP_N0:
|
||||
temp_step = (bbf_dcoc_step >> 3U) / 3.6F;
|
||||
break;
|
||||
case TZA_STEP_N1:
|
||||
temp_step = temp_step * (xcvr_common_config.dcoc_tza_step_01_init >> 16)/(xcvr_common_config.dcoc_tza_step_00_init >> 16);
|
||||
break;
|
||||
case TZA_STEP_N2:
|
||||
temp_step = temp_step * (xcvr_common_config.dcoc_tza_step_02_init >> 16)/(xcvr_common_config.dcoc_tza_step_01_init >> 16);
|
||||
break;
|
||||
case TZA_STEP_N3:
|
||||
temp_step = temp_step * (xcvr_common_config.dcoc_tza_step_03_init >> 16)/(xcvr_common_config.dcoc_tza_step_02_init >> 16);
|
||||
break;
|
||||
case TZA_STEP_N4:
|
||||
temp_step = temp_step * (xcvr_common_config.dcoc_tza_step_04_init >> 16)/(xcvr_common_config.dcoc_tza_step_03_init >> 16);
|
||||
break;
|
||||
case TZA_STEP_N5:
|
||||
temp_step = temp_step * (xcvr_common_config.dcoc_tza_step_05_init >> 16)/(xcvr_common_config.dcoc_tza_step_04_init >> 16);
|
||||
break;
|
||||
case TZA_STEP_N6:
|
||||
temp_step = temp_step * (xcvr_common_config.dcoc_tza_step_06_init >> 16)/(xcvr_common_config.dcoc_tza_step_05_init >> 16);
|
||||
break;
|
||||
case TZA_STEP_N7:
|
||||
temp_step = temp_step * (xcvr_common_config.dcoc_tza_step_07_init >> 16)/(xcvr_common_config.dcoc_tza_step_06_init >> 16);
|
||||
break;
|
||||
case TZA_STEP_N8:
|
||||
temp_step = temp_step * (xcvr_common_config.dcoc_tza_step_08_init >> 16)/(xcvr_common_config.dcoc_tza_step_07_init >> 16);
|
||||
break;
|
||||
case TZA_STEP_N9:
|
||||
temp_step = temp_step * (xcvr_common_config.dcoc_tza_step_09_init >> 16)/(xcvr_common_config.dcoc_tza_step_08_init >> 16);
|
||||
break;
|
||||
case TZA_STEP_N10:
|
||||
temp_step = temp_step * (xcvr_common_config.dcoc_tza_step_10_init >> 16)/(xcvr_common_config.dcoc_tza_step_09_init >> 16);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
tza_dcoc_step[i-TZA_STEP_N0].dcoc_step = (uint32_t)roundf(temp_step * 8);
|
||||
tza_dcoc_step[i-TZA_STEP_N0].dcoc_step_rcp = (uint32_t)roundf((float)0x8000 / temp_step);
|
||||
}
|
||||
|
||||
/* Make the trims active. */
|
||||
XCVR_RX_DIG->DCOC_BBA_STEP = XCVR_RX_DIG_DCOC_BBA_STEP_BBA_DCOC_STEP(bbf_dcoc_step) | XCVR_RX_DIG_DCOC_BBA_STEP_BBA_DCOC_STEP_RECIP(bbf_dcoc_step_rcp) ;
|
||||
XCVR_RX_DIG->DCOC_TZA_STEP_0 = XCVR_RX_DIG_DCOC_TZA_STEP_0_DCOC_TZA_STEP_GAIN_0(tza_dcoc_step[0].dcoc_step) | XCVR_RX_DIG_DCOC_TZA_STEP_0_DCOC_TZA_STEP_RCP_0(tza_dcoc_step[0].dcoc_step_rcp) ;
|
||||
XCVR_RX_DIG->DCOC_TZA_STEP_1 = XCVR_RX_DIG_DCOC_TZA_STEP_1_DCOC_TZA_STEP_GAIN_1(tza_dcoc_step[1].dcoc_step) | XCVR_RX_DIG_DCOC_TZA_STEP_1_DCOC_TZA_STEP_RCP_1(tza_dcoc_step[1].dcoc_step_rcp) ;
|
||||
XCVR_RX_DIG->DCOC_TZA_STEP_2 = XCVR_RX_DIG_DCOC_TZA_STEP_2_DCOC_TZA_STEP_GAIN_2(tza_dcoc_step[2].dcoc_step) | XCVR_RX_DIG_DCOC_TZA_STEP_2_DCOC_TZA_STEP_RCP_2(tza_dcoc_step[2].dcoc_step_rcp) ;
|
||||
XCVR_RX_DIG->DCOC_TZA_STEP_3 = XCVR_RX_DIG_DCOC_TZA_STEP_3_DCOC_TZA_STEP_GAIN_3(tza_dcoc_step[3].dcoc_step) | XCVR_RX_DIG_DCOC_TZA_STEP_3_DCOC_TZA_STEP_RCP_3(tza_dcoc_step[3].dcoc_step_rcp) ;
|
||||
XCVR_RX_DIG->DCOC_TZA_STEP_4 = XCVR_RX_DIG_DCOC_TZA_STEP_4_DCOC_TZA_STEP_GAIN_4(tza_dcoc_step[4].dcoc_step) | XCVR_RX_DIG_DCOC_TZA_STEP_4_DCOC_TZA_STEP_RCP_4(tza_dcoc_step[4].dcoc_step_rcp) ;
|
||||
XCVR_RX_DIG->DCOC_TZA_STEP_5 = XCVR_RX_DIG_DCOC_TZA_STEP_5_DCOC_TZA_STEP_GAIN_5(tza_dcoc_step[5].dcoc_step) | XCVR_RX_DIG_DCOC_TZA_STEP_5_DCOC_TZA_STEP_RCP_5(tza_dcoc_step[5].dcoc_step_rcp) ;
|
||||
XCVR_RX_DIG->DCOC_TZA_STEP_6 = XCVR_RX_DIG_DCOC_TZA_STEP_6_DCOC_TZA_STEP_GAIN_6(tza_dcoc_step[6].dcoc_step) | XCVR_RX_DIG_DCOC_TZA_STEP_6_DCOC_TZA_STEP_RCP_6(tza_dcoc_step[6].dcoc_step_rcp) ;
|
||||
XCVR_RX_DIG->DCOC_TZA_STEP_7 = XCVR_RX_DIG_DCOC_TZA_STEP_7_DCOC_TZA_STEP_GAIN_7(tza_dcoc_step[7].dcoc_step) | XCVR_RX_DIG_DCOC_TZA_STEP_7_DCOC_TZA_STEP_RCP_7(tza_dcoc_step[7].dcoc_step_rcp) ;
|
||||
XCVR_RX_DIG->DCOC_TZA_STEP_8 = XCVR_RX_DIG_DCOC_TZA_STEP_8_DCOC_TZA_STEP_GAIN_8(tza_dcoc_step[8].dcoc_step) | XCVR_RX_DIG_DCOC_TZA_STEP_8_DCOC_TZA_STEP_RCP_8(tza_dcoc_step[8].dcoc_step_rcp) ;
|
||||
XCVR_RX_DIG->DCOC_TZA_STEP_9 = XCVR_RX_DIG_DCOC_TZA_STEP_9_DCOC_TZA_STEP_GAIN_9(tza_dcoc_step[9].dcoc_step) | XCVR_RX_DIG_DCOC_TZA_STEP_9_DCOC_TZA_STEP_RCP_9(tza_dcoc_step[9].dcoc_step_rcp) ;
|
||||
XCVR_RX_DIG->DCOC_TZA_STEP_10 = XCVR_RX_DIG_DCOC_TZA_STEP_10_DCOC_TZA_STEP_GAIN_10(tza_dcoc_step[10].dcoc_step) | XCVR_RX_DIG_DCOC_TZA_STEP_10_DCOC_TZA_STEP_RCP_10(tza_dcoc_step[10].dcoc_step_rcp) ;
|
||||
|
||||
status = 1; /* Success */
|
||||
}
|
||||
else
|
||||
{
|
||||
status = 0; /* Failure */
|
||||
}
|
||||
|
||||
/* Restore Registers. */
|
||||
XCVR_RX_DIG->DCOC_CTRL_0 = dcoc_ctrl_0_stack; /* Restore DCOC_CTRL_0 state to prior settings. */
|
||||
XCVR_RX_DIG->DCOC_CTRL_1 = dcoc_ctrl_1_stack; /* Restore DCOC_CTRL_1 state to prior settings. */
|
||||
XCVR_RX_DIG->RX_DIG_CTRL = rx_dig_ctrl_stack; /* Restore RX_DIG_CTRL state to prior settings. */
|
||||
XCVR_RX_DIG->DCOC_CAL_GAIN = dcoc_cal_gain_state; /* Restore DCOC_CAL_GAIN state to prior setting. */
|
||||
XCVR_RX_DIG->AGC_CTRL_1 = agc_ctrl_1_stack; /* Save state of RX_DIG_CTRL for later restore. */
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
/*! *********************************************************************************
|
||||
* \brief This function performs one point of the DC GAIN calibration process on the DUT
|
||||
*
|
||||
* \param[in] chan - whether the I or Q channel is being tested.
|
||||
* \param[in] stage - whether the BBF or TZA gain stage is being tested.
|
||||
* \param[in] dcoc_init_val - the value being set in the ***DCOC_INIT_* register by the parent.
|
||||
* \param[in] ext_measmt - the external measurement (in milliVolts) captured by the parent after the ***DCOC_INIT_* register was setup.
|
||||
*
|
||||
* \ingroup PublicAPIs
|
||||
*
|
||||
* \details
|
||||
* Relies on a static array to store each point of data for later processing in ::DC_GainCalc().
|
||||
*
|
||||
***********************************************************************************/
|
||||
void DC_Measure_short(IQ_t chan, DAC_SWEEP_STEP2_t dcoc_init_val)
|
||||
{
|
||||
int16_t dc_meas_i = 0;
|
||||
int16_t dc_meas_q = 0;
|
||||
int16_t sum_dc_meas_i = 0;
|
||||
int16_t sum_dc_meas_q = 0;
|
||||
|
||||
{
|
||||
int8_t i;
|
||||
const int8_t iterations = 1;
|
||||
sum_dc_meas_i = 0;
|
||||
sum_dc_meas_q = 0;
|
||||
|
||||
for (i = 0; i < iterations; i++)
|
||||
{
|
||||
rx_dc_sample_average(&dc_meas_i, &dc_meas_q);
|
||||
sum_dc_meas_i = sum_dc_meas_i + dc_meas_i;
|
||||
sum_dc_meas_q = sum_dc_meas_q + dc_meas_q;
|
||||
}
|
||||
sum_dc_meas_i = sum_dc_meas_i / iterations;
|
||||
sum_dc_meas_q = sum_dc_meas_q / iterations;
|
||||
}
|
||||
|
||||
measurement_tbl2[chan][dcoc_init_val].step_value = sweep_step_values2[dcoc_init_val];
|
||||
|
||||
if (chan == I_CHANNEL)
|
||||
{
|
||||
measurement_tbl2[chan][dcoc_init_val].internal_measurement = dc_meas_i;
|
||||
}
|
||||
else
|
||||
{
|
||||
measurement_tbl2[chan][dcoc_init_val].internal_measurement = dc_meas_q;
|
||||
}
|
||||
}
|
||||
|
||||
/*! *********************************************************************************
|
||||
* \brief This function calculates one point of DC DAC step based on digital samples of I or Q.
|
||||
*
|
||||
* \param[in] meas_ptr - pointer to the structure containing the measured data from internal measurement.
|
||||
* \param[in] baseline_meas_ptr - pointer to the structure containing the baseline measured data from internal measurement.
|
||||
*
|
||||
* \return result of the calculation, the measurement DCOC DAC step value for this measurement point.
|
||||
*
|
||||
***********************************************************************************/
|
||||
float calc_dcoc_dac_step(GAIN_CALC_TBL_ENTRY2_T * meas_ptr, GAIN_CALC_TBL_ENTRY2_T * baseline_meas_ptr )
|
||||
{
|
||||
static int16_t norm_dc_code;
|
||||
static float dc_step;
|
||||
|
||||
/* Normalize internal measurement */
|
||||
norm_dc_code = meas_ptr->internal_measurement - baseline_meas_ptr->internal_measurement;
|
||||
dc_step = (float)(norm_dc_code) / (float)(meas_ptr->step_value);
|
||||
dc_step = (dc_step < 0)? -dc_step: dc_step;
|
||||
|
||||
return dc_step;
|
||||
}
|
||||
|
||||
/*! *********************************************************************************
|
||||
* \brief Temporary delay function
|
||||
*
|
||||
* \param[in] none.
|
||||
*
|
||||
* \return none.
|
||||
*
|
||||
* \details
|
||||
*
|
||||
***********************************************************************************/
|
||||
void XcvrCalDelay(uint32_t time)
|
||||
{
|
||||
while(time * 32 > 0) /* Time delay is roughly in uSec. */
|
||||
{
|
||||
time--;
|
||||
}
|
||||
}
|
||||
|
||||
/*! *********************************************************************************
|
||||
* \brief This function calculates the average (DC value) based on a smaller set of digital samples of I and Q.
|
||||
*
|
||||
* \param[in] i_avg - pointer to the location for storing the calculated average for I channel samples.
|
||||
* \param[in] q_avg - pointer to the location for storing the calculated average for Q channel samples.
|
||||
*
|
||||
***********************************************************************************/
|
||||
void rx_dc_sample_average(int16_t * i_avg, int16_t * q_avg)
|
||||
{
|
||||
static uint32_t samples[128]; /* 544*2*2 (entire packet ram1/2 size) */
|
||||
uint16_t i;
|
||||
uint32_t rx_sample;
|
||||
uint16_t * sample_ptr;
|
||||
uint32_t temp, end_of_rx_wu;
|
||||
uint32_t num_iq_samples;
|
||||
float avg_i = 0;
|
||||
float avg_q = 0;
|
||||
|
||||
num_iq_samples = 128;
|
||||
|
||||
/* Clear the entire allocated sample buffer */
|
||||
for (i = 0; i < num_iq_samples; i++)
|
||||
{
|
||||
samples[i]=0;
|
||||
}
|
||||
|
||||
/* Assume this has been called *AFTER* RxWu has completed. */
|
||||
/* XCVR_ForceRxWu(); */
|
||||
|
||||
/* Wait for TSM to reach the end of warmup (unless you want to capture some samples during DCOC cal phase) */
|
||||
temp = XCVR_TSM->END_OF_SEQ;
|
||||
end_of_rx_wu = (temp & XCVR_TSM_END_OF_SEQ_END_OF_RX_WU_MASK) >> XCVR_TSM_END_OF_SEQ_END_OF_RX_WU_SHIFT;
|
||||
while ((( XCVR_MISC->XCVR_STATUS & XCVR_CTRL_XCVR_STATUS_TSM_COUNT_MASK) >> XCVR_CTRL_XCVR_STATUS_TSM_COUNT_SHIFT ) != end_of_rx_wu) {};
|
||||
|
||||
dbg_ram_init();
|
||||
/* Argument below is # of bytes, so *2 (I+Q) and *2 (2bytes/sample) */
|
||||
#if RADIO_IS_GEN_3P0
|
||||
dbg_ram_start_capture(DBG_PAGE_RXDIGIQ, NO_START_TRIG, NO_STOP_TRIG);
|
||||
dbg_ram_wait_for_complete();
|
||||
dbg_ram_postproc_capture(DBG_PAGE_RXDIGIQ, num_iq_samples * 2 * 2, &samples[0]);
|
||||
dbg_ram_release();
|
||||
#else
|
||||
(void)dbg_ram_capture(DBG_PAGE_RXDIGIQ, num_iq_samples * 2 * 2, &samples[0]);
|
||||
#endif /* RADIO_IS_GEN_3P0 */
|
||||
|
||||
/* Sign extend the IQ samples in place in the sample buffer. */
|
||||
sample_ptr = (uint16_t *)(&samples[0]);
|
||||
for (i = 0; i < num_iq_samples * 2; i++)
|
||||
{
|
||||
rx_sample = *sample_ptr;
|
||||
rx_sample |= ((rx_sample & 0x800U) ? 0xF000U : 0x0U); /* Sign extend from 12 to 16 bits. */
|
||||
*sample_ptr = rx_sample;
|
||||
sample_ptr++;
|
||||
}
|
||||
|
||||
sample_ptr = (uint16_t *)(&samples[0]);
|
||||
for (i = 0; i < num_iq_samples * 2; i += 2)
|
||||
{
|
||||
static int16_t i_value;
|
||||
static int16_t q_value;
|
||||
|
||||
/* Average I & Q channels separately. */
|
||||
i_value = *(sample_ptr + i); /* Sign extend from 12 to 16 bits. */
|
||||
q_value = *(sample_ptr + i + 1); /* Sign extend from 12 to 16 bits. */
|
||||
avg_i += ((float)i_value - avg_i) / (float)(i + 1); /* Rolling average I */
|
||||
avg_q += ((float)q_value - avg_q) / (float)(i + 1); /* Rolling average Q */
|
||||
}
|
||||
XcvrCalDelay(10);
|
||||
*i_avg = (int16_t)avg_i;
|
||||
*q_avg = (int16_t)avg_q;
|
||||
}
|
||||
|
||||
/*! *********************************************************************************
|
||||
* \brief This function calculates the average (DC value) based on a larger set of digital samples of I and Q.
|
||||
*
|
||||
* \param[in] i_avg - pointer to the location for storing the calculated average for I channel samples.
|
||||
* \param[in] q_avg - pointer to the location for storing the calculated average for Q channel samples.
|
||||
*
|
||||
***********************************************************************************/
|
||||
void rx_dc_sample_average_long(int16_t * i_avg, int16_t * q_avg)
|
||||
{
|
||||
static uint32_t samples[512]; /* 544*2*2 (entire packet ram1/2 size) */
|
||||
uint16_t i;
|
||||
uint32_t rx_sample;
|
||||
uint16_t * sample_ptr;
|
||||
uint32_t temp, end_of_rx_wu;
|
||||
uint32_t num_iq_samples;
|
||||
float avg_i = 0;
|
||||
float avg_q = 0;
|
||||
|
||||
num_iq_samples = 512;
|
||||
|
||||
/* Clear the entire allocated sample buffer. */
|
||||
for (i = 0; i < num_iq_samples; i++)
|
||||
{
|
||||
samples[i]=0;
|
||||
}
|
||||
|
||||
/* Assume this has been called *AFTER* RxWu has completed. */
|
||||
/* XCVR_ForceRxWu(); */
|
||||
|
||||
/* Wait for TSM to reach the end of warmup (unless you want to capture some samples during DCOC cal phase). */
|
||||
temp = XCVR_TSM->END_OF_SEQ;
|
||||
end_of_rx_wu = (temp & XCVR_TSM_END_OF_SEQ_END_OF_RX_WU_MASK) >> XCVR_TSM_END_OF_SEQ_END_OF_RX_WU_SHIFT;
|
||||
while ((( XCVR_MISC->XCVR_STATUS & XCVR_CTRL_XCVR_STATUS_TSM_COUNT_MASK) >> XCVR_CTRL_XCVR_STATUS_TSM_COUNT_SHIFT ) != end_of_rx_wu) {};
|
||||
|
||||
dbg_ram_init();
|
||||
/* Argument below is # of bytes, so *2 (I+Q) and *2 (2bytes/sample) */
|
||||
#if RADIO_IS_GEN_3P0
|
||||
dbg_ram_start_capture(DBG_PAGE_RXDIGIQ, NO_START_TRIG, NO_STOP_TRIG);
|
||||
dbg_ram_wait_for_complete();
|
||||
dbg_ram_postproc_capture(DBG_PAGE_RXDIGIQ,num_iq_samples * 2 * 2, &samples[0]);
|
||||
dbg_ram_release();
|
||||
#else
|
||||
(void)dbg_ram_capture(DBG_PAGE_RXDIGIQ, num_iq_samples * 2 * 2, &samples[0]);
|
||||
#endif /* RADIO_IS_GEN_3P0 */
|
||||
|
||||
/* Sign extend the IQ samples in place in the sample buffer. */
|
||||
|
||||
sample_ptr = (uint16_t *)(&samples[0]);
|
||||
for (i = 0; i < num_iq_samples * 2; i++)
|
||||
{
|
||||
rx_sample = *sample_ptr;
|
||||
rx_sample |= ((rx_sample & 0x800U) ? 0xF000U : 0x0U); /* Sign extend from 12 to 16 bits. */
|
||||
*sample_ptr = rx_sample;
|
||||
sample_ptr++;
|
||||
}
|
||||
|
||||
sample_ptr = (uint16_t *)(&samples[0]);
|
||||
for (i = 0; i < num_iq_samples * 2; i += 2)
|
||||
{
|
||||
static int16_t i_value;
|
||||
static int16_t q_value;
|
||||
|
||||
/* Average I & Q channels separately. */
|
||||
i_value = *(sample_ptr + i); /* Sign extend from 12 to 16 bits */
|
||||
q_value = *(sample_ptr + i + 1); /* Sign extend from 12 to 16 bits */
|
||||
avg_i += ((float)i_value - avg_i) / (float)(i + 1); /* Rolling average I */
|
||||
avg_q += ((float)q_value - avg_q) / (float)(i + 1); /* Rolling average Q */
|
||||
}
|
||||
|
||||
XcvrCalDelay(10);
|
||||
*i_avg = (int16_t)avg_i;
|
||||
*q_avg = (int16_t)avg_q;
|
||||
}
|
||||
|
||||
/*! *********************************************************************************
|
||||
* rx_dc_est_average : Get DC EST values and return the Average
|
||||
***********************************************************************************/
|
||||
void rx_dc_est_average(int16_t * i_avg, int16_t * q_avg, uint16_t SampleNumber)
|
||||
{
|
||||
float avg_i = 0;
|
||||
float avg_q = 0;
|
||||
uint16_t i = 0;
|
||||
static uint32_t dc_temp, temp;
|
||||
uint32_t end_of_rx_wu = 0;
|
||||
static int16_t dc_meas_i;
|
||||
static int16_t dc_meas_q;
|
||||
|
||||
/* Wait for TSM to reach the end of warmup (unless you want to capture some samples during DCOC cal phase). */
|
||||
temp = XCVR_TSM->END_OF_SEQ;
|
||||
end_of_rx_wu = (temp & XCVR_TSM_END_OF_SEQ_END_OF_RX_WU_MASK) >> XCVR_TSM_END_OF_SEQ_END_OF_RX_WU_SHIFT;
|
||||
while ((( XCVR_MISC->XCVR_STATUS & XCVR_CTRL_XCVR_STATUS_TSM_COUNT_MASK) >> XCVR_CTRL_XCVR_STATUS_TSM_COUNT_SHIFT ) != end_of_rx_wu) {};
|
||||
|
||||
/* Read DCOC DC EST register. */
|
||||
for (i = 0; i < SampleNumber; i++)
|
||||
{
|
||||
dc_temp = XCVR_RX_DIG->DCOC_DC_EST;
|
||||
dc_meas_i = dc_temp & XCVR_RX_DIG_DCOC_DC_EST_DC_EST_I_MASK;
|
||||
temp = dc_meas_i;
|
||||
temp |= ((temp & 0x800U) ? 0xF000U : 0x0U); /* Sign extend from 12 to 16 bits. */
|
||||
dc_meas_i = temp;
|
||||
avg_i += (float) dc_meas_i;
|
||||
|
||||
dc_meas_q = (dc_temp & XCVR_RX_DIG_DCOC_DC_EST_DC_EST_Q_MASK) >> XCVR_RX_DIG_DCOC_DC_EST_DC_EST_Q_SHIFT;
|
||||
temp = dc_meas_q;
|
||||
temp |= ((temp & 0x800U) ? 0xF000U : 0x0U); /* Sign extend from 12 to 16 bits. */
|
||||
dc_meas_q = temp;
|
||||
avg_q += (float) dc_meas_q;
|
||||
}
|
||||
|
||||
avg_i /= (float) SampleNumber;
|
||||
avg_q /= (float) SampleNumber;
|
||||
|
||||
*i_avg = (int16_t)avg_i;
|
||||
*q_avg = (int16_t)avg_q;
|
||||
}
|
||||
|
||||
/*! *********************************************************************************
|
||||
* \brief This function performs a trim of the BBA DCOC DAC on the DUT
|
||||
*
|
||||
* \return status - 1 if passed, 0 if failed.
|
||||
*
|
||||
* \ingroup PublicAPIs
|
||||
*
|
||||
* \details
|
||||
* Requires the RX to be warmed up before this function is called.
|
||||
*
|
||||
***********************************************************************************/
|
||||
uint8_t rx_bba_dcoc_dac_trim_DCest(void)
|
||||
{
|
||||
uint8_t i;
|
||||
float temp_mi = 0;
|
||||
float temp_mq = 0;
|
||||
float temp_pi = 0;
|
||||
float temp_pq = 0;
|
||||
float temp_step = 0;
|
||||
|
||||
uint32_t bbf_dcoc_step;
|
||||
uint32_t bbf_dcoc_step_rcp;
|
||||
TZAdcocstep_t tza_dcoc_step[11];
|
||||
uint8_t status = 0;
|
||||
|
||||
uint8_t bbf_dacinit_i, bbf_dacinit_q;
|
||||
uint8_t tza_dacinit_i, tza_dacinit_q;
|
||||
int16_t dc_meas_i;
|
||||
int16_t dc_meas_q;
|
||||
uint32_t dcoc_init_reg_value_dcgain = 0x80802020; /* Used in 2nd & 3rd Generation DCOC Trims only */
|
||||
uint32_t temp;
|
||||
|
||||
uint32_t dcoc_ctrl_0_stack;
|
||||
uint32_t dcoc_ctrl_1_stack;
|
||||
uint32_t agc_ctrl_1_stack;
|
||||
uint32_t rx_dig_ctrl_stack;
|
||||
uint32_t dcoc_cal_gain_state;
|
||||
|
||||
/* Save register */
|
||||
dcoc_ctrl_0_stack = XCVR_RX_DIG->DCOC_CTRL_0; /* Save state of DCOC_CTRL_0 for later restore */
|
||||
dcoc_ctrl_1_stack = XCVR_RX_DIG->DCOC_CTRL_1; /* Save state of DCOC_CTRL_1 for later restore */
|
||||
rx_dig_ctrl_stack = XCVR_RX_DIG->RX_DIG_CTRL; /* Save state of RX_DIG_CTRL for later restore */
|
||||
agc_ctrl_1_stack = XCVR_RX_DIG->AGC_CTRL_1; /* Save state of RX_DIG_CTRL for later restore */
|
||||
dcoc_cal_gain_state = XCVR_RX_DIG->DCOC_CAL_GAIN; /* Save state of DCOC_CAL_GAIN for later restore */
|
||||
|
||||
/* Register config */
|
||||
/* Ensure AGC, DCOC and RX_DIG_CTRL is in correct mode */
|
||||
temp = XCVR_RX_DIG->RX_DIG_CTRL;
|
||||
temp &= ~XCVR_RX_DIG_RX_DIG_CTRL_RX_AGC_EN_MASK; /* Turn OFF AGC */
|
||||
temp &= ~XCVR_RX_DIG_RX_DIG_CTRL_RX_DCOC_CAL_EN_MASK; /* Disable for SW control of DCOC */
|
||||
temp &= ~XCVR_RX_DIG_RX_DIG_CTRL_RX_DC_RESID_EN_MASK; /* Disable for SW control of DCOC */
|
||||
XCVR_RX_DIG->RX_DIG_CTRL = temp;
|
||||
|
||||
XCVR_RX_DIG->AGC_CTRL_1 = XCVR_RX_DIG_AGC_CTRL_1_USER_LNA_GAIN_EN(1) | /* Enable LNA Manual Gain */
|
||||
XCVR_RX_DIG_AGC_CTRL_1_USER_BBA_GAIN_EN(1) | /* Enable BBA Manual Gain */
|
||||
XCVR_RX_DIG_AGC_CTRL_1_LNA_USER_GAIN(0x0) | /* Set LNA Manual Gain */
|
||||
XCVR_RX_DIG_AGC_CTRL_1_BBA_USER_GAIN(0x0); /* Set BBA Manual Gain */
|
||||
|
||||
/* DCOC_CTRL_0 @ 4005_C02C -- Define default DCOC DAC settings in manual mode */
|
||||
temp = XCVR_RX_DIG->DCOC_CTRL_0;
|
||||
temp |= XCVR_RX_DIG_DCOC_CTRL_0_DCOC_MAN(1); /* Enable Manual DCOC */
|
||||
temp |= XCVR_RX_DIG_DCOC_CTRL_0_DCOC_CORRECT_SRC(1); /* Ensure DCOC Tracking is enabled */
|
||||
temp |= XCVR_RX_DIG_DCOC_CTRL_0_DCOC_TRK_EST_OVR(1); /* Enable DC Estimator */
|
||||
temp |= XCVR_RX_DIG_DCOC_CTRL_0_DCOC_CORRECT_EN(1); /* Ensure DC correction is enabled */
|
||||
XCVR_RX_DIG->DCOC_CTRL_0 = temp;
|
||||
|
||||
XCVR_RX_DIG->DCOC_DAC_INIT = XCVR_RX_DIG_DCOC_DAC_INIT_BBA_DCOC_INIT_I(0x20) |
|
||||
XCVR_RX_DIG_DCOC_DAC_INIT_BBA_DCOC_INIT_Q(0x20) |
|
||||
XCVR_RX_DIG_DCOC_DAC_INIT_TZA_DCOC_INIT_I(0x80) |
|
||||
XCVR_RX_DIG_DCOC_DAC_INIT_TZA_DCOC_INIT_Q(0x80);
|
||||
|
||||
XcvrCalDelay(TsettleCal);
|
||||
|
||||
/* Set default DCOC DAC INIT Value */
|
||||
dcoc_init_reg_value_dcgain = XCVR_RX_DIG->DCOC_DAC_INIT; /* Store DCOC DAC INIT values */
|
||||
bbf_dacinit_i = (dcoc_init_reg_value_dcgain & 0x000000FFU);
|
||||
bbf_dacinit_q = (dcoc_init_reg_value_dcgain & 0x0000FF00U)>>8;
|
||||
tza_dacinit_i = (dcoc_init_reg_value_dcgain & 0x00FF0000U)>>16;
|
||||
tza_dacinit_q = dcoc_init_reg_value_dcgain >> 24;
|
||||
|
||||
XcvrCalDelay(TsettleCal * 4);
|
||||
rx_dc_est_average(&dc_meas_i, &dc_meas_q, 64);
|
||||
measurement_tbl2[I_CHANNEL][NOMINAL2].step_value = sweep_step_values2[NOMINAL2];
|
||||
measurement_tbl2[Q_CHANNEL][NOMINAL2].step_value = sweep_step_values2[NOMINAL2];
|
||||
measurement_tbl2[I_CHANNEL][NOMINAL2].internal_measurement = dc_meas_i;
|
||||
measurement_tbl2[Q_CHANNEL][NOMINAL2].internal_measurement = dc_meas_q;
|
||||
|
||||
/* SWEEP I/Q CHANNEL */
|
||||
/* BBF NEG STEP */
|
||||
XCVR_RX_DIG->DCOC_DAC_INIT = XCVR_RX_DIG_DCOC_DAC_INIT_BBA_DCOC_INIT_I(bbf_dacinit_i - 16) |
|
||||
XCVR_RX_DIG_DCOC_DAC_INIT_BBA_DCOC_INIT_Q(bbf_dacinit_q - 16) |
|
||||
XCVR_RX_DIG_DCOC_DAC_INIT_TZA_DCOC_INIT_I(tza_dacinit_i) |
|
||||
XCVR_RX_DIG_DCOC_DAC_INIT_TZA_DCOC_INIT_Q(tza_dacinit_q);
|
||||
XcvrCalDelay(TsettleCal * 2);
|
||||
|
||||
rx_dc_est_average(&dc_meas_i, &dc_meas_q, 64);
|
||||
measurement_tbl2[I_CHANNEL][BBF_NEG].step_value = -16;
|
||||
measurement_tbl2[Q_CHANNEL][BBF_NEG].step_value = -16;
|
||||
measurement_tbl2[I_CHANNEL][BBF_NEG].internal_measurement = dc_meas_i;
|
||||
measurement_tbl2[Q_CHANNEL][BBF_NEG].internal_measurement = dc_meas_q;
|
||||
|
||||
|
||||
/* BBF POS STEP */
|
||||
XCVR_RX_DIG->DCOC_DAC_INIT = XCVR_RX_DIG_DCOC_DAC_INIT_BBA_DCOC_INIT_I(bbf_dacinit_i + 16) |
|
||||
XCVR_RX_DIG_DCOC_DAC_INIT_BBA_DCOC_INIT_Q(bbf_dacinit_q + 16) |
|
||||
XCVR_RX_DIG_DCOC_DAC_INIT_TZA_DCOC_INIT_I(tza_dacinit_i) |
|
||||
XCVR_RX_DIG_DCOC_DAC_INIT_TZA_DCOC_INIT_Q(tza_dacinit_q);
|
||||
XcvrCalDelay(TsettleCal * 2);
|
||||
rx_dc_est_average(&dc_meas_i, &dc_meas_q, 64);
|
||||
measurement_tbl2[I_CHANNEL][BBF_POS].step_value = +16;
|
||||
measurement_tbl2[Q_CHANNEL][BBF_POS].step_value = +16;
|
||||
measurement_tbl2[I_CHANNEL][BBF_POS].internal_measurement = dc_meas_i;
|
||||
measurement_tbl2[Q_CHANNEL][BBF_POS].internal_measurement = dc_meas_q;
|
||||
|
||||
XCVR_RX_DIG->DCOC_DAC_INIT = dcoc_init_reg_value_dcgain; /* Return DAC setting to initial */
|
||||
|
||||
/* Calculate BBF DCOC STEPS, RECIPROCALS */
|
||||
temp_mi = calc_dcoc_dac_step(&measurement_tbl2[I_CHANNEL][BBF_NEG], &measurement_tbl2[I_CHANNEL][NOMINAL2]);
|
||||
temp_mq = calc_dcoc_dac_step(&measurement_tbl2[Q_CHANNEL][BBF_NEG], &measurement_tbl2[Q_CHANNEL][NOMINAL2]);
|
||||
temp_pi = calc_dcoc_dac_step(&measurement_tbl2[I_CHANNEL][BBF_POS], &measurement_tbl2[I_CHANNEL][NOMINAL2]);
|
||||
temp_pq = calc_dcoc_dac_step(&measurement_tbl2[Q_CHANNEL][BBF_POS], &measurement_tbl2[Q_CHANNEL][NOMINAL2]);
|
||||
|
||||
temp_step = (temp_mi + temp_pi + temp_mq + temp_pq) / 4;
|
||||
bbf_dcoc_step = (uint32_t)roundf(temp_step * 8U);
|
||||
|
||||
if ((bbf_dcoc_step > 265) & (bbf_dcoc_step < 305))
|
||||
{
|
||||
bbf_dcoc_step_rcp = (uint32_t)roundf((float)0x8000U / temp_step);
|
||||
|
||||
/* Calculate TZA DCOC STEPS & RECIPROCALS and IQ_DC_GAIN_MISMATCH */
|
||||
for (i = TZA_STEP_N0; i <= TZA_STEP_N10; i++)
|
||||
{
|
||||
/* Calculate TZA DCOC STEPSIZE & its RECIPROCAL */
|
||||
switch(i){
|
||||
case TZA_STEP_N0:
|
||||
temp_step = (bbf_dcoc_step>>3U) / 3.6F;
|
||||
break;
|
||||
case TZA_STEP_N1:
|
||||
temp_step = temp_step * (xcvr_common_config.dcoc_tza_step_01_init >> 16) / (xcvr_common_config.dcoc_tza_step_00_init >> 16);
|
||||
break;
|
||||
case TZA_STEP_N2:
|
||||
temp_step = temp_step * (xcvr_common_config.dcoc_tza_step_02_init >> 16) / (xcvr_common_config.dcoc_tza_step_01_init >> 16);
|
||||
break;
|
||||
case TZA_STEP_N3:
|
||||
temp_step = temp_step * (xcvr_common_config.dcoc_tza_step_03_init >> 16) / (xcvr_common_config.dcoc_tza_step_02_init >> 16);
|
||||
break;
|
||||
case TZA_STEP_N4:
|
||||
temp_step = temp_step * (xcvr_common_config.dcoc_tza_step_04_init >> 16) / (xcvr_common_config.dcoc_tza_step_03_init >> 16);
|
||||
break;
|
||||
case TZA_STEP_N5:
|
||||
temp_step = temp_step * (xcvr_common_config.dcoc_tza_step_05_init >> 16) / (xcvr_common_config.dcoc_tza_step_04_init >> 16);
|
||||
break;
|
||||
case TZA_STEP_N6:
|
||||
temp_step = temp_step * (xcvr_common_config.dcoc_tza_step_06_init >> 16) / (xcvr_common_config.dcoc_tza_step_05_init >> 16);
|
||||
break;
|
||||
case TZA_STEP_N7:
|
||||
temp_step = temp_step * (xcvr_common_config.dcoc_tza_step_07_init >> 16) / (xcvr_common_config.dcoc_tza_step_06_init >> 16);
|
||||
break;
|
||||
case TZA_STEP_N8:
|
||||
temp_step = temp_step * (xcvr_common_config.dcoc_tza_step_08_init >> 16) / (xcvr_common_config.dcoc_tza_step_07_init >> 16);
|
||||
break;
|
||||
case TZA_STEP_N9:
|
||||
temp_step = temp_step * (xcvr_common_config.dcoc_tza_step_09_init >> 16) / (xcvr_common_config.dcoc_tza_step_08_init >> 16);
|
||||
break;
|
||||
case TZA_STEP_N10:
|
||||
temp_step = temp_step * (xcvr_common_config.dcoc_tza_step_10_init >> 16) / (xcvr_common_config.dcoc_tza_step_09_init >> 16);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
tza_dcoc_step[i-TZA_STEP_N0].dcoc_step = (uint32_t)roundf(temp_step * 8);
|
||||
tza_dcoc_step[i-TZA_STEP_N0].dcoc_step_rcp = (uint32_t)roundf((float)0x8000 / temp_step);
|
||||
}
|
||||
|
||||
/* Make the trims active */
|
||||
XCVR_RX_DIG->DCOC_BBA_STEP = XCVR_RX_DIG_DCOC_BBA_STEP_BBA_DCOC_STEP(bbf_dcoc_step) | XCVR_RX_DIG_DCOC_BBA_STEP_BBA_DCOC_STEP_RECIP(bbf_dcoc_step_rcp);
|
||||
XCVR_RX_DIG->DCOC_TZA_STEP_0 = XCVR_RX_DIG_DCOC_TZA_STEP_0_DCOC_TZA_STEP_GAIN_0(tza_dcoc_step[0].dcoc_step) | XCVR_RX_DIG_DCOC_TZA_STEP_0_DCOC_TZA_STEP_RCP_0(tza_dcoc_step[0].dcoc_step_rcp);
|
||||
XCVR_RX_DIG->DCOC_TZA_STEP_1 = XCVR_RX_DIG_DCOC_TZA_STEP_1_DCOC_TZA_STEP_GAIN_1(tza_dcoc_step[1].dcoc_step) | XCVR_RX_DIG_DCOC_TZA_STEP_1_DCOC_TZA_STEP_RCP_1(tza_dcoc_step[1].dcoc_step_rcp);
|
||||
XCVR_RX_DIG->DCOC_TZA_STEP_2 = XCVR_RX_DIG_DCOC_TZA_STEP_2_DCOC_TZA_STEP_GAIN_2(tza_dcoc_step[2].dcoc_step) | XCVR_RX_DIG_DCOC_TZA_STEP_2_DCOC_TZA_STEP_RCP_2(tza_dcoc_step[2].dcoc_step_rcp);
|
||||
XCVR_RX_DIG->DCOC_TZA_STEP_3 = XCVR_RX_DIG_DCOC_TZA_STEP_3_DCOC_TZA_STEP_GAIN_3(tza_dcoc_step[3].dcoc_step) | XCVR_RX_DIG_DCOC_TZA_STEP_3_DCOC_TZA_STEP_RCP_3(tza_dcoc_step[3].dcoc_step_rcp);
|
||||
XCVR_RX_DIG->DCOC_TZA_STEP_4 = XCVR_RX_DIG_DCOC_TZA_STEP_4_DCOC_TZA_STEP_GAIN_4(tza_dcoc_step[4].dcoc_step) | XCVR_RX_DIG_DCOC_TZA_STEP_4_DCOC_TZA_STEP_RCP_4(tza_dcoc_step[4].dcoc_step_rcp);
|
||||
XCVR_RX_DIG->DCOC_TZA_STEP_5 = XCVR_RX_DIG_DCOC_TZA_STEP_5_DCOC_TZA_STEP_GAIN_5(tza_dcoc_step[5].dcoc_step) | XCVR_RX_DIG_DCOC_TZA_STEP_5_DCOC_TZA_STEP_RCP_5(tza_dcoc_step[5].dcoc_step_rcp);
|
||||
XCVR_RX_DIG->DCOC_TZA_STEP_6 = XCVR_RX_DIG_DCOC_TZA_STEP_6_DCOC_TZA_STEP_GAIN_6(tza_dcoc_step[6].dcoc_step) | XCVR_RX_DIG_DCOC_TZA_STEP_6_DCOC_TZA_STEP_RCP_6(tza_dcoc_step[6].dcoc_step_rcp);
|
||||
XCVR_RX_DIG->DCOC_TZA_STEP_7 = XCVR_RX_DIG_DCOC_TZA_STEP_7_DCOC_TZA_STEP_GAIN_7(tza_dcoc_step[7].dcoc_step) | XCVR_RX_DIG_DCOC_TZA_STEP_7_DCOC_TZA_STEP_RCP_7(tza_dcoc_step[7].dcoc_step_rcp);
|
||||
XCVR_RX_DIG->DCOC_TZA_STEP_8 = XCVR_RX_DIG_DCOC_TZA_STEP_8_DCOC_TZA_STEP_GAIN_8(tza_dcoc_step[8].dcoc_step) | XCVR_RX_DIG_DCOC_TZA_STEP_8_DCOC_TZA_STEP_RCP_8(tza_dcoc_step[8].dcoc_step_rcp);
|
||||
XCVR_RX_DIG->DCOC_TZA_STEP_9 = XCVR_RX_DIG_DCOC_TZA_STEP_9_DCOC_TZA_STEP_GAIN_9(tza_dcoc_step[9].dcoc_step) | XCVR_RX_DIG_DCOC_TZA_STEP_9_DCOC_TZA_STEP_RCP_9(tza_dcoc_step[9].dcoc_step_rcp);
|
||||
XCVR_RX_DIG->DCOC_TZA_STEP_10 = XCVR_RX_DIG_DCOC_TZA_STEP_10_DCOC_TZA_STEP_GAIN_10(tza_dcoc_step[10].dcoc_step) | XCVR_RX_DIG_DCOC_TZA_STEP_10_DCOC_TZA_STEP_RCP_10(tza_dcoc_step[10].dcoc_step_rcp);
|
||||
|
||||
status = 1; /* Success */
|
||||
}
|
||||
else
|
||||
{
|
||||
status = 0; /* Failure */
|
||||
}
|
||||
|
||||
/* Restore Registers */
|
||||
XCVR_RX_DIG->DCOC_CTRL_0 = dcoc_ctrl_0_stack; /* Restore DCOC_CTRL_0 state to prior settings */
|
||||
XCVR_RX_DIG->DCOC_CTRL_1 = dcoc_ctrl_1_stack; /* Restore DCOC_CTRL_1 state to prior settings */
|
||||
XCVR_RX_DIG->RX_DIG_CTRL = rx_dig_ctrl_stack; /* Restore RX_DIG_CTRL state to prior settings */
|
||||
XCVR_RX_DIG->DCOC_CAL_GAIN = dcoc_cal_gain_state; /* Restore DCOC_CAL_GAIN state to prior setting */
|
||||
XCVR_RX_DIG->AGC_CTRL_1 = agc_ctrl_1_stack; /* Save state of RX_DIG_CTRL for later restore */
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
/*! *********************************************************************************
|
||||
* DCOC_DAC_INIT_Cal : slope sign seek depending on measure's sign
|
||||
***********************************************************************************/
|
||||
void DCOC_DAC_INIT_Cal(uint8_t standalone_operation)
|
||||
{
|
||||
int16_t dc_meas_i = 2000, dc_meas_i_p = 2000;
|
||||
int16_t dc_meas_q = 2000, dc_meas_q_p = 2000;
|
||||
uint8_t curr_tza_dac_i, curr_tza_dac_q;
|
||||
uint8_t curr_bba_dac_i, curr_bba_dac_q;
|
||||
uint8_t p_tza_dac_i, p_tza_dac_q;
|
||||
uint8_t p_bba_dac_i, p_bba_dac_q;
|
||||
uint8_t i = 0;
|
||||
uint8_t bba_gain = 11;
|
||||
bool TZA_I_OK = 0, TZA_Q_OK = 0, BBA_I_OK = 0, BBA_Q_OK = 0;
|
||||
|
||||
uint32_t dcoc_ctrl_0_stack;
|
||||
uint32_t dcoc_ctrl_1_stack;
|
||||
uint32_t agc_ctrl_1_stack;
|
||||
uint32_t rx_dig_ctrl_stack;
|
||||
uint32_t dcoc_cal_gain_state;
|
||||
uint32_t xcvr_ctrl_stack;
|
||||
|
||||
uint32_t temp;
|
||||
|
||||
/* Save registers */
|
||||
dcoc_ctrl_0_stack = XCVR_RX_DIG->DCOC_CTRL_0; /* Save state of DCOC_CTRL_0 for later restore */
|
||||
dcoc_ctrl_1_stack = XCVR_RX_DIG->DCOC_CTRL_1; /* Save state of DCOC_CTRL_1 for later restore */
|
||||
rx_dig_ctrl_stack = XCVR_RX_DIG->RX_DIG_CTRL; /* Save state of RX_DIG_CTRL for later restore */
|
||||
agc_ctrl_1_stack = XCVR_RX_DIG->AGC_CTRL_1; /* Save state of RX_DIG_CTRL for later restore */
|
||||
dcoc_cal_gain_state = XCVR_RX_DIG->DCOC_CAL_GAIN; /* Save state of DCOC_CAL_GAIN for later restore */
|
||||
|
||||
/* WarmUp */
|
||||
if (standalone_operation)
|
||||
{
|
||||
temp = XCVR_MISC->XCVR_CTRL;
|
||||
xcvr_ctrl_stack = temp;
|
||||
temp &= ~(XCVR_CTRL_XCVR_CTRL_PROTOCOL_MASK);
|
||||
temp |= XCVR_CTRL_XCVR_CTRL_PROTOCOL(0);
|
||||
XCVR_MISC->XCVR_CTRL = temp;
|
||||
XCVR_OverrideChannel(12, 1); /* Calibrate on channel #12, 2.426 GHz in BLE map */
|
||||
XCVR_ForceRxWu();
|
||||
XcvrCalDelay(2000);
|
||||
}
|
||||
|
||||
/* Register config */
|
||||
/* Ensure AGC, DCOC and RX_DIG_CTRL is in correct mode */
|
||||
temp = XCVR_RX_DIG->RX_DIG_CTRL;
|
||||
temp &= ~XCVR_RX_DIG_RX_DIG_CTRL_RX_AGC_EN_MASK; /* Turn OFF AGC */
|
||||
temp &= ~XCVR_RX_DIG_RX_DIG_CTRL_RX_DCOC_CAL_EN_MASK; /* Disable for SW control of DCOC */
|
||||
temp &= ~XCVR_RX_DIG_RX_DIG_CTRL_RX_DC_RESID_EN_MASK; /* Disable for SW control of DCOC */
|
||||
XCVR_RX_DIG->RX_DIG_CTRL = temp;
|
||||
|
||||
XCVR_RX_DIG->AGC_CTRL_1 = XCVR_RX_DIG_AGC_CTRL_1_USER_LNA_GAIN_EN(1) | /* Enable LNA Manual Gain */
|
||||
XCVR_RX_DIG_AGC_CTRL_1_USER_BBA_GAIN_EN(1) | /* Enable BBA Manual Gain */
|
||||
XCVR_RX_DIG_AGC_CTRL_1_LNA_USER_GAIN(0x0) | /* Set LNA Manual Gain */
|
||||
XCVR_RX_DIG_AGC_CTRL_1_BBA_USER_GAIN(0x0); /* Set BBA Manual Gain */
|
||||
|
||||
/* DCOC_CTRL_0 @ 4005_C02C -- Define default DCOC DAC settings in manual mode */
|
||||
temp = XCVR_RX_DIG->DCOC_CTRL_0;
|
||||
temp |= XCVR_RX_DIG_DCOC_CTRL_0_DCOC_MAN(1); /* Enable Manual DCOC */
|
||||
temp |= XCVR_RX_DIG_DCOC_CTRL_0_DCOC_CORRECT_SRC(1); /* Ensure DCOC Tracking is enabled */
|
||||
temp |= XCVR_RX_DIG_DCOC_CTRL_0_DCOC_TRK_EST_OVR(1); /* Enable DC Estimator */
|
||||
temp |= XCVR_RX_DIG_DCOC_CTRL_0_DCOC_CORRECT_EN(1); /* Ensure DC correction is enabled */
|
||||
XCVR_RX_DIG->DCOC_CTRL_0 = temp;
|
||||
|
||||
XcvrCalDelay(TsettleCal);
|
||||
|
||||
/* Set default DCOC DAC INIT Value */
|
||||
/* LNA and BBA DAC Sweep */
|
||||
curr_bba_dac_i = 0x20;
|
||||
curr_bba_dac_q = 0x20;
|
||||
curr_tza_dac_i = 0x80;
|
||||
curr_tza_dac_q = 0x80;
|
||||
|
||||
/* Perform a first DC measurement to ensure that measurement is not clipping */
|
||||
XCVR_RX_DIG->DCOC_DAC_INIT = XCVR_RX_DIG_DCOC_DAC_INIT_BBA_DCOC_INIT_I(curr_bba_dac_i) |
|
||||
XCVR_RX_DIG_DCOC_DAC_INIT_BBA_DCOC_INIT_Q(curr_bba_dac_q) |
|
||||
XCVR_RX_DIG_DCOC_DAC_INIT_TZA_DCOC_INIT_I(curr_tza_dac_i) |
|
||||
XCVR_RX_DIG_DCOC_DAC_INIT_TZA_DCOC_INIT_Q(curr_tza_dac_q);
|
||||
|
||||
do
|
||||
{
|
||||
bba_gain--;
|
||||
/* Set DAC user gain */
|
||||
XCVR_RX_DIG->AGC_CTRL_1 = XCVR_RX_DIG_AGC_CTRL_1_USER_LNA_GAIN_EN(1) |
|
||||
XCVR_RX_DIG_AGC_CTRL_1_LNA_USER_GAIN(0) | /* 2 */
|
||||
XCVR_RX_DIG_AGC_CTRL_1_USER_BBA_GAIN_EN(1) |
|
||||
XCVR_RX_DIG_AGC_CTRL_1_BBA_USER_GAIN(bba_gain) ; /* 10 */
|
||||
XcvrCalDelay(TsettleCal * 2);
|
||||
rx_dc_est_average(&dc_meas_i, &dc_meas_q, 64);
|
||||
} while ((ABS(dc_meas_i) > 1900) | (ABS(dc_meas_q) > 1900));
|
||||
|
||||
for (i = 0; i < 0x0F; i++)
|
||||
{
|
||||
/* I channel : */
|
||||
if (!TZA_I_OK)
|
||||
{
|
||||
if ((ISIGN(dc_meas_i) != ISIGN(dc_meas_i_p)) && (i > 0))
|
||||
{
|
||||
if (ABS(dc_meas_i) != MIN(ABS(dc_meas_i), ABS(dc_meas_i_p)))
|
||||
{
|
||||
curr_tza_dac_i = p_tza_dac_i;
|
||||
}
|
||||
|
||||
TZA_I_OK = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
p_tza_dac_i = curr_tza_dac_i;
|
||||
|
||||
if (ISIGN(dc_meas_i)) /* If positif */
|
||||
{
|
||||
curr_tza_dac_i--;
|
||||
}
|
||||
else
|
||||
{
|
||||
curr_tza_dac_i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
else /* Sweep BBA I */
|
||||
{
|
||||
if (!BBA_I_OK)
|
||||
{
|
||||
if ((ISIGN(dc_meas_i) != ISIGN(dc_meas_i_p)) && (curr_bba_dac_i != 0x20))
|
||||
{
|
||||
if (ABS(dc_meas_i) != MIN(ABS(dc_meas_i), ABS(dc_meas_i_p)))
|
||||
{
|
||||
curr_bba_dac_i = p_bba_dac_i;
|
||||
}
|
||||
|
||||
BBA_I_OK = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
p_bba_dac_i = curr_bba_dac_i;
|
||||
if (ISIGN(dc_meas_i)) /* If positif */
|
||||
{
|
||||
curr_bba_dac_i--;
|
||||
}
|
||||
else
|
||||
{
|
||||
curr_bba_dac_i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Q channel : */
|
||||
if (!TZA_Q_OK)
|
||||
{
|
||||
if ((ISIGN(dc_meas_q) != ISIGN(dc_meas_q_p)) && (i > 0))
|
||||
{
|
||||
if (ABS(dc_meas_q) != MIN(ABS(dc_meas_q), ABS(dc_meas_q_p)))
|
||||
{
|
||||
curr_tza_dac_q = p_tza_dac_q;
|
||||
}
|
||||
TZA_Q_OK = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
p_tza_dac_q = curr_tza_dac_q;
|
||||
if (ISIGN(dc_meas_q)) /* If positif */
|
||||
{
|
||||
curr_tza_dac_q--;
|
||||
}
|
||||
else
|
||||
{
|
||||
curr_tza_dac_q++;
|
||||
}
|
||||
}
|
||||
}
|
||||
else /* Sweep BBA Q */
|
||||
{
|
||||
if (!BBA_Q_OK)
|
||||
{
|
||||
if ((ISIGN(dc_meas_q) != ISIGN(dc_meas_q_p)) && (curr_bba_dac_q != 0x20))
|
||||
{
|
||||
if (ABS(dc_meas_q) != MIN(ABS(dc_meas_q), ABS(dc_meas_q_p)))
|
||||
{
|
||||
curr_bba_dac_q = p_bba_dac_q;
|
||||
}
|
||||
BBA_Q_OK = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
p_bba_dac_q = curr_bba_dac_q;
|
||||
if (ISIGN(dc_meas_q)) /* If positif */
|
||||
{
|
||||
curr_bba_dac_q--;
|
||||
}
|
||||
else
|
||||
{
|
||||
curr_bba_dac_q++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* DC OK break : */
|
||||
if (TZA_I_OK && TZA_Q_OK && BBA_I_OK && BBA_Q_OK)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
dc_meas_i_p = dc_meas_i; /* Store as previous value */
|
||||
dc_meas_q_p = dc_meas_q; /* Store as previous value */
|
||||
XCVR_RX_DIG->DCOC_DAC_INIT = XCVR_RX_DIG_DCOC_DAC_INIT_BBA_DCOC_INIT_I(curr_bba_dac_i) |
|
||||
XCVR_RX_DIG_DCOC_DAC_INIT_BBA_DCOC_INIT_Q(curr_bba_dac_q) |
|
||||
XCVR_RX_DIG_DCOC_DAC_INIT_TZA_DCOC_INIT_I(curr_tza_dac_i) |
|
||||
XCVR_RX_DIG_DCOC_DAC_INIT_TZA_DCOC_INIT_Q(curr_tza_dac_q);
|
||||
XcvrCalDelay(TsettleCal * 2);
|
||||
rx_dc_est_average(&dc_meas_i, &dc_meas_q, 64);
|
||||
}
|
||||
|
||||
/* Apply optimized DCOC DAC INIT : */
|
||||
XCVR_RX_DIG->DCOC_DAC_INIT = XCVR_RX_DIG_DCOC_DAC_INIT_BBA_DCOC_INIT_I(curr_bba_dac_i) |
|
||||
XCVR_RX_DIG_DCOC_DAC_INIT_BBA_DCOC_INIT_Q(curr_bba_dac_q) |
|
||||
XCVR_RX_DIG_DCOC_DAC_INIT_TZA_DCOC_INIT_I(curr_tza_dac_i) |
|
||||
XCVR_RX_DIG_DCOC_DAC_INIT_TZA_DCOC_INIT_Q(curr_tza_dac_q);
|
||||
|
||||
/* WarmDown */
|
||||
if (standalone_operation)
|
||||
{
|
||||
XCVR_ForceRxWd(); /* Don't leave the receiver running. */
|
||||
XcvrCalDelay(200);
|
||||
XCVR_OverrideChannel(0xFF,1); /* Release channel overrides */
|
||||
XCVR_MISC->XCVR_CTRL = xcvr_ctrl_stack;
|
||||
}
|
||||
|
||||
/* Restore register */
|
||||
XCVR_RX_DIG->DCOC_CTRL_0 = dcoc_ctrl_0_stack; /* Restore DCOC_CTRL_0 state to prior settings */
|
||||
XCVR_RX_DIG->DCOC_CTRL_1 = dcoc_ctrl_1_stack; /* Restore DCOC_CTRL_1 state to prior settings */
|
||||
XCVR_RX_DIG->RX_DIG_CTRL = rx_dig_ctrl_stack; /* Restore RX_DIG_CTRL state to prior settings */
|
||||
XCVR_RX_DIG->DCOC_CAL_GAIN = dcoc_cal_gain_state; /* Restore DCOC_CAL_GAIN state to prior setting */
|
||||
XCVR_RX_DIG->AGC_CTRL_1 = agc_ctrl_1_stack; /* Save state of RX_DIG_CTRL for later restore */
|
||||
}
|
||||
|
||||
-132
@@ -1,132 +0,0 @@
|
||||
/*
|
||||
* Copyright 2016-2017 NXP
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* o Redistributions of source code must retain the above copyright notice, this list
|
||||
* of conditions and the following disclaimer.
|
||||
*
|
||||
* o 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.
|
||||
*
|
||||
* o Neither the name of Freescale Semiconductor, Inc. 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 HOLDER 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 _FSL_XCVR_TRIM_H_
|
||||
/* Clang-format off. */
|
||||
#define _FSL_XCVR_TRIM_H_
|
||||
/* Clang-format on. */
|
||||
|
||||
#include "fsl_device_registers.h"
|
||||
/*!
|
||||
* @addtogroup xcvr
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*! @file*/
|
||||
|
||||
/************************************************************************************
|
||||
*************************************************************************************
|
||||
* Public constant definitions
|
||||
*************************************************************************************
|
||||
************************************************************************************/
|
||||
|
||||
/************************************************************************************
|
||||
*************************************************************************************
|
||||
* Public type definitions
|
||||
*************************************************************************************
|
||||
************************************************************************************/
|
||||
|
||||
/* \brief The enumerations used to define the I & Q channel selections. */
|
||||
typedef enum
|
||||
{
|
||||
I_CHANNEL = 0,
|
||||
Q_CHANNEL = 1,
|
||||
NUM_I_Q_CHAN = 2
|
||||
} IQ_t;
|
||||
|
||||
typedef enum /* Enumeration of ADC_GAIN_CAL 2 */
|
||||
{
|
||||
NOMINAL2 = 0,
|
||||
BBF_NEG = 1,
|
||||
BBF_POS = 2,
|
||||
TZA_STEP_N0 = 3,
|
||||
TZA_STEP_N1 = 4,
|
||||
TZA_STEP_N2 = 5,
|
||||
TZA_STEP_N3 = 6,
|
||||
TZA_STEP_N4 = 7,
|
||||
TZA_STEP_N5 = 8,
|
||||
TZA_STEP_N6 = 9,
|
||||
TZA_STEP_N7 = 10,
|
||||
TZA_STEP_N8 = 11,
|
||||
TZA_STEP_N9 = 12,
|
||||
TZA_STEP_N10 = 13,
|
||||
TZA_STEP_P0 = 14,
|
||||
TZA_STEP_P1 = 15,
|
||||
TZA_STEP_P2 = 16,
|
||||
TZA_STEP_P3 = 17,
|
||||
TZA_STEP_P4 = 18,
|
||||
TZA_STEP_P5 = 19,
|
||||
TZA_STEP_P6 = 20,
|
||||
TZA_STEP_P7 = 21,
|
||||
TZA_STEP_P8 = 22,
|
||||
TZA_STEP_P9 = 23,
|
||||
TZA_STEP_P10 = 24,
|
||||
|
||||
NUM_SWEEP_STEP_ENTRIES2 = 25 /* Including the baseline entry #0. */
|
||||
} DAC_SWEEP_STEP2_t;
|
||||
|
||||
/* \brief Defines an entry in an array of structs to describe TZA DCOC STEP and TZA_DCOC_STEP_RECIPROCAL. */
|
||||
typedef struct
|
||||
{
|
||||
uint16_t dcoc_step;
|
||||
uint16_t dcoc_step_rcp;
|
||||
// uint16_t dcoc_step_q;
|
||||
// uint16_t dcoc_step_rcp_q;
|
||||
} TZAdcocstep_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int8_t step_value; /* The offset from nominal DAC value (see sweep_step_values[]) */
|
||||
int16_t internal_measurement; /* The value (average code) measured from DMA samples. */
|
||||
// uint8_t valid; /* Set to TRUE (non zero) when a value is written to this table entry. */
|
||||
} GAIN_CALC_TBL_ENTRY2_T;
|
||||
|
||||
/*******************************************************************************
|
||||
* Definitions
|
||||
******************************************************************************/
|
||||
void rx_dc_sample_average(int16_t * i_avg, int16_t * q_avg);
|
||||
void rx_dc_sample_average_long(int16_t * i_avg, int16_t * q_avg);
|
||||
uint8_t rx_bba_dcoc_dac_trim_shortIQ(void);
|
||||
void XcvrCalDelay(uint32_t time);
|
||||
void rx_dc_est_average(int16_t * i_avg, int16_t * q_avg, uint16_t SampleNumber);
|
||||
uint8_t rx_bba_dcoc_dac_trim_DCest(void);
|
||||
void DCOC_DAC_INIT_Cal(uint8_t standalone_operation);
|
||||
|
||||
|
||||
|
||||
|
||||
/* @} */
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
/*! @}*/
|
||||
|
||||
#endif /* _FSL_XCVR_TRIM_H_ */
|
||||
|
||||
-532
@@ -1,532 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Freescale Semiconductor, Inc.
|
||||
* Copyright 2016-2017 NXP
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* o Redistributions of source code must retain the above copyright notice, this list
|
||||
* of conditions and the following disclaimer.
|
||||
*
|
||||
* o 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.
|
||||
*
|
||||
* o Neither the name of Freescale Semiconductor, Inc. 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 HOLDER 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 "fsl_device_registers.h"
|
||||
#include "fsl_xcvr.h"
|
||||
#include "ifr_radio.h"
|
||||
#include "fsl_common.h"
|
||||
|
||||
/*******************************************************************************
|
||||
* Definitions
|
||||
******************************************************************************/
|
||||
#define IFR_RAM (0)
|
||||
|
||||
#if RADIO_IS_GEN_3P0
|
||||
#define RDINDX (0x41U)
|
||||
#define K3_BASE_INDEX (0x11U) /* Based for read index */
|
||||
#else
|
||||
#define RDRSRC (0x03U)
|
||||
#define KW4x_512_BASE (0x20000U)
|
||||
#define KW4x_256_BASE (0x10000U)
|
||||
#endif /* RADIO_IS_GEN_3P0 */
|
||||
|
||||
#if RADIO_IS_GEN_2P1
|
||||
#define FTFA (FTFE)
|
||||
#endif /* RADIO_IS_GEN_2P1 */
|
||||
|
||||
/*******************************************************************************
|
||||
* Prototypes
|
||||
******************************************************************************/
|
||||
uint32_t read_another_ifr_word(void);
|
||||
uint32_t read_first_ifr_word(uint32_t read_addr);
|
||||
|
||||
#if RADIO_IS_GEN_3P0
|
||||
uint64_t read_index_ifr(uint32_t read_addr);
|
||||
#else
|
||||
/*! *********************************************************************************
|
||||
* @brief Reads a location in block 1 IFR for use by the radio.
|
||||
*
|
||||
* This function handles reading IFR data from flash memory for trim loading.
|
||||
*
|
||||
* @param read_addr the address in the IFR to be read.
|
||||
*
|
||||
* @details This function wraps both the Gen2 read_resource command and the Gen2.1 and Gen3 read_index
|
||||
***********************************************************************************/
|
||||
#if RADIO_IS_GEN_2P1
|
||||
uint64_t read_resource_ifr(uint32_t read_addr);
|
||||
#else
|
||||
uint32_t read_resource_ifr(uint32_t read_addr);
|
||||
#endif /* RADIO_IS_GEN_2P1 */
|
||||
#endif /* RADIO_IS_GEN_3P0 */
|
||||
|
||||
void store_sw_trim(IFR_SW_TRIM_TBL_ENTRY_T * sw_trim_tbl, uint16_t num_entries, uint32_t addr, uint32_t data);
|
||||
|
||||
/*******************************************************************************
|
||||
* Variables
|
||||
******************************************************************************/
|
||||
static uint32_t ifr_read_addr;
|
||||
|
||||
#if RADIO_IS_GEN_3P0
|
||||
static uint64_t packed_data_long; /* Storage for 2 32 bit values to be read by read_index */
|
||||
static uint8_t num_words_avail; /* Number of 32 bit words available in packed_data_long storage */
|
||||
const uint32_t BLOCK_1_IFR[]=
|
||||
{
|
||||
/* Revised fallback table which should work with untrimmed parts */
|
||||
0xABCDFFFEU, /* Version #FFFE indicates default trim values */
|
||||
|
||||
/* Trim table is empty for Gen3 by default */
|
||||
|
||||
/* No TRIM_STATUS in SW fallback array. */
|
||||
0xFEED0E0FU /* End of File */
|
||||
};
|
||||
#else
|
||||
#if RADIO_IS_GEN_2P0
|
||||
const uint32_t BLOCK_1_IFR[]=
|
||||
{
|
||||
/* Revised fallback table which should work with untrimmed parts */
|
||||
0xABCDFFFEU, /* Version #FFFE indicates default trim values */
|
||||
|
||||
0x4005912CU, /* RSIM_ANA_TRIM address */
|
||||
0x784B0000U, /* RSIM_ANA_TRIM default value */
|
||||
|
||||
/* No TRIM_STATUS in SW fallback array. */
|
||||
0xFEED0E0FU /* End of File */
|
||||
};
|
||||
#else
|
||||
static uint64_t packed_data_long; /* Storage for 2 32 bit values to be read by read_index */
|
||||
static uint8_t num_words_avail; /* Number of 32 bit words available in packed_data_long storage */
|
||||
const uint32_t BLOCK_1_IFR[]=
|
||||
{
|
||||
/* Revised fallback table which should work with untrimmed parts */
|
||||
0xABCDFFFEU, /* Version #FFFE indicates default trim values */
|
||||
|
||||
0x4005912CU, /* RSIM_ANA_TRIM address */
|
||||
0x784B0000U, /* RSIM_ANA_TRIM default value */
|
||||
|
||||
/* No TRIM_STATUS in SW fallback array. */
|
||||
0xFEED0E0FU /* End of File */
|
||||
};
|
||||
#endif /* RADIO_IS_GEN_2P0 */
|
||||
#endif /* RADIO_IS_GEN_3P0 */
|
||||
|
||||
/*******************************************************************************
|
||||
* Code
|
||||
******************************************************************************/
|
||||
|
||||
/*! *********************************************************************************
|
||||
* \brief Read command for reading the first 32bit word from IFR, encapsulates different
|
||||
* flash IFR read mechanisms for multiple generations of SOC
|
||||
*
|
||||
* \param read_addr flash address
|
||||
*
|
||||
* \return 8 bytes of packed data containing radio trims only
|
||||
*
|
||||
***********************************************************************************/
|
||||
uint32_t read_first_ifr_word(uint32_t read_addr)
|
||||
{
|
||||
ifr_read_addr = read_addr;
|
||||
return read_another_ifr_word();
|
||||
}
|
||||
|
||||
/*! *********************************************************************************
|
||||
* \brief Read command for reading additional 32bit words from IFR. Encapsulates multiple IFR read mechanisms.
|
||||
*
|
||||
* \param read_addr flash address
|
||||
*
|
||||
* \return 8 bytes of packed data containing radio trims only
|
||||
*
|
||||
* \remarks PRE-CONDITIONS:
|
||||
* The function read_first_ifr_word() must have been called so that the ifr_read_addr variable is setup prior to use.
|
||||
*
|
||||
***********************************************************************************/
|
||||
uint32_t read_another_ifr_word(void)
|
||||
{
|
||||
uint32_t packed_data;
|
||||
|
||||
#if (RADIO_IS_GEN_3P0 || RADIO_IS_GEN_2P1)
|
||||
/* Using some static storage and alternating reads to read_index_ifr to replace read_resource_ifr */
|
||||
if (num_words_avail == 0)
|
||||
{
|
||||
#if RADIO_IS_GEN_3P0
|
||||
packed_data_long = read_index_ifr(ifr_read_addr);
|
||||
#else /* Use 64 bit return version of read_resource */
|
||||
packed_data_long = read_resource_ifr(ifr_read_addr);
|
||||
#endif /* RADIO_IS_GEN_3P0 */
|
||||
|
||||
num_words_avail = 2;
|
||||
ifr_read_addr++; /* Read index addresses increment by 1 */
|
||||
}
|
||||
|
||||
packed_data = (uint32_t)(packed_data_long & 0xFFFFFFFF);
|
||||
packed_data_long = packed_data_long >> 32;
|
||||
num_words_avail--;
|
||||
#else
|
||||
packed_data = read_resource_ifr(ifr_read_addr);
|
||||
ifr_read_addr += 4; /* Read resource addresses increment by 4 */
|
||||
#endif /* (RADIO_IS_GEN_3P0 || RADIO_IS_GEN_2P1) */
|
||||
|
||||
return packed_data;
|
||||
}
|
||||
|
||||
#if RADIO_IS_GEN_3P0
|
||||
/*! *********************************************************************************
|
||||
* \brief Read command for reading from IFR using RDINDEX command
|
||||
*
|
||||
* \param read_addr flash address
|
||||
*
|
||||
* \return 8 bytes of packed data containing radio trims only
|
||||
*
|
||||
***********************************************************************************/
|
||||
uint64_t read_index_ifr(uint32_t read_addr)
|
||||
{
|
||||
uint8_t rdindex = read_addr;
|
||||
uint64_t read_data;
|
||||
uint8_t i;
|
||||
uint32_t primask;
|
||||
|
||||
while ((FTFE_FSTAT_CCIF_MASK & FTFE->FSTAT) == 0); /* Wait till CCIF=1 to make sure not interrupting a prior operation */
|
||||
|
||||
if ((FTFE->FSTAT & FTFE_FSTAT_ACCERR_MASK) == FTFE_FSTAT_ACCERR_MASK )
|
||||
{
|
||||
FTFE->FSTAT = (1 << FTFE_FSTAT_ACCERR_SHIFT); /* Write 1 to ACCEER to clear errors */
|
||||
}
|
||||
|
||||
FTFE->FCCOB[0] = RDINDX;
|
||||
FTFE->FCCOB[1] = rdindex;
|
||||
|
||||
primask = DisableGlobalIRQ();
|
||||
FTFE->FSTAT = FTFE_FSTAT_CCIF_MASK;
|
||||
while((FTFE_FSTAT_CCIF_MASK & FTFE->FSTAT) == 0); /* Wait till CCIF=1 */
|
||||
EnableGlobalIRQ(primask);
|
||||
|
||||
/* Pack read data back into 64 bit type */
|
||||
read_data = FTFE->FCCOB[11]; /* MSB goes in first, will be shifted left sequentially */
|
||||
for (i = 10; i > 3; i--)
|
||||
{
|
||||
read_data = read_data << 8;
|
||||
read_data |= FTFE->FCCOB[i];
|
||||
}
|
||||
|
||||
return read_data;
|
||||
}
|
||||
#else
|
||||
|
||||
/*! *********************************************************************************
|
||||
* \brief Read command for reading from IFR
|
||||
*
|
||||
* \param read_addr flash address
|
||||
*
|
||||
* \return packed data containing radio trims only
|
||||
*
|
||||
***********************************************************************************/
|
||||
#if RADIO_IS_GEN_2P0
|
||||
uint32_t read_resource_ifr(uint32_t read_addr)
|
||||
{
|
||||
uint32_t primask;
|
||||
uint32_t packed_data;
|
||||
uint8_t flash_addr23_16, flash_addr15_8, flash_addr7_0;
|
||||
uint32_t read_data31_24, read_data23_16, read_data15_8, read_data7_0;
|
||||
|
||||
flash_addr23_16 = (uint8_t)((read_addr & 0xFF0000) >> 16);
|
||||
flash_addr15_8 = (uint8_t)((read_addr & 0x00FF00) >> 8);
|
||||
flash_addr7_0 = (uint8_t)(read_addr & 0xFF);
|
||||
|
||||
while ((FTFA_FSTAT_CCIF_MASK & FTFA->FSTAT) == 0); /* Wait till CCIF=1 */
|
||||
|
||||
if ((FTFA->FSTAT & FTFA_FSTAT_ACCERR_MASK) == FTFA_FSTAT_ACCERR_MASK )
|
||||
{
|
||||
FTFA->FSTAT = (1<<FTFA_FSTAT_ACCERR_SHIFT); /* Write 1 to ACCEER to clear errors */
|
||||
}
|
||||
|
||||
FTFA->FCCOB0 = RDRSRC;
|
||||
FTFA->FCCOB1 = flash_addr23_16;
|
||||
FTFA->FCCOB2 = flash_addr15_8;
|
||||
FTFA->FCCOB3 = flash_addr7_0;
|
||||
FTFA->FCCOB8 = 0x00;
|
||||
|
||||
primask = DisableGlobalIRQ();
|
||||
FTFA->FSTAT = FTFA_FSTAT_CCIF_MASK;
|
||||
while ((FTFA_FSTAT_CCIF_MASK & FTFA->FSTAT) == 0); /* Wait till CCIF=1 */
|
||||
EnableGlobalIRQ(primask);
|
||||
|
||||
/* Start reading */
|
||||
read_data31_24 = FTFA->FCCOB4; /* FTFA->FCCOB[4] */
|
||||
read_data23_16 = FTFA->FCCOB5; /* FTFA->FCCOB[5] */
|
||||
read_data15_8 = FTFA->FCCOB6; /* FTFA->FCCOB[6] */
|
||||
read_data7_0 = FTFA->FCCOB7; /* FTFA->FCCOB[7] */
|
||||
|
||||
packed_data = (read_data31_24 << 24) | (read_data23_16 << 16) | (read_data15_8 << 8) | (read_data7_0 << 0);
|
||||
|
||||
return packed_data;
|
||||
}
|
||||
#else
|
||||
uint64_t read_resource_ifr(uint32_t read_addr)
|
||||
{
|
||||
uint32_t primask;
|
||||
uint64_t packed_data;
|
||||
uint8_t flash_addr23_16, flash_addr15_8, flash_addr7_0;
|
||||
uint8_t read_data[8];
|
||||
uint64_t temp_64;
|
||||
uint8_t i;
|
||||
|
||||
flash_addr23_16 = (uint8_t)((read_addr & 0xFF0000) >> 16);
|
||||
flash_addr15_8 = (uint8_t)((read_addr & 0x00FF00) >> 8);
|
||||
flash_addr7_0 = (uint8_t)(read_addr & 0xFF);
|
||||
while((FTFE_FSTAT_CCIF_MASK & FTFE->FSTAT) == 0); /* Wait till CCIF=1 */
|
||||
|
||||
if ((FTFE->FSTAT & FTFE_FSTAT_ACCERR_MASK) == FTFE_FSTAT_ACCERR_MASK )
|
||||
{
|
||||
FTFE->FSTAT = (1<<FTFE_FSTAT_ACCERR_SHIFT); /* Write 1 to ACCEER to clear errors */
|
||||
}
|
||||
|
||||
FTFE->FCCOB0 = RDRSRC;
|
||||
FTFE->FCCOB1 = flash_addr23_16;
|
||||
FTFE->FCCOB2 = flash_addr15_8;
|
||||
FTFE->FCCOB3 = flash_addr7_0;
|
||||
FTFE->FCCOB4 = 0x00;
|
||||
|
||||
primask = DisableGlobalIRQ();
|
||||
FTFE->FSTAT = FTFE_FSTAT_CCIF_MASK;
|
||||
while ((FTFE_FSTAT_CCIF_MASK & FTFE->FSTAT) == 0); /* Wait till CCIF=1 */
|
||||
EnableGlobalIRQ(primask);
|
||||
|
||||
/* Start reading */
|
||||
read_data[7] = FTFE->FCCOB4;
|
||||
read_data[6] = FTFE->FCCOB5;
|
||||
read_data[5] = FTFE->FCCOB6;
|
||||
read_data[4] = FTFE->FCCOB7;
|
||||
read_data[3] = FTFE->FCCOB8;
|
||||
read_data[2] = FTFE->FCCOB9;
|
||||
read_data[1] = FTFE->FCCOBA;
|
||||
read_data[0] = FTFE->FCCOBB;
|
||||
|
||||
packed_data = 0;
|
||||
for (i = 0; i < 8; i++)
|
||||
{
|
||||
temp_64 = read_data[i];
|
||||
packed_data |= temp_64 << (i * 8);
|
||||
}
|
||||
|
||||
return packed_data;
|
||||
}
|
||||
|
||||
#endif /* RADIO_IS_GEN_2P0 */
|
||||
#endif /* RADIO_IS_GEN_3P0 */
|
||||
|
||||
/*! *********************************************************************************
|
||||
* \brief Store a SW trim value in the table passed in from calling function.
|
||||
*
|
||||
* \param sw_trim_tbl pointer to the software trim table to hold SW trim values
|
||||
* \param num_entries the number of entries in the SW trim table
|
||||
* \param addr the software trim ID
|
||||
* \param data the value of the software trim
|
||||
*
|
||||
***********************************************************************************/
|
||||
void store_sw_trim(IFR_SW_TRIM_TBL_ENTRY_T * sw_trim_tbl, uint16_t num_entries, uint32_t addr, uint32_t data)
|
||||
{
|
||||
uint16_t i;
|
||||
|
||||
if (sw_trim_tbl != NULL)
|
||||
{
|
||||
for (i = 0; i < num_entries; i++)
|
||||
{
|
||||
if (addr == sw_trim_tbl[i].trim_id)
|
||||
{
|
||||
sw_trim_tbl[i].trim_value = data;
|
||||
sw_trim_tbl[i].valid = 1;
|
||||
break; /* Don't need to scan the array any further... */
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*! *********************************************************************************
|
||||
* \brief Process block 1 IFR data.
|
||||
*
|
||||
* \param sw_trim_tbl pointer to the software trim table to hold SW trim values
|
||||
* \param num_entries the number of entries in the SW trim table
|
||||
*
|
||||
* \remarks
|
||||
* Uses a IFR v2 formatted default array if the IFR is blank or corrupted.
|
||||
* Stores SW trim values to an array passed into this function.
|
||||
*
|
||||
***********************************************************************************/
|
||||
void handle_ifr(IFR_SW_TRIM_TBL_ENTRY_T * sw_trim_tbl, uint16_t num_entries)
|
||||
{
|
||||
uint32_t dest_addr;
|
||||
uint32_t read_addr;
|
||||
uint32_t dest_data;
|
||||
uint32_t packed_data;
|
||||
uint32_t *ifr_ptr;
|
||||
|
||||
#if RADIO_IS_GEN_3P0
|
||||
num_words_avail = 0; /* Prep for handling 64 bit words from flash */
|
||||
#endif /* RADIO_IS_GEN_3P0 */
|
||||
|
||||
#if RADIO_IS_GEN_3P0
|
||||
read_addr = K3_BASE_INDEX;
|
||||
#else
|
||||
#ifdef CPU_MKW41Z256VHT4
|
||||
read_addr = KW4x_256_BASE;
|
||||
#else
|
||||
read_addr = KW4x_512_BASE;
|
||||
#endif /* CPU_MKW41Z256VHT4 */
|
||||
#endif /* RADIO_IS_GEN_3P0 */
|
||||
|
||||
/* Read first entry in IFR table */
|
||||
packed_data = read_first_ifr_word(read_addr);
|
||||
if ((packed_data&~IFR_VERSION_MASK) == IFR_VERSION_HDR)
|
||||
{
|
||||
/* Valid header was found, process real IFR data */
|
||||
XCVR_MISC->OVERWRITE_VER = (packed_data & IFR_VERSION_MASK);
|
||||
store_sw_trim(sw_trim_tbl, num_entries, 0xABCD, (packed_data & IFR_VERSION_MASK)); /* Place IFR version # in SW trim array*/
|
||||
packed_data = read_another_ifr_word();
|
||||
|
||||
while (packed_data !=IFR_EOF_SYMBOL)
|
||||
{
|
||||
if (IS_A_SW_ID(packed_data)) /* SW Trim case (non_reg writes) */
|
||||
{
|
||||
dest_addr = packed_data;
|
||||
packed_data = read_another_ifr_word();
|
||||
dest_data = packed_data;
|
||||
/* Place SW trim in array for driver SW to use */
|
||||
store_sw_trim(sw_trim_tbl, num_entries, dest_addr, dest_data);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (IS_VALID_REG_ADDR(packed_data)) /* Valid register write address */
|
||||
{
|
||||
dest_addr = packed_data;
|
||||
packed_data = read_another_ifr_word();
|
||||
dest_data = packed_data;
|
||||
*(uint32_t *)(dest_addr) = dest_data;
|
||||
}
|
||||
else
|
||||
{ /* Invalid address case */
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
packed_data=read_another_ifr_word();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Valid header is not present, use blind IFR trim table */
|
||||
ifr_ptr = (void *)BLOCK_1_IFR;
|
||||
packed_data = *ifr_ptr;
|
||||
XCVR_MISC->OVERWRITE_VER = (packed_data & IFR_VERSION_MASK);
|
||||
store_sw_trim(sw_trim_tbl, num_entries, 0xABCD, (packed_data & IFR_VERSION_MASK)); /* Place IFR version # in SW trim array */
|
||||
ifr_ptr++;
|
||||
packed_data= *ifr_ptr;
|
||||
|
||||
while (packed_data != IFR_EOF_SYMBOL)
|
||||
{
|
||||
if (IS_A_SW_ID(packed_data))
|
||||
{
|
||||
/* SW Trim case (non_reg writes) */
|
||||
dest_addr = packed_data;
|
||||
ifr_ptr++;
|
||||
packed_data = *(ifr_ptr);
|
||||
dest_data = packed_data;
|
||||
/* Place SW trim in array for driver SW to use */
|
||||
store_sw_trim(sw_trim_tbl, num_entries, dest_addr, dest_data);
|
||||
}
|
||||
else
|
||||
{
|
||||
dest_addr = packed_data;
|
||||
ifr_ptr++;
|
||||
packed_data = *ifr_ptr;
|
||||
dest_data = packed_data;
|
||||
|
||||
/* Valid register write address */
|
||||
if (IS_VALID_REG_ADDR(dest_addr))
|
||||
{
|
||||
*(uint32_t *)(dest_addr) = dest_data;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Invalid address case */
|
||||
}
|
||||
}
|
||||
|
||||
ifr_ptr++;
|
||||
packed_data= *ifr_ptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#if RADIO_IS_GEN_3P0
|
||||
|
||||
#else
|
||||
uint32_t handle_ifr_die_id(void)
|
||||
{
|
||||
uint32_t id_x, id_y;
|
||||
uint32_t id;
|
||||
|
||||
id = read_resource_ifr(0x90);
|
||||
id_x = id & 0x00FF0000;
|
||||
id_y = id & 0x000000FF;
|
||||
|
||||
return (id_x | id_y);
|
||||
}
|
||||
|
||||
uint32_t handle_ifr_die_kw_type(void)
|
||||
{
|
||||
uint32_t zb, ble;
|
||||
|
||||
zb = read_resource_ifr(0x80) & 0x8000;
|
||||
ble= read_resource_ifr(0x88) & 0x100000;
|
||||
|
||||
return (zb | ble);
|
||||
}
|
||||
|
||||
#endif /* RADIO_IS_GEN_3P0 */
|
||||
|
||||
/*! *********************************************************************************
|
||||
* \brief Dumps block 1 IFR data to an array.
|
||||
*
|
||||
* \param dump_tbl pointer to the table to hold the dumped IFR values
|
||||
* \param num_entries the number of entries to dump
|
||||
*
|
||||
* \remarks
|
||||
* Starts at the first address in IFR and dumps sequential entries.
|
||||
*
|
||||
***********************************************************************************/
|
||||
void dump_ifr(uint32_t * dump_tbl, uint8_t num_entries)
|
||||
{
|
||||
#if RADIO_IS_GEN_3P0
|
||||
uint32_t ifr_address = 0x20000;
|
||||
#else
|
||||
uint32_t ifr_address = 0x20000;
|
||||
#endif /* RADIO_IS_GEN_3P0 */
|
||||
uint32_t * dump_ptr = dump_tbl;
|
||||
uint8_t i;
|
||||
|
||||
*dump_ptr = read_first_ifr_word(ifr_address);
|
||||
dump_ptr++;
|
||||
|
||||
for (i = 0; i < num_entries - 1; i++)
|
||||
{
|
||||
*dump_ptr = read_another_ifr_word();
|
||||
dump_ptr++;
|
||||
}
|
||||
}
|
||||
|
||||
-199
@@ -1,199 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Freescale Semiconductor, Inc.
|
||||
* Copyright 2016-2017 NXP
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* o Redistributions of source code must retain the above copyright notice, this list
|
||||
* of conditions and the following disclaimer.
|
||||
*
|
||||
* o 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.
|
||||
*
|
||||
* o Neither the name of Freescale Semiconductor, Inc. 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 HOLDER 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 __IFR_RADIO_H__
|
||||
/* clang-format off */
|
||||
#define __IFR_RADIO_H__
|
||||
/* clang-format on */
|
||||
|
||||
#include <stdint.h>
|
||||
/* clang-format off */
|
||||
#define _FSL_XCVR_H_
|
||||
/* clang-format on */
|
||||
|
||||
/*!
|
||||
* @addtogroup xcvr
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*! @file*/
|
||||
|
||||
/*******************************************************************************
|
||||
* Definitions
|
||||
******************************************************************************/
|
||||
#define IFR_EOF_SYMBOL (0xFEED0E0FU) /* < Denotes the "End of File" for IFR data */
|
||||
#define IFR_VERSION_HDR (0xABCD0000U) /* < Constant value for upper 16 bits of IFR data header */
|
||||
#define IFR_VERSION_MASK (0x0000FFFFU) /* < Mask for version number (lower 16 bits) of IFR data header */
|
||||
#define IFR_SW_ID_MIN (0x00000000U) /* < Lower limit of SW trim IDs */
|
||||
#define IFR_SW_ID_MAX (0x0000FFFFU) /* < Lower limit of SW trim IDs */
|
||||
|
||||
#define IS_A_SW_ID(x) ((IFR_SW_ID_MIN < (x)) && (IFR_SW_ID_MAX >= (x)))
|
||||
|
||||
/* K3 valid registers support */
|
||||
#if (defined(CPU_K32W042S1M2CAx_M0P) || defined(CPU_K32W042S1M2VPJ_M0P))
|
||||
#define IS_VALID_REG_ADDR(x) (((x) & 0xFFFF0000U) == 0x41000000U) /* Valid addresses are 0x410xxxxx */
|
||||
#endif /* (defined(CPU_K32W042S1M2CAx_M0P) || defined(CPU_K32W042S1M2VPJ_M0P)) */
|
||||
/* KW41 and KW35/36 valid registers support */
|
||||
#if (defined(CPU_MKW41Z256VHT4) || defined(CPU_MKW41Z512VHT4) || \
|
||||
defined(CPU_MKW31Z256VHT4) || defined(CPU_MKW31Z512VHT4) || \
|
||||
defined(CPU_MKW21Z256VHT4) || defined(CPU_MKW21Z512VHT4) || \
|
||||
defined(CPU_MKW35A512VFP4) || defined(CPU_MKW36A512VFP4) )
|
||||
|
||||
#define IS_VALID_REG_ADDR(x) (((x) & 0xFFFF0000U) == 0x40050000U) /* Valid addresses are 0x4005xxxx */
|
||||
#endif
|
||||
|
||||
#define MAKE_MASK(size) ((1 << (size)) - 1)
|
||||
#define MAKE_MASKSHFT(size, bitpos) (MAKE_MASK(size) << (bitpos))
|
||||
|
||||
#define IFR_TZA_CAP_TUNE_MASK (0x0000000FU)
|
||||
#define IFR_TZA_CAP_TUNE_SHIFT (0)
|
||||
#define IFR_BBF_CAP_TUNE_MASK (0x000F0000U)
|
||||
#define IFR_BBF_CAP_TUNE_SHIFT (16)
|
||||
#define IFR_RES_TUNE2_MASK (0x00F00000U)
|
||||
#define IFR_RES_TUNE2_SHIFT (20)
|
||||
|
||||
/* \var typedef uint8_t IFR_ERROR_T */
|
||||
/* \brief The IFR error reporting type. */
|
||||
/* See #IFR_ERROR_T_enum for the enumeration definitions. */
|
||||
typedef uint8_t IFR_ERROR_T;
|
||||
|
||||
/* \brief The enumerations used to describe IFR errors. */
|
||||
enum IFR_ERROR_T_enum
|
||||
{
|
||||
IFR_SUCCESS = 0,
|
||||
INVALID_POINTER = 1, /* < NULL pointer error */
|
||||
INVALID_DEST_SIZE_SHIFT = 2, /* < the bits won't fit as specified in the destination */
|
||||
};
|
||||
|
||||
/* \var typedef uint16_t SW_TRIM_ID_T */
|
||||
/* \brief The SW trim ID type. */
|
||||
/* See #SW_TRIM_ID_T_enum for the enumeration definitions. */
|
||||
typedef uint16_t SW_TRIM_ID_T;
|
||||
|
||||
/* \brief The enumerations used to define SW trim IDs. */
|
||||
enum SW_TRIM_ID_T_enum
|
||||
{
|
||||
Q_RELATIVE_GAIN_BY_PART = 0, /* < Q vs I relative gain trim ID */
|
||||
ADC_GAIN = 1, /* < ADC gain trim ID */
|
||||
ZB_FILT_TRIM = 2, /* < Baseband Bandwidth filter trim ID for BLE */
|
||||
BLE_FILT_TRIM = 3, /* < Baseband Bandwidth filter trim ID for BLE */
|
||||
TRIM_STATUS = 4, /* < Status result of the trim process (error indications) */
|
||||
TRIM_VERSION = 0xABCD, /* < Version number of the IFR trim algorithm/format. */
|
||||
};
|
||||
|
||||
/* \var typedef uint32_t IFR_TRIM_STATUS_T */
|
||||
/* \brief The definition of failure bits stored in IFR trim status word. */
|
||||
/* See #IFR_TRIM_STATUS_T_enum for the enumeration definitions. */
|
||||
typedef uint32_t IFR_TRIM_STATUS_T;
|
||||
|
||||
/* \brief The enumerations used to describe trim algorithm failures in the status entry in IFR. */
|
||||
/* This enum represents multiple values which can be OR'd together in a single status word. */
|
||||
enum IFR_TRIM_STATUS_T_enum
|
||||
{
|
||||
TRIM_ALGORITHM_SUCCESS = 0,
|
||||
BGAP_VOLTAGE_TRIM_FAILED = 1, /* < algorithm failure in BGAP voltagetrim */
|
||||
IQMC_GAIN_ADJ_FAILED = 2, /* < algorithm failure in IQMC gain trim */
|
||||
IQMC_PHASE_ADJ_FAILED = 4, /* < algorithm failure in IQMC phase trim */
|
||||
IQMC_DC_GAIN_ADJ_FAILED = 8, /* < */
|
||||
ADC_GAIN_TRIM_FAILED = 10, /* <*/
|
||||
ZB_FILT_TRIM_FAILED = 20, /* < */
|
||||
BLE_FILT_TRIM_FAILED = 40, /* < */
|
||||
};
|
||||
|
||||
/* \var typedef struct IFR_SW_TRIM_TBL_ENTRY_T */
|
||||
/* \brief Structure defining an entry in a table used to contain values to be passed back from IFR */
|
||||
/* handling routine to XCVR driver software. */
|
||||
typedef struct
|
||||
{
|
||||
SW_TRIM_ID_T trim_id; /* < The assigned ID */
|
||||
uint32_t trim_value; /* < The value fetched from IFR.*/
|
||||
uint8_t valid; /* < validity of the trim_value field after IFR processing is complete (TRUE/FALSE).*/
|
||||
} IFR_SW_TRIM_TBL_ENTRY_T;
|
||||
|
||||
/*******************************************************************************
|
||||
* API
|
||||
******************************************************************************/
|
||||
/*!
|
||||
* @brief Reads a location in block 1 IFR for use by the radio.
|
||||
*
|
||||
* This function handles reading IFR data from flash memory for trim loading.
|
||||
*
|
||||
* @param read_addr the address in the IFR to be read.
|
||||
*/
|
||||
uint32_t read_resource_ifr(uint32_t read_addr);
|
||||
|
||||
/*!
|
||||
* @brief Reads a location in a simulated data array to support IFR handler testing.
|
||||
*
|
||||
* This function handles reading data from a const table for testing the trim loading functions.
|
||||
*
|
||||
* @param read_addr the address in the IFR to be read.
|
||||
*/
|
||||
uint32_t read_resource(uint16_t resource_id);
|
||||
|
||||
/*!
|
||||
* @brief Main IFR handler function called by XCVR driver software to process trim table.
|
||||
*
|
||||
* This function handles reading data from IFR and either loading to registers or storing to a SW trim values table.
|
||||
*
|
||||
* @param sw_trim_tbl pointer to the table used to store software trim values.
|
||||
* @param num_entries the number of entries that can be stored in the SW trim table.
|
||||
*/
|
||||
void handle_ifr(IFR_SW_TRIM_TBL_ENTRY_T * sw_trim_tbl, uint16_t num_entries);
|
||||
|
||||
/*!
|
||||
* @brief Handler function to read die_id from IFR locations..
|
||||
*
|
||||
* This function handles reading die ID value for debug and testing usage.
|
||||
*
|
||||
* @return the value of the die ID field.
|
||||
*/
|
||||
uint32_t handle_ifr_die_id(void);
|
||||
|
||||
/*!
|
||||
* @brief Handler function to read KW chip version from IFR locations..
|
||||
*
|
||||
* This function handles reading KW chip version for debug and testing usage.
|
||||
*
|
||||
* @return the value of the KW version field.
|
||||
*/
|
||||
uint32_t handle_ifr_die_kw_type(void);
|
||||
|
||||
/*!
|
||||
* @brief Debug function to dump the IFR contents to a RAM array.
|
||||
*
|
||||
* This function handles reading data from IFR and storing to a RAM array for debug.
|
||||
*
|
||||
* @param dump_tbl pointer to the table used to store IFR entry values.
|
||||
* @param num_entries the number of entries that can be stored in the dump table.
|
||||
*/
|
||||
void dump_ifr(uint32_t * dump_tbl, uint8_t num_entries);
|
||||
|
||||
#endif /*__IFR_RADIO_H__ */
|
||||
|
||||
-302
@@ -1,302 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Freescale Semiconductor, Inc.
|
||||
* Copyright 2016-2017 NXP
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* o Redistributions of source code must retain the above copyright notice, this list
|
||||
* of conditions and the following disclaimer.
|
||||
*
|
||||
* o 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.
|
||||
*
|
||||
* o Neither the name of Freescale Semiconductor, Inc. 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 HOLDER 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* How to setup clock using clock driver functions:
|
||||
*
|
||||
* 1. CLOCK_SetSimSafeDivs, to make sure core clock, bus clock, flexbus clock
|
||||
* and flash clock are in allowed range during clock mode switch.
|
||||
*
|
||||
* 2. Call CLOCK_Osc0Init to setup OSC clock, if it is used in target mode.
|
||||
*
|
||||
* 3. Set MCG configuration, MCG includes three parts: FLL clock, PLL clock and
|
||||
* internal reference clock(MCGIRCLK). Follow the steps to setup:
|
||||
*
|
||||
* 1). Call CLOCK_BootToXxxMode to set MCG to target mode.
|
||||
*
|
||||
* 2). If target mode is FBI/BLPI/PBI mode, the MCGIRCLK has been configured
|
||||
* correctly. For other modes, need to call CLOCK_SetInternalRefClkConfig
|
||||
* explicitly to setup MCGIRCLK.
|
||||
*
|
||||
* 3). Don't need to configure FLL explicitly, because if target mode is FLL
|
||||
* mode, then FLL has been configured by the function CLOCK_BootToXxxMode,
|
||||
* if the target mode is not FLL mode, the FLL is disabled.
|
||||
*
|
||||
* 4). If target mode is PEE/PBE/PEI/PBI mode, then the related PLL has been
|
||||
* setup by CLOCK_BootToXxxMode. In FBE/FBI/FEE/FBE mode, the PLL could
|
||||
* be enabled independently, call CLOCK_EnablePll0 explicitly in this case.
|
||||
*
|
||||
* 4. Call CLOCK_SetSimConfig to set the clock configuration in SIM.
|
||||
*/
|
||||
|
||||
/* TEXT BELOW IS USED AS SETTING FOR THE CLOCKS TOOL *****************************
|
||||
!!ClocksProfile
|
||||
product: Clocks v1.0
|
||||
processor: MKW41Z512xxx4
|
||||
package_id: MKW41Z512VHT4
|
||||
mcu_data: ksdk2_0
|
||||
processor_version: 0.1.28
|
||||
board: FRDM-KW41Z
|
||||
* BE CAREFUL MODIFYING THIS COMMENT - IT IS YAML SETTINGS FOR THE CLOCKS TOOL **/
|
||||
|
||||
#include "fsl_rtc.h"
|
||||
#include "clock_config.h"
|
||||
|
||||
/*******************************************************************************
|
||||
* Definitions
|
||||
******************************************************************************/
|
||||
#define RTC_OSC_CAP_LOAD_0PF 0x0U /*!< RTC oscillator capacity load: 0pF */
|
||||
#define SIM_LPUART_CLK_SEL_OSCERCLK_CLK 2U /*!< LPUART clock select: OSCERCLK clock */
|
||||
#define SIM_OSC32KSEL_OSC32KCLK_CLK 0U /*!< OSC32KSEL select: OSC32KCLK clock */
|
||||
#define SIM_TPM_CLK_SEL_OSCERCLK_CLK 2U /*!< TPM clock select: OSCERCLK clock */
|
||||
|
||||
/*******************************************************************************
|
||||
* Variables
|
||||
******************************************************************************/
|
||||
/* System clock frequency. */
|
||||
extern uint32_t SystemCoreClock;
|
||||
|
||||
/*******************************************************************************
|
||||
* Code
|
||||
******************************************************************************/
|
||||
/*FUNCTION**********************************************************************
|
||||
*
|
||||
* Function Name : CLOCK_CONFIG_FllStableDelay
|
||||
* Description : This function is used to delay for FLL stable.
|
||||
*
|
||||
*END**************************************************************************/
|
||||
static void CLOCK_CONFIG_FllStableDelay(void)
|
||||
{
|
||||
uint32_t i = 30000U;
|
||||
|
||||
while (i--)
|
||||
{
|
||||
__NOP();
|
||||
}
|
||||
}
|
||||
|
||||
/*FUNCTION**********************************************************************
|
||||
*
|
||||
* Function Name : CLOCK_CONFIG_SetRtcClock
|
||||
* Description : This function is used to configuring RTC clock
|
||||
*
|
||||
*END**************************************************************************/
|
||||
static void CLOCK_CONFIG_SetRtcClock()
|
||||
{
|
||||
/* RTC clock gate enable */
|
||||
CLOCK_EnableClock(kCLOCK_Rtc0);
|
||||
|
||||
/* Set RTC_TSR if there is fault value in RTC */
|
||||
if (RTC->SR & RTC_SR_TIF_MASK)
|
||||
{
|
||||
RTC -> TSR = RTC -> TSR;
|
||||
}
|
||||
|
||||
/* RTC clock gate disable */
|
||||
CLOCK_DisableClock(kCLOCK_Rtc0);
|
||||
}
|
||||
|
||||
/*FUNCTION**********************************************************************
|
||||
*
|
||||
* Function Name : CLOCK_CONFIG_EnableRtcOsc
|
||||
* Description : This function is used to enabling RTC oscillator
|
||||
* Param capLoad : Oscillator capacity load
|
||||
*
|
||||
*END**************************************************************************/
|
||||
static void CLOCK_CONFIG_EnableRtcOsc(uint32_t capLoad)
|
||||
{
|
||||
/* RTC clock gate enable */
|
||||
CLOCK_EnableClock(kCLOCK_Rtc0);
|
||||
|
||||
if ((RTC->CR & RTC_CR_OSCE_MASK) == 0u) /* Only if the Rtc oscillator is not already enabled */
|
||||
{
|
||||
/* Set the specified capacitor configuration for the RTC oscillator */
|
||||
RTC_SetOscCapLoad(RTC, capLoad);
|
||||
/* Enable the RTC 32KHz oscillator */
|
||||
RTC->CR |= RTC_CR_OSCE_MASK;
|
||||
}
|
||||
|
||||
/* RTC clock gate disable */
|
||||
CLOCK_DisableClock(kCLOCK_Rtc0);
|
||||
CLOCK_SetXtal32Freq(32768);
|
||||
}
|
||||
|
||||
/*FUNCTION**********************************************************************
|
||||
*
|
||||
* Function Name : BOARD_RfOscInit
|
||||
* Description : This function is used to setup Ref oscillator for KW40_512.
|
||||
*
|
||||
*END**************************************************************************/
|
||||
void BOARD_RfOscInit(void)
|
||||
{
|
||||
uint32_t tempTrim;
|
||||
uint8_t revId;
|
||||
|
||||
/* Obtain REV ID from SIM */
|
||||
revId = (uint8_t)((uint32_t)(SIM->SDID & SIM_SDID_REVID_MASK) >> SIM_SDID_REVID_SHIFT);
|
||||
|
||||
if (0 == revId)
|
||||
{
|
||||
tempTrim = RSIM->ANA_TRIM;
|
||||
RSIM->ANA_TRIM |= RSIM_ANA_TRIM_BB_LDO_XO_TRIM_MASK; /* Set max trim for BB LDO for XO */
|
||||
}/* Workaround for Rev 1.0 XTAL startup and ADC analog diagnostics circuitry */
|
||||
|
||||
/* Turn on clocks for the XCVR */
|
||||
|
||||
/* Enable RF OSC in RSIM and wait for ready */
|
||||
RSIM->CONTROL = ((RSIM->CONTROL & ~RSIM_CONTROL_RF_OSC_EN_MASK) | RSIM_CONTROL_RF_OSC_EN(1));
|
||||
|
||||
/* ERR010224 */
|
||||
RSIM->RF_OSC_CTRL |=
|
||||
RSIM_RF_OSC_CTRL_RADIO_EXT_OSC_OVRD_EN_MASK; /* Prevent XTAL_OUT_EN from generating XTAL_OUT request */
|
||||
|
||||
while ((RSIM->CONTROL & RSIM_CONTROL_RF_OSC_READY_MASK) == 0); /* Wait for RF_OSC_READY */
|
||||
|
||||
if (0 == revId)
|
||||
{
|
||||
SIM->SCGC5 |= SIM_SCGC5_PHYDIG_MASK;
|
||||
XCVR_TSM->OVRD0 |= XCVR_TSM_OVRD0_BB_LDO_ADCDAC_EN_OVRD_EN_MASK |
|
||||
XCVR_TSM_OVRD0_BB_LDO_ADCDAC_EN_OVRD_MASK; /* Force ADC DAC LDO on to prevent BGAP failure */
|
||||
|
||||
RSIM->ANA_TRIM = tempTrim; /* Reset LDO trim settings */
|
||||
}/* Workaround for Rev 1.0 XTAL startup and ADC analog diagnostics circuitry */
|
||||
|
||||
}
|
||||
|
||||
/*FUNCTION**********************************************************************
|
||||
*
|
||||
* Function Name : BOARD_InitOsc0
|
||||
* Description : This function is used to setup MCG OSC with Ref oscillator for KW40_512.
|
||||
*
|
||||
*END**************************************************************************/
|
||||
void BOARD_InitOsc0(void)
|
||||
{
|
||||
const osc_config_t oscConfig =
|
||||
{
|
||||
.freq = BOARD_XTAL0_CLK_HZ, .workMode = kOSC_ModeExt,
|
||||
};
|
||||
|
||||
/* Initializes OSC0 according to previous configuration to meet Ref OSC needs. */
|
||||
CLOCK_InitOsc0(&oscConfig);
|
||||
|
||||
/* Passing the XTAL0 frequency to clock driver. */
|
||||
CLOCK_SetXtal0Freq(BOARD_XTAL0_CLK_HZ);
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
********************** Configuration BOARD_BootClockRUN ***********************
|
||||
******************************************************************************/
|
||||
/* TEXT BELOW IS USED AS SETTING FOR THE CLOCKS TOOL *****************************
|
||||
!!Configuration
|
||||
name: BOARD_BootClockRUN
|
||||
outputs:
|
||||
- {id: Bus_clock.outFreq, value: 23.986176 MHz}
|
||||
- {id: Core_clock.outFreq, value: 47.972352 MHz}
|
||||
- {id: ERCLK32K.outFreq, value: 32.768 kHz}
|
||||
- {id: Flash_clock.outFreq, value: 23.986176 MHz}
|
||||
- {id: LPO_clock.outFreq, value: 1 kHz}
|
||||
- {id: LPUART0CLK.outFreq, value: 32 MHz}
|
||||
- {id: MCGFLLCLK.outFreq, value: 47.972352 MHz}
|
||||
- {id: MCGIRCLK.outFreq, value: 32.768 kHz}
|
||||
- {id: OSCERCLK.outFreq, value: 32 MHz}
|
||||
- {id: System_clock.outFreq, value: 47.972352 MHz}
|
||||
- {id: TPMCLK.outFreq, value: 32 MHz}
|
||||
settings:
|
||||
- {id: MCGMode, value: FEE}
|
||||
- {id: LPUART0ClkConfig, value: 'yes'}
|
||||
- {id: MCG.FCRDIV.scale, value: '1'}
|
||||
- {id: MCG.FLL_mul.scale, value: '1464'}
|
||||
- {id: MCG.IREFS.sel, value: MCG.FRDIV}
|
||||
- {id: MCG.OSCSEL.sel, value: RTC_32K.OSCCLK32K}
|
||||
- {id: MCG_C1_IRCLKEN_CFG, value: Enabled}
|
||||
- {id: RTC_CR_OSCE_CFG, value: Oscillator_enabled}
|
||||
- {id: SIM.LPUART0SRCSEL.sel, value: REFOSC.OSCCLK}
|
||||
- {id: SIM.TPMSRCSEL.sel, value: REFOSC.OSCCLK}
|
||||
- {id: TPMClkConfig, value: 'yes'}
|
||||
sources:
|
||||
- {id: REFOSC.OSC.outFreq, value: 32 MHz, enabled: true}
|
||||
- {id: RTC_32K.OSC32kHz.outFreq, value: 32.768 kHz, enabled: true}
|
||||
* BE CAREFUL MODIFYING THIS COMMENT - IT IS YAML SETTINGS FOR THE CLOCKS TOOL **/
|
||||
|
||||
/*******************************************************************************
|
||||
* Variables for BOARD_BootClockRUN configuration
|
||||
******************************************************************************/
|
||||
const mcg_config_t mcgConfig_BOARD_BootClockRUN =
|
||||
{
|
||||
.mcgMode = kMCG_ModeFEE, /* FEE - FLL Engaged External */
|
||||
.irclkEnableMode = kMCG_IrclkEnable, /* MCGIRCLK enabled, MCGIRCLK disabled in STOP mode */
|
||||
.ircs = kMCG_IrcSlow, /* Slow internal reference clock selected */
|
||||
.fcrdiv = 0x0U, /* Fast IRC divider: divided by 1 */
|
||||
.frdiv = 0x0U, /* FLL reference clock divider: divided by 1 */
|
||||
.drs = kMCG_DrsMid, /* Mid frequency range */
|
||||
.dmx32 = kMCG_Dmx32Fine, /* DCO is fine-tuned for maximum frequency with 32.768 kHz reference */
|
||||
.oscsel = kMCG_OscselRtc, /* Selects 32 kHz RTC Oscillator */
|
||||
};
|
||||
const sim_clock_config_t simConfig_BOARD_BootClockRUN =
|
||||
{
|
||||
.er32kSrc = SIM_OSC32KSEL_OSC32KCLK_CLK, /* OSC32KSEL select: OSC32KCLK clock */
|
||||
.clkdiv1 = 0x10000U, /* SIM_CLKDIV1 - OUTDIV1: /1, OUTDIV4: /2 */
|
||||
};
|
||||
|
||||
/*******************************************************************************
|
||||
* Code for BOARD_BootClockRUN configuration
|
||||
******************************************************************************/
|
||||
void BOARD_BootClockRUN(void)
|
||||
{
|
||||
/* Setup the reference oscillator. */
|
||||
BOARD_RfOscInit();
|
||||
/* Set the system clock dividers in SIM to safe value. */
|
||||
CLOCK_SetSimSafeDivs();
|
||||
/* Enable RTC oscillator. */
|
||||
CLOCK_CONFIG_EnableRtcOsc(RTC_OSC_CAP_LOAD_0PF);
|
||||
/* Initializes OSC0 according to Ref OSC needs. */
|
||||
BOARD_InitOsc0();
|
||||
/* Set MCG to FEE mode. */
|
||||
CLOCK_BootToFeeMode(mcgConfig_BOARD_BootClockRUN.oscsel,
|
||||
mcgConfig_BOARD_BootClockRUN.frdiv,
|
||||
mcgConfig_BOARD_BootClockRUN.dmx32,
|
||||
mcgConfig_BOARD_BootClockRUN.drs,
|
||||
CLOCK_CONFIG_FllStableDelay);
|
||||
/* Configure the Internal Reference clock (MCGIRCLK). */
|
||||
CLOCK_SetInternalRefClkConfig(mcgConfig_BOARD_BootClockRUN.irclkEnableMode,
|
||||
mcgConfig_BOARD_BootClockRUN.ircs,
|
||||
mcgConfig_BOARD_BootClockRUN.fcrdiv);
|
||||
/* Set the clock configuration in SIM module. */
|
||||
CLOCK_SetSimConfig(&simConfig_BOARD_BootClockRUN);
|
||||
/* Configure RTC clock. */
|
||||
CLOCK_CONFIG_SetRtcClock();
|
||||
/* Set SystemCoreClock variable. */
|
||||
SystemCoreClock = BOARD_BOOTCLOCKRUN_CORE_CLOCK;
|
||||
/* Set LPUART0 clock source. */
|
||||
CLOCK_SetLpuartClock(SIM_LPUART_CLK_SEL_OSCERCLK_CLK);
|
||||
/* Set TPM clock source. */
|
||||
CLOCK_SetTpmClock(SIM_TPM_CLK_SEL_OSCERCLK_CLK);
|
||||
}
|
||||
|
||||
-77
@@ -1,77 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Freescale Semiconductor, Inc.
|
||||
* Copyright 2016-2017 NXP
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* o Redistributions of source code must retain the above copyright notice, this list
|
||||
* of conditions and the following disclaimer.
|
||||
*
|
||||
* o 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.
|
||||
*
|
||||
* o Neither the name of Freescale Semiconductor, Inc. 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 HOLDER 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 _CLOCK_CONFIG_H_
|
||||
#define _CLOCK_CONFIG_H_
|
||||
|
||||
#include "fsl_common.h"
|
||||
|
||||
/*******************************************************************************
|
||||
* Definitions
|
||||
******************************************************************************/
|
||||
#define BOARD_XTAL0_CLK_HZ 32000000U /*!< Board xtal0 frequency in Hz */
|
||||
|
||||
/*******************************************************************************
|
||||
********************** Configuration BOARD_BootClockRUN ***********************
|
||||
******************************************************************************/
|
||||
/*******************************************************************************
|
||||
* Definitions for BOARD_BootClockRUN configuration
|
||||
******************************************************************************/
|
||||
#define BOARD_BOOTCLOCKRUN_CORE_CLOCK 47972352U /*!< Core clock frequency: 47972352Hz */
|
||||
|
||||
/*! @brief MCG set for BOARD_BootClockRUN configuration.
|
||||
*/
|
||||
extern const mcg_config_t mcgConfig_BOARD_BootClockRUN;
|
||||
/*! @brief SIM module set for BOARD_BootClockRUN configuration.
|
||||
*/
|
||||
extern const sim_clock_config_t simConfig_BOARD_BootClockRUN;
|
||||
/*! @brief OSC set for BOARD_BootClockRUN configuration.
|
||||
*/
|
||||
extern const osc_config_t oscConfig_BOARD_BootClockRUN;
|
||||
|
||||
/*******************************************************************************
|
||||
* API for BOARD_BootClockRUN configuration
|
||||
******************************************************************************/
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif /* __cplusplus*/
|
||||
|
||||
/*!
|
||||
* @brief This function executes configuration of clocks.
|
||||
*
|
||||
*/
|
||||
void BOARD_BootClockRUN(void);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif /* __cplusplus*/
|
||||
|
||||
#endif /* _CLOCK_CONFIG_H_ */
|
||||
|
||||
-1696
File diff suppressed because it is too large
Load Diff
@@ -1,71 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2016 ARM Limited. All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the License); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
|
||||
* Copyright (c) 2016, Freescale Semiconductor, Inc.
|
||||
* Copyright 2016-2017 NXP
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* o Redistributions of source code must retain the above copyright notice, this list
|
||||
* of conditions and the following disclaimer.
|
||||
*
|
||||
* o 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.
|
||||
*
|
||||
* o Neither the name of the copyright holder 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 HOLDER 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 _FSL_DSPI_CMSISI_H_
|
||||
#define _FSL_DSPI_CMSISI_H_
|
||||
|
||||
#include "fsl_common.h"
|
||||
#include "RTE_Device.h"
|
||||
#include "Driver_SPI.h"
|
||||
#if (defined(FSL_FEATURE_SOC_EDMA_COUNT) && FSL_FEATURE_SOC_EDMA_COUNT)
|
||||
#include "fsl_dspi_edma.h"
|
||||
#include "fsl_dmamux.h"
|
||||
#include "fsl_edma.h"
|
||||
#endif
|
||||
|
||||
#if defined(DSPI0)
|
||||
extern ARM_DRIVER_SPI Driver_SPI0;
|
||||
#endif /* DSPI0 */
|
||||
|
||||
#if defined(DSPI1)
|
||||
extern ARM_DRIVER_SPI Driver_SPI1;
|
||||
#endif /* DSPI1 */
|
||||
|
||||
#if defined(DSPI2)
|
||||
extern ARM_DRIVER_SPI Driver_SPI2;
|
||||
#endif /* DSPI2 */
|
||||
|
||||
#endif
|
||||
-1996
File diff suppressed because it is too large
Load Diff
@@ -1,79 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2016 ARM Limited. All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the License); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
|
||||
* Copyright (c) 2016, Freescale Semiconductor, Inc.
|
||||
* Copyright 2016-2017 NXP
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* o Redistributions of source code must retain the above copyright notice, this list
|
||||
* of conditions and the following disclaimer.
|
||||
*
|
||||
* o 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.
|
||||
*
|
||||
* o Neither the name of the copyright holder 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 HOLDER 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 _FSL_I2C_CMSIS_H_
|
||||
#define _FSL_I2C_CMSIS_H_
|
||||
#include "fsl_common.h"
|
||||
#include "Driver_I2C.h"
|
||||
#include "RTE_Device.h"
|
||||
#include "fsl_i2c.h"
|
||||
#if (defined(FSL_FEATURE_SOC_DMAMUX_COUNT) && FSL_FEATURE_SOC_DMAMUX_COUNT)
|
||||
#include "fsl_dmamux.h"
|
||||
#endif
|
||||
#if (defined(FSL_FEATURE_SOC_DMA_COUNT) && FSL_FEATURE_SOC_DMA_COUNT)
|
||||
#include "fsl_i2c_dma.h"
|
||||
#endif
|
||||
#if (defined(FSL_FEATURE_SOC_EDMA_COUNT) && FSL_FEATURE_SOC_EDMA_COUNT)
|
||||
#include "fsl_i2c_edma.h"
|
||||
#endif
|
||||
|
||||
#if defined(I2C0)
|
||||
extern ARM_DRIVER_I2C Driver_I2C0;
|
||||
#endif
|
||||
|
||||
#if defined(I2C1)
|
||||
extern ARM_DRIVER_I2C Driver_I2C1;
|
||||
#endif
|
||||
|
||||
#if defined(I2C2)
|
||||
extern ARM_DRIVER_I2C Driver_I2C2;
|
||||
#endif
|
||||
|
||||
#if defined(I2C3)
|
||||
extern ARM_DRIVER_I2C Driver_I2C3;
|
||||
#endif
|
||||
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,105 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2016 ARM Limited. All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the License); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
|
||||
* Copyright (c) 2016, Freescale Semiconductor, Inc.
|
||||
* Copyright 2016-2017 NXP
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* o Redistributions of source code must retain the above copyright notice, this list
|
||||
* of conditions and the following disclaimer.
|
||||
*
|
||||
* o 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.
|
||||
*
|
||||
* o Neither the name of the copyright holder 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 HOLDER 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 _FSL_LPUART_CMSIS_H_
|
||||
#define _FSL_LPUART_CMSIS_H_
|
||||
|
||||
#include "fsl_common.h"
|
||||
#include "Driver_USART.h"
|
||||
#include "RTE_Device.h"
|
||||
#include "fsl_lpuart.h"
|
||||
#if (defined(FSL_FEATURE_SOC_DMAMUX_COUNT) && FSL_FEATURE_SOC_DMAMUX_COUNT)
|
||||
#include "fsl_dmamux.h"
|
||||
#endif
|
||||
#if (defined(FSL_FEATURE_SOC_DMA_COUNT) && FSL_FEATURE_SOC_DMA_COUNT)
|
||||
#include "fsl_lpuart_dma.h"
|
||||
#endif
|
||||
#if (defined(FSL_FEATURE_SOC_EDMA_COUNT) && FSL_FEATURE_SOC_EDMA_COUNT)
|
||||
#include "fsl_lpuart_edma.h"
|
||||
#endif
|
||||
|
||||
#if defined(LPUART0)
|
||||
extern ARM_DRIVER_USART Driver_USART0;
|
||||
#endif /* LPUART0 */
|
||||
|
||||
#if defined(LPUART1)
|
||||
extern ARM_DRIVER_USART Driver_USART1;
|
||||
#endif /* LPUART1 */
|
||||
|
||||
#if defined(LPUART2)
|
||||
extern ARM_DRIVER_USART Driver_USART2;
|
||||
#endif /* LPUART2 */
|
||||
|
||||
#if defined(LPUART3)
|
||||
extern ARM_DRIVER_USART Driver_USART3;
|
||||
#endif /* LPUART3 */
|
||||
|
||||
#if defined(LPUART4)
|
||||
extern ARM_DRIVER_USART Driver_USART4;
|
||||
#endif /* LPUART4 */
|
||||
|
||||
#if defined(LPUART5)
|
||||
extern ARM_DRIVER_USART Driver_USART5;
|
||||
#endif /* LPUART5 */
|
||||
|
||||
#if (FSL_FEATURE_SOC_LPUART_COUNT == 1) && (FSL_FEATURE_SOC_UART_COUNT == 3)
|
||||
|
||||
extern ARM_DRIVER_USART Driver_USART3;
|
||||
|
||||
#endif
|
||||
|
||||
#if (FSL_FEATURE_SOC_LPUART_COUNT == 1) && (FSL_FEATURE_SOC_UART_COUNT == 4)
|
||||
|
||||
extern ARM_DRIVER_USART Driver_USART4;
|
||||
|
||||
#endif
|
||||
|
||||
#if (FSL_FEATURE_SOC_LPUART_COUNT == 1) && (FSL_FEATURE_SOC_UART_COUNT == 5)
|
||||
extern ARM_DRIVER_USART Driver_USART5;
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* _FSL_LPUART_CMSIS_H_ */
|
||||
-370
@@ -1,370 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Freescale Semiconductor, Inc.
|
||||
* Copyright 2016-2017 NXP
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* o Redistributions of source code must retain the above copyright notice, this list
|
||||
* of conditions and the following disclaimer.
|
||||
*
|
||||
* o 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.
|
||||
*
|
||||
* o Neither the name of the copyright holder 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 HOLDER 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 "fsl_adc16.h"
|
||||
|
||||
/*******************************************************************************
|
||||
* Prototypes
|
||||
******************************************************************************/
|
||||
/*!
|
||||
* @brief Get instance number for ADC16 module.
|
||||
*
|
||||
* @param base ADC16 peripheral base address
|
||||
*/
|
||||
static uint32_t ADC16_GetInstance(ADC_Type *base);
|
||||
|
||||
/*******************************************************************************
|
||||
* Variables
|
||||
******************************************************************************/
|
||||
/*! @brief Pointers to ADC16 bases for each instance. */
|
||||
static ADC_Type *const s_adc16Bases[] = ADC_BASE_PTRS;
|
||||
|
||||
#if !(defined(FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL) && FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL)
|
||||
/*! @brief Pointers to ADC16 clocks for each instance. */
|
||||
static const clock_ip_name_t s_adc16Clocks[] = ADC16_CLOCKS;
|
||||
#endif /* FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL */
|
||||
|
||||
/*******************************************************************************
|
||||
* Code
|
||||
******************************************************************************/
|
||||
static uint32_t ADC16_GetInstance(ADC_Type *base)
|
||||
{
|
||||
uint32_t instance;
|
||||
|
||||
/* Find the instance index from base address mappings. */
|
||||
for (instance = 0; instance < ARRAY_SIZE(s_adc16Bases); instance++)
|
||||
{
|
||||
if (s_adc16Bases[instance] == base)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
assert(instance < ARRAY_SIZE(s_adc16Bases));
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
void ADC16_Init(ADC_Type *base, const adc16_config_t *config)
|
||||
{
|
||||
assert(NULL != config);
|
||||
|
||||
uint32_t tmp32;
|
||||
|
||||
#if !(defined(FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL) && FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL)
|
||||
/* Enable the clock. */
|
||||
CLOCK_EnableClock(s_adc16Clocks[ADC16_GetInstance(base)]);
|
||||
#endif /* FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL */
|
||||
|
||||
/* ADCx_CFG1. */
|
||||
tmp32 = ADC_CFG1_ADICLK(config->clockSource) | ADC_CFG1_MODE(config->resolution);
|
||||
if (kADC16_LongSampleDisabled != config->longSampleMode)
|
||||
{
|
||||
tmp32 |= ADC_CFG1_ADLSMP_MASK;
|
||||
}
|
||||
tmp32 |= ADC_CFG1_ADIV(config->clockDivider);
|
||||
if (config->enableLowPower)
|
||||
{
|
||||
tmp32 |= ADC_CFG1_ADLPC_MASK;
|
||||
}
|
||||
base->CFG1 = tmp32;
|
||||
|
||||
/* ADCx_CFG2. */
|
||||
tmp32 = base->CFG2 & ~(ADC_CFG2_ADACKEN_MASK | ADC_CFG2_ADHSC_MASK | ADC_CFG2_ADLSTS_MASK);
|
||||
if (kADC16_LongSampleDisabled != config->longSampleMode)
|
||||
{
|
||||
tmp32 |= ADC_CFG2_ADLSTS(config->longSampleMode);
|
||||
}
|
||||
if (config->enableHighSpeed)
|
||||
{
|
||||
tmp32 |= ADC_CFG2_ADHSC_MASK;
|
||||
}
|
||||
if (config->enableAsynchronousClock)
|
||||
{
|
||||
tmp32 |= ADC_CFG2_ADACKEN_MASK;
|
||||
}
|
||||
base->CFG2 = tmp32;
|
||||
|
||||
/* ADCx_SC2. */
|
||||
tmp32 = base->SC2 & ~(ADC_SC2_REFSEL_MASK);
|
||||
tmp32 |= ADC_SC2_REFSEL(config->referenceVoltageSource);
|
||||
base->SC2 = tmp32;
|
||||
|
||||
/* ADCx_SC3. */
|
||||
if (config->enableContinuousConversion)
|
||||
{
|
||||
base->SC3 |= ADC_SC3_ADCO_MASK;
|
||||
}
|
||||
else
|
||||
{
|
||||
base->SC3 &= ~ADC_SC3_ADCO_MASK;
|
||||
}
|
||||
}
|
||||
|
||||
void ADC16_Deinit(ADC_Type *base)
|
||||
{
|
||||
#if !(defined(FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL) && FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL)
|
||||
/* Disable the clock. */
|
||||
CLOCK_DisableClock(s_adc16Clocks[ADC16_GetInstance(base)]);
|
||||
#endif /* FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL */
|
||||
}
|
||||
|
||||
void ADC16_GetDefaultConfig(adc16_config_t *config)
|
||||
{
|
||||
assert(NULL != config);
|
||||
|
||||
config->referenceVoltageSource = kADC16_ReferenceVoltageSourceVref;
|
||||
config->clockSource = kADC16_ClockSourceAsynchronousClock;
|
||||
config->enableAsynchronousClock = true;
|
||||
config->clockDivider = kADC16_ClockDivider8;
|
||||
config->resolution = kADC16_ResolutionSE12Bit;
|
||||
config->longSampleMode = kADC16_LongSampleDisabled;
|
||||
config->enableHighSpeed = false;
|
||||
config->enableLowPower = false;
|
||||
config->enableContinuousConversion = false;
|
||||
}
|
||||
|
||||
#if defined(FSL_FEATURE_ADC16_HAS_CALIBRATION) && FSL_FEATURE_ADC16_HAS_CALIBRATION
|
||||
status_t ADC16_DoAutoCalibration(ADC_Type *base)
|
||||
{
|
||||
bool bHWTrigger = false;
|
||||
volatile uint32_t tmp32; /* 'volatile' here is for the dummy read of ADCx_R[0] register. */
|
||||
status_t status = kStatus_Success;
|
||||
|
||||
/* The calibration would be failed when in hardwar mode.
|
||||
* Remember the hardware trigger state here and restore it later if the hardware trigger is enabled.*/
|
||||
if (0U != (ADC_SC2_ADTRG_MASK & base->SC2))
|
||||
{
|
||||
bHWTrigger = true;
|
||||
base->SC2 &= ~ADC_SC2_ADTRG_MASK;
|
||||
}
|
||||
|
||||
/* Clear the CALF and launch the calibration. */
|
||||
base->SC3 |= ADC_SC3_CAL_MASK | ADC_SC3_CALF_MASK;
|
||||
while (0U == (kADC16_ChannelConversionDoneFlag & ADC16_GetChannelStatusFlags(base, 0U)))
|
||||
{
|
||||
/* Check the CALF when the calibration is active. */
|
||||
if (0U != (kADC16_CalibrationFailedFlag & ADC16_GetStatusFlags(base)))
|
||||
{
|
||||
status = kStatus_Fail;
|
||||
break;
|
||||
}
|
||||
}
|
||||
tmp32 = base->R[0]; /* Dummy read to clear COCO caused by calibration. */
|
||||
|
||||
/* Restore the hardware trigger setting if it was enabled before. */
|
||||
if (bHWTrigger)
|
||||
{
|
||||
base->SC2 |= ADC_SC2_ADTRG_MASK;
|
||||
}
|
||||
/* Check the CALF at the end of calibration. */
|
||||
if (0U != (kADC16_CalibrationFailedFlag & ADC16_GetStatusFlags(base)))
|
||||
{
|
||||
status = kStatus_Fail;
|
||||
}
|
||||
if (kStatus_Success != status) /* Check if the calibration process is succeed. */
|
||||
{
|
||||
return status;
|
||||
}
|
||||
|
||||
/* Calculate the calibration values. */
|
||||
tmp32 = base->CLP0 + base->CLP1 + base->CLP2 + base->CLP3 + base->CLP4 + base->CLPS;
|
||||
tmp32 = 0x8000U | (tmp32 >> 1U);
|
||||
base->PG = tmp32;
|
||||
|
||||
#if defined(FSL_FEATURE_ADC16_HAS_DIFF_MODE) && FSL_FEATURE_ADC16_HAS_DIFF_MODE
|
||||
tmp32 = base->CLM0 + base->CLM1 + base->CLM2 + base->CLM3 + base->CLM4 + base->CLMS;
|
||||
tmp32 = 0x8000U | (tmp32 >> 1U);
|
||||
base->MG = tmp32;
|
||||
#endif /* FSL_FEATURE_ADC16_HAS_DIFF_MODE */
|
||||
|
||||
return kStatus_Success;
|
||||
}
|
||||
#endif /* FSL_FEATURE_ADC16_HAS_CALIBRATION */
|
||||
|
||||
#if defined(FSL_FEATURE_ADC16_HAS_MUX_SELECT) && FSL_FEATURE_ADC16_HAS_MUX_SELECT
|
||||
void ADC16_SetChannelMuxMode(ADC_Type *base, adc16_channel_mux_mode_t mode)
|
||||
{
|
||||
if (kADC16_ChannelMuxA == mode)
|
||||
{
|
||||
base->CFG2 &= ~ADC_CFG2_MUXSEL_MASK;
|
||||
}
|
||||
else /* kADC16_ChannelMuxB. */
|
||||
{
|
||||
base->CFG2 |= ADC_CFG2_MUXSEL_MASK;
|
||||
}
|
||||
}
|
||||
#endif /* FSL_FEATURE_ADC16_HAS_MUX_SELECT */
|
||||
|
||||
void ADC16_SetHardwareCompareConfig(ADC_Type *base, const adc16_hardware_compare_config_t *config)
|
||||
{
|
||||
uint32_t tmp32 = base->SC2 & ~(ADC_SC2_ACFE_MASK | ADC_SC2_ACFGT_MASK | ADC_SC2_ACREN_MASK);
|
||||
|
||||
if (!config) /* Pass "NULL" to disable the feature. */
|
||||
{
|
||||
base->SC2 = tmp32;
|
||||
return;
|
||||
}
|
||||
/* Enable the feature. */
|
||||
tmp32 |= ADC_SC2_ACFE_MASK;
|
||||
|
||||
/* Select the hardware compare working mode. */
|
||||
switch (config->hardwareCompareMode)
|
||||
{
|
||||
case kADC16_HardwareCompareMode0:
|
||||
break;
|
||||
case kADC16_HardwareCompareMode1:
|
||||
tmp32 |= ADC_SC2_ACFGT_MASK;
|
||||
break;
|
||||
case kADC16_HardwareCompareMode2:
|
||||
tmp32 |= ADC_SC2_ACREN_MASK;
|
||||
break;
|
||||
case kADC16_HardwareCompareMode3:
|
||||
tmp32 |= ADC_SC2_ACFGT_MASK | ADC_SC2_ACREN_MASK;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
base->SC2 = tmp32;
|
||||
|
||||
/* Load the compare values. */
|
||||
base->CV1 = ADC_CV1_CV(config->value1);
|
||||
base->CV2 = ADC_CV2_CV(config->value2);
|
||||
}
|
||||
|
||||
#if defined(FSL_FEATURE_ADC16_HAS_HW_AVERAGE) && FSL_FEATURE_ADC16_HAS_HW_AVERAGE
|
||||
void ADC16_SetHardwareAverage(ADC_Type *base, adc16_hardware_average_mode_t mode)
|
||||
{
|
||||
uint32_t tmp32 = base->SC3 & ~(ADC_SC3_AVGE_MASK | ADC_SC3_AVGS_MASK);
|
||||
|
||||
if (kADC16_HardwareAverageDisabled != mode)
|
||||
{
|
||||
tmp32 |= ADC_SC3_AVGE_MASK | ADC_SC3_AVGS(mode);
|
||||
}
|
||||
base->SC3 = tmp32;
|
||||
}
|
||||
#endif /* FSL_FEATURE_ADC16_HAS_HW_AVERAGE */
|
||||
|
||||
#if defined(FSL_FEATURE_ADC16_HAS_PGA) && FSL_FEATURE_ADC16_HAS_PGA
|
||||
void ADC16_SetPGAConfig(ADC_Type *base, const adc16_pga_config_t *config)
|
||||
{
|
||||
uint32_t tmp32;
|
||||
|
||||
if (!config) /* Passing "NULL" is to disable the feature. */
|
||||
{
|
||||
base->PGA = 0U;
|
||||
return;
|
||||
}
|
||||
|
||||
/* Enable the PGA and set the gain value. */
|
||||
tmp32 = ADC_PGA_PGAEN_MASK | ADC_PGA_PGAG(config->pgaGain);
|
||||
|
||||
/* Configure the misc features for PGA. */
|
||||
if (config->enableRunInNormalMode)
|
||||
{
|
||||
tmp32 |= ADC_PGA_PGALPb_MASK;
|
||||
}
|
||||
#if defined(FSL_FEATURE_ADC16_HAS_PGA_CHOPPING) && FSL_FEATURE_ADC16_HAS_PGA_CHOPPING
|
||||
if (config->disablePgaChopping)
|
||||
{
|
||||
tmp32 |= ADC_PGA_PGACHPb_MASK;
|
||||
}
|
||||
#endif /* FSL_FEATURE_ADC16_HAS_PGA_CHOPPING */
|
||||
#if defined(FSL_FEATURE_ADC16_HAS_PGA_OFFSET_MEASUREMENT) && FSL_FEATURE_ADC16_HAS_PGA_OFFSET_MEASUREMENT
|
||||
if (config->enableRunInOffsetMeasurement)
|
||||
{
|
||||
tmp32 |= ADC_PGA_PGAOFSM_MASK;
|
||||
}
|
||||
#endif /* FSL_FEATURE_ADC16_HAS_PGA_OFFSET_MEASUREMENT */
|
||||
base->PGA = tmp32;
|
||||
}
|
||||
#endif /* FSL_FEATURE_ADC16_HAS_PGA */
|
||||
|
||||
uint32_t ADC16_GetStatusFlags(ADC_Type *base)
|
||||
{
|
||||
uint32_t ret = 0;
|
||||
|
||||
if (0U != (base->SC2 & ADC_SC2_ADACT_MASK))
|
||||
{
|
||||
ret |= kADC16_ActiveFlag;
|
||||
}
|
||||
#if defined(FSL_FEATURE_ADC16_HAS_CALIBRATION) && FSL_FEATURE_ADC16_HAS_CALIBRATION
|
||||
if (0U != (base->SC3 & ADC_SC3_CALF_MASK))
|
||||
{
|
||||
ret |= kADC16_CalibrationFailedFlag;
|
||||
}
|
||||
#endif /* FSL_FEATURE_ADC16_HAS_CALIBRATION */
|
||||
return ret;
|
||||
}
|
||||
|
||||
void ADC16_ClearStatusFlags(ADC_Type *base, uint32_t mask)
|
||||
{
|
||||
#if defined(FSL_FEATURE_ADC16_HAS_CALIBRATION) && FSL_FEATURE_ADC16_HAS_CALIBRATION
|
||||
if (0U != (mask & kADC16_CalibrationFailedFlag))
|
||||
{
|
||||
base->SC3 |= ADC_SC3_CALF_MASK;
|
||||
}
|
||||
#endif /* FSL_FEATURE_ADC16_HAS_CALIBRATION */
|
||||
}
|
||||
|
||||
void ADC16_SetChannelConfig(ADC_Type *base, uint32_t channelGroup, const adc16_channel_config_t *config)
|
||||
{
|
||||
assert(channelGroup < ADC_SC1_COUNT);
|
||||
assert(NULL != config);
|
||||
|
||||
uint32_t sc1 = ADC_SC1_ADCH(config->channelNumber); /* Set the channel number. */
|
||||
|
||||
#if defined(FSL_FEATURE_ADC16_HAS_DIFF_MODE) && FSL_FEATURE_ADC16_HAS_DIFF_MODE
|
||||
/* Enable the differential conversion. */
|
||||
if (config->enableDifferentialConversion)
|
||||
{
|
||||
sc1 |= ADC_SC1_DIFF_MASK;
|
||||
}
|
||||
#endif /* FSL_FEATURE_ADC16_HAS_DIFF_MODE */
|
||||
/* Enable the interrupt when the conversion is done. */
|
||||
if (config->enableInterruptOnConversionCompleted)
|
||||
{
|
||||
sc1 |= ADC_SC1_AIEN_MASK;
|
||||
}
|
||||
base->SC1[channelGroup] = sc1;
|
||||
}
|
||||
|
||||
uint32_t ADC16_GetChannelStatusFlags(ADC_Type *base, uint32_t channelGroup)
|
||||
{
|
||||
assert(channelGroup < ADC_SC1_COUNT);
|
||||
|
||||
uint32_t ret = 0U;
|
||||
|
||||
if (0U != (base->SC1[channelGroup] & ADC_SC1_COCO_MASK))
|
||||
{
|
||||
ret |= kADC16_ChannelConversionDoneFlag;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
-525
@@ -1,525 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Freescale Semiconductor, Inc.
|
||||
* Copyright 2016-2017 NXP
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* o Redistributions of source code must retain the above copyright notice, this list
|
||||
* of conditions and the following disclaimer.
|
||||
*
|
||||
* o 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.
|
||||
*
|
||||
* o Neither the name of the copyright holder 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 HOLDER 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 _FSL_ADC16_H_
|
||||
#define _FSL_ADC16_H_
|
||||
|
||||
#include "fsl_common.h"
|
||||
|
||||
/*!
|
||||
* @addtogroup adc16
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
* Definitions
|
||||
******************************************************************************/
|
||||
|
||||
/*! @name Driver version */
|
||||
/*@{*/
|
||||
/*! @brief ADC16 driver version 2.0.0. */
|
||||
#define FSL_ADC16_DRIVER_VERSION (MAKE_VERSION(2, 0, 0))
|
||||
/*@}*/
|
||||
|
||||
/*!
|
||||
* @brief Channel status flags.
|
||||
*/
|
||||
enum _adc16_channel_status_flags
|
||||
{
|
||||
kADC16_ChannelConversionDoneFlag = ADC_SC1_COCO_MASK, /*!< Conversion done. */
|
||||
};
|
||||
|
||||
/*!
|
||||
* @brief Converter status flags.
|
||||
*/
|
||||
enum _adc16_status_flags
|
||||
{
|
||||
kADC16_ActiveFlag = ADC_SC2_ADACT_MASK, /*!< Converter is active. */
|
||||
#if defined(FSL_FEATURE_ADC16_HAS_CALIBRATION) && FSL_FEATURE_ADC16_HAS_CALIBRATION
|
||||
kADC16_CalibrationFailedFlag = ADC_SC3_CALF_MASK, /*!< Calibration is failed. */
|
||||
#endif /* FSL_FEATURE_ADC16_HAS_CALIBRATION */
|
||||
};
|
||||
|
||||
#if defined(FSL_FEATURE_ADC16_HAS_MUX_SELECT) && FSL_FEATURE_ADC16_HAS_MUX_SELECT
|
||||
/*!
|
||||
* @brief Channel multiplexer mode for each channel.
|
||||
*
|
||||
* For some ADC16 channels, there are two pin selections in channel multiplexer. For example, ADC0_SE4a and ADC0_SE4b
|
||||
* are the different channels that share the same channel number.
|
||||
*/
|
||||
typedef enum _adc_channel_mux_mode
|
||||
{
|
||||
kADC16_ChannelMuxA = 0U, /*!< For channel with channel mux a. */
|
||||
kADC16_ChannelMuxB = 1U, /*!< For channel with channel mux b. */
|
||||
} adc16_channel_mux_mode_t;
|
||||
#endif /* FSL_FEATURE_ADC16_HAS_MUX_SELECT */
|
||||
|
||||
/*!
|
||||
* @brief Clock divider for the converter.
|
||||
*/
|
||||
typedef enum _adc16_clock_divider
|
||||
{
|
||||
kADC16_ClockDivider1 = 0U, /*!< For divider 1 from the input clock to the module. */
|
||||
kADC16_ClockDivider2 = 1U, /*!< For divider 2 from the input clock to the module. */
|
||||
kADC16_ClockDivider4 = 2U, /*!< For divider 4 from the input clock to the module. */
|
||||
kADC16_ClockDivider8 = 3U, /*!< For divider 8 from the input clock to the module. */
|
||||
} adc16_clock_divider_t;
|
||||
|
||||
/*!
|
||||
*@brief Converter's resolution.
|
||||
*/
|
||||
typedef enum _adc16_resolution
|
||||
{
|
||||
/* This group of enumeration is for internal use which is related to register setting. */
|
||||
kADC16_Resolution8or9Bit = 0U, /*!< Single End 8-bit or Differential Sample 9-bit. */
|
||||
kADC16_Resolution12or13Bit = 1U, /*!< Single End 12-bit or Differential Sample 13-bit. */
|
||||
kADC16_Resolution10or11Bit = 2U, /*!< Single End 10-bit or Differential Sample 11-bit. */
|
||||
|
||||
/* This group of enumeration is for a public user. */
|
||||
kADC16_ResolutionSE8Bit = kADC16_Resolution8or9Bit, /*!< Single End 8-bit. */
|
||||
kADC16_ResolutionSE12Bit = kADC16_Resolution12or13Bit, /*!< Single End 12-bit. */
|
||||
kADC16_ResolutionSE10Bit = kADC16_Resolution10or11Bit, /*!< Single End 10-bit. */
|
||||
#if defined(FSL_FEATURE_ADC16_HAS_DIFF_MODE) && FSL_FEATURE_ADC16_HAS_DIFF_MODE
|
||||
kADC16_ResolutionDF9Bit = kADC16_Resolution8or9Bit, /*!< Differential Sample 9-bit. */
|
||||
kADC16_ResolutionDF13Bit = kADC16_Resolution12or13Bit, /*!< Differential Sample 13-bit. */
|
||||
kADC16_ResolutionDF11Bit = kADC16_Resolution10or11Bit, /*!< Differential Sample 11-bit. */
|
||||
#endif /* FSL_FEATURE_ADC16_HAS_DIFF_MODE */
|
||||
|
||||
#if defined(FSL_FEATURE_ADC16_MAX_RESOLUTION) && (FSL_FEATURE_ADC16_MAX_RESOLUTION >= 16U)
|
||||
/* 16-bit is supported by default. */
|
||||
kADC16_Resolution16Bit = 3U, /*!< Single End 16-bit or Differential Sample 16-bit. */
|
||||
kADC16_ResolutionSE16Bit = kADC16_Resolution16Bit, /*!< Single End 16-bit. */
|
||||
#if defined(FSL_FEATURE_ADC16_HAS_DIFF_MODE) && FSL_FEATURE_ADC16_HAS_DIFF_MODE
|
||||
kADC16_ResolutionDF16Bit = kADC16_Resolution16Bit, /*!< Differential Sample 16-bit. */
|
||||
#endif /* FSL_FEATURE_ADC16_HAS_DIFF_MODE */
|
||||
#endif /* FSL_FEATURE_ADC16_MAX_RESOLUTION >= 16U */
|
||||
} adc16_resolution_t;
|
||||
|
||||
/*!
|
||||
* @brief Clock source.
|
||||
*/
|
||||
typedef enum _adc16_clock_source
|
||||
{
|
||||
kADC16_ClockSourceAlt0 = 0U, /*!< Selection 0 of the clock source. */
|
||||
kADC16_ClockSourceAlt1 = 1U, /*!< Selection 1 of the clock source. */
|
||||
kADC16_ClockSourceAlt2 = 2U, /*!< Selection 2 of the clock source. */
|
||||
kADC16_ClockSourceAlt3 = 3U, /*!< Selection 3 of the clock source. */
|
||||
|
||||
/* Chip defined clock source */
|
||||
kADC16_ClockSourceAsynchronousClock = kADC16_ClockSourceAlt3, /*!< Using internal asynchronous clock. */
|
||||
} adc16_clock_source_t;
|
||||
|
||||
/*!
|
||||
* @brief Long sample mode.
|
||||
*/
|
||||
typedef enum _adc16_long_sample_mode
|
||||
{
|
||||
kADC16_LongSampleCycle24 = 0U, /*!< 20 extra ADCK cycles, 24 ADCK cycles total. */
|
||||
kADC16_LongSampleCycle16 = 1U, /*!< 12 extra ADCK cycles, 16 ADCK cycles total. */
|
||||
kADC16_LongSampleCycle10 = 2U, /*!< 6 extra ADCK cycles, 10 ADCK cycles total. */
|
||||
kADC16_LongSampleCycle6 = 3U, /*!< 2 extra ADCK cycles, 6 ADCK cycles total. */
|
||||
kADC16_LongSampleDisabled = 4U, /*!< Disable the long sample feature. */
|
||||
} adc16_long_sample_mode_t;
|
||||
|
||||
/*!
|
||||
* @brief Reference voltage source.
|
||||
*/
|
||||
typedef enum _adc16_reference_voltage_source
|
||||
{
|
||||
kADC16_ReferenceVoltageSourceVref = 0U, /*!< For external pins pair of VrefH and VrefL. */
|
||||
kADC16_ReferenceVoltageSourceValt = 1U, /*!< For alternate reference pair of ValtH and ValtL. */
|
||||
} adc16_reference_voltage_source_t;
|
||||
|
||||
#if defined(FSL_FEATURE_ADC16_HAS_HW_AVERAGE) && FSL_FEATURE_ADC16_HAS_HW_AVERAGE
|
||||
/*!
|
||||
* @brief Hardware average mode.
|
||||
*/
|
||||
typedef enum _adc16_hardware_average_mode
|
||||
{
|
||||
kADC16_HardwareAverageCount4 = 0U, /*!< For hardware average with 4 samples. */
|
||||
kADC16_HardwareAverageCount8 = 1U, /*!< For hardware average with 8 samples. */
|
||||
kADC16_HardwareAverageCount16 = 2U, /*!< For hardware average with 16 samples. */
|
||||
kADC16_HardwareAverageCount32 = 3U, /*!< For hardware average with 32 samples. */
|
||||
kADC16_HardwareAverageDisabled = 4U, /*!< Disable the hardware average feature.*/
|
||||
} adc16_hardware_average_mode_t;
|
||||
#endif /* FSL_FEATURE_ADC16_HAS_HW_AVERAGE */
|
||||
|
||||
/*!
|
||||
* @brief Hardware compare mode.
|
||||
*/
|
||||
typedef enum _adc16_hardware_compare_mode
|
||||
{
|
||||
kADC16_HardwareCompareMode0 = 0U, /*!< x < value1. */
|
||||
kADC16_HardwareCompareMode1 = 1U, /*!< x > value1. */
|
||||
kADC16_HardwareCompareMode2 = 2U, /*!< if value1 <= value2, then x < value1 || x > value2;
|
||||
else, value1 > x > value2. */
|
||||
kADC16_HardwareCompareMode3 = 3U, /*!< if value1 <= value2, then value1 <= x <= value2;
|
||||
else x >= value1 || x <= value2. */
|
||||
} adc16_hardware_compare_mode_t;
|
||||
|
||||
#if defined(FSL_FEATURE_ADC16_HAS_PGA) && FSL_FEATURE_ADC16_HAS_PGA
|
||||
/*!
|
||||
* @brief PGA's Gain mode.
|
||||
*/
|
||||
typedef enum _adc16_pga_gain
|
||||
{
|
||||
kADC16_PGAGainValueOf1 = 0U, /*!< For amplifier gain of 1. */
|
||||
kADC16_PGAGainValueOf2 = 1U, /*!< For amplifier gain of 2. */
|
||||
kADC16_PGAGainValueOf4 = 2U, /*!< For amplifier gain of 4. */
|
||||
kADC16_PGAGainValueOf8 = 3U, /*!< For amplifier gain of 8. */
|
||||
kADC16_PGAGainValueOf16 = 4U, /*!< For amplifier gain of 16. */
|
||||
kADC16_PGAGainValueOf32 = 5U, /*!< For amplifier gain of 32. */
|
||||
kADC16_PGAGainValueOf64 = 6U, /*!< For amplifier gain of 64. */
|
||||
} adc16_pga_gain_t;
|
||||
#endif /* FSL_FEATURE_ADC16_HAS_PGA */
|
||||
|
||||
/*!
|
||||
* @brief ADC16 converter configuration.
|
||||
*/
|
||||
typedef struct _adc16_config
|
||||
{
|
||||
adc16_reference_voltage_source_t referenceVoltageSource; /*!< Select the reference voltage source. */
|
||||
adc16_clock_source_t clockSource; /*!< Select the input clock source to converter. */
|
||||
bool enableAsynchronousClock; /*!< Enable the asynchronous clock output. */
|
||||
adc16_clock_divider_t clockDivider; /*!< Select the divider of input clock source. */
|
||||
adc16_resolution_t resolution; /*!< Select the sample resolution mode. */
|
||||
adc16_long_sample_mode_t longSampleMode; /*!< Select the long sample mode. */
|
||||
bool enableHighSpeed; /*!< Enable the high-speed mode. */
|
||||
bool enableLowPower; /*!< Enable low power. */
|
||||
bool enableContinuousConversion; /*!< Enable continuous conversion mode. */
|
||||
} adc16_config_t;
|
||||
|
||||
/*!
|
||||
* @brief ADC16 Hardware comparison configuration.
|
||||
*/
|
||||
typedef struct _adc16_hardware_compare_config
|
||||
{
|
||||
adc16_hardware_compare_mode_t hardwareCompareMode; /*!< Select the hardware compare mode.
|
||||
See "adc16_hardware_compare_mode_t". */
|
||||
int16_t value1; /*!< Setting value1 for hardware compare mode. */
|
||||
int16_t value2; /*!< Setting value2 for hardware compare mode. */
|
||||
} adc16_hardware_compare_config_t;
|
||||
|
||||
/*!
|
||||
* @brief ADC16 channel conversion configuration.
|
||||
*/
|
||||
typedef struct _adc16_channel_config
|
||||
{
|
||||
uint32_t channelNumber; /*!< Setting the conversion channel number. The available range is 0-31.
|
||||
See channel connection information for each chip in Reference
|
||||
Manual document. */
|
||||
bool enableInterruptOnConversionCompleted; /*!< Generate an interrupt request once the conversion is completed. */
|
||||
#if defined(FSL_FEATURE_ADC16_HAS_DIFF_MODE) && FSL_FEATURE_ADC16_HAS_DIFF_MODE
|
||||
bool enableDifferentialConversion; /*!< Using Differential sample mode. */
|
||||
#endif /* FSL_FEATURE_ADC16_HAS_DIFF_MODE */
|
||||
} adc16_channel_config_t;
|
||||
|
||||
#if defined(FSL_FEATURE_ADC16_HAS_PGA) && FSL_FEATURE_ADC16_HAS_PGA
|
||||
/*!
|
||||
* @brief ADC16 programmable gain amplifier configuration.
|
||||
*/
|
||||
typedef struct _adc16_pga_config
|
||||
{
|
||||
adc16_pga_gain_t pgaGain; /*!< Setting PGA gain. */
|
||||
bool enableRunInNormalMode; /*!< Enable PGA working in normal mode, or low power mode by default. */
|
||||
#if defined(FSL_FEATURE_ADC16_HAS_PGA_CHOPPING) && FSL_FEATURE_ADC16_HAS_PGA_CHOPPING
|
||||
bool disablePgaChopping; /*!< Disable the PGA chopping function.
|
||||
The PGA employs chopping to remove/reduce offset and 1/f noise and offers
|
||||
an offset measurement configuration that aids the offset calibration. */
|
||||
#endif /* FSL_FEATURE_ADC16_HAS_PGA_CHOPPING */
|
||||
#if defined(FSL_FEATURE_ADC16_HAS_PGA_OFFSET_MEASUREMENT) && FSL_FEATURE_ADC16_HAS_PGA_OFFSET_MEASUREMENT
|
||||
bool enableRunInOffsetMeasurement; /*!< Enable the PGA working in offset measurement mode.
|
||||
When this feature is enabled, the PGA disconnects itself from the external
|
||||
inputs and auto-configures into offset measurement mode. With this field
|
||||
set, run the ADC in the recommended settings and enable the maximum hardware
|
||||
averaging to get the PGA offset number. The output is the
|
||||
(PGA offset * (64+1)) for the given PGA setting. */
|
||||
#endif /* FSL_FEATURE_ADC16_HAS_PGA_OFFSET_MEASUREMENT */
|
||||
} adc16_pga_config_t;
|
||||
#endif /* FSL_FEATURE_ADC16_HAS_PGA */
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*******************************************************************************
|
||||
* API
|
||||
******************************************************************************/
|
||||
|
||||
/*!
|
||||
* @name Initialization
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*!
|
||||
* @brief Initializes the ADC16 module.
|
||||
*
|
||||
* @param base ADC16 peripheral base address.
|
||||
* @param config Pointer to configuration structure. See "adc16_config_t".
|
||||
*/
|
||||
void ADC16_Init(ADC_Type *base, const adc16_config_t *config);
|
||||
|
||||
/*!
|
||||
* @brief De-initializes the ADC16 module.
|
||||
*
|
||||
* @param base ADC16 peripheral base address.
|
||||
*/
|
||||
void ADC16_Deinit(ADC_Type *base);
|
||||
|
||||
/*!
|
||||
* @brief Gets an available pre-defined settings for the converter's configuration.
|
||||
*
|
||||
* This function initializes the converter configuration structure with available settings. The default values are as follows.
|
||||
* @code
|
||||
* config->referenceVoltageSource = kADC16_ReferenceVoltageSourceVref;
|
||||
* config->clockSource = kADC16_ClockSourceAsynchronousClock;
|
||||
* config->enableAsynchronousClock = true;
|
||||
* config->clockDivider = kADC16_ClockDivider8;
|
||||
* config->resolution = kADC16_ResolutionSE12Bit;
|
||||
* config->longSampleMode = kADC16_LongSampleDisabled;
|
||||
* config->enableHighSpeed = false;
|
||||
* config->enableLowPower = false;
|
||||
* config->enableContinuousConversion = false;
|
||||
* @endcode
|
||||
* @param config Pointer to the configuration structure.
|
||||
*/
|
||||
void ADC16_GetDefaultConfig(adc16_config_t *config);
|
||||
|
||||
#if defined(FSL_FEATURE_ADC16_HAS_CALIBRATION) && FSL_FEATURE_ADC16_HAS_CALIBRATION
|
||||
/*!
|
||||
* @brief Automates the hardware calibration.
|
||||
*
|
||||
* This auto calibration helps to adjust the plus/minus side gain automatically.
|
||||
* Execute the calibration before using the converter. Note that the hardware trigger should be used
|
||||
* during the calibration.
|
||||
*
|
||||
* @param base ADC16 peripheral base address.
|
||||
*
|
||||
* @return Execution status.
|
||||
* @retval kStatus_Success Calibration is done successfully.
|
||||
* @retval kStatus_Fail Calibration has failed.
|
||||
*/
|
||||
status_t ADC16_DoAutoCalibration(ADC_Type *base);
|
||||
#endif /* FSL_FEATURE_ADC16_HAS_CALIBRATION */
|
||||
|
||||
#if defined(FSL_FEATURE_ADC16_HAS_OFFSET_CORRECTION) && FSL_FEATURE_ADC16_HAS_OFFSET_CORRECTION
|
||||
/*!
|
||||
* @brief Sets the offset value for the conversion result.
|
||||
*
|
||||
* This offset value takes effect on the conversion result. If the offset value is not zero, the reading result
|
||||
* is subtracted by it. Note, the hardware calibration fills the offset value automatically.
|
||||
*
|
||||
* @param base ADC16 peripheral base address.
|
||||
* @param value Setting offset value.
|
||||
*/
|
||||
static inline void ADC16_SetOffsetValue(ADC_Type *base, int16_t value)
|
||||
{
|
||||
base->OFS = (uint32_t)(value);
|
||||
}
|
||||
#endif /* FSL_FEATURE_ADC16_HAS_OFFSET_CORRECTION */
|
||||
|
||||
/* @} */
|
||||
|
||||
/*!
|
||||
* @name Advanced Features
|
||||
* @{
|
||||
*/
|
||||
|
||||
#if defined(FSL_FEATURE_ADC16_HAS_DMA) && FSL_FEATURE_ADC16_HAS_DMA
|
||||
/*!
|
||||
* @brief Enables generating the DMA trigger when the conversion is complete.
|
||||
*
|
||||
* @param base ADC16 peripheral base address.
|
||||
* @param enable Switcher of the DMA feature. "true" means enabled, "false" means not enabled.
|
||||
*/
|
||||
static inline void ADC16_EnableDMA(ADC_Type *base, bool enable)
|
||||
{
|
||||
if (enable)
|
||||
{
|
||||
base->SC2 |= ADC_SC2_DMAEN_MASK;
|
||||
}
|
||||
else
|
||||
{
|
||||
base->SC2 &= ~ADC_SC2_DMAEN_MASK;
|
||||
}
|
||||
}
|
||||
#endif /* FSL_FEATURE_ADC16_HAS_DMA */
|
||||
|
||||
/*!
|
||||
* @brief Enables the hardware trigger mode.
|
||||
*
|
||||
* @param base ADC16 peripheral base address.
|
||||
* @param enable Switcher of the hardware trigger feature. "true" means enabled, "false" means not enabled.
|
||||
*/
|
||||
static inline void ADC16_EnableHardwareTrigger(ADC_Type *base, bool enable)
|
||||
{
|
||||
if (enable)
|
||||
{
|
||||
base->SC2 |= ADC_SC2_ADTRG_MASK;
|
||||
}
|
||||
else
|
||||
{
|
||||
base->SC2 &= ~ADC_SC2_ADTRG_MASK;
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(FSL_FEATURE_ADC16_HAS_MUX_SELECT) && FSL_FEATURE_ADC16_HAS_MUX_SELECT
|
||||
/*!
|
||||
* @brief Sets the channel mux mode.
|
||||
*
|
||||
* Some sample pins share the same channel index. The channel mux mode decides which pin is used for an
|
||||
* indicated channel.
|
||||
*
|
||||
* @param base ADC16 peripheral base address.
|
||||
* @param mode Setting channel mux mode. See "adc16_channel_mux_mode_t".
|
||||
*/
|
||||
void ADC16_SetChannelMuxMode(ADC_Type *base, adc16_channel_mux_mode_t mode);
|
||||
#endif /* FSL_FEATURE_ADC16_HAS_MUX_SELECT */
|
||||
|
||||
/*!
|
||||
* @brief Configures the hardware compare mode.
|
||||
*
|
||||
* The hardware compare mode provides a way to process the conversion result automatically by using hardware. Only the result
|
||||
* in the compare range is available. To compare the range, see "adc16_hardware_compare_mode_t" or the appopriate reference
|
||||
* manual for more information.
|
||||
*
|
||||
* @param base ADC16 peripheral base address.
|
||||
* @param config Pointer to the "adc16_hardware_compare_config_t" structure. Passing "NULL" disables the feature.
|
||||
*/
|
||||
void ADC16_SetHardwareCompareConfig(ADC_Type *base, const adc16_hardware_compare_config_t *config);
|
||||
|
||||
#if defined(FSL_FEATURE_ADC16_HAS_HW_AVERAGE) && FSL_FEATURE_ADC16_HAS_HW_AVERAGE
|
||||
/*!
|
||||
* @brief Sets the hardware average mode.
|
||||
*
|
||||
* The hardware average mode provides a way to process the conversion result automatically by using hardware. The multiple
|
||||
* conversion results are accumulated and averaged internally making them easier to read.
|
||||
*
|
||||
* @param base ADC16 peripheral base address.
|
||||
* @param mode Setting the hardware average mode. See "adc16_hardware_average_mode_t".
|
||||
*/
|
||||
void ADC16_SetHardwareAverage(ADC_Type *base, adc16_hardware_average_mode_t mode);
|
||||
#endif /* FSL_FEATURE_ADC16_HAS_HW_AVERAGE */
|
||||
|
||||
#if defined(FSL_FEATURE_ADC16_HAS_PGA) && FSL_FEATURE_ADC16_HAS_PGA
|
||||
/*!
|
||||
* @brief Configures the PGA for the converter's front end.
|
||||
*
|
||||
* @param base ADC16 peripheral base address.
|
||||
* @param config Pointer to the "adc16_pga_config_t" structure. Passing "NULL" disables the feature.
|
||||
*/
|
||||
void ADC16_SetPGAConfig(ADC_Type *base, const adc16_pga_config_t *config);
|
||||
#endif /* FSL_FEATURE_ADC16_HAS_PGA */
|
||||
|
||||
/*!
|
||||
* @brief Gets the status flags of the converter.
|
||||
*
|
||||
* @param base ADC16 peripheral base address.
|
||||
*
|
||||
* @return Flags' mask if indicated flags are asserted. See "_adc16_status_flags".
|
||||
*/
|
||||
uint32_t ADC16_GetStatusFlags(ADC_Type *base);
|
||||
|
||||
/*!
|
||||
* @brief Clears the status flags of the converter.
|
||||
*
|
||||
* @param base ADC16 peripheral base address.
|
||||
* @param mask Mask value for the cleared flags. See "_adc16_status_flags".
|
||||
*/
|
||||
void ADC16_ClearStatusFlags(ADC_Type *base, uint32_t mask);
|
||||
|
||||
/* @} */
|
||||
|
||||
/*!
|
||||
* @name Conversion Channel
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*!
|
||||
* @brief Configures the conversion channel.
|
||||
*
|
||||
* This operation triggers the conversion when in software trigger mode. When in hardware trigger mode, this API
|
||||
* configures the channel while the external trigger source helps to trigger the conversion.
|
||||
*
|
||||
* Note that the "Channel Group" has a detailed description.
|
||||
* To allow sequential conversions of the ADC to be triggered by internal peripherals, the ADC has more than one
|
||||
* group of status and control registers, one for each conversion. The channel group parameter indicates which group of
|
||||
* registers are used, for example, channel group 0 is for Group A registers and channel group 1 is for Group B registers. The
|
||||
* channel groups are used in a "ping-pong" approach to control the ADC operation. At any point, only one of
|
||||
* the channel groups is actively controlling ADC conversions. The channel group 0 is used for both software and hardware
|
||||
* trigger modes. Channel group 1 and greater indicates multiple channel group registers for
|
||||
* use only in hardware trigger mode. See the chip configuration information in the appropriate MCU reference manual for the
|
||||
* number of SC1n registers (channel groups) specific to this device. Channel group 1 or greater are not used
|
||||
* for software trigger operation. Therefore, writing to these channel groups does not initiate a new conversion.
|
||||
* Updating the channel group 0 while a different channel group is actively controlling a conversion is allowed and
|
||||
* vice versa. Writing any of the channel group registers while that specific channel group is actively controlling a
|
||||
* conversion aborts the current conversion.
|
||||
*
|
||||
* @param base ADC16 peripheral base address.
|
||||
* @param channelGroup Channel group index.
|
||||
* @param config Pointer to the "adc16_channel_config_t" structure for the conversion channel.
|
||||
*/
|
||||
void ADC16_SetChannelConfig(ADC_Type *base, uint32_t channelGroup, const adc16_channel_config_t *config);
|
||||
|
||||
/*!
|
||||
* @brief Gets the conversion value.
|
||||
*
|
||||
* @param base ADC16 peripheral base address.
|
||||
* @param channelGroup Channel group index.
|
||||
*
|
||||
* @return Conversion value.
|
||||
*/
|
||||
static inline uint32_t ADC16_GetChannelConversionValue(ADC_Type *base, uint32_t channelGroup)
|
||||
{
|
||||
assert(channelGroup < ADC_R_COUNT);
|
||||
|
||||
return base->R[channelGroup];
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Gets the status flags of channel.
|
||||
*
|
||||
* @param base ADC16 peripheral base address.
|
||||
* @param channelGroup Channel group index.
|
||||
*
|
||||
* @return Flags' mask if indicated flags are asserted. See "_adc16_channel_status_flags".
|
||||
*/
|
||||
uint32_t ADC16_GetChannelStatusFlags(ADC_Type *base, uint32_t channelGroup);
|
||||
|
||||
/* @} */
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
/*!
|
||||
* @}
|
||||
*/
|
||||
#endif /* _FSL_ADC16_H_ */
|
||||
-1374
File diff suppressed because it is too large
Load Diff
-1191
File diff suppressed because it is too large
Load Diff
-285
@@ -1,285 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Freescale Semiconductor, Inc.
|
||||
* Copyright 2016-2017 NXP
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* o Redistributions of source code must retain the above copyright notice, this list
|
||||
* of conditions and the following disclaimer.
|
||||
*
|
||||
* o 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.
|
||||
*
|
||||
* o Neither the name of the copyright holder 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 HOLDER 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 "fsl_cmp.h"
|
||||
|
||||
/*******************************************************************************
|
||||
* Prototypes
|
||||
******************************************************************************/
|
||||
/*!
|
||||
* @brief Get instance number for CMP module.
|
||||
*
|
||||
* @param base CMP peripheral base address
|
||||
*/
|
||||
static uint32_t CMP_GetInstance(CMP_Type *base);
|
||||
|
||||
/*******************************************************************************
|
||||
* Variables
|
||||
******************************************************************************/
|
||||
/*! @brief Pointers to CMP bases for each instance. */
|
||||
static CMP_Type *const s_cmpBases[] = CMP_BASE_PTRS;
|
||||
#if !(defined(FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL) && FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL)
|
||||
/*! @brief Pointers to CMP clocks for each instance. */
|
||||
static const clock_ip_name_t s_cmpClocks[] = CMP_CLOCKS;
|
||||
#endif /* FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL */
|
||||
|
||||
/*******************************************************************************
|
||||
* Codes
|
||||
******************************************************************************/
|
||||
static uint32_t CMP_GetInstance(CMP_Type *base)
|
||||
{
|
||||
uint32_t instance;
|
||||
|
||||
/* Find the instance index from base address mappings. */
|
||||
for (instance = 0; instance < ARRAY_SIZE(s_cmpBases); instance++)
|
||||
{
|
||||
if (s_cmpBases[instance] == base)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
assert(instance < ARRAY_SIZE(s_cmpBases));
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
void CMP_Init(CMP_Type *base, const cmp_config_t *config)
|
||||
{
|
||||
assert(NULL != config);
|
||||
|
||||
uint8_t tmp8;
|
||||
|
||||
#if !(defined(FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL) && FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL)
|
||||
/* Enable the clock. */
|
||||
CLOCK_EnableClock(s_cmpClocks[CMP_GetInstance(base)]);
|
||||
#endif /* FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL */
|
||||
|
||||
/* Configure. */
|
||||
CMP_Enable(base, false); /* Disable the CMP module during configuring. */
|
||||
/* CMPx_CR1. */
|
||||
tmp8 = base->CR1 & ~(CMP_CR1_PMODE_MASK | CMP_CR1_INV_MASK | CMP_CR1_COS_MASK | CMP_CR1_OPE_MASK);
|
||||
if (config->enableHighSpeed)
|
||||
{
|
||||
tmp8 |= CMP_CR1_PMODE_MASK;
|
||||
}
|
||||
if (config->enableInvertOutput)
|
||||
{
|
||||
tmp8 |= CMP_CR1_INV_MASK;
|
||||
}
|
||||
if (config->useUnfilteredOutput)
|
||||
{
|
||||
tmp8 |= CMP_CR1_COS_MASK;
|
||||
}
|
||||
if (config->enablePinOut)
|
||||
{
|
||||
tmp8 |= CMP_CR1_OPE_MASK;
|
||||
}
|
||||
#if defined(FSL_FEATURE_CMP_HAS_TRIGGER_MODE) && FSL_FEATURE_CMP_HAS_TRIGGER_MODE
|
||||
if (config->enableTriggerMode)
|
||||
{
|
||||
tmp8 |= CMP_CR1_TRIGM_MASK;
|
||||
}
|
||||
else
|
||||
{
|
||||
tmp8 &= ~CMP_CR1_TRIGM_MASK;
|
||||
}
|
||||
#endif /* FSL_FEATURE_CMP_HAS_TRIGGER_MODE */
|
||||
base->CR1 = tmp8;
|
||||
|
||||
/* CMPx_CR0. */
|
||||
tmp8 = base->CR0 & ~CMP_CR0_HYSTCTR_MASK;
|
||||
tmp8 |= CMP_CR0_HYSTCTR(config->hysteresisMode);
|
||||
base->CR0 = tmp8;
|
||||
|
||||
CMP_Enable(base, config->enableCmp); /* Enable the CMP module after configured or not. */
|
||||
}
|
||||
|
||||
void CMP_Deinit(CMP_Type *base)
|
||||
{
|
||||
/* Disable the CMP module. */
|
||||
CMP_Enable(base, false);
|
||||
|
||||
#if !(defined(FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL) && FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL)
|
||||
/* Disable the clock. */
|
||||
CLOCK_DisableClock(s_cmpClocks[CMP_GetInstance(base)]);
|
||||
#endif /* FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL */
|
||||
}
|
||||
|
||||
void CMP_GetDefaultConfig(cmp_config_t *config)
|
||||
{
|
||||
assert(NULL != config);
|
||||
|
||||
config->enableCmp = true; /* Enable the CMP module after initialization. */
|
||||
config->hysteresisMode = kCMP_HysteresisLevel0;
|
||||
config->enableHighSpeed = false;
|
||||
config->enableInvertOutput = false;
|
||||
config->useUnfilteredOutput = false;
|
||||
config->enablePinOut = false;
|
||||
#if defined(FSL_FEATURE_CMP_HAS_TRIGGER_MODE) && FSL_FEATURE_CMP_HAS_TRIGGER_MODE
|
||||
config->enableTriggerMode = false;
|
||||
#endif /* FSL_FEATURE_CMP_HAS_TRIGGER_MODE */
|
||||
}
|
||||
|
||||
void CMP_SetInputChannels(CMP_Type *base, uint8_t positiveChannel, uint8_t negativeChannel)
|
||||
{
|
||||
uint8_t tmp8 = base->MUXCR;
|
||||
|
||||
tmp8 &= ~(CMP_MUXCR_PSEL_MASK | CMP_MUXCR_MSEL_MASK);
|
||||
tmp8 |= CMP_MUXCR_PSEL(positiveChannel) | CMP_MUXCR_MSEL(negativeChannel);
|
||||
base->MUXCR = tmp8;
|
||||
}
|
||||
|
||||
#if defined(FSL_FEATURE_CMP_HAS_DMA) && FSL_FEATURE_CMP_HAS_DMA
|
||||
void CMP_EnableDMA(CMP_Type *base, bool enable)
|
||||
{
|
||||
uint8_t tmp8 = base->SCR & ~(CMP_SCR_CFR_MASK | CMP_SCR_CFF_MASK); /* To avoid change the w1c bits. */
|
||||
|
||||
if (enable)
|
||||
{
|
||||
tmp8 |= CMP_SCR_DMAEN_MASK;
|
||||
}
|
||||
else
|
||||
{
|
||||
tmp8 &= ~CMP_SCR_DMAEN_MASK;
|
||||
}
|
||||
base->SCR = tmp8;
|
||||
}
|
||||
#endif /* FSL_FEATURE_CMP_HAS_DMA */
|
||||
|
||||
void CMP_SetFilterConfig(CMP_Type *base, const cmp_filter_config_t *config)
|
||||
{
|
||||
assert(NULL != config);
|
||||
|
||||
uint8_t tmp8;
|
||||
|
||||
#if defined(FSL_FEATURE_CMP_HAS_EXTERNAL_SAMPLE_SUPPORT) && FSL_FEATURE_CMP_HAS_EXTERNAL_SAMPLE_SUPPORT
|
||||
/* Choose the clock source for sampling. */
|
||||
if (config->enableSample)
|
||||
{
|
||||
base->CR1 |= CMP_CR1_SE_MASK; /* Choose the external SAMPLE clock. */
|
||||
}
|
||||
else
|
||||
{
|
||||
base->CR1 &= ~CMP_CR1_SE_MASK; /* Choose the internal divided bus clock. */
|
||||
}
|
||||
#endif /* FSL_FEATURE_CMP_HAS_EXTERNAL_SAMPLE_SUPPORT */
|
||||
/* Set the filter count. */
|
||||
tmp8 = base->CR0 & ~CMP_CR0_FILTER_CNT_MASK;
|
||||
tmp8 |= CMP_CR0_FILTER_CNT(config->filterCount);
|
||||
base->CR0 = tmp8;
|
||||
/* Set the filter period. It is used as the divider to bus clock. */
|
||||
base->FPR = CMP_FPR_FILT_PER(config->filterPeriod);
|
||||
}
|
||||
|
||||
void CMP_SetDACConfig(CMP_Type *base, const cmp_dac_config_t *config)
|
||||
{
|
||||
uint8_t tmp8 = 0U;
|
||||
|
||||
if (NULL == config)
|
||||
{
|
||||
/* Passing "NULL" as input parameter means no available configuration. So the DAC feature is disabled.*/
|
||||
base->DACCR = 0U;
|
||||
return;
|
||||
}
|
||||
/* CMPx_DACCR. */
|
||||
tmp8 |= CMP_DACCR_DACEN_MASK; /* Enable the internal DAC. */
|
||||
if (kCMP_VrefSourceVin2 == config->referenceVoltageSource)
|
||||
{
|
||||
tmp8 |= CMP_DACCR_VRSEL_MASK;
|
||||
}
|
||||
tmp8 |= CMP_DACCR_VOSEL(config->DACValue);
|
||||
|
||||
base->DACCR = tmp8;
|
||||
}
|
||||
|
||||
void CMP_EnableInterrupts(CMP_Type *base, uint32_t mask)
|
||||
{
|
||||
uint8_t tmp8 = base->SCR & ~(CMP_SCR_CFR_MASK | CMP_SCR_CFF_MASK); /* To avoid change the w1c bits. */
|
||||
|
||||
if (0U != (kCMP_OutputRisingInterruptEnable & mask))
|
||||
{
|
||||
tmp8 |= CMP_SCR_IER_MASK;
|
||||
}
|
||||
if (0U != (kCMP_OutputFallingInterruptEnable & mask))
|
||||
{
|
||||
tmp8 |= CMP_SCR_IEF_MASK;
|
||||
}
|
||||
base->SCR = tmp8;
|
||||
}
|
||||
|
||||
void CMP_DisableInterrupts(CMP_Type *base, uint32_t mask)
|
||||
{
|
||||
uint8_t tmp8 = base->SCR & ~(CMP_SCR_CFR_MASK | CMP_SCR_CFF_MASK); /* To avoid change the w1c bits. */
|
||||
|
||||
if (0U != (kCMP_OutputRisingInterruptEnable & mask))
|
||||
{
|
||||
tmp8 &= ~CMP_SCR_IER_MASK;
|
||||
}
|
||||
if (0U != (kCMP_OutputFallingInterruptEnable & mask))
|
||||
{
|
||||
tmp8 &= ~CMP_SCR_IEF_MASK;
|
||||
}
|
||||
base->SCR = tmp8;
|
||||
}
|
||||
|
||||
uint32_t CMP_GetStatusFlags(CMP_Type *base)
|
||||
{
|
||||
uint32_t ret32 = 0U;
|
||||
|
||||
if (0U != (CMP_SCR_CFR_MASK & base->SCR))
|
||||
{
|
||||
ret32 |= kCMP_OutputRisingEventFlag;
|
||||
}
|
||||
if (0U != (CMP_SCR_CFF_MASK & base->SCR))
|
||||
{
|
||||
ret32 |= kCMP_OutputFallingEventFlag;
|
||||
}
|
||||
if (0U != (CMP_SCR_COUT_MASK & base->SCR))
|
||||
{
|
||||
ret32 |= kCMP_OutputAssertEventFlag;
|
||||
}
|
||||
return ret32;
|
||||
}
|
||||
|
||||
void CMP_ClearStatusFlags(CMP_Type *base, uint32_t mask)
|
||||
{
|
||||
uint8_t tmp8 = base->SCR & ~(CMP_SCR_CFR_MASK | CMP_SCR_CFF_MASK); /* To avoid change the w1c bits. */
|
||||
|
||||
if (0U != (kCMP_OutputRisingEventFlag & mask))
|
||||
{
|
||||
tmp8 |= CMP_SCR_CFR_MASK;
|
||||
}
|
||||
if (0U != (kCMP_OutputFallingEventFlag & mask))
|
||||
{
|
||||
tmp8 |= CMP_SCR_CFF_MASK;
|
||||
}
|
||||
base->SCR = tmp8;
|
||||
}
|
||||
-343
@@ -1,343 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Freescale Semiconductor, Inc.
|
||||
* Copyright 2016-2017 NXP
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* o Redistributions of source code must retain the above copyright notice, this list
|
||||
* of conditions and the following disclaimer.
|
||||
*
|
||||
* o 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.
|
||||
*
|
||||
* o Neither the name of the copyright holder 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 HOLDER 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 _FSL_CMP_H_
|
||||
#define _FSL_CMP_H_
|
||||
|
||||
#include "fsl_common.h"
|
||||
|
||||
/*!
|
||||
* @addtogroup cmp
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
* Definitions
|
||||
******************************************************************************/
|
||||
|
||||
/*! @name Driver version */
|
||||
/*@{*/
|
||||
/*! @brief CMP driver version 2.0.0. */
|
||||
#define FSL_CMP_DRIVER_VERSION (MAKE_VERSION(2, 0, 0))
|
||||
/*@}*/
|
||||
|
||||
/*!
|
||||
* @brief Interrupt enable/disable mask.
|
||||
*/
|
||||
enum _cmp_interrupt_enable
|
||||
{
|
||||
kCMP_OutputRisingInterruptEnable = CMP_SCR_IER_MASK, /*!< Comparator interrupt enable rising. */
|
||||
kCMP_OutputFallingInterruptEnable = CMP_SCR_IEF_MASK, /*!< Comparator interrupt enable falling. */
|
||||
};
|
||||
|
||||
/*!
|
||||
* @brief Status flags' mask.
|
||||
*/
|
||||
enum _cmp_status_flags
|
||||
{
|
||||
kCMP_OutputRisingEventFlag = CMP_SCR_CFR_MASK, /*!< Rising-edge on the comparison output has occurred. */
|
||||
kCMP_OutputFallingEventFlag = CMP_SCR_CFF_MASK, /*!< Falling-edge on the comparison output has occurred. */
|
||||
kCMP_OutputAssertEventFlag = CMP_SCR_COUT_MASK, /*!< Return the current value of the analog comparator output. */
|
||||
};
|
||||
|
||||
/*!
|
||||
* @brief CMP Hysteresis mode.
|
||||
*/
|
||||
typedef enum _cmp_hysteresis_mode
|
||||
{
|
||||
kCMP_HysteresisLevel0 = 0U, /*!< Hysteresis level 0. */
|
||||
kCMP_HysteresisLevel1 = 1U, /*!< Hysteresis level 1. */
|
||||
kCMP_HysteresisLevel2 = 2U, /*!< Hysteresis level 2. */
|
||||
kCMP_HysteresisLevel3 = 3U, /*!< Hysteresis level 3. */
|
||||
} cmp_hysteresis_mode_t;
|
||||
|
||||
/*!
|
||||
* @brief CMP Voltage Reference source.
|
||||
*/
|
||||
typedef enum _cmp_reference_voltage_source
|
||||
{
|
||||
kCMP_VrefSourceVin1 = 0U, /*!< Vin1 is selected as a resistor ladder network supply reference Vin. */
|
||||
kCMP_VrefSourceVin2 = 1U, /*!< Vin2 is selected as a resistor ladder network supply reference Vin. */
|
||||
} cmp_reference_voltage_source_t;
|
||||
|
||||
/*!
|
||||
* @brief Configures the comparator.
|
||||
*/
|
||||
typedef struct _cmp_config
|
||||
{
|
||||
bool enableCmp; /*!< Enable the CMP module. */
|
||||
cmp_hysteresis_mode_t hysteresisMode; /*!< CMP Hysteresis mode. */
|
||||
bool enableHighSpeed; /*!< Enable High-speed (HS) comparison mode. */
|
||||
bool enableInvertOutput; /*!< Enable the inverted comparator output. */
|
||||
bool useUnfilteredOutput; /*!< Set the compare output(COUT) to equal COUTA(true) or COUT(false). */
|
||||
bool enablePinOut; /*!< The comparator output is available on the associated pin. */
|
||||
#if defined(FSL_FEATURE_CMP_HAS_TRIGGER_MODE) && FSL_FEATURE_CMP_HAS_TRIGGER_MODE
|
||||
bool enableTriggerMode; /*!< Enable the trigger mode. */
|
||||
#endif /* FSL_FEATURE_CMP_HAS_TRIGGER_MODE */
|
||||
} cmp_config_t;
|
||||
|
||||
/*!
|
||||
* @brief Configures the filter.
|
||||
*/
|
||||
typedef struct _cmp_filter_config
|
||||
{
|
||||
#if defined(FSL_FEATURE_CMP_HAS_EXTERNAL_SAMPLE_SUPPORT) && FSL_FEATURE_CMP_HAS_EXTERNAL_SAMPLE_SUPPORT
|
||||
bool enableSample; /*!< Using the external SAMPLE as a sampling clock input or using a divided bus clock. */
|
||||
#endif /* FSL_FEATURE_CMP_HAS_EXTERNAL_SAMPLE_SUPPORT */
|
||||
uint8_t filterCount; /*!< Filter Sample Count. Available range is 1-7; 0 disables the filter.*/
|
||||
uint8_t filterPeriod; /*!< Filter Sample Period. The divider to the bus clock. Available range is 0-255. */
|
||||
} cmp_filter_config_t;
|
||||
|
||||
/*!
|
||||
* @brief Configures the internal DAC.
|
||||
*/
|
||||
typedef struct _cmp_dac_config
|
||||
{
|
||||
cmp_reference_voltage_source_t referenceVoltageSource; /*!< Supply voltage reference source. */
|
||||
uint8_t DACValue; /*!< Value for the DAC Output Voltage. Available range is 0-63.*/
|
||||
} cmp_dac_config_t;
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*******************************************************************************
|
||||
* API
|
||||
******************************************************************************/
|
||||
|
||||
/*!
|
||||
* @name Initialization
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*!
|
||||
* @brief Initializes the CMP.
|
||||
*
|
||||
* This function initializes the CMP module. The operations included are as follows.
|
||||
* - Enabling the clock for CMP module.
|
||||
* - Configuring the comparator.
|
||||
* - Enabling the CMP module.
|
||||
* Note that for some devices, multiple CMP instances share the same clock gate. In this case, to enable the clock for
|
||||
* any instance enables all CMPs. See the appropriate MCU reference manual for the clock assignment of the CMP.
|
||||
*
|
||||
* @param base CMP peripheral base address.
|
||||
* @param config Pointer to the configuration structure.
|
||||
*/
|
||||
void CMP_Init(CMP_Type *base, const cmp_config_t *config);
|
||||
|
||||
/*!
|
||||
* @brief De-initializes the CMP module.
|
||||
*
|
||||
* This function de-initializes the CMP module. The operations included are as follows.
|
||||
* - Disabling the CMP module.
|
||||
* - Disabling the clock for CMP module.
|
||||
*
|
||||
* This function disables the clock for the CMP.
|
||||
* Note that for some devices, multiple CMP instances share the same clock gate. In this case, before disabling the
|
||||
* clock for the CMP, ensure that all the CMP instances are not used.
|
||||
*
|
||||
* @param base CMP peripheral base address.
|
||||
*/
|
||||
void CMP_Deinit(CMP_Type *base);
|
||||
|
||||
/*!
|
||||
* @brief Enables/disables the CMP module.
|
||||
*
|
||||
* @param base CMP peripheral base address.
|
||||
* @param enable Enables or disables the module.
|
||||
*/
|
||||
static inline void CMP_Enable(CMP_Type *base, bool enable)
|
||||
{
|
||||
if (enable)
|
||||
{
|
||||
base->CR1 |= CMP_CR1_EN_MASK;
|
||||
}
|
||||
else
|
||||
{
|
||||
base->CR1 &= ~CMP_CR1_EN_MASK;
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Initializes the CMP user configuration structure.
|
||||
*
|
||||
* This function initializes the user configuration structure to these default values.
|
||||
* @code
|
||||
* config->enableCmp = true;
|
||||
* config->hysteresisMode = kCMP_HysteresisLevel0;
|
||||
* config->enableHighSpeed = false;
|
||||
* config->enableInvertOutput = false;
|
||||
* config->useUnfilteredOutput = false;
|
||||
* config->enablePinOut = false;
|
||||
* config->enableTriggerMode = false;
|
||||
* @endcode
|
||||
* @param config Pointer to the configuration structure.
|
||||
*/
|
||||
void CMP_GetDefaultConfig(cmp_config_t *config);
|
||||
|
||||
/*!
|
||||
* @brief Sets the input channels for the comparator.
|
||||
*
|
||||
* This function sets the input channels for the comparator.
|
||||
* Note that two input channels cannot be set the same way in the application. When the user selects the same input
|
||||
* from the analog mux to the positive and negative port, the comparator is disabled automatically.
|
||||
*
|
||||
* @param base CMP peripheral base address.
|
||||
* @param positiveChannel Positive side input channel number. Available range is 0-7.
|
||||
* @param negativeChannel Negative side input channel number. Available range is 0-7.
|
||||
*/
|
||||
void CMP_SetInputChannels(CMP_Type *base, uint8_t positiveChannel, uint8_t negativeChannel);
|
||||
|
||||
/* @} */
|
||||
|
||||
/*!
|
||||
* @name Advanced Features
|
||||
* @{
|
||||
*/
|
||||
|
||||
#if defined(FSL_FEATURE_CMP_HAS_DMA) && FSL_FEATURE_CMP_HAS_DMA
|
||||
/*!
|
||||
* @brief Enables/disables the DMA request for rising/falling events.
|
||||
*
|
||||
* This function enables/disables the DMA request for rising/falling events. Either event triggers the generation of
|
||||
* the DMA request from CMP if the DMA feature is enabled. Both events are ignored for generating the DMA request from the CMP
|
||||
* if the DMA is disabled.
|
||||
*
|
||||
* @param base CMP peripheral base address.
|
||||
* @param enable Enables or disables the feature.
|
||||
*/
|
||||
void CMP_EnableDMA(CMP_Type *base, bool enable);
|
||||
#endif /* FSL_FEATURE_CMP_HAS_DMA */
|
||||
|
||||
#if defined(FSL_FEATURE_CMP_HAS_WINDOW_MODE) && FSL_FEATURE_CMP_HAS_WINDOW_MODE
|
||||
/*!
|
||||
* @brief Enables/disables the window mode.
|
||||
*
|
||||
* @param base CMP peripheral base address.
|
||||
* @param enable Enables or disables the feature.
|
||||
*/
|
||||
static inline void CMP_EnableWindowMode(CMP_Type *base, bool enable)
|
||||
{
|
||||
if (enable)
|
||||
{
|
||||
base->CR1 |= CMP_CR1_WE_MASK;
|
||||
}
|
||||
else
|
||||
{
|
||||
base->CR1 &= ~CMP_CR1_WE_MASK;
|
||||
}
|
||||
}
|
||||
#endif /* FSL_FEATURE_CMP_HAS_WINDOW_MODE */
|
||||
|
||||
#if defined(FSL_FEATURE_CMP_HAS_PASS_THROUGH_MODE) && FSL_FEATURE_CMP_HAS_PASS_THROUGH_MODE
|
||||
/*!
|
||||
* @brief Enables/disables the pass through mode.
|
||||
*
|
||||
* @param base CMP peripheral base address.
|
||||
* @param enable Enables or disables the feature.
|
||||
*/
|
||||
static inline void CMP_EnablePassThroughMode(CMP_Type *base, bool enable)
|
||||
{
|
||||
if (enable)
|
||||
{
|
||||
base->MUXCR |= CMP_MUXCR_PSTM_MASK;
|
||||
}
|
||||
else
|
||||
{
|
||||
base->MUXCR &= ~CMP_MUXCR_PSTM_MASK;
|
||||
}
|
||||
}
|
||||
#endif /* FSL_FEATURE_CMP_HAS_PASS_THROUGH_MODE */
|
||||
|
||||
/*!
|
||||
* @brief Configures the filter.
|
||||
*
|
||||
* @param base CMP peripheral base address.
|
||||
* @param config Pointer to the configuration structure.
|
||||
*/
|
||||
void CMP_SetFilterConfig(CMP_Type *base, const cmp_filter_config_t *config);
|
||||
|
||||
/*!
|
||||
* @brief Configures the internal DAC.
|
||||
*
|
||||
* @param base CMP peripheral base address.
|
||||
* @param config Pointer to the configuration structure. "NULL" disables the feature.
|
||||
*/
|
||||
void CMP_SetDACConfig(CMP_Type *base, const cmp_dac_config_t *config);
|
||||
|
||||
/*!
|
||||
* @brief Enables the interrupts.
|
||||
*
|
||||
* @param base CMP peripheral base address.
|
||||
* @param mask Mask value for interrupts. See "_cmp_interrupt_enable".
|
||||
*/
|
||||
void CMP_EnableInterrupts(CMP_Type *base, uint32_t mask);
|
||||
|
||||
/*!
|
||||
* @brief Disables the interrupts.
|
||||
*
|
||||
* @param base CMP peripheral base address.
|
||||
* @param mask Mask value for interrupts. See "_cmp_interrupt_enable".
|
||||
*/
|
||||
void CMP_DisableInterrupts(CMP_Type *base, uint32_t mask);
|
||||
|
||||
/* @} */
|
||||
|
||||
/*!
|
||||
* @name Results
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*!
|
||||
* @brief Gets the status flags.
|
||||
*
|
||||
* @param base CMP peripheral base address.
|
||||
*
|
||||
* @return Mask value for the asserted flags. See "_cmp_status_flags".
|
||||
*/
|
||||
uint32_t CMP_GetStatusFlags(CMP_Type *base);
|
||||
|
||||
/*!
|
||||
* @brief Clears the status flags.
|
||||
*
|
||||
* @param base CMP peripheral base address.
|
||||
* @param mask Mask value for the flags. See "_cmp_status_flags".
|
||||
*/
|
||||
void CMP_ClearStatusFlags(CMP_Type *base, uint32_t mask);
|
||||
|
||||
/* @} */
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
/*!
|
||||
* @}
|
||||
*/
|
||||
#endif /* _FSL_CMP_H_ */
|
||||
-265
@@ -1,265 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2016, Freescale Semiconductor, Inc.
|
||||
* Copyright 2016-2017 NXP
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* o Redistributions of source code must retain the above copyright notice, this list
|
||||
* of conditions and the following disclaimer.
|
||||
*
|
||||
* o 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.
|
||||
*
|
||||
* o Neither the name of the copyright holder 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 HOLDER 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 "fsl_cmt.h"
|
||||
|
||||
/*******************************************************************************
|
||||
* Definitions
|
||||
******************************************************************************/
|
||||
|
||||
/* The standard intermediate frequency (IF). */
|
||||
#define CMT_INTERMEDIATEFREQUENCY_8MHZ (8000000U)
|
||||
/* CMT data modulate mask. */
|
||||
#define CMT_MODULATE_COUNT_WIDTH (8U)
|
||||
/* CMT diver 1. */
|
||||
#define CMT_CMTDIV_ONE (1)
|
||||
/* CMT diver 2. */
|
||||
#define CMT_CMTDIV_TWO (2)
|
||||
/* CMT diver 4. */
|
||||
#define CMT_CMTDIV_FOUR (4)
|
||||
/* CMT diver 8. */
|
||||
#define CMT_CMTDIV_EIGHT (8)
|
||||
|
||||
/*******************************************************************************
|
||||
* Prototypes
|
||||
******************************************************************************/
|
||||
|
||||
/*!
|
||||
* @brief Get instance number for CMT module.
|
||||
*
|
||||
* @param base CMT peripheral base address.
|
||||
*/
|
||||
static uint32_t CMT_GetInstance(CMT_Type *base);
|
||||
|
||||
/*******************************************************************************
|
||||
* Variables
|
||||
******************************************************************************/
|
||||
|
||||
#if !(defined(FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL) && FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL)
|
||||
/*! @brief Pointers to cmt clocks for each instance. */
|
||||
static const clock_ip_name_t s_cmtClock[FSL_FEATURE_SOC_CMT_COUNT] = CMT_CLOCKS;
|
||||
#endif /* FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL */
|
||||
|
||||
/*! @brief Pointers to cmt bases for each instance. */
|
||||
static CMT_Type *const s_cmtBases[] = CMT_BASE_PTRS;
|
||||
|
||||
/*! @brief Pointers to cmt IRQ number for each instance. */
|
||||
static const IRQn_Type s_cmtIrqs[] = CMT_IRQS;
|
||||
|
||||
/*******************************************************************************
|
||||
* Codes
|
||||
******************************************************************************/
|
||||
|
||||
static uint32_t CMT_GetInstance(CMT_Type *base)
|
||||
{
|
||||
uint32_t instance;
|
||||
|
||||
/* Find the instance index from base address mappings. */
|
||||
for (instance = 0; instance < ARRAY_SIZE(s_cmtBases); instance++)
|
||||
{
|
||||
if (s_cmtBases[instance] == base)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
assert(instance < ARRAY_SIZE(s_cmtBases));
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
void CMT_GetDefaultConfig(cmt_config_t *config)
|
||||
{
|
||||
assert(config);
|
||||
|
||||
/* Default infrared output is enabled and set with high active, the divider is set to 1. */
|
||||
config->isInterruptEnabled = false;
|
||||
config->isIroEnabled = true;
|
||||
config->iroPolarity = kCMT_IROActiveHigh;
|
||||
config->divider = kCMT_SecondClkDiv1;
|
||||
}
|
||||
|
||||
void CMT_Init(CMT_Type *base, const cmt_config_t *config, uint32_t busClock_Hz)
|
||||
{
|
||||
assert(config);
|
||||
assert(busClock_Hz >= CMT_INTERMEDIATEFREQUENCY_8MHZ);
|
||||
|
||||
uint8_t divider;
|
||||
|
||||
#if !(defined(FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL) && FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL)
|
||||
/* Ungate clock. */
|
||||
CLOCK_EnableClock(s_cmtClock[CMT_GetInstance(base)]);
|
||||
#endif /* FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL */
|
||||
|
||||
/* Sets clock divider. The divider set in pps should be set
|
||||
to make sycClock_Hz/divder = 8MHz */
|
||||
base->PPS = CMT_PPS_PPSDIV(busClock_Hz / CMT_INTERMEDIATEFREQUENCY_8MHZ - 1);
|
||||
divider = base->MSC;
|
||||
divider &= ~CMT_MSC_CMTDIV_MASK;
|
||||
divider |= CMT_MSC_CMTDIV(config->divider);
|
||||
base->MSC = divider;
|
||||
|
||||
/* Set the IRO signal. */
|
||||
base->OC = CMT_OC_CMTPOL(config->iroPolarity) | CMT_OC_IROPEN(config->isIroEnabled);
|
||||
|
||||
/* Set interrupt. */
|
||||
if (config->isInterruptEnabled)
|
||||
{
|
||||
CMT_EnableInterrupts(base, kCMT_EndOfCycleInterruptEnable);
|
||||
EnableIRQ(s_cmtIrqs[CMT_GetInstance(base)]);
|
||||
}
|
||||
}
|
||||
|
||||
void CMT_Deinit(CMT_Type *base)
|
||||
{
|
||||
/*Disable the CMT modulator. */
|
||||
base->MSC = 0;
|
||||
|
||||
/* Disable the interrupt. */
|
||||
CMT_DisableInterrupts(base, kCMT_EndOfCycleInterruptEnable);
|
||||
DisableIRQ(s_cmtIrqs[CMT_GetInstance(base)]);
|
||||
|
||||
#if !(defined(FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL) && FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL)
|
||||
/* Gate the clock. */
|
||||
CLOCK_DisableClock(s_cmtClock[CMT_GetInstance(base)]);
|
||||
#endif /* FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL */
|
||||
}
|
||||
|
||||
void CMT_SetMode(CMT_Type *base, cmt_mode_t mode, cmt_modulate_config_t *modulateConfig)
|
||||
{
|
||||
uint8_t mscReg = base->MSC;
|
||||
|
||||
/* Judge the mode. */
|
||||
if (mode != kCMT_DirectIROCtl)
|
||||
{
|
||||
assert(modulateConfig);
|
||||
|
||||
/* Set carrier generator. */
|
||||
CMT_SetCarrirGenerateCountOne(base, modulateConfig->highCount1, modulateConfig->lowCount1);
|
||||
if (mode == kCMT_FSKMode)
|
||||
{
|
||||
CMT_SetCarrirGenerateCountTwo(base, modulateConfig->highCount2, modulateConfig->lowCount2);
|
||||
}
|
||||
|
||||
/* Set carrier modulator. */
|
||||
CMT_SetModulateMarkSpace(base, modulateConfig->markCount, modulateConfig->spaceCount);
|
||||
mscReg &= ~ (CMT_MSC_FSK_MASK | CMT_MSC_BASE_MASK);
|
||||
mscReg |= mode;
|
||||
}
|
||||
else
|
||||
{
|
||||
mscReg &= ~CMT_MSC_MCGEN_MASK;
|
||||
}
|
||||
/* Set the CMT mode. */
|
||||
base->MSC = mscReg;
|
||||
}
|
||||
|
||||
cmt_mode_t CMT_GetMode(CMT_Type *base)
|
||||
{
|
||||
uint8_t mode = base->MSC;
|
||||
|
||||
if (!(mode & CMT_MSC_MCGEN_MASK))
|
||||
{ /* Carrier modulator disabled and the IRO signal is in direct software control. */
|
||||
return kCMT_DirectIROCtl;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Carrier modulator is enabled. */
|
||||
if (mode & CMT_MSC_BASE_MASK)
|
||||
{
|
||||
/* Base band mode. */
|
||||
return kCMT_BasebandMode;
|
||||
}
|
||||
else if (mode & CMT_MSC_FSK_MASK)
|
||||
{
|
||||
/* FSK mode. */
|
||||
return kCMT_FSKMode;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Time mode. */
|
||||
return kCMT_TimeMode;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t CMT_GetCMTFrequency(CMT_Type *base, uint32_t busClock_Hz)
|
||||
{
|
||||
uint32_t frequency;
|
||||
uint32_t divider;
|
||||
|
||||
/* Get intermediate frequency. */
|
||||
frequency = busClock_Hz / ((base->PPS & CMT_PPS_PPSDIV_MASK) + 1);
|
||||
|
||||
/* Get the second divider. */
|
||||
divider = ((base->MSC & CMT_MSC_CMTDIV_MASK) >> CMT_MSC_CMTDIV_SHIFT);
|
||||
/* Get CMT frequency. */
|
||||
switch ((cmt_second_clkdiv_t)divider)
|
||||
{
|
||||
case kCMT_SecondClkDiv1:
|
||||
frequency = frequency / CMT_CMTDIV_ONE;
|
||||
break;
|
||||
case kCMT_SecondClkDiv2:
|
||||
frequency = frequency / CMT_CMTDIV_TWO;
|
||||
break;
|
||||
case kCMT_SecondClkDiv4:
|
||||
frequency = frequency / CMT_CMTDIV_FOUR;
|
||||
break;
|
||||
case kCMT_SecondClkDiv8:
|
||||
frequency = frequency / CMT_CMTDIV_EIGHT;
|
||||
break;
|
||||
default:
|
||||
frequency = frequency / CMT_CMTDIV_ONE;
|
||||
break;
|
||||
}
|
||||
|
||||
return frequency;
|
||||
}
|
||||
|
||||
void CMT_SetModulateMarkSpace(CMT_Type *base, uint32_t markCount, uint32_t spaceCount)
|
||||
{
|
||||
/* Set modulate mark. */
|
||||
base->CMD1 = (markCount >> CMT_MODULATE_COUNT_WIDTH) & CMT_CMD1_MB_MASK;
|
||||
base->CMD2 = (markCount & CMT_CMD2_MB_MASK);
|
||||
/* Set modulate space. */
|
||||
base->CMD3 = (spaceCount >> CMT_MODULATE_COUNT_WIDTH) & CMT_CMD3_SB_MASK;
|
||||
base->CMD4 = spaceCount & CMT_CMD4_SB_MASK;
|
||||
}
|
||||
|
||||
void CMT_SetIroState(CMT_Type *base, cmt_infrared_output_state_t state)
|
||||
{
|
||||
uint8_t ocReg = base->OC;
|
||||
|
||||
ocReg &= ~CMT_OC_IROL_MASK;
|
||||
ocReg |= CMT_OC_IROL(state);
|
||||
|
||||
/* Set the infrared output signal control. */
|
||||
base->OC = ocReg;
|
||||
}
|
||||
-401
@@ -1,401 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Freescale Semiconductor, Inc.
|
||||
* Copyright 2016-2017 NXP
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* o Redistributions of source code must retain the above copyright notice, this list
|
||||
* of conditions and the following disclaimer.
|
||||
*
|
||||
* o 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.
|
||||
*
|
||||
* o Neither the name of the copyright holder 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 HOLDER 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 _FSL_CMT_H_
|
||||
#define _FSL_CMT_H_
|
||||
|
||||
#include "fsl_common.h"
|
||||
|
||||
/*!
|
||||
* @addtogroup cmt
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
* Definitions
|
||||
******************************************************************************/
|
||||
|
||||
/*! @name Driver version */
|
||||
/*@{*/
|
||||
/*! @brief CMT driver version 2.0.1. */
|
||||
#define FSL_CMT_DRIVER_VERSION (MAKE_VERSION(2, 0, 1))
|
||||
/*@}*/
|
||||
|
||||
/*!
|
||||
* @brief The modes of CMT.
|
||||
*/
|
||||
typedef enum _cmt_mode
|
||||
{
|
||||
kCMT_DirectIROCtl = 0x00U, /*!< Carrier modulator is disabled and the IRO signal is directly in software control */
|
||||
kCMT_TimeMode = 0x01U, /*!< Carrier modulator is enabled in time mode. */
|
||||
kCMT_FSKMode = 0x05U, /*!< Carrier modulator is enabled in FSK mode. */
|
||||
kCMT_BasebandMode = 0x09U /*!< Carrier modulator is enabled in baseband mode. */
|
||||
} cmt_mode_t;
|
||||
|
||||
/*!
|
||||
* @brief The CMT clock divide primary prescaler.
|
||||
* The primary clock divider is used to divider the bus clock to
|
||||
* get the intermediate frequency to approximately equal to 8 MHZ.
|
||||
* When the bus clock is 8 MHZ, set primary prescaler to "kCMT_PrimaryClkDiv1".
|
||||
*/
|
||||
typedef enum _cmt_primary_clkdiv
|
||||
{
|
||||
kCMT_PrimaryClkDiv1 = 0U, /*!< The intermediate frequency is the bus clock divided by 1. */
|
||||
kCMT_PrimaryClkDiv2 = 1U, /*!< The intermediate frequency is the bus clock divided by 2. */
|
||||
kCMT_PrimaryClkDiv3 = 2U, /*!< The intermediate frequency is the bus clock divided by 3. */
|
||||
kCMT_PrimaryClkDiv4 = 3U, /*!< The intermediate frequency is the bus clock divided by 4. */
|
||||
kCMT_PrimaryClkDiv5 = 4U, /*!< The intermediate frequency is the bus clock divided by 5. */
|
||||
kCMT_PrimaryClkDiv6 = 5U, /*!< The intermediate frequency is the bus clock divided by 6. */
|
||||
kCMT_PrimaryClkDiv7 = 6U, /*!< The intermediate frequency is the bus clock divided by 7. */
|
||||
kCMT_PrimaryClkDiv8 = 7U, /*!< The intermediate frequency is the bus clock divided by 8. */
|
||||
kCMT_PrimaryClkDiv9 = 8U, /*!< The intermediate frequency is the bus clock divided by 9. */
|
||||
kCMT_PrimaryClkDiv10 = 9U, /*!< The intermediate frequency is the bus clock divided by 10. */
|
||||
kCMT_PrimaryClkDiv11 = 10U, /*!< The intermediate frequency is the bus clock divided by 11. */
|
||||
kCMT_PrimaryClkDiv12 = 11U, /*!< The intermediate frequency is the bus clock divided by 12. */
|
||||
kCMT_PrimaryClkDiv13 = 12U, /*!< The intermediate frequency is the bus clock divided by 13. */
|
||||
kCMT_PrimaryClkDiv14 = 13U, /*!< The intermediate frequency is the bus clock divided by 14. */
|
||||
kCMT_PrimaryClkDiv15 = 14U, /*!< The intermediate frequency is the bus clock divided by 15. */
|
||||
kCMT_PrimaryClkDiv16 = 15U /*!< The intermediate frequency is the bus clock divided by 16. */
|
||||
} cmt_primary_clkdiv_t;
|
||||
|
||||
/*!
|
||||
* @brief The CMT clock divide secondary prescaler.
|
||||
* The second prescaler can be used to divide the 8 MHZ CMT clock
|
||||
* by 1, 2, 4, or 8 according to the specification.
|
||||
*/
|
||||
typedef enum _cmt_second_clkdiv
|
||||
{
|
||||
kCMT_SecondClkDiv1 = 0U, /*!< The CMT clock is the intermediate frequency frequency divided by 1. */
|
||||
kCMT_SecondClkDiv2 = 1U, /*!< The CMT clock is the intermediate frequency frequency divided by 2. */
|
||||
kCMT_SecondClkDiv4 = 2U, /*!< The CMT clock is the intermediate frequency frequency divided by 4. */
|
||||
kCMT_SecondClkDiv8 = 3U /*!< The CMT clock is the intermediate frequency frequency divided by 8. */
|
||||
} cmt_second_clkdiv_t;
|
||||
|
||||
/*!
|
||||
* @brief The CMT infrared output polarity.
|
||||
*/
|
||||
typedef enum _cmt_infrared_output_polarity
|
||||
{
|
||||
kCMT_IROActiveLow = 0U, /*!< The CMT infrared output signal polarity is active-low. */
|
||||
kCMT_IROActiveHigh = 1U /*!< The CMT infrared output signal polarity is active-high. */
|
||||
} cmt_infrared_output_polarity_t;
|
||||
|
||||
/*!
|
||||
* @brief The CMT infrared output signal state control.
|
||||
*/
|
||||
typedef enum _cmt_infrared_output_state
|
||||
{
|
||||
kCMT_IROCtlLow = 0U, /*!< The CMT Infrared output signal state is controlled to low. */
|
||||
kCMT_IROCtlHigh = 1U /*!< The CMT Infrared output signal state is controlled to high. */
|
||||
} cmt_infrared_output_state_t;
|
||||
|
||||
/*!
|
||||
* @brief CMT interrupt configuration structure, default settings all disabled.
|
||||
*
|
||||
* This structure contains the settings for all of the CMT interrupt configurations.
|
||||
*/
|
||||
enum _cmt_interrupt_enable
|
||||
{
|
||||
kCMT_EndOfCycleInterruptEnable = CMT_MSC_EOCIE_MASK, /*!< CMT end of cycle interrupt. */
|
||||
};
|
||||
|
||||
/*!
|
||||
* @brief CMT carrier generator and modulator configuration structure
|
||||
*
|
||||
*/
|
||||
typedef struct _cmt_modulate_config
|
||||
{
|
||||
uint8_t highCount1; /*!< The high-time for carrier generator first register. */
|
||||
uint8_t lowCount1; /*!< The low-time for carrier generator first register. */
|
||||
uint8_t highCount2; /*!< The high-time for carrier generator second register for FSK mode. */
|
||||
uint8_t lowCount2; /*!< The low-time for carrier generator second register for FSK mode. */
|
||||
uint16_t markCount; /*!< The mark time for the modulator gate. */
|
||||
uint16_t spaceCount; /*!< The space time for the modulator gate. */
|
||||
} cmt_modulate_config_t;
|
||||
|
||||
/*! @brief CMT basic configuration structure. */
|
||||
typedef struct _cmt_config
|
||||
{
|
||||
bool isInterruptEnabled; /*!< Timer interrupt 0-disable, 1-enable. */
|
||||
bool isIroEnabled; /*!< The IRO output 0-disabled, 1-enabled. */
|
||||
cmt_infrared_output_polarity_t iroPolarity; /*!< The IRO polarity. */
|
||||
cmt_second_clkdiv_t divider; /*!< The CMT clock divide prescaler. */
|
||||
} cmt_config_t;
|
||||
|
||||
/*******************************************************************************
|
||||
* API
|
||||
******************************************************************************/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*!
|
||||
* @name Initialization and deinitialization
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*!
|
||||
* @brief Gets the CMT default configuration structure. This API
|
||||
* gets the default configuration structure for the CMT_Init().
|
||||
* Use the initialized structure unchanged in CMT_Init() or modify
|
||||
* fields of the structure before calling the CMT_Init().
|
||||
*
|
||||
* @param config The CMT configuration structure pointer.
|
||||
*/
|
||||
void CMT_GetDefaultConfig(cmt_config_t *config);
|
||||
|
||||
/*!
|
||||
* @brief Initializes the CMT module.
|
||||
*
|
||||
* This function ungates the module clock and sets the CMT internal clock,
|
||||
* interrupt, and infrared output signal for the CMT module.
|
||||
*
|
||||
* @param base CMT peripheral base address.
|
||||
* @param config The CMT basic configuration structure.
|
||||
* @param busClock_Hz The CMT module input clock - bus clock frequency.
|
||||
*/
|
||||
void CMT_Init(CMT_Type *base, const cmt_config_t *config, uint32_t busClock_Hz);
|
||||
|
||||
/*!
|
||||
* @brief Disables the CMT module and gate control.
|
||||
*
|
||||
* This function disables CMT modulator, interrupts, and gates the
|
||||
* CMT clock control. CMT_Init must be called to use the CMT again.
|
||||
*
|
||||
* @param base CMT peripheral base address.
|
||||
*/
|
||||
void CMT_Deinit(CMT_Type *base);
|
||||
|
||||
/*! @}*/
|
||||
|
||||
/*!
|
||||
* @name Basic Control Operations
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*!
|
||||
* @brief Selects the mode for CMT.
|
||||
*
|
||||
* @param base CMT peripheral base address.
|
||||
* @param mode The CMT feature mode enumeration. See "cmt_mode_t".
|
||||
* @param modulateConfig The carrier generation and modulator configuration.
|
||||
*/
|
||||
void CMT_SetMode(CMT_Type *base, cmt_mode_t mode, cmt_modulate_config_t *modulateConfig);
|
||||
|
||||
/*!
|
||||
* @brief Gets the mode of the CMT module.
|
||||
*
|
||||
* @param base CMT peripheral base address.
|
||||
* @return The CMT mode.
|
||||
* kCMT_DirectIROCtl Carrier modulator is disabled; the IRO signal is directly in software control.
|
||||
* kCMT_TimeMode Carrier modulator is enabled in time mode.
|
||||
* kCMT_FSKMode Carrier modulator is enabled in FSK mode.
|
||||
* kCMT_BasebandMode Carrier modulator is enabled in baseband mode.
|
||||
*/
|
||||
cmt_mode_t CMT_GetMode(CMT_Type *base);
|
||||
|
||||
/*!
|
||||
* @brief Gets the actual CMT clock frequency.
|
||||
*
|
||||
* @param base CMT peripheral base address.
|
||||
* @param busClock_Hz CMT module input clock - bus clock frequency.
|
||||
* @return The CMT clock frequency.
|
||||
*/
|
||||
uint32_t CMT_GetCMTFrequency(CMT_Type *base, uint32_t busClock_Hz);
|
||||
|
||||
/*!
|
||||
* @brief Sets the primary data set for the CMT carrier generator counter.
|
||||
*
|
||||
* This function sets the high-time and low-time of the primary data set for the
|
||||
* CMT carrier generator counter to control the period and the duty cycle of the
|
||||
* output carrier signal.
|
||||
* If the CMT clock period is Tcmt, the period of the carrier generator signal equals
|
||||
* (highCount + lowCount) * Tcmt. The duty cycle equals to highCount / (highCount + lowCount).
|
||||
*
|
||||
* @param base CMT peripheral base address.
|
||||
* @param highCount The number of CMT clocks for carrier generator signal high time,
|
||||
* integer in the range of 1 ~ 0xFF.
|
||||
* @param lowCount The number of CMT clocks for carrier generator signal low time,
|
||||
* integer in the range of 1 ~ 0xFF.
|
||||
*/
|
||||
static inline void CMT_SetCarrirGenerateCountOne(CMT_Type *base, uint32_t highCount, uint32_t lowCount)
|
||||
{
|
||||
assert(highCount <= CMT_CGH1_PH_MASK);
|
||||
assert(highCount);
|
||||
assert(lowCount <= CMT_CGL1_PL_MASK);
|
||||
assert(lowCount);
|
||||
|
||||
base->CGH1 = highCount;
|
||||
base->CGL1 = lowCount;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Sets the secondary data set for the CMT carrier generator counter.
|
||||
*
|
||||
* This function is used for FSK mode setting the high-time and low-time of the secondary
|
||||
* data set CMT carrier generator counter to control the period and the duty cycle
|
||||
* of the output carrier signal.
|
||||
* If the CMT clock period is Tcmt, the period of the carrier generator signal equals
|
||||
* (highCount + lowCount) * Tcmt. The duty cycle equals highCount / (highCount + lowCount).
|
||||
*
|
||||
* @param base CMT peripheral base address.
|
||||
* @param highCount The number of CMT clocks for carrier generator signal high time,
|
||||
* integer in the range of 1 ~ 0xFF.
|
||||
* @param lowCount The number of CMT clocks for carrier generator signal low time,
|
||||
* integer in the range of 1 ~ 0xFF.
|
||||
*/
|
||||
static inline void CMT_SetCarrirGenerateCountTwo(CMT_Type *base, uint32_t highCount, uint32_t lowCount)
|
||||
{
|
||||
assert(highCount <= CMT_CGH2_SH_MASK);
|
||||
assert(highCount);
|
||||
assert(lowCount <= CMT_CGL2_SL_MASK);
|
||||
assert(lowCount);
|
||||
|
||||
base->CGH2 = highCount;
|
||||
base->CGL2 = lowCount;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Sets the modulation mark and space time period for the CMT modulator.
|
||||
*
|
||||
* This function sets the mark time period of the CMT modulator counter
|
||||
* to control the mark time of the output modulated signal from the carrier generator output signal.
|
||||
* If the CMT clock frequency is Fcmt and the carrier out signal frequency is fcg:
|
||||
* - In Time and Baseband mode: The mark period of the generated signal equals (markCount + 1) / (Fcmt/8).
|
||||
* The space period of the generated signal equals spaceCount / (Fcmt/8).
|
||||
* - In FSK mode: The mark period of the generated signal equals (markCount + 1)/fcg.
|
||||
* The space period of the generated signal equals spaceCount / fcg.
|
||||
*
|
||||
* @param base Base address for current CMT instance.
|
||||
* @param markCount The number of clock period for CMT modulator signal mark period,
|
||||
* in the range of 0 ~ 0xFFFF.
|
||||
* @param spaceCount The number of clock period for CMT modulator signal space period,
|
||||
* in the range of the 0 ~ 0xFFFF.
|
||||
*/
|
||||
void CMT_SetModulateMarkSpace(CMT_Type *base, uint32_t markCount, uint32_t spaceCount);
|
||||
|
||||
/*!
|
||||
* @brief Enables or disables the extended space operation.
|
||||
*
|
||||
* This function is used to make the space period longer
|
||||
* for time, baseband, and FSK modes.
|
||||
*
|
||||
* @param base CMT peripheral base address.
|
||||
* @param enable True enable the extended space, false disable the extended space.
|
||||
*/
|
||||
static inline void CMT_EnableExtendedSpace(CMT_Type *base, bool enable)
|
||||
{
|
||||
if (enable)
|
||||
{
|
||||
base->MSC |= CMT_MSC_EXSPC_MASK;
|
||||
}
|
||||
else
|
||||
{
|
||||
base->MSC &= ~CMT_MSC_EXSPC_MASK;
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Sets the IRO (infrared output) signal state.
|
||||
*
|
||||
* Changes the states of the IRO signal when the kCMT_DirectIROMode mode is set
|
||||
* and the IRO signal is enabled.
|
||||
*
|
||||
* @param base CMT peripheral base address.
|
||||
* @param state The control of the IRO signal. See "cmt_infrared_output_state_t"
|
||||
*/
|
||||
void CMT_SetIroState(CMT_Type *base, cmt_infrared_output_state_t state);
|
||||
|
||||
/*!
|
||||
* @brief Enables the CMT interrupt.
|
||||
*
|
||||
* This function enables the CMT interrupts according to the provided mask if enabled.
|
||||
* The CMT only has the end of the cycle interrupt - an interrupt occurs at the end
|
||||
* of the modulator cycle. This interrupt provides a means for the user
|
||||
* to reload the new mark/space values into the CMT modulator data registers
|
||||
* and verify the modulator mark and space.
|
||||
* For example, to enable the end of cycle, do the following.
|
||||
* @code
|
||||
* CMT_EnableInterrupts(CMT, kCMT_EndOfCycleInterruptEnable);
|
||||
* @endcode
|
||||
* @param base CMT peripheral base address.
|
||||
* @param mask The interrupts to enable. Logical OR of @ref _cmt_interrupt_enable.
|
||||
*/
|
||||
static inline void CMT_EnableInterrupts(CMT_Type *base, uint32_t mask)
|
||||
{
|
||||
base->MSC |= mask;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Disables the CMT interrupt.
|
||||
*
|
||||
* This function disables the CMT interrupts according to the provided maskIf enabled.
|
||||
* The CMT only has the end of the cycle interrupt.
|
||||
* For example, to disable the end of cycle, do the following.
|
||||
* @code
|
||||
* CMT_DisableInterrupts(CMT, kCMT_EndOfCycleInterruptEnable);
|
||||
* @endcode
|
||||
*
|
||||
* @param base CMT peripheral base address.
|
||||
* @param mask The interrupts to enable. Logical OR of @ref _cmt_interrupt_enable.
|
||||
*/
|
||||
static inline void CMT_DisableInterrupts(CMT_Type *base, uint32_t mask)
|
||||
{
|
||||
base->MSC &= ~mask;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Gets the end of the cycle status flag.
|
||||
*
|
||||
* The flag is set:
|
||||
* - When the modulator is not currently active and carrier and modulator
|
||||
* are set to start the initial CMT transmission.
|
||||
* - At the end of each modulation cycle when the counter is reloaded and
|
||||
* the carrier and modulator are enabled.
|
||||
* @param base CMT peripheral base address.
|
||||
* @return Current status of the end of cycle status flag
|
||||
* @arg non-zero: End-of-cycle has occurred.
|
||||
* @arg zero: End-of-cycle has not yet occurred since the flag last cleared.
|
||||
*/
|
||||
static inline uint32_t CMT_GetStatusFlags(CMT_Type *base)
|
||||
{
|
||||
return base->MSC & CMT_MSC_EOCF_MASK;
|
||||
}
|
||||
|
||||
/*! @}*/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
/*! @}*/
|
||||
|
||||
#endif /* _FSL_CMT_H_*/
|
||||
-176
@@ -1,176 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2015-2016, Freescale Semiconductor, Inc.
|
||||
* Copyright 2016-2017 NXP
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* o Redistributions of source code must retain the above copyright notice, this list
|
||||
* of conditions and the following disclaimer.
|
||||
*
|
||||
* o 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.
|
||||
*
|
||||
* o Neither the name of the copyright holder 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 HOLDER 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 "fsl_common.h"
|
||||
//#include "fsl_debug_console.h"
|
||||
|
||||
#ifndef NDEBUG
|
||||
#if (defined(__CC_ARM)) || (defined(__ICCARM__))
|
||||
void __aeabi_assert(const char *failedExpr, const char *file, int line)
|
||||
{
|
||||
//PRINTF("ASSERT ERROR \" %s \": file \"%s\" Line \"%d\" \n", failedExpr, file, line);
|
||||
for (;;)
|
||||
{
|
||||
__BKPT(0);
|
||||
}
|
||||
}
|
||||
#elif(defined(__REDLIB__))
|
||||
|
||||
#if SDK_DEBUGCONSOLE
|
||||
void __assertion_failed(char *_Expr)
|
||||
{
|
||||
PRINTF("%s\n", _Expr);
|
||||
for (;;)
|
||||
{
|
||||
__asm("bkpt #0");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#elif(defined(__GNUC__))
|
||||
void __assert_func(const char *file, int line, const char *func, const char *failedExpr)
|
||||
{
|
||||
PRINTF("ASSERT ERROR \" %s \": file \"%s\" Line \"%d\" function name \"%s\" \n", failedExpr, file, line, func);
|
||||
for (;;)
|
||||
{
|
||||
__BKPT(0);
|
||||
}
|
||||
}
|
||||
#endif /* (defined(__CC_ARM)) || (defined (__ICCARM__)) */
|
||||
#endif /* NDEBUG */
|
||||
|
||||
#ifndef __GIC_PRIO_BITS
|
||||
uint32_t InstallIRQHandler(IRQn_Type irq, uint32_t irqHandler)
|
||||
{
|
||||
/* Addresses for VECTOR_TABLE and VECTOR_RAM come from the linker file */
|
||||
#if defined(__CC_ARM)
|
||||
extern uint32_t Image$$VECTOR_ROM$$Base[];
|
||||
extern uint32_t Image$$VECTOR_RAM$$Base[];
|
||||
extern uint32_t Image$$RW_m_data$$Base[];
|
||||
|
||||
#define __VECTOR_TABLE Image$$VECTOR_ROM$$Base
|
||||
#define __VECTOR_RAM Image$$VECTOR_RAM$$Base
|
||||
#define __RAM_VECTOR_TABLE_SIZE (((uint32_t)Image$$RW_m_data$$Base - (uint32_t)Image$$VECTOR_RAM$$Base))
|
||||
#elif defined(__ICCARM__)
|
||||
extern uint32_t __RAM_VECTOR_TABLE_SIZE[];
|
||||
extern uint32_t __VECTOR_TABLE[];
|
||||
extern uint32_t __VECTOR_RAM[];
|
||||
#elif defined(__GNUC__)
|
||||
extern uint32_t __VECTOR_TABLE[];
|
||||
extern uint32_t __VECTOR_RAM[];
|
||||
extern uint32_t __RAM_VECTOR_TABLE_SIZE_BYTES[];
|
||||
uint32_t __RAM_VECTOR_TABLE_SIZE = (uint32_t)(__RAM_VECTOR_TABLE_SIZE_BYTES);
|
||||
#endif /* defined(__CC_ARM) */
|
||||
uint32_t n;
|
||||
uint32_t ret;
|
||||
uint32_t irqMaskValue;
|
||||
|
||||
irqMaskValue = DisableGlobalIRQ();
|
||||
if (SCB->VTOR != (uint32_t)__VECTOR_RAM)
|
||||
{
|
||||
/* Copy the vector table from ROM to RAM */
|
||||
for (n = 0; n < ((uint32_t)__RAM_VECTOR_TABLE_SIZE) / sizeof(uint32_t); n++)
|
||||
{
|
||||
__VECTOR_RAM[n] = __VECTOR_TABLE[n];
|
||||
}
|
||||
/* Point the VTOR to the position of vector table */
|
||||
SCB->VTOR = (uint32_t)__VECTOR_RAM;
|
||||
}
|
||||
|
||||
ret = __VECTOR_RAM[irq + 16];
|
||||
/* make sure the __VECTOR_RAM is noncachable */
|
||||
__VECTOR_RAM[irq + 16] = irqHandler;
|
||||
|
||||
EnableGlobalIRQ(irqMaskValue);
|
||||
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef CPU_QN908X
|
||||
#if (defined(FSL_FEATURE_SOC_SYSCON_COUNT) && (FSL_FEATURE_SOC_SYSCON_COUNT > 0))
|
||||
|
||||
void EnableDeepSleepIRQ(IRQn_Type interrupt)
|
||||
{
|
||||
uint32_t index = 0;
|
||||
uint32_t intNumber = (uint32_t)interrupt;
|
||||
while (intNumber >= 32u)
|
||||
{
|
||||
index++;
|
||||
intNumber -= 32u;
|
||||
}
|
||||
|
||||
SYSCON->STARTERSET[index] = 1u << intNumber;
|
||||
EnableIRQ(interrupt); /* also enable interrupt at NVIC */
|
||||
}
|
||||
|
||||
void DisableDeepSleepIRQ(IRQn_Type interrupt)
|
||||
{
|
||||
uint32_t index = 0;
|
||||
uint32_t intNumber = (uint32_t)interrupt;
|
||||
while (intNumber >= 32u)
|
||||
{
|
||||
index++;
|
||||
intNumber -= 32u;
|
||||
}
|
||||
|
||||
DisableIRQ(interrupt); /* also disable interrupt at NVIC */
|
||||
SYSCON->STARTERCLR[index] = 1u << intNumber;
|
||||
}
|
||||
#endif /* FSL_FEATURE_SOC_SYSCON_COUNT */
|
||||
#else
|
||||
void EnableDeepSleepIRQ(IRQn_Type interrupt)
|
||||
{
|
||||
uint32_t index = 0;
|
||||
uint32_t intNumber = (uint32_t)interrupt;
|
||||
while (intNumber >= 32u)
|
||||
{
|
||||
index++;
|
||||
intNumber -= 32u;
|
||||
}
|
||||
|
||||
/* SYSCON->STARTERSET[index] = 1u << intNumber; */
|
||||
EnableIRQ(interrupt); /* also enable interrupt at NVIC */
|
||||
}
|
||||
|
||||
void DisableDeepSleepIRQ(IRQn_Type interrupt)
|
||||
{
|
||||
uint32_t index = 0;
|
||||
uint32_t intNumber = (uint32_t)interrupt;
|
||||
while (intNumber >= 32u)
|
||||
{
|
||||
index++;
|
||||
intNumber -= 32u;
|
||||
}
|
||||
|
||||
DisableIRQ(interrupt); /* also disable interrupt at NVIC */
|
||||
/* SYSCON->STARTERCLR[index] = 1u << intNumber; */
|
||||
}
|
||||
#endif /*CPU_QN908X */
|
||||
-348
@@ -1,348 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2015-2016, Freescale Semiconductor, Inc.
|
||||
* Copyright 2016-2017 NXP
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* o Redistributions of source code must retain the above copyright notice, this list
|
||||
* of conditions and the following disclaimer.
|
||||
*
|
||||
* o 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.
|
||||
*
|
||||
* o Neither the name of the copyright holder 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 HOLDER 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 _FSL_COMMON_H_
|
||||
#define _FSL_COMMON_H_
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
#if defined(__ICCARM__)
|
||||
#include <stddef.h>
|
||||
#endif
|
||||
|
||||
#include "fsl_device_registers.h"
|
||||
|
||||
/*!
|
||||
* @addtogroup ksdk_common
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*******************************************************************************
|
||||
* Definitions
|
||||
******************************************************************************/
|
||||
|
||||
/*! @brief Construct a status code value from a group and code number. */
|
||||
#define MAKE_STATUS(group, code) ((((group)*100) + (code)))
|
||||
|
||||
/*! @brief Construct the version number for drivers. */
|
||||
#define MAKE_VERSION(major, minor, bugfix) (((major) << 16) | ((minor) << 8) | (bugfix))
|
||||
|
||||
/* Debug console type definition. */
|
||||
#define DEBUG_CONSOLE_DEVICE_TYPE_NONE 0U /*!< No debug console. */
|
||||
#define DEBUG_CONSOLE_DEVICE_TYPE_UART 1U /*!< Debug console base on UART. */
|
||||
#define DEBUG_CONSOLE_DEVICE_TYPE_LPUART 2U /*!< Debug console base on LPUART. */
|
||||
#define DEBUG_CONSOLE_DEVICE_TYPE_LPSCI 3U /*!< Debug console base on LPSCI. */
|
||||
#define DEBUG_CONSOLE_DEVICE_TYPE_USBCDC 4U /*!< Debug console base on USBCDC. */
|
||||
#define DEBUG_CONSOLE_DEVICE_TYPE_FLEXCOMM 5U /*!< Debug console base on USBCDC. */
|
||||
#define DEBUG_CONSOLE_DEVICE_TYPE_IUART 6U /*!< Debug console base on i.MX UART. */
|
||||
|
||||
/*! @brief Status group numbers. */
|
||||
enum _status_groups
|
||||
{
|
||||
kStatusGroup_Generic = 0, /*!< Group number for generic status codes. */
|
||||
kStatusGroup_FLASH = 1, /*!< Group number for FLASH status codes. */
|
||||
kStatusGroup_LPSPI = 4, /*!< Group number for LPSPI status codes. */
|
||||
kStatusGroup_FLEXIO_SPI = 5, /*!< Group number for FLEXIO SPI status codes. */
|
||||
kStatusGroup_DSPI = 6, /*!< Group number for DSPI status codes. */
|
||||
kStatusGroup_FLEXIO_UART = 7, /*!< Group number for FLEXIO UART status codes. */
|
||||
kStatusGroup_FLEXIO_I2C = 8, /*!< Group number for FLEXIO I2C status codes. */
|
||||
kStatusGroup_LPI2C = 9, /*!< Group number for LPI2C status codes. */
|
||||
kStatusGroup_UART = 10, /*!< Group number for UART status codes. */
|
||||
kStatusGroup_I2C = 11, /*!< Group number for UART status codes. */
|
||||
kStatusGroup_LPSCI = 12, /*!< Group number for LPSCI status codes. */
|
||||
kStatusGroup_LPUART = 13, /*!< Group number for LPUART status codes. */
|
||||
kStatusGroup_SPI = 14, /*!< Group number for SPI status code.*/
|
||||
kStatusGroup_XRDC = 15, /*!< Group number for XRDC status code.*/
|
||||
kStatusGroup_SEMA42 = 16, /*!< Group number for SEMA42 status code.*/
|
||||
kStatusGroup_SDHC = 17, /*!< Group number for SDHC status code */
|
||||
kStatusGroup_SDMMC = 18, /*!< Group number for SDMMC status code */
|
||||
kStatusGroup_SAI = 19, /*!< Group number for SAI status code */
|
||||
kStatusGroup_MCG = 20, /*!< Group number for MCG status codes. */
|
||||
kStatusGroup_SCG = 21, /*!< Group number for SCG status codes. */
|
||||
kStatusGroup_SDSPI = 22, /*!< Group number for SDSPI status codes. */
|
||||
kStatusGroup_FLEXIO_I2S = 23, /*!< Group number for FLEXIO I2S status codes */
|
||||
kStatusGroup_FLEXIO_MCULCD = 24, /*!< Group number for FLEXIO LCD status codes */
|
||||
kStatusGroup_FLASHIAP = 25, /*!< Group number for FLASHIAP status codes */
|
||||
kStatusGroup_FLEXCOMM_I2C = 26, /*!< Group number for FLEXCOMM I2C status codes */
|
||||
kStatusGroup_I2S = 27, /*!< Group number for I2S status codes */
|
||||
kStatusGroup_IUART = 28, /*!< Group number for IUART status codes */
|
||||
kStatusGroup_SDRAMC = 35, /*!< Group number for SDRAMC status codes. */
|
||||
kStatusGroup_POWER = 39, /*!< Group number for POWER status codes. */
|
||||
kStatusGroup_ENET = 40, /*!< Group number for ENET status codes. */
|
||||
kStatusGroup_PHY = 41, /*!< Group number for PHY status codes. */
|
||||
kStatusGroup_TRGMUX = 42, /*!< Group number for TRGMUX status codes. */
|
||||
kStatusGroup_SMARTCARD = 43, /*!< Group number for SMARTCARD status codes. */
|
||||
kStatusGroup_LMEM = 44, /*!< Group number for LMEM status codes. */
|
||||
kStatusGroup_QSPI = 45, /*!< Group number for QSPI status codes. */
|
||||
kStatusGroup_DMA = 50, /*!< Group number for DMA status codes. */
|
||||
kStatusGroup_EDMA = 51, /*!< Group number for EDMA status codes. */
|
||||
kStatusGroup_DMAMGR = 52, /*!< Group number for DMAMGR status codes. */
|
||||
kStatusGroup_FLEXCAN = 53, /*!< Group number for FlexCAN status codes. */
|
||||
kStatusGroup_LTC = 54, /*!< Group number for LTC status codes. */
|
||||
kStatusGroup_FLEXIO_CAMERA = 55, /*!< Group number for FLEXIO CAMERA status codes. */
|
||||
kStatusGroup_LPC_SPI = 56, /*!< Group number for LPC_SPI status codes. */
|
||||
kStatusGroup_LPC_USART = 57, /*!< Group number for LPC_USART status codes. */
|
||||
kStatusGroup_DMIC = 58, /*!< Group number for DMIC status codes. */
|
||||
kStatusGroup_SDIF = 59, /*!< Group number for SDIF status codes.*/
|
||||
kStatusGroup_SPIFI = 60, /*!< Group number for SPIFI status codes. */
|
||||
kStatusGroup_OTP = 61, /*!< Group number for OTP status codes. */
|
||||
kStatusGroup_MCAN = 62, /*!< Group number for MCAN status codes. */
|
||||
kStatusGroup_CAAM = 63, /*!< Group number for CAAM status codes. */
|
||||
kStatusGroup_ECSPI = 64, /*!< Group number for ECSPI status codes. */
|
||||
kStatusGroup_USDHC = 65, /*!< Group number for USDHC status codes.*/
|
||||
kStatusGroup_ESAI = 69, /*!< Group number for ESAI status codes. */
|
||||
kStatusGroup_FLEXSPI = 70, /*!< Group number for FLEXSPI status codes. */
|
||||
kStatusGroup_NOTIFIER = 98, /*!< Group number for NOTIFIER status codes. */
|
||||
kStatusGroup_DebugConsole = 99, /*!< Group number for debug console status codes. */
|
||||
kStatusGroup_ApplicationRangeStart = 100, /*!< Starting number for application groups. */
|
||||
};
|
||||
|
||||
/*! @brief Generic status return codes. */
|
||||
enum _generic_status
|
||||
{
|
||||
kStatus_Success = MAKE_STATUS(kStatusGroup_Generic, 0),
|
||||
kStatus_Fail = MAKE_STATUS(kStatusGroup_Generic, 1),
|
||||
kStatus_ReadOnly = MAKE_STATUS(kStatusGroup_Generic, 2),
|
||||
kStatus_OutOfRange = MAKE_STATUS(kStatusGroup_Generic, 3),
|
||||
kStatus_InvalidArgument = MAKE_STATUS(kStatusGroup_Generic, 4),
|
||||
kStatus_Timeout = MAKE_STATUS(kStatusGroup_Generic, 5),
|
||||
kStatus_NoTransferInProgress = MAKE_STATUS(kStatusGroup_Generic, 6),
|
||||
};
|
||||
|
||||
/*! @brief Type used for all status and error return values. */
|
||||
typedef int32_t status_t;
|
||||
|
||||
/*
|
||||
* The fsl_clock.h is included here because it needs MAKE_VERSION/MAKE_STATUS/status_t
|
||||
* defined in previous of this file.
|
||||
*/
|
||||
#include "fsl_clock.h"
|
||||
|
||||
/*
|
||||
* Chip level peripheral reset API, for MCUs that implement peripheral reset control external to a peripheral
|
||||
*/
|
||||
#if ((defined(FSL_FEATURE_SOC_SYSCON_COUNT) && (FSL_FEATURE_SOC_SYSCON_COUNT > 0)) || \
|
||||
(defined(FSL_FEATURE_SOC_ASYNC_SYSCON_COUNT) && (FSL_FEATURE_SOC_ASYNC_SYSCON_COUNT > 0)))
|
||||
#include "fsl_reset.h"
|
||||
#endif
|
||||
|
||||
/*! @name Min/max macros */
|
||||
/* @{ */
|
||||
#if !defined(MIN)
|
||||
#define MIN(a, b) ((a) < (b) ? (a) : (b))
|
||||
#endif
|
||||
|
||||
#if !defined(MAX)
|
||||
#define MAX(a, b) ((a) > (b) ? (a) : (b))
|
||||
#endif
|
||||
/* @} */
|
||||
|
||||
/*! @brief Computes the number of elements in an array. */
|
||||
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
|
||||
|
||||
/*! @name UINT16_MAX/UINT32_MAX value */
|
||||
/* @{ */
|
||||
#if !defined(UINT16_MAX)
|
||||
#define UINT16_MAX ((uint16_t)-1)
|
||||
#endif
|
||||
|
||||
#if !defined(UINT32_MAX)
|
||||
#define UINT32_MAX ((uint32_t)-1)
|
||||
#endif
|
||||
/* @} */
|
||||
|
||||
/*! @name Timer utilities */
|
||||
/* @{ */
|
||||
/*! Macro to convert a microsecond period to raw count value */
|
||||
#define USEC_TO_COUNT(us, clockFreqInHz) (uint64_t)((uint64_t)us * clockFreqInHz / 1000000U)
|
||||
/*! Macro to convert a raw count value to microsecond */
|
||||
#define COUNT_TO_USEC(count, clockFreqInHz) (uint64_t)((uint64_t)count * 1000000U / clockFreqInHz)
|
||||
|
||||
/*! Macro to convert a millisecond period to raw count value */
|
||||
#define MSEC_TO_COUNT(ms, clockFreqInHz) (uint64_t)((uint64_t)ms * clockFreqInHz / 1000U)
|
||||
/*! Macro to convert a raw count value to millisecond */
|
||||
#define COUNT_TO_MSEC(count, clockFreqInHz) (uint64_t)((uint64_t)count * 1000U / clockFreqInHz)
|
||||
/* @} */
|
||||
|
||||
/*******************************************************************************
|
||||
* API
|
||||
******************************************************************************/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*!
|
||||
* @brief Enable specific interrupt.
|
||||
*
|
||||
* Enable the interrupt not routed from intmux.
|
||||
*
|
||||
* @param interrupt The IRQ number.
|
||||
*/
|
||||
static inline void EnableIRQ(IRQn_Type interrupt)
|
||||
{
|
||||
if (NotAvail_IRQn == interrupt)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
#if defined(FSL_FEATURE_SOC_INTMUX_COUNT) && (FSL_FEATURE_SOC_INTMUX_COUNT > 0)
|
||||
if (interrupt < FSL_FEATURE_INTMUX_IRQ_START_INDEX)
|
||||
#endif
|
||||
{
|
||||
#if defined(__GIC_PRIO_BITS)
|
||||
GIC_EnableIRQ(interrupt);
|
||||
#else
|
||||
NVIC_EnableIRQ(interrupt);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Disable specific interrupt.
|
||||
*
|
||||
* Disable the interrupt not routed from intmux.
|
||||
*
|
||||
* @param interrupt The IRQ number.
|
||||
*/
|
||||
static inline void DisableIRQ(IRQn_Type interrupt)
|
||||
{
|
||||
if (NotAvail_IRQn == interrupt)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
#if defined(FSL_FEATURE_SOC_INTMUX_COUNT) && (FSL_FEATURE_SOC_INTMUX_COUNT > 0)
|
||||
if (interrupt < FSL_FEATURE_INTMUX_IRQ_START_INDEX)
|
||||
#endif
|
||||
{
|
||||
#if defined(__GIC_PRIO_BITS)
|
||||
GIC_DisableIRQ(interrupt);
|
||||
#else
|
||||
NVIC_DisableIRQ(interrupt);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Disable the global IRQ
|
||||
*
|
||||
* Disable the global interrupt and return the current primask register. User is required to provided the primask
|
||||
* register for the EnableGlobalIRQ().
|
||||
*
|
||||
* @return Current primask value.
|
||||
*/
|
||||
static inline uint32_t DisableGlobalIRQ(void)
|
||||
{
|
||||
#if defined(CPSR_I_Msk)
|
||||
uint32_t cpsr = __get_CPSR() & CPSR_I_Msk;
|
||||
|
||||
__disable_irq();
|
||||
|
||||
return cpsr;
|
||||
#else
|
||||
uint32_t regPrimask = __get_PRIMASK();
|
||||
|
||||
__disable_irq();
|
||||
|
||||
return regPrimask;
|
||||
#endif
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Enaable the global IRQ
|
||||
*
|
||||
* Set the primask register with the provided primask value but not just enable the primask. The idea is for the
|
||||
* convinience of integration of RTOS. some RTOS get its own management mechanism of primask. User is required to
|
||||
* use the EnableGlobalIRQ() and DisableGlobalIRQ() in pair.
|
||||
*
|
||||
* @param primask value of primask register to be restored. The primask value is supposed to be provided by the
|
||||
* DisableGlobalIRQ().
|
||||
*/
|
||||
static inline void EnableGlobalIRQ(uint32_t primask)
|
||||
{
|
||||
#if defined(CPSR_I_Msk)
|
||||
__set_CPSR((__get_CPSR() & ~CPSR_I_Msk) | primask);
|
||||
#else
|
||||
__set_PRIMASK(primask);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief install IRQ handler
|
||||
*
|
||||
* @param irq IRQ number
|
||||
* @param irqHandler IRQ handler address
|
||||
* @return The old IRQ handler address
|
||||
*/
|
||||
uint32_t InstallIRQHandler(IRQn_Type irq, uint32_t irqHandler);
|
||||
|
||||
#if (defined(FSL_FEATURE_SOC_SYSCON_COUNT) && (FSL_FEATURE_SOC_SYSCON_COUNT > 0))
|
||||
/*!
|
||||
* @brief Enable specific interrupt for wake-up from deep-sleep mode.
|
||||
*
|
||||
* Enable the interrupt for wake-up from deep sleep mode.
|
||||
* Some interrupts are typically used in sleep mode only and will not occur during
|
||||
* deep-sleep mode because relevant clocks are stopped. However, it is possible to enable
|
||||
* those clocks (significantly increasing power consumption in the reduced power mode),
|
||||
* making these wake-ups possible.
|
||||
*
|
||||
* @note This function also enables the interrupt in the NVIC (EnableIRQ() is called internally).
|
||||
*
|
||||
* @param interrupt The IRQ number.
|
||||
*/
|
||||
void EnableDeepSleepIRQ(IRQn_Type interrupt);
|
||||
|
||||
/*!
|
||||
* @brief Disable specific interrupt for wake-up from deep-sleep mode.
|
||||
*
|
||||
* Disable the interrupt for wake-up from deep sleep mode.
|
||||
* Some interrupts are typically used in sleep mode only and will not occur during
|
||||
* deep-sleep mode because relevant clocks are stopped. However, it is possible to enable
|
||||
* those clocks (significantly increasing power consumption in the reduced power mode),
|
||||
* making these wake-ups possible.
|
||||
*
|
||||
* @note This function also disables the interrupt in the NVIC (DisableIRQ() is called internally).
|
||||
*
|
||||
* @param interrupt The IRQ number.
|
||||
*/
|
||||
void DisableDeepSleepIRQ(IRQn_Type interrupt);
|
||||
#endif /* FSL_FEATURE_SOC_SYSCON_COUNT */
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
/*! @} */
|
||||
|
||||
#endif /* _FSL_COMMON_H_ */
|
||||
-77
@@ -1,77 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Freescale Semiconductor, Inc.
|
||||
* Copyright 2016-2017 NXP
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* o Redistributions of source code must retain the above copyright notice, this list
|
||||
* of conditions and the following disclaimer.
|
||||
*
|
||||
* o 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.
|
||||
*
|
||||
* o Neither the name of the copyright holder 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 HOLDER 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 "fsl_cop.h"
|
||||
|
||||
/*******************************************************************************
|
||||
* Code
|
||||
******************************************************************************/
|
||||
|
||||
void COP_GetDefaultConfig(cop_config_t *config)
|
||||
{
|
||||
assert(config);
|
||||
|
||||
config->enableWindowMode = false;
|
||||
#if defined(FSL_FEATURE_COP_HAS_LONGTIME_MODE) && FSL_FEATURE_COP_HAS_LONGTIME_MODE
|
||||
config->timeoutMode = kCOP_LongTimeoutMode;
|
||||
config->enableStop = false;
|
||||
config->enableDebug = false;
|
||||
#endif /* FSL_FEATURE_COP_HAS_LONGTIME_MODE */
|
||||
config->clockSource = kCOP_LpoClock;
|
||||
config->timeoutCycles = kCOP_2Power10CyclesOr2Power18Cycles;
|
||||
}
|
||||
|
||||
void COP_Init(SIM_Type *base, const cop_config_t *config)
|
||||
{
|
||||
assert(config);
|
||||
|
||||
uint32_t value = 0U;
|
||||
|
||||
#if defined(FSL_FEATURE_COP_HAS_LONGTIME_MODE) && FSL_FEATURE_COP_HAS_LONGTIME_MODE
|
||||
value = SIM_COPC_COPW(config->enableWindowMode) | SIM_COPC_COPCLKS(config->timeoutMode) |
|
||||
SIM_COPC_COPT(config->timeoutCycles) | SIM_COPC_COPSTPEN(config->enableStop) |
|
||||
SIM_COPC_COPDBGEN(config->enableDebug) | SIM_COPC_COPCLKSEL(config->clockSource);
|
||||
#else
|
||||
value = SIM_COPC_COPW(config->enableWindowMode) | SIM_COPC_COPCLKS(config->clockSource) |
|
||||
SIM_COPC_COPT(config->timeoutCycles);
|
||||
#endif /* FSL_FEATURE_COP_HAS_LONGTIME_MODE */
|
||||
base->COPC = value;
|
||||
}
|
||||
|
||||
void COP_Refresh(SIM_Type *base)
|
||||
{
|
||||
uint32_t primaskValue = 0U;
|
||||
|
||||
/* Disable the global interrupt to protect refresh sequence */
|
||||
primaskValue = DisableGlobalIRQ();
|
||||
base->SRVCOP = COP_FIRST_BYTE_OF_REFRESH;
|
||||
base->SRVCOP = COP_SECOND_BYTE_OF_REFRESH;
|
||||
EnableGlobalIRQ(primaskValue);
|
||||
}
|
||||
-187
@@ -1,187 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Freescale Semiconductor, Inc.
|
||||
* Copyright 2016-2017 NXP
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* o Redistributions of source code must retain the above copyright notice, this list
|
||||
* of conditions and the following disclaimer.
|
||||
*
|
||||
* o 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.
|
||||
*
|
||||
* o Neither the name of the copyright holder 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 HOLDER 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 _FSL_COP_H_
|
||||
#define _FSL_COP_H_
|
||||
|
||||
#include "fsl_common.h"
|
||||
|
||||
/*!
|
||||
* @addtogroup cop
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
* Definitions
|
||||
*******************************************************************************/
|
||||
|
||||
/*! @name Driver version */
|
||||
/*@{*/
|
||||
/*! @brief COP driver version 2.0.0. */
|
||||
#define FSL_COP_DRIVER_VERSION (MAKE_VERSION(2, 0, 0))
|
||||
/*@}*/
|
||||
|
||||
/*! @name COP refresh sequence. */
|
||||
/*@{*/
|
||||
#define COP_FIRST_BYTE_OF_REFRESH (0x55U) /*!< First byte of refresh sequence */
|
||||
#define COP_SECOND_BYTE_OF_REFRESH (0xAAU) /*!< Second byte of refresh sequence */
|
||||
/*@}*/
|
||||
|
||||
/*! @brief COP clock source selection. */
|
||||
typedef enum _cop_clock_source
|
||||
{
|
||||
kCOP_LpoClock = 0U, /*!< COP clock sourced from LPO */
|
||||
#if defined(FSL_FEATURE_COP_HAS_MORE_CLKSRC) && FSL_FEATURE_COP_HAS_MORE_CLKSRC
|
||||
kCOP_McgIrClock = 1U, /*!< COP clock sourced from MCGIRCLK */
|
||||
kCOP_OscErClock = 2U, /*!< COP clock sourced from OSCERCLK */
|
||||
#endif /* FSL_FEATURE_COP_HAS_MORE_CLKSRC */
|
||||
kCOP_BusClock = 3U, /*!< COP clock sourced from Bus clock */
|
||||
} cop_clock_source_t;
|
||||
|
||||
/*! @brief Define the COP timeout cycles. */
|
||||
typedef enum _cop_timeout_cycles
|
||||
{
|
||||
kCOP_2Power5CyclesOr2Power13Cycles = 1U, /*!< 2^5 or 2^13 clock cycles */
|
||||
kCOP_2Power8CyclesOr2Power16Cycles = 2U, /*!< 2^8 or 2^16 clock cycles */
|
||||
kCOP_2Power10CyclesOr2Power18Cycles = 3U, /*!< 2^10 or 2^18 clock cycles */
|
||||
} cop_timeout_cycles_t;
|
||||
|
||||
#if defined(FSL_FEATURE_COP_HAS_LONGTIME_MODE) && FSL_FEATURE_COP_HAS_LONGTIME_MODE
|
||||
/*! @breif Define the COP timeout mode. */
|
||||
typedef enum _cop_timeout_mode
|
||||
{
|
||||
kCOP_ShortTimeoutMode = 0U, /*!< COP selects long timeout */
|
||||
kCOP_LongTimeoutMode = 1U, /*!< COP selects short timeout */
|
||||
} cop_timeout_mode_t;
|
||||
#endif /* FSL_FEATURE_COP_HAS_LONGTIME_MODE */
|
||||
|
||||
/*! @brief Describes COP configuration structure. */
|
||||
typedef struct _cop_config
|
||||
{
|
||||
bool enableWindowMode; /*!< COP run mode: window mode or normal mode */
|
||||
#if defined(FSL_FEATURE_COP_HAS_LONGTIME_MODE) && FSL_FEATURE_COP_HAS_LONGTIME_MODE
|
||||
cop_timeout_mode_t timeoutMode; /*!< COP timeout mode: long timeout or short timeout */
|
||||
bool enableStop; /*!< Enable or disable COP in STOP mode */
|
||||
bool enableDebug; /*!< Enable or disable COP in DEBUG mode */
|
||||
#endif /* FSL_FEATURE_COP_HAS_LONGTIME_MODE */
|
||||
cop_clock_source_t clockSource; /*!< Set COP clock source */
|
||||
cop_timeout_cycles_t timeoutCycles; /*!< Set COP timeout value */
|
||||
} cop_config_t;
|
||||
|
||||
/*******************************************************************************
|
||||
* API
|
||||
*******************************************************************************/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif /* __cplusplus*/
|
||||
|
||||
/*!
|
||||
* @name COP Functional Operation
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*!
|
||||
* @brief Initializes the COP configuration structure.
|
||||
*
|
||||
* This function initializes the COP configuration structure to default values. The default
|
||||
* values are:
|
||||
* @code
|
||||
* copConfig->enableWindowMode = false;
|
||||
* copConfig->timeoutMode = kCOP_LongTimeoutMode;
|
||||
* copConfig->enableStop = false;
|
||||
* copConfig->enableDebug = false;
|
||||
* copConfig->clockSource = kCOP_LpoClock;
|
||||
* copConfig->timeoutCycles = kCOP_2Power10CyclesOr2Power18Cycles;
|
||||
* @endcode
|
||||
*
|
||||
* @param config Pointer to the COP configuration structure.
|
||||
* @see cop_config_t
|
||||
*/
|
||||
void COP_GetDefaultConfig(cop_config_t *config);
|
||||
|
||||
/*!
|
||||
* @brief Initializes the COP module.
|
||||
*
|
||||
* This function configures the COP. After it is called, the COP
|
||||
* starts running according to the configuration.
|
||||
* Because all COP control registers are write-once only, the COP_Init function
|
||||
* and the COP_Disable function can be called only once. A second call has no effect.
|
||||
*
|
||||
* Example:
|
||||
* @code
|
||||
* cop_config_t config;
|
||||
* COP_GetDefaultConfig(&config);
|
||||
* config.timeoutCycles = kCOP_2Power8CyclesOr2Power16Cycles;
|
||||
* COP_Init(sim_base,&config);
|
||||
* @endcode
|
||||
*
|
||||
* @param base SIM peripheral base address.
|
||||
* @param config The configuration of COP.
|
||||
*/
|
||||
void COP_Init(SIM_Type *base, const cop_config_t *config);
|
||||
|
||||
/*!
|
||||
* @brief De-initializes the COP module.
|
||||
* This dedicated function is not provided. Instead, the COP_Disable function can be used to disable the COP.
|
||||
*/
|
||||
|
||||
/*!
|
||||
* @brief Disables the COP module.
|
||||
*
|
||||
* This function disables the COP Watchdog.
|
||||
* Note: The COP configuration register is a write-once after reset.
|
||||
* To disable the COP Watchdog, call this function first.
|
||||
*
|
||||
* @param base SIM peripheral base address.
|
||||
*/
|
||||
static inline void COP_Disable(SIM_Type *base)
|
||||
{
|
||||
base->COPC &= ~SIM_COPC_COPT_MASK;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Refreshes the COP timer
|
||||
*
|
||||
* This function feeds the COP.
|
||||
*
|
||||
* @param base SIM peripheral base address.
|
||||
*/
|
||||
void COP_Refresh(SIM_Type *base);
|
||||
|
||||
/*@}*/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/*! @}*/
|
||||
|
||||
#endif /* _FSL_COP_H_ */
|
||||
-220
@@ -1,220 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Freescale Semiconductor, Inc.
|
||||
* Copyright 2016-2017 NXP
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* o Redistributions of source code must retain the above copyright notice, this list
|
||||
* of conditions and the following disclaimer.
|
||||
*
|
||||
* o 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.
|
||||
*
|
||||
* o Neither the name of the copyright holder 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 HOLDER 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 "fsl_dac.h"
|
||||
|
||||
/*******************************************************************************
|
||||
* Prototypes
|
||||
******************************************************************************/
|
||||
/*!
|
||||
* @brief Get instance number for DAC module.
|
||||
*
|
||||
* @param base DAC peripheral base address
|
||||
*/
|
||||
static uint32_t DAC_GetInstance(DAC_Type *base);
|
||||
|
||||
/*******************************************************************************
|
||||
* Variables
|
||||
******************************************************************************/
|
||||
/*! @brief Pointers to DAC bases for each instance. */
|
||||
static DAC_Type *const s_dacBases[] = DAC_BASE_PTRS;
|
||||
#if !(defined(FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL) && FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL)
|
||||
/*! @brief Pointers to DAC clocks for each instance. */
|
||||
static const clock_ip_name_t s_dacClocks[] = DAC_CLOCKS;
|
||||
#endif /* FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL */
|
||||
|
||||
/*******************************************************************************
|
||||
* Codes
|
||||
******************************************************************************/
|
||||
static uint32_t DAC_GetInstance(DAC_Type *base)
|
||||
{
|
||||
uint32_t instance;
|
||||
|
||||
/* Find the instance index from base address mappings. */
|
||||
for (instance = 0; instance < ARRAY_SIZE(s_dacBases); instance++)
|
||||
{
|
||||
if (s_dacBases[instance] == base)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
assert(instance < ARRAY_SIZE(s_dacBases));
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
void DAC_Init(DAC_Type *base, const dac_config_t *config)
|
||||
{
|
||||
assert(NULL != config);
|
||||
|
||||
uint8_t tmp8;
|
||||
|
||||
#if !(defined(FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL) && FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL)
|
||||
/* Enable the clock. */
|
||||
CLOCK_EnableClock(s_dacClocks[DAC_GetInstance(base)]);
|
||||
#endif /* FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL */
|
||||
|
||||
/* Configure. */
|
||||
/* DACx_C0. */
|
||||
tmp8 = base->C0 & ~(DAC_C0_DACRFS_MASK | DAC_C0_LPEN_MASK);
|
||||
if (kDAC_ReferenceVoltageSourceVref2 == config->referenceVoltageSource)
|
||||
{
|
||||
tmp8 |= DAC_C0_DACRFS_MASK;
|
||||
}
|
||||
if (config->enableLowPowerMode)
|
||||
{
|
||||
tmp8 |= DAC_C0_LPEN_MASK;
|
||||
}
|
||||
base->C0 = tmp8;
|
||||
|
||||
/* DAC_Enable(base, true); */
|
||||
/* Tip: The DAC output can be enabled till then after user sets their own available data in application. */
|
||||
}
|
||||
|
||||
void DAC_Deinit(DAC_Type *base)
|
||||
{
|
||||
DAC_Enable(base, false);
|
||||
|
||||
#if !(defined(FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL) && FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL)
|
||||
/* Disable the clock. */
|
||||
CLOCK_DisableClock(s_dacClocks[DAC_GetInstance(base)]);
|
||||
#endif /* FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL */
|
||||
}
|
||||
|
||||
void DAC_GetDefaultConfig(dac_config_t *config)
|
||||
{
|
||||
assert(NULL != config);
|
||||
|
||||
config->referenceVoltageSource = kDAC_ReferenceVoltageSourceVref2;
|
||||
config->enableLowPowerMode = false;
|
||||
}
|
||||
|
||||
void DAC_SetBufferConfig(DAC_Type *base, const dac_buffer_config_t *config)
|
||||
{
|
||||
assert(NULL != config);
|
||||
|
||||
uint8_t tmp8;
|
||||
|
||||
/* DACx_C0. */
|
||||
tmp8 = base->C0 & ~(DAC_C0_DACTRGSEL_MASK);
|
||||
if (kDAC_BufferTriggerBySoftwareMode == config->triggerMode)
|
||||
{
|
||||
tmp8 |= DAC_C0_DACTRGSEL_MASK;
|
||||
}
|
||||
base->C0 = tmp8;
|
||||
|
||||
/* DACx_C1. */
|
||||
tmp8 = base->C1 &
|
||||
~(
|
||||
#if defined(FSL_FEATURE_DAC_HAS_WATERMARK_SELECTION) && FSL_FEATURE_DAC_HAS_WATERMARK_SELECTION
|
||||
DAC_C1_DACBFWM_MASK |
|
||||
#endif /* FSL_FEATURE_DAC_HAS_WATERMARK_SELECTION */
|
||||
DAC_C1_DACBFMD_MASK);
|
||||
#if defined(FSL_FEATURE_DAC_HAS_WATERMARK_SELECTION) && FSL_FEATURE_DAC_HAS_WATERMARK_SELECTION
|
||||
tmp8 |= DAC_C1_DACBFWM(config->watermark);
|
||||
#endif /* FSL_FEATURE_DAC_HAS_WATERMARK_SELECTION */
|
||||
tmp8 |= DAC_C1_DACBFMD(config->workMode);
|
||||
base->C1 = tmp8;
|
||||
|
||||
/* DACx_C2. */
|
||||
tmp8 = base->C2 & ~DAC_C2_DACBFUP_MASK;
|
||||
tmp8 |= DAC_C2_DACBFUP(config->upperLimit);
|
||||
base->C2 = tmp8;
|
||||
}
|
||||
|
||||
void DAC_GetDefaultBufferConfig(dac_buffer_config_t *config)
|
||||
{
|
||||
assert(NULL != config);
|
||||
|
||||
config->triggerMode = kDAC_BufferTriggerBySoftwareMode;
|
||||
#if defined(FSL_FEATURE_DAC_HAS_WATERMARK_SELECTION) && FSL_FEATURE_DAC_HAS_WATERMARK_SELECTION
|
||||
config->watermark = kDAC_BufferWatermark1Word;
|
||||
#endif /* FSL_FEATURE_DAC_HAS_WATERMARK_SELECTION */
|
||||
config->workMode = kDAC_BufferWorkAsNormalMode;
|
||||
config->upperLimit = DAC_DATL_COUNT - 1U;
|
||||
}
|
||||
|
||||
void DAC_SetBufferValue(DAC_Type *base, uint8_t index, uint16_t value)
|
||||
{
|
||||
assert(index < DAC_DATL_COUNT);
|
||||
|
||||
base->DAT[index].DATL = (uint8_t)(0xFFU & value); /* Low 8-bit. */
|
||||
base->DAT[index].DATH = (uint8_t)((0xF00U & value) >> 8); /* High 4-bit. */
|
||||
}
|
||||
|
||||
void DAC_SetBufferReadPointer(DAC_Type *base, uint8_t index)
|
||||
{
|
||||
assert(index < DAC_DATL_COUNT);
|
||||
|
||||
uint8_t tmp8 = base->C2 & ~DAC_C2_DACBFRP_MASK;
|
||||
|
||||
tmp8 |= DAC_C2_DACBFRP(index);
|
||||
base->C2 = tmp8;
|
||||
}
|
||||
|
||||
void DAC_EnableBufferInterrupts(DAC_Type *base, uint32_t mask)
|
||||
{
|
||||
mask &= (
|
||||
#if defined(FSL_FEATURE_DAC_HAS_WATERMARK_DETECTION) && FSL_FEATURE_DAC_HAS_WATERMARK_DETECTION
|
||||
DAC_C0_DACBWIEN_MASK |
|
||||
#endif /* FSL_FEATURE_DAC_HAS_WATERMARK_DETECTION */
|
||||
DAC_C0_DACBTIEN_MASK | DAC_C0_DACBBIEN_MASK);
|
||||
base->C0 |= ((uint8_t)mask); /* Write 1 to enable. */
|
||||
}
|
||||
|
||||
void DAC_DisableBufferInterrupts(DAC_Type *base, uint32_t mask)
|
||||
{
|
||||
mask &= (
|
||||
#if defined(FSL_FEATURE_DAC_HAS_WATERMARK_DETECTION) && FSL_FEATURE_DAC_HAS_WATERMARK_DETECTION
|
||||
DAC_C0_DACBWIEN_MASK |
|
||||
#endif /* FSL_FEATURE_DAC_HAS_WATERMARK_DETECTION */
|
||||
DAC_C0_DACBTIEN_MASK | DAC_C0_DACBBIEN_MASK);
|
||||
base->C0 &= (uint8_t)(~((uint8_t)mask)); /* Write 0 to disable. */
|
||||
}
|
||||
|
||||
uint32_t DAC_GetBufferStatusFlags(DAC_Type *base)
|
||||
{
|
||||
return (uint32_t)(base->SR & (
|
||||
#if defined(FSL_FEATURE_DAC_HAS_WATERMARK_DETECTION) && FSL_FEATURE_DAC_HAS_WATERMARK_DETECTION
|
||||
DAC_SR_DACBFWMF_MASK |
|
||||
#endif /* FSL_FEATURE_DAC_HAS_WATERMARK_DETECTION */
|
||||
DAC_SR_DACBFRPTF_MASK | DAC_SR_DACBFRPBF_MASK));
|
||||
}
|
||||
|
||||
void DAC_ClearBufferStatusFlags(DAC_Type *base, uint32_t mask)
|
||||
{
|
||||
mask &= (
|
||||
#if defined(FSL_FEATURE_DAC_HAS_WATERMARK_DETECTION) && FSL_FEATURE_DAC_HAS_WATERMARK_DETECTION
|
||||
DAC_SR_DACBFWMF_MASK |
|
||||
#endif /* FSL_FEATURE_DAC_HAS_WATERMARK_DETECTION */
|
||||
DAC_SR_DACBFRPTF_MASK | DAC_SR_DACBFRPBF_MASK);
|
||||
base->SR &= (uint8_t)(~((uint8_t)mask)); /* Write 0 to clear flags. */
|
||||
}
|
||||
-378
@@ -1,378 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Freescale Semiconductor, Inc.
|
||||
* Copyright 2016-2017 NXP
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* o Redistributions of source code must retain the above copyright notice, this list
|
||||
* of conditions and the following disclaimer.
|
||||
*
|
||||
* o 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.
|
||||
*
|
||||
* o Neither the name of the copyright holder 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 HOLDER 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 _FSL_DAC_H_
|
||||
#define _FSL_DAC_H_
|
||||
|
||||
#include "fsl_common.h"
|
||||
|
||||
/*!
|
||||
* @addtogroup dac
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
* Definitions
|
||||
******************************************************************************/
|
||||
|
||||
/*! @name Driver version */
|
||||
/*@{*/
|
||||
/*! @brief DAC driver version 2.0.1. */
|
||||
#define FSL_DAC_DRIVER_VERSION (MAKE_VERSION(2, 0, 1))
|
||||
/*@}*/
|
||||
|
||||
/*!
|
||||
* @brief DAC buffer flags.
|
||||
*/
|
||||
enum _dac_buffer_status_flags
|
||||
{
|
||||
#if defined(FSL_FEATURE_DAC_HAS_WATERMARK_DETECTION) && FSL_FEATURE_DAC_HAS_WATERMARK_DETECTION
|
||||
kDAC_BufferWatermarkFlag = DAC_SR_DACBFWMF_MASK, /*!< DAC Buffer Watermark Flag. */
|
||||
#endif /* FSL_FEATURE_DAC_HAS_WATERMARK_DETECTION */
|
||||
kDAC_BufferReadPointerTopPositionFlag = DAC_SR_DACBFRPTF_MASK, /*!< DAC Buffer Read Pointer Top Position Flag. */
|
||||
kDAC_BufferReadPointerBottomPositionFlag = DAC_SR_DACBFRPBF_MASK, /*!< DAC Buffer Read Pointer Bottom Position
|
||||
Flag. */
|
||||
};
|
||||
|
||||
/*!
|
||||
* @brief DAC buffer interrupts.
|
||||
*/
|
||||
enum _dac_buffer_interrupt_enable
|
||||
{
|
||||
#if defined(FSL_FEATURE_DAC_HAS_WATERMARK_DETECTION) && FSL_FEATURE_DAC_HAS_WATERMARK_DETECTION
|
||||
kDAC_BufferWatermarkInterruptEnable = DAC_C0_DACBWIEN_MASK, /*!< DAC Buffer Watermark Interrupt Enable. */
|
||||
#endif /* FSL_FEATURE_DAC_HAS_WATERMARK_DETECTION */
|
||||
kDAC_BufferReadPointerTopInterruptEnable = DAC_C0_DACBTIEN_MASK, /*!< DAC Buffer Read Pointer Top Flag Interrupt
|
||||
Enable. */
|
||||
kDAC_BufferReadPointerBottomInterruptEnable = DAC_C0_DACBBIEN_MASK, /*!< DAC Buffer Read Pointer Bottom Flag
|
||||
Interrupt Enable */
|
||||
};
|
||||
|
||||
/*!
|
||||
* @brief DAC reference voltage source.
|
||||
*/
|
||||
typedef enum _dac_reference_voltage_source
|
||||
{
|
||||
kDAC_ReferenceVoltageSourceVref1 = 0U, /*!< The DAC selects DACREF_1 as the reference voltage. */
|
||||
kDAC_ReferenceVoltageSourceVref2 = 1U, /*!< The DAC selects DACREF_2 as the reference voltage. */
|
||||
} dac_reference_voltage_source_t;
|
||||
|
||||
/*!
|
||||
* @brief DAC buffer trigger mode.
|
||||
*/
|
||||
typedef enum _dac_buffer_trigger_mode
|
||||
{
|
||||
kDAC_BufferTriggerByHardwareMode = 0U, /*!< The DAC hardware trigger is selected. */
|
||||
kDAC_BufferTriggerBySoftwareMode = 1U, /*!< The DAC software trigger is selected. */
|
||||
} dac_buffer_trigger_mode_t;
|
||||
|
||||
#if defined(FSL_FEATURE_DAC_HAS_WATERMARK_SELECTION) && FSL_FEATURE_DAC_HAS_WATERMARK_SELECTION
|
||||
/*!
|
||||
* @brief DAC buffer watermark.
|
||||
*/
|
||||
typedef enum _dac_buffer_watermark
|
||||
{
|
||||
#if defined(FSL_FEATURE_DAC_HAS_WATERMARK_1_WORD) && FSL_FEATURE_DAC_HAS_WATERMARK_1_WORD
|
||||
kDAC_BufferWatermark1Word = 0U, /*!< 1 word away from the upper limit. */
|
||||
#endif /* FSL_FEATURE_DAC_HAS_WATERMARK_1_WORD */
|
||||
#if defined(FSL_FEATURE_DAC_HAS_WATERMARK_2_WORDS) && FSL_FEATURE_DAC_HAS_WATERMARK_2_WORDS
|
||||
kDAC_BufferWatermark2Word = 1U, /*!< 2 words away from the upper limit. */
|
||||
#endif /* FSL_FEATURE_DAC_HAS_WATERMARK_2_WORDS */
|
||||
#if defined(FSL_FEATURE_DAC_HAS_WATERMARK_3_WORDS) && FSL_FEATURE_DAC_HAS_WATERMARK_3_WORDS
|
||||
kDAC_BufferWatermark3Word = 2U, /*!< 3 words away from the upper limit. */
|
||||
#endif /* FSL_FEATURE_DAC_HAS_WATERMARK_3_WORDS */
|
||||
#if defined(FSL_FEATURE_DAC_HAS_WATERMARK_4_WORDS) && FSL_FEATURE_DAC_HAS_WATERMARK_4_WORDS
|
||||
kDAC_BufferWatermark4Word = 3U, /*!< 4 words away from the upper limit. */
|
||||
#endif /* FSL_FEATURE_DAC_HAS_WATERMARK_4_WORDS */
|
||||
} dac_buffer_watermark_t;
|
||||
#endif /* FSL_FEATURE_DAC_HAS_WATERMARK_SELECTION */
|
||||
|
||||
/*!
|
||||
* @brief DAC buffer work mode.
|
||||
*/
|
||||
typedef enum _dac_buffer_work_mode
|
||||
{
|
||||
kDAC_BufferWorkAsNormalMode = 0U, /*!< Normal mode. */
|
||||
#if defined(FSL_FEATURE_DAC_HAS_BUFFER_SWING_MODE) && FSL_FEATURE_DAC_HAS_BUFFER_SWING_MODE
|
||||
kDAC_BufferWorkAsSwingMode, /*!< Swing mode. */
|
||||
#endif /* FSL_FEATURE_DAC_HAS_BUFFER_SWING_MODE */
|
||||
kDAC_BufferWorkAsOneTimeScanMode, /*!< One-Time Scan mode. */
|
||||
#if defined(FSL_FEATURE_DAC_HAS_BUFFER_FIFO_MODE) && FSL_FEATURE_DAC_HAS_BUFFER_FIFO_MODE
|
||||
kDAC_BufferWorkAsFIFOMode, /*!< FIFO mode. */
|
||||
#endif /* FSL_FEATURE_DAC_HAS_BUFFER_FIFO_MODE */
|
||||
} dac_buffer_work_mode_t;
|
||||
|
||||
/*!
|
||||
* @brief DAC module configuration.
|
||||
*/
|
||||
typedef struct _dac_config
|
||||
{
|
||||
dac_reference_voltage_source_t referenceVoltageSource; /*!< Select the DAC reference voltage source. */
|
||||
bool enableLowPowerMode; /*!< Enable the low-power mode. */
|
||||
} dac_config_t;
|
||||
|
||||
/*!
|
||||
* @brief DAC buffer configuration.
|
||||
*/
|
||||
typedef struct _dac_buffer_config
|
||||
{
|
||||
dac_buffer_trigger_mode_t triggerMode; /*!< Select the buffer's trigger mode. */
|
||||
#if defined(FSL_FEATURE_DAC_HAS_WATERMARK_SELECTION) && FSL_FEATURE_DAC_HAS_WATERMARK_SELECTION
|
||||
dac_buffer_watermark_t watermark; /*!< Select the buffer's watermark. */
|
||||
#endif /* FSL_FEATURE_DAC_HAS_WATERMARK_SELECTION */
|
||||
dac_buffer_work_mode_t workMode; /*!< Select the buffer's work mode. */
|
||||
uint8_t upperLimit; /*!< Set the upper limit for the buffer index.
|
||||
Normally, 0-15 is available for a buffer with 16 items. */
|
||||
} dac_buffer_config_t;
|
||||
|
||||
/*******************************************************************************
|
||||
* API
|
||||
******************************************************************************/
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*!
|
||||
* @name Initialization
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*!
|
||||
* @brief Initializes the DAC module.
|
||||
*
|
||||
* This function initializes the DAC module including the following operations.
|
||||
* - Enabling the clock for DAC module.
|
||||
* - Configuring the DAC converter with a user configuration.
|
||||
* - Enabling the DAC module.
|
||||
*
|
||||
* @param base DAC peripheral base address.
|
||||
* @param config Pointer to the configuration structure. See "dac_config_t".
|
||||
*/
|
||||
void DAC_Init(DAC_Type *base, const dac_config_t *config);
|
||||
|
||||
/*!
|
||||
* @brief De-initializes the DAC module.
|
||||
*
|
||||
* This function de-initializes the DAC module including the following operations.
|
||||
* - Disabling the DAC module.
|
||||
* - Disabling the clock for the DAC module.
|
||||
*
|
||||
* @param base DAC peripheral base address.
|
||||
*/
|
||||
void DAC_Deinit(DAC_Type *base);
|
||||
|
||||
/*!
|
||||
* @brief Initializes the DAC user configuration structure.
|
||||
*
|
||||
* This function initializes the user configuration structure to a default value. The default values are as follows.
|
||||
* @code
|
||||
* config->referenceVoltageSource = kDAC_ReferenceVoltageSourceVref2;
|
||||
* config->enableLowPowerMode = false;
|
||||
* @endcode
|
||||
* @param config Pointer to the configuration structure. See "dac_config_t".
|
||||
*/
|
||||
void DAC_GetDefaultConfig(dac_config_t *config);
|
||||
|
||||
/*!
|
||||
* @brief Enables the DAC module.
|
||||
*
|
||||
* @param base DAC peripheral base address.
|
||||
* @param enable Enables or disables the feature.
|
||||
*/
|
||||
static inline void DAC_Enable(DAC_Type *base, bool enable)
|
||||
{
|
||||
if (enable)
|
||||
{
|
||||
base->C0 |= DAC_C0_DACEN_MASK;
|
||||
}
|
||||
else
|
||||
{
|
||||
base->C0 &= ~DAC_C0_DACEN_MASK;
|
||||
}
|
||||
}
|
||||
|
||||
/* @} */
|
||||
|
||||
/*!
|
||||
* @name Buffer
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*!
|
||||
* @brief Enables the DAC buffer.
|
||||
*
|
||||
* @param base DAC peripheral base address.
|
||||
* @param enable Enables or disables the feature.
|
||||
*/
|
||||
static inline void DAC_EnableBuffer(DAC_Type *base, bool enable)
|
||||
{
|
||||
if (enable)
|
||||
{
|
||||
base->C1 |= DAC_C1_DACBFEN_MASK;
|
||||
}
|
||||
else
|
||||
{
|
||||
base->C1 &= ~DAC_C1_DACBFEN_MASK;
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Configures the CMP buffer.
|
||||
*
|
||||
* @param base DAC peripheral base address.
|
||||
* @param config Pointer to the configuration structure. See "dac_buffer_config_t".
|
||||
*/
|
||||
void DAC_SetBufferConfig(DAC_Type *base, const dac_buffer_config_t *config);
|
||||
|
||||
/*!
|
||||
* @brief Initializes the DAC buffer configuration structure.
|
||||
*
|
||||
* This function initializes the DAC buffer configuration structure to default values. The default values are as follows.
|
||||
* @code
|
||||
* config->triggerMode = kDAC_BufferTriggerBySoftwareMode;
|
||||
* config->watermark = kDAC_BufferWatermark1Word;
|
||||
* config->workMode = kDAC_BufferWorkAsNormalMode;
|
||||
* config->upperLimit = DAC_DATL_COUNT - 1U;
|
||||
* @endcode
|
||||
* @param config Pointer to the configuration structure. See "dac_buffer_config_t".
|
||||
*/
|
||||
void DAC_GetDefaultBufferConfig(dac_buffer_config_t *config);
|
||||
|
||||
/*!
|
||||
* @brief Enables the DMA for DAC buffer.
|
||||
*
|
||||
* @param base DAC peripheral base address.
|
||||
* @param enable Enables or disables the feature.
|
||||
*/
|
||||
static inline void DAC_EnableBufferDMA(DAC_Type *base, bool enable)
|
||||
{
|
||||
if (enable)
|
||||
{
|
||||
base->C1 |= DAC_C1_DMAEN_MASK;
|
||||
}
|
||||
else
|
||||
{
|
||||
base->C1 &= ~DAC_C1_DMAEN_MASK;
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Sets the value for items in the buffer.
|
||||
*
|
||||
* @param base DAC peripheral base address.
|
||||
* @param index Setting the index for items in the buffer. The available index should not exceed the size of the DAC buffer.
|
||||
* @param value Setting the value for items in the buffer. 12-bits are available.
|
||||
*/
|
||||
void DAC_SetBufferValue(DAC_Type *base, uint8_t index, uint16_t value);
|
||||
|
||||
/*!
|
||||
* @brief Triggers the buffer using software and updates the read pointer of the DAC buffer.
|
||||
*
|
||||
* This function triggers the function using software. The read pointer of the DAC buffer is updated with one step
|
||||
* after this function is called. Changing the read pointer depends on the buffer's work mode.
|
||||
*
|
||||
* @param base DAC peripheral base address.
|
||||
*/
|
||||
static inline void DAC_DoSoftwareTriggerBuffer(DAC_Type *base)
|
||||
{
|
||||
base->C0 |= DAC_C0_DACSWTRG_MASK;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Gets the current read pointer of the DAC buffer.
|
||||
*
|
||||
* This function gets the current read pointer of the DAC buffer.
|
||||
* The current output value depends on the item indexed by the read pointer. It is updated either
|
||||
* by a software trigger or a hardware trigger.
|
||||
*
|
||||
* @param base DAC peripheral base address.
|
||||
*
|
||||
* @return The current read pointer of the DAC buffer.
|
||||
*/
|
||||
static inline uint8_t DAC_GetBufferReadPointer(DAC_Type *base)
|
||||
{
|
||||
return ((base->C2 & DAC_C2_DACBFRP_MASK) >> DAC_C2_DACBFRP_SHIFT);
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Sets the current read pointer of the DAC buffer.
|
||||
*
|
||||
* This function sets the current read pointer of the DAC buffer.
|
||||
* The current output value depends on the item indexed by the read pointer. It is updated either by a
|
||||
* software trigger or a hardware trigger. After the read pointer changes, the DAC output value also changes.
|
||||
*
|
||||
* @param base DAC peripheral base address.
|
||||
* @param index Setting an index value for the pointer.
|
||||
*/
|
||||
void DAC_SetBufferReadPointer(DAC_Type *base, uint8_t index);
|
||||
|
||||
/*!
|
||||
* @brief Enables interrupts for the DAC buffer.
|
||||
*
|
||||
* @param base DAC peripheral base address.
|
||||
* @param mask Mask value for interrupts. See "_dac_buffer_interrupt_enable".
|
||||
*/
|
||||
void DAC_EnableBufferInterrupts(DAC_Type *base, uint32_t mask);
|
||||
|
||||
/*!
|
||||
* @brief Disables interrupts for the DAC buffer.
|
||||
*
|
||||
* @param base DAC peripheral base address.
|
||||
* @param mask Mask value for interrupts. See "_dac_buffer_interrupt_enable".
|
||||
*/
|
||||
void DAC_DisableBufferInterrupts(DAC_Type *base, uint32_t mask);
|
||||
|
||||
/*!
|
||||
* @brief Gets the flags of events for the DAC buffer.
|
||||
*
|
||||
* @param base DAC peripheral base address.
|
||||
*
|
||||
* @return Mask value for the asserted flags. See "_dac_buffer_status_flags".
|
||||
*/
|
||||
uint32_t DAC_GetBufferStatusFlags(DAC_Type *base);
|
||||
|
||||
/*!
|
||||
* @brief Clears the flags of events for the DAC buffer.
|
||||
*
|
||||
* @param base DAC peripheral base address.
|
||||
* @param mask Mask value for flags. See "_dac_buffer_status_flags_t".
|
||||
*/
|
||||
void DAC_ClearBufferStatusFlags(DAC_Type *base, uint32_t mask);
|
||||
|
||||
/* @} */
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
/*!
|
||||
* @}
|
||||
*/
|
||||
#endif /* _FSL_DAC_H_ */
|
||||
-93
@@ -1,93 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Freescale Semiconductor, Inc.
|
||||
* Copyright 2016-2017 NXP
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* o Redistributions of source code must retain the above copyright notice, this list
|
||||
* of conditions and the following disclaimer.
|
||||
*
|
||||
* o 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.
|
||||
*
|
||||
* o Neither the name of the copyright holder 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 HOLDER 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 "fsl_dmamux.h"
|
||||
|
||||
/*******************************************************************************
|
||||
* Definitions
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* Prototypes
|
||||
******************************************************************************/
|
||||
|
||||
/*!
|
||||
* @brief Get instance number for DMAMUX.
|
||||
*
|
||||
* @param base DMAMUX peripheral base address.
|
||||
*/
|
||||
static uint32_t DMAMUX_GetInstance(DMAMUX_Type *base);
|
||||
|
||||
/*******************************************************************************
|
||||
* Variables
|
||||
******************************************************************************/
|
||||
|
||||
/*! @brief Array to map DMAMUX instance number to base pointer. */
|
||||
static DMAMUX_Type *const s_dmamuxBases[] = DMAMUX_BASE_PTRS;
|
||||
|
||||
#if !(defined(FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL) && FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL)
|
||||
/*! @brief Array to map DMAMUX instance number to clock name. */
|
||||
static const clock_ip_name_t s_dmamuxClockName[] = DMAMUX_CLOCKS;
|
||||
#endif /* FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL */
|
||||
|
||||
/*******************************************************************************
|
||||
* Code
|
||||
******************************************************************************/
|
||||
static uint32_t DMAMUX_GetInstance(DMAMUX_Type *base)
|
||||
{
|
||||
uint32_t instance;
|
||||
|
||||
/* Find the instance index from base address mappings. */
|
||||
for (instance = 0; instance < ARRAY_SIZE(s_dmamuxBases); instance++)
|
||||
{
|
||||
if (s_dmamuxBases[instance] == base)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
assert(instance < ARRAY_SIZE(s_dmamuxBases));
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
void DMAMUX_Init(DMAMUX_Type *base)
|
||||
{
|
||||
#if !(defined(FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL) && FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL)
|
||||
CLOCK_EnableClock(s_dmamuxClockName[DMAMUX_GetInstance(base)]);
|
||||
#endif /* FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL */
|
||||
}
|
||||
|
||||
void DMAMUX_Deinit(DMAMUX_Type *base)
|
||||
{
|
||||
#if !(defined(FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL) && FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL)
|
||||
CLOCK_DisableClock(s_dmamuxClockName[DMAMUX_GetInstance(base)]);
|
||||
#endif /* FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL */
|
||||
}
|
||||
-200
@@ -1,200 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Freescale Semiconductor, Inc.
|
||||
* Copyright 2016-2017 NXP
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* o Redistributions of source code must retain the above copyright notice, this list
|
||||
* of conditions and the following disclaimer.
|
||||
*
|
||||
* o 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.
|
||||
*
|
||||
* o Neither the name of the copyright holder 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 HOLDER 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 _FSL_DMAMUX_H_
|
||||
#define _FSL_DMAMUX_H_
|
||||
|
||||
#include "fsl_common.h"
|
||||
|
||||
/*!
|
||||
* @addtogroup dmamux
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
* Definitions
|
||||
******************************************************************************/
|
||||
|
||||
/*! @name Driver version */
|
||||
/*@{*/
|
||||
/*! @brief DMAMUX driver version 2.0.2. */
|
||||
#define FSL_DMAMUX_DRIVER_VERSION (MAKE_VERSION(2, 0, 2))
|
||||
/*@}*/
|
||||
|
||||
/*******************************************************************************
|
||||
* API
|
||||
******************************************************************************/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/*!
|
||||
* @name DMAMUX Initialization and de-initialization
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*!
|
||||
* @brief Initializes the DMAMUX peripheral.
|
||||
*
|
||||
* This function ungates the DMAMUX clock.
|
||||
*
|
||||
* @param base DMAMUX peripheral base address.
|
||||
*
|
||||
*/
|
||||
void DMAMUX_Init(DMAMUX_Type *base);
|
||||
|
||||
/*!
|
||||
* @brief Deinitializes the DMAMUX peripheral.
|
||||
*
|
||||
* This function gates the DMAMUX clock.
|
||||
*
|
||||
* @param base DMAMUX peripheral base address.
|
||||
*/
|
||||
void DMAMUX_Deinit(DMAMUX_Type *base);
|
||||
|
||||
/* @} */
|
||||
/*!
|
||||
* @name DMAMUX Channel Operation
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*!
|
||||
* @brief Enables the DMAMUX channel.
|
||||
*
|
||||
* This function enables the DMAMUX channel.
|
||||
*
|
||||
* @param base DMAMUX peripheral base address.
|
||||
* @param channel DMAMUX channel number.
|
||||
*/
|
||||
static inline void DMAMUX_EnableChannel(DMAMUX_Type *base, uint32_t channel)
|
||||
{
|
||||
assert(channel < FSL_FEATURE_DMAMUX_MODULE_CHANNEL);
|
||||
|
||||
base->CHCFG[channel] |= DMAMUX_CHCFG_ENBL_MASK;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Disables the DMAMUX channel.
|
||||
*
|
||||
* This function disables the DMAMUX channel.
|
||||
*
|
||||
* @note The user must disable the DMAMUX channel before configuring it.
|
||||
* @param base DMAMUX peripheral base address.
|
||||
* @param channel DMAMUX channel number.
|
||||
*/
|
||||
static inline void DMAMUX_DisableChannel(DMAMUX_Type *base, uint32_t channel)
|
||||
{
|
||||
assert(channel < FSL_FEATURE_DMAMUX_MODULE_CHANNEL);
|
||||
|
||||
base->CHCFG[channel] &= ~DMAMUX_CHCFG_ENBL_MASK;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Configures the DMAMUX channel source.
|
||||
*
|
||||
* @param base DMAMUX peripheral base address.
|
||||
* @param channel DMAMUX channel number.
|
||||
* @param source Channel source, which is used to trigger the DMA transfer.
|
||||
*/
|
||||
static inline void DMAMUX_SetSource(DMAMUX_Type *base, uint32_t channel, uint32_t source)
|
||||
{
|
||||
assert(channel < FSL_FEATURE_DMAMUX_MODULE_CHANNEL);
|
||||
|
||||
base->CHCFG[channel] = ((base->CHCFG[channel] & ~DMAMUX_CHCFG_SOURCE_MASK) | DMAMUX_CHCFG_SOURCE(source));
|
||||
}
|
||||
|
||||
#if defined(FSL_FEATURE_DMAMUX_HAS_TRIG) && FSL_FEATURE_DMAMUX_HAS_TRIG > 0U
|
||||
/*!
|
||||
* @brief Enables the DMAMUX period trigger.
|
||||
*
|
||||
* This function enables the DMAMUX period trigger feature.
|
||||
*
|
||||
* @param base DMAMUX peripheral base address.
|
||||
* @param channel DMAMUX channel number.
|
||||
*/
|
||||
static inline void DMAMUX_EnablePeriodTrigger(DMAMUX_Type *base, uint32_t channel)
|
||||
{
|
||||
assert(channel < FSL_FEATURE_DMAMUX_MODULE_CHANNEL);
|
||||
|
||||
base->CHCFG[channel] |= DMAMUX_CHCFG_TRIG_MASK;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Disables the DMAMUX period trigger.
|
||||
*
|
||||
* This function disables the DMAMUX period trigger.
|
||||
*
|
||||
* @param base DMAMUX peripheral base address.
|
||||
* @param channel DMAMUX channel number.
|
||||
*/
|
||||
static inline void DMAMUX_DisablePeriodTrigger(DMAMUX_Type *base, uint32_t channel)
|
||||
{
|
||||
assert(channel < FSL_FEATURE_DMAMUX_MODULE_CHANNEL);
|
||||
|
||||
base->CHCFG[channel] &= ~DMAMUX_CHCFG_TRIG_MASK;
|
||||
}
|
||||
#endif /* FSL_FEATURE_DMAMUX_HAS_TRIG */
|
||||
|
||||
#if (defined(FSL_FEATURE_DMAMUX_HAS_A_ON) && FSL_FEATURE_DMAMUX_HAS_A_ON)
|
||||
/*!
|
||||
* @brief Enables the DMA channel to be always ON.
|
||||
*
|
||||
* This function enables the DMAMUX channel always ON feature.
|
||||
*
|
||||
* @param base DMAMUX peripheral base address.
|
||||
* @param channel DMAMUX channel number.
|
||||
* @param enable Switcher of the always ON feature. "true" means enabled, "false" means disabled.
|
||||
*/
|
||||
static inline void DMAMUX_EnableAlwaysOn(DMAMUX_Type *base, uint32_t channel, bool enable)
|
||||
{
|
||||
assert(channel < FSL_FEATURE_DMAMUX_MODULE_CHANNEL);
|
||||
|
||||
if (enable)
|
||||
{
|
||||
base->CHCFG[channel] |= DMAMUX_CHCFG_A_ON_MASK;
|
||||
}
|
||||
else
|
||||
{
|
||||
base->CHCFG[channel] &= ~DMAMUX_CHCFG_A_ON_MASK;
|
||||
}
|
||||
}
|
||||
#endif /* FSL_FEATURE_DMAMUX_HAS_A_ON */
|
||||
|
||||
/* @} */
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/* @} */
|
||||
|
||||
#endif /* _FSL_DMAMUX_H_ */
|
||||
-1669
File diff suppressed because it is too large
Load Diff
-1180
File diff suppressed because it is too large
Load Diff
-1248
File diff suppressed because it is too large
Load Diff
-281
@@ -1,281 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Freescale Semiconductor, Inc.
|
||||
* Copyright 2016-2017 NXP
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* o Redistributions of source code must retain the above copyright notice, this list
|
||||
* of conditions and the following disclaimer.
|
||||
*
|
||||
* o 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.
|
||||
*
|
||||
* o Neither the name of the copyright holder 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 HOLDER 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 _FSL_DSPI_EDMA_H_
|
||||
#define _FSL_DSPI_EDMA_H_
|
||||
|
||||
#include "fsl_dspi.h"
|
||||
#include "fsl_edma.h"
|
||||
/*!
|
||||
* @addtogroup dspi_edma_driver
|
||||
* @{
|
||||
*/
|
||||
|
||||
/***********************************************************************************************************************
|
||||
* Definitions
|
||||
**********************************************************************************************************************/
|
||||
|
||||
/*!
|
||||
* @brief Forward declaration of the DSPI eDMA master handle typedefs.
|
||||
*/
|
||||
typedef struct _dspi_master_edma_handle dspi_master_edma_handle_t;
|
||||
|
||||
/*!
|
||||
* @brief Forward declaration of the DSPI eDMA slave handle typedefs.
|
||||
*/
|
||||
typedef struct _dspi_slave_edma_handle dspi_slave_edma_handle_t;
|
||||
|
||||
/*!
|
||||
* @brief Completion callback function pointer type.
|
||||
*
|
||||
* @param base DSPI peripheral base address.
|
||||
* @param handle A pointer to the handle for the DSPI master.
|
||||
* @param status Success or error code describing whether the transfer completed.
|
||||
* @param userData An arbitrary pointer-dataSized value passed from the application.
|
||||
*/
|
||||
typedef void (*dspi_master_edma_transfer_callback_t)(SPI_Type *base,
|
||||
dspi_master_edma_handle_t *handle,
|
||||
status_t status,
|
||||
void *userData);
|
||||
/*!
|
||||
* @brief Completion callback function pointer type.
|
||||
*
|
||||
* @param base DSPI peripheral base address.
|
||||
* @param handle A pointer to the handle for the DSPI slave.
|
||||
* @param status Success or error code describing whether the transfer completed.
|
||||
* @param userData An arbitrary pointer-dataSized value passed from the application.
|
||||
*/
|
||||
typedef void (*dspi_slave_edma_transfer_callback_t)(SPI_Type *base,
|
||||
dspi_slave_edma_handle_t *handle,
|
||||
status_t status,
|
||||
void *userData);
|
||||
|
||||
/*! @brief DSPI master eDMA transfer handle structure used for the transactional API. */
|
||||
struct _dspi_master_edma_handle
|
||||
{
|
||||
uint32_t bitsPerFrame; /*!< The desired number of bits per frame. */
|
||||
volatile uint32_t command; /*!< The desired data command. */
|
||||
volatile uint32_t lastCommand; /*!< The desired last data command. */
|
||||
|
||||
uint8_t fifoSize; /*!< FIFO dataSize. */
|
||||
|
||||
volatile bool
|
||||
isPcsActiveAfterTransfer; /*!< Indicates whether the PCS signal keeps active after the last frame transfer.*/
|
||||
|
||||
uint8_t nbytes; /*!< eDMA minor byte transfer count initially configured. */
|
||||
volatile uint8_t state; /*!< DSPI transfer state , _dspi_transfer_state.*/
|
||||
|
||||
uint8_t *volatile txData; /*!< Send buffer. */
|
||||
uint8_t *volatile rxData; /*!< Receive buffer. */
|
||||
volatile size_t remainingSendByteCount; /*!< A number of bytes remaining to send.*/
|
||||
volatile size_t remainingReceiveByteCount; /*!< A number of bytes remaining to receive.*/
|
||||
size_t totalByteCount; /*!< A number of transfer bytes*/
|
||||
|
||||
uint32_t rxBuffIfNull; /*!< Used if there is not rxData for DMA purpose.*/
|
||||
uint32_t txBuffIfNull; /*!< Used if there is not txData for DMA purpose.*/
|
||||
|
||||
dspi_master_edma_transfer_callback_t callback; /*!< Completion callback. */
|
||||
void *userData; /*!< Callback user data. */
|
||||
|
||||
edma_handle_t *edmaRxRegToRxDataHandle; /*!<edma_handle_t handle point used for RxReg to RxData buff*/
|
||||
edma_handle_t *edmaTxDataToIntermediaryHandle; /*!<edma_handle_t handle point used for TxData to Intermediary*/
|
||||
edma_handle_t *edmaIntermediaryToTxRegHandle; /*!<edma_handle_t handle point used for Intermediary to TxReg*/
|
||||
|
||||
edma_tcd_t dspiSoftwareTCD[2]; /*!<SoftwareTCD , internal used*/
|
||||
};
|
||||
|
||||
/*! @brief DSPI slave eDMA transfer handle structure used for the transactional API.*/
|
||||
struct _dspi_slave_edma_handle
|
||||
{
|
||||
uint32_t bitsPerFrame; /*!< The desired number of bits per frame. */
|
||||
|
||||
uint8_t *volatile txData; /*!< Send buffer. */
|
||||
uint8_t *volatile rxData; /*!< Receive buffer. */
|
||||
volatile size_t remainingSendByteCount; /*!< A number of bytes remaining to send.*/
|
||||
volatile size_t remainingReceiveByteCount; /*!< A number of bytes remaining to receive.*/
|
||||
size_t totalByteCount; /*!< A number of transfer bytes*/
|
||||
|
||||
uint32_t rxBuffIfNull; /*!< Used if there is not rxData for DMA purpose.*/
|
||||
uint32_t txBuffIfNull; /*!< Used if there is not txData for DMA purpose.*/
|
||||
uint32_t txLastData; /*!< Used if there is an extra byte when 16bits per frame for DMA purpose.*/
|
||||
|
||||
uint8_t nbytes; /*!< eDMA minor byte transfer count initially configured. */
|
||||
|
||||
volatile uint8_t state; /*!< DSPI transfer state.*/
|
||||
|
||||
dspi_slave_edma_transfer_callback_t callback; /*!< Completion callback. */
|
||||
void *userData; /*!< Callback user data. */
|
||||
|
||||
edma_handle_t *edmaRxRegToRxDataHandle; /*!<edma_handle_t handle point used for RxReg to RxData buff*/
|
||||
edma_handle_t *edmaTxDataToTxRegHandle; /*!<edma_handle_t handle point used for TxData to TxReg*/
|
||||
};
|
||||
|
||||
/***********************************************************************************************************************
|
||||
* API
|
||||
**********************************************************************************************************************/
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif /*_cplusplus*/
|
||||
|
||||
/*Transactional APIs*/
|
||||
|
||||
/*!
|
||||
* @brief Initializes the DSPI master eDMA handle.
|
||||
*
|
||||
* This function initializes the DSPI eDMA handle which can be used for other DSPI transactional APIs. Usually, for a
|
||||
* specified DSPI instance, call this API once to get the initialized handle.
|
||||
*
|
||||
* Note that DSPI eDMA has separated (RX and TX as two sources) or shared (RX and TX are the same source) DMA request
|
||||
* source.
|
||||
* (1) For the separated DMA request source, enable and set the RX DMAMUX source for edmaRxRegToRxDataHandle and
|
||||
* TX DMAMUX source for edmaIntermediaryToTxRegHandle.
|
||||
* (2) For the shared DMA request source, enable and set the RX/RX DMAMUX source for the edmaRxRegToRxDataHandle.
|
||||
*
|
||||
* @param base DSPI peripheral base address.
|
||||
* @param handle DSPI handle pointer to dspi_master_edma_handle_t.
|
||||
* @param callback DSPI callback.
|
||||
* @param userData A callback function parameter.
|
||||
* @param edmaRxRegToRxDataHandle edmaRxRegToRxDataHandle pointer to edma_handle_t.
|
||||
* @param edmaTxDataToIntermediaryHandle edmaTxDataToIntermediaryHandle pointer to edma_handle_t.
|
||||
* @param edmaIntermediaryToTxRegHandle edmaIntermediaryToTxRegHandle pointer to edma_handle_t.
|
||||
*/
|
||||
void DSPI_MasterTransferCreateHandleEDMA(SPI_Type *base,
|
||||
dspi_master_edma_handle_t *handle,
|
||||
dspi_master_edma_transfer_callback_t callback,
|
||||
void *userData,
|
||||
edma_handle_t *edmaRxRegToRxDataHandle,
|
||||
edma_handle_t *edmaTxDataToIntermediaryHandle,
|
||||
edma_handle_t *edmaIntermediaryToTxRegHandle);
|
||||
|
||||
/*!
|
||||
* @brief DSPI master transfer data using eDMA.
|
||||
*
|
||||
* This function transfers data using eDMA. This is a non-blocking function, which returns right away. When all data
|
||||
* is transferred, the callback function is called.
|
||||
*
|
||||
* @param base DSPI peripheral base address.
|
||||
* @param handle A pointer to the dspi_master_edma_handle_t structure which stores the transfer state.
|
||||
* @param transfer A pointer to the dspi_transfer_t structure.
|
||||
* @return status of status_t.
|
||||
*/
|
||||
status_t DSPI_MasterTransferEDMA(SPI_Type *base, dspi_master_edma_handle_t *handle, dspi_transfer_t *transfer);
|
||||
|
||||
/*!
|
||||
* @brief DSPI master aborts a transfer which is using eDMA.
|
||||
*
|
||||
* This function aborts a transfer which is using eDMA.
|
||||
*
|
||||
* @param base DSPI peripheral base address.
|
||||
* @param handle A pointer to the dspi_master_edma_handle_t structure which stores the transfer state.
|
||||
*/
|
||||
void DSPI_MasterTransferAbortEDMA(SPI_Type *base, dspi_master_edma_handle_t *handle);
|
||||
|
||||
/*!
|
||||
* @brief Gets the master eDMA transfer count.
|
||||
*
|
||||
* This function gets the master eDMA transfer count.
|
||||
*
|
||||
* @param base DSPI peripheral base address.
|
||||
* @param handle A pointer to the dspi_master_edma_handle_t structure which stores the transfer state.
|
||||
* @param count A number of bytes transferred by the non-blocking transaction.
|
||||
* @return status of status_t.
|
||||
*/
|
||||
status_t DSPI_MasterTransferGetCountEDMA(SPI_Type *base, dspi_master_edma_handle_t *handle, size_t *count);
|
||||
|
||||
/*!
|
||||
* @brief Initializes the DSPI slave eDMA handle.
|
||||
*
|
||||
* This function initializes the DSPI eDMA handle which can be used for other DSPI transactional APIs. Usually, for a
|
||||
* specified DSPI instance, call this API once to get the initialized handle.
|
||||
*
|
||||
* Note that DSPI eDMA has separated (RN and TX in 2 sources) or shared (RX and TX are the same source) DMA request
|
||||
* source.
|
||||
* (1)For the separated DMA request source, enable and set the RX DMAMUX source for edmaRxRegToRxDataHandle and
|
||||
* TX DMAMUX source for edmaTxDataToTxRegHandle.
|
||||
* (2)For the shared DMA request source, enable and set the RX/RX DMAMUX source for the edmaRxRegToRxDataHandle.
|
||||
*
|
||||
* @param base DSPI peripheral base address.
|
||||
* @param handle DSPI handle pointer to dspi_slave_edma_handle_t.
|
||||
* @param callback DSPI callback.
|
||||
* @param userData A callback function parameter.
|
||||
* @param edmaRxRegToRxDataHandle edmaRxRegToRxDataHandle pointer to edma_handle_t.
|
||||
* @param edmaTxDataToTxRegHandle edmaTxDataToTxRegHandle pointer to edma_handle_t.
|
||||
*/
|
||||
void DSPI_SlaveTransferCreateHandleEDMA(SPI_Type *base,
|
||||
dspi_slave_edma_handle_t *handle,
|
||||
dspi_slave_edma_transfer_callback_t callback,
|
||||
void *userData,
|
||||
edma_handle_t *edmaRxRegToRxDataHandle,
|
||||
edma_handle_t *edmaTxDataToTxRegHandle);
|
||||
|
||||
/*!
|
||||
* @brief DSPI slave transfer data using eDMA.
|
||||
*
|
||||
* This function transfers data using eDMA. This is a non-blocking function, which returns right away. When all data
|
||||
* is transferred, the callback function is called.
|
||||
* Note that the slave eDMA transfer doesn't support transfer_size is 1 when the bitsPerFrame is greater
|
||||
* than eight.
|
||||
|
||||
* @param base DSPI peripheral base address.
|
||||
* @param handle A pointer to the dspi_slave_edma_handle_t structure which stores the transfer state.
|
||||
* @param transfer A pointer to the dspi_transfer_t structure.
|
||||
* @return status of status_t.
|
||||
*/
|
||||
status_t DSPI_SlaveTransferEDMA(SPI_Type *base, dspi_slave_edma_handle_t *handle, dspi_transfer_t *transfer);
|
||||
|
||||
/*!
|
||||
* @brief DSPI slave aborts a transfer which is using eDMA.
|
||||
*
|
||||
* This function aborts a transfer which is using eDMA.
|
||||
*
|
||||
* @param base DSPI peripheral base address.
|
||||
* @param handle A pointer to the dspi_slave_edma_handle_t structure which stores the transfer state.
|
||||
*/
|
||||
void DSPI_SlaveTransferAbortEDMA(SPI_Type *base, dspi_slave_edma_handle_t *handle);
|
||||
|
||||
/*!
|
||||
* @brief Gets the slave eDMA transfer count.
|
||||
*
|
||||
* This function gets the slave eDMA transfer count.
|
||||
*
|
||||
* @param base DSPI peripheral base address.
|
||||
* @param handle A pointer to the dspi_slave_edma_handle_t structure which stores the transfer state.
|
||||
* @param count A number of bytes transferred so far by the non-blocking transaction.
|
||||
* @return status of status_t.
|
||||
*/
|
||||
status_t DSPI_SlaveTransferGetCountEDMA(SPI_Type *base, dspi_slave_edma_handle_t *handle, size_t *count);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif /*_cplusplus*/
|
||||
/*!
|
||||
*@}
|
||||
*/
|
||||
|
||||
#endif /*_FSL_DSPI_EDMA_H_*/
|
||||
-121
@@ -1,121 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Freescale Semiconductor, Inc.
|
||||
* Copyright 2016-2017 NXP
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* o Redistributions of source code must retain the above copyright notice, this list
|
||||
* of conditions and the following disclaimer.
|
||||
*
|
||||
* o 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.
|
||||
*
|
||||
* o Neither the name of the copyright holder 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 HOLDER 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 "fsl_dspi_freertos.h"
|
||||
|
||||
static void DSPI_RTOS_Callback(SPI_Type *base, dspi_master_handle_t *drv_handle, status_t status, void *userData)
|
||||
{
|
||||
dspi_rtos_handle_t *handle = (dspi_rtos_handle_t *)userData;
|
||||
BaseType_t reschedule;
|
||||
|
||||
xSemaphoreGiveFromISR(handle->event, &reschedule);
|
||||
portYIELD_FROM_ISR(reschedule);
|
||||
}
|
||||
|
||||
status_t DSPI_RTOS_Init(dspi_rtos_handle_t *handle,
|
||||
SPI_Type *base,
|
||||
const dspi_master_config_t *masterConfig,
|
||||
uint32_t srcClock_Hz)
|
||||
{
|
||||
if (handle == NULL)
|
||||
{
|
||||
return kStatus_InvalidArgument;
|
||||
}
|
||||
|
||||
if (base == NULL)
|
||||
{
|
||||
return kStatus_InvalidArgument;
|
||||
}
|
||||
|
||||
memset(handle, 0, sizeof(dspi_rtos_handle_t));
|
||||
|
||||
#if (configSUPPORT_STATIC_ALLOCATION == 1)
|
||||
handle->mutex = xSemaphoreCreateMutexStatic(&handle->mutexBuffer);
|
||||
#else
|
||||
handle->mutex = xSemaphoreCreateMutex();
|
||||
#endif
|
||||
if (handle->mutex == NULL)
|
||||
{
|
||||
return kStatus_Fail;
|
||||
}
|
||||
#if (configSUPPORT_STATIC_ALLOCATION == 1)
|
||||
handle->event = xSemaphoreCreateBinaryStatic(&handle->semaphoreBuffer);
|
||||
#else
|
||||
handle->event = xSemaphoreCreateBinary();
|
||||
#endif
|
||||
if (handle->event == NULL)
|
||||
{
|
||||
vSemaphoreDelete(handle->mutex);
|
||||
return kStatus_Fail;
|
||||
}
|
||||
|
||||
handle->base = base;
|
||||
|
||||
DSPI_MasterInit(handle->base, masterConfig, srcClock_Hz);
|
||||
DSPI_MasterTransferCreateHandle(handle->base, &handle->drv_handle, DSPI_RTOS_Callback, (void *)handle);
|
||||
|
||||
return kStatus_Success;
|
||||
}
|
||||
|
||||
status_t DSPI_RTOS_Deinit(dspi_rtos_handle_t *handle)
|
||||
{
|
||||
DSPI_Deinit(handle->base);
|
||||
vSemaphoreDelete(handle->event);
|
||||
vSemaphoreDelete(handle->mutex);
|
||||
|
||||
return kStatus_Success;
|
||||
}
|
||||
|
||||
status_t DSPI_RTOS_Transfer(dspi_rtos_handle_t *handle, dspi_transfer_t *transfer)
|
||||
{
|
||||
status_t status;
|
||||
|
||||
/* Lock resource mutex */
|
||||
if (xSemaphoreTake(handle->mutex, portMAX_DELAY) != pdTRUE)
|
||||
{
|
||||
return kStatus_DSPI_Busy;
|
||||
}
|
||||
|
||||
status = DSPI_MasterTransferNonBlocking(handle->base, &handle->drv_handle, transfer);
|
||||
if (status != kStatus_Success)
|
||||
{
|
||||
xSemaphoreGive(handle->mutex);
|
||||
return status;
|
||||
}
|
||||
|
||||
/* Wait for transfer to finish */
|
||||
xSemaphoreTake(handle->event, portMAX_DELAY);
|
||||
|
||||
/* Unlock resource mutex */
|
||||
xSemaphoreGive(handle->mutex);
|
||||
|
||||
/* Return status captured by callback function */
|
||||
return handle->async_status;
|
||||
}
|
||||
-128
@@ -1,128 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Freescale Semiconductor, Inc.
|
||||
* Copyright 2016-2017 NXP
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* o Redistributions of source code must retain the above copyright notice, this list
|
||||
* of conditions and the following disclaimer.
|
||||
*
|
||||
* o 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.
|
||||
*
|
||||
* o Neither the name of the copyright holder 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 HOLDER 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 __FSL_DSPI_FREERTOS_H__
|
||||
#define __FSL_DSPI_FREERTOS_H__
|
||||
|
||||
#include "FreeRTOSConfig.h"
|
||||
#include "FreeRTOS.h"
|
||||
#include "portable.h"
|
||||
#include "semphr.h"
|
||||
|
||||
#include "fsl_dspi.h"
|
||||
|
||||
/*!
|
||||
* @addtogroup dspi_freertos_driver
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*******************************************************************************
|
||||
* Definitions
|
||||
******************************************************************************/
|
||||
|
||||
/*!
|
||||
* @cond RTOS_PRIVATE
|
||||
* @brief DSPI FreeRTOS handle
|
||||
*/
|
||||
typedef struct _dspi_rtos_handle
|
||||
{
|
||||
SPI_Type *base; /*!< DSPI base address */
|
||||
dspi_master_handle_t drv_handle; /*!< Handle of the underlying driver, treated as opaque by the RTOS layer */
|
||||
status_t async_status; /*!< Transactional state of the underlying driver */
|
||||
SemaphoreHandle_t mutex; /*!< Mutex to lock the handle during a transfer */
|
||||
SemaphoreHandle_t event; /*!< Semaphore to notify and unblock a task when a transfer ends */
|
||||
#if (configSUPPORT_STATIC_ALLOCATION == 1)
|
||||
StaticSemaphore_t mutexBuffer; /*!< Statically allocated memory for mutex */
|
||||
StaticSemaphore_t semaphoreBuffer; /*!< Statically allocated memory for event */
|
||||
#endif
|
||||
} dspi_rtos_handle_t;
|
||||
/*! \endcond */
|
||||
|
||||
/*******************************************************************************
|
||||
* API
|
||||
******************************************************************************/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*!
|
||||
* @name DSPI RTOS Operation
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*!
|
||||
* @brief Initializes the DSPI.
|
||||
*
|
||||
* This function initializes the DSPI module and the related RTOS context.
|
||||
*
|
||||
* @param handle The RTOS DSPI handle, the pointer to an allocated space for RTOS context.
|
||||
* @param base The pointer base address of the DSPI instance to initialize.
|
||||
* @param masterConfig A configuration structure to set-up the DSPI in master mode.
|
||||
* @param srcClock_Hz A frequency of the input clock of the DSPI module.
|
||||
* @return status of the operation.
|
||||
*/
|
||||
status_t DSPI_RTOS_Init(dspi_rtos_handle_t *handle,
|
||||
SPI_Type *base,
|
||||
const dspi_master_config_t *masterConfig,
|
||||
uint32_t srcClock_Hz);
|
||||
|
||||
/*!
|
||||
* @brief Deinitializes the DSPI.
|
||||
*
|
||||
* This function deinitializes the DSPI module and the related RTOS context.
|
||||
*
|
||||
* @param handle The RTOS DSPI handle.
|
||||
*/
|
||||
status_t DSPI_RTOS_Deinit(dspi_rtos_handle_t *handle);
|
||||
|
||||
/*!
|
||||
* @brief Performs the SPI transfer.
|
||||
*
|
||||
* This function performs the SPI transfer according to the data given in the transfer structure.
|
||||
*
|
||||
* @param handle The RTOS DSPI handle.
|
||||
* @param transfer A structure specifying the transfer parameters.
|
||||
* @return status of the operation.
|
||||
*/
|
||||
status_t DSPI_RTOS_Transfer(dspi_rtos_handle_t *handle, dspi_transfer_t *transfer);
|
||||
|
||||
/*!
|
||||
* @}
|
||||
*/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
/*!
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* __FSL_DSPI_FREERTOS_H__ */
|
||||
-1754
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user