Skip to content

Commit

Permalink
Support bluetooth on nrf52832
Browse files Browse the repository at this point in the history
externals/nrf52/: Modify for Spresense.
sdk/modules/bluetooth/: Add nrf52.
  • Loading branch information
SPRESENSE committed Jul 19, 2022
1 parent d8d9106 commit 2f089e1
Show file tree
Hide file tree
Showing 44 changed files with 10,357 additions and 13,599 deletions.
27 changes: 27 additions & 0 deletions externals/nrf52/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#
# For a description of the syntax of this configuration file,
# see the file kconfig-language.txt in the NuttX tools repository.
#

config EXTERNALS_NRF52
bool "NRF52 Libraries"
depends on BLUETOOTH_NRF52
default n
---help---
Enable NRF52 Libraries.
from https://www.nordicsemi.com/Products/Development-software/nRF5-SDK/Download
For details, see https://infocenter.nordicsemi.com/index.jsp?topic=%2Fstruct_sdk%2Fstruct%2Fsdk_nrf5_latest.html .

if EXTERNALS_NRF52

choice
prompt "nRF52xxx & Soft Device"
default EXTERNALS_NRF52_S132

config EXTERNALS_NRF52_S132
bool "Select nRF52832 & SoftDevice S132"

endchoice

endif # EXTERNALS_NRF52

56 changes: 56 additions & 0 deletions externals/nrf52/LibIncludes.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
############################################################################
# externals/nrf52/LibIncludes.mk
#
# Copyright 2022 Sony Semiconductor Solutions Corporation
#
# 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 Sony Semiconductor Solutions Corporation 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.
#
############################################################################

BLEDIR := $(SDKDIR)$(DELIM)modules$(DELIM)bluetooth$(DELIM)hal$(DELIM)nrf52

BLE_IGNORE_DIR := "*s132*"
BLE_API_VERSION := 7

ifeq ($(CONFIG_EXTERNALS_NRF52),y)
CFLAGS += -DBLE_STACK_SUPPORT_REQD -DNRF_SD_BLE_API_VERSION=$(BLE_API_VERSION) -DSVCALL_AS_NORMAL_FUNCTION -DBLE_SUPPORT_BLE5 -std=c99
CFLAGS += -DBLE_ENABLE_NORDIC_ORIGINAL
endif

ifeq ($(CONFIG_EXTERNALS_NRF52),y)
CFLAGS += ${shell $(INCDIR) $(INCDIROPT) "$(CC)" "$(SDKDIR)/../externals/nrf52/nRF5_SDK_17.1.0_ddde560"}
CFLAGS += ${shell $(INCDIR) $(INCDIROPT) "$(CC)" "$(SDKDIR)/../externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/softdevice/common"}
CFLAGS += ${shell $(INCDIR) $(INCDIROPT) "$(CC)" "$(SDKDIR)/../externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/softdevice/s132/headers"}
CFLAGS += ${shell $(INCDIR) $(INCDIROPT) "$(CC)" "$(SDKDIR)/../externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/libraries/experimental_section_vars"}
CFLAGS += ${shell $(INCDIR) $(INCDIROPT) "$(CC)" "$(SDKDIR)/../externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/libraries/util"}
CFLAGS += ${shell $(INCDIR) $(INCDIROPT) "$(CC)" "$(SDKDIR)/../externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/libraries/queue"}
CFLAGS += ${shell $(INCDIR) $(INCDIROPT) "$(CC)" "$(SDKDIR)/../externals/nrf52/nRF5_SDK_17.1.0_ddde560/components/libraries/log"}
CFLAGS += ${shell $(INCDIR) $(INCDIROPT) "$(CC)" "$(SDKDIR)/../externals/nrf52/nRF5_SDK_17.1.0_ddde560/modules/nrfx/mdk"}
CFLAGS += ${shell $(INCDIR) $(INCDIROPT) "$(CC)" "$(SDKDIR)/../externals/nrf52/nRF5_SDK_17.1.0_ddde560/config/nrf52832/config"}
endif
40 changes: 40 additions & 0 deletions externals/nrf52/Library.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
############################################################################
# externals/nrf52/Library.mk
#
# Copyright 2022 Sony Semiconductor Solutions Corporation
#
# 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 Sony Semiconductor Solutions Corporation 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.
#
############################################################################

ifeq ($(CONFIG_EXTERNALS_NRF52),y)
EXTRA_LIBPATHS += -L "$(EXTLIBDIR)$(DELIM)nrf52"
EXTRA_LIBS += -lnrf52
endif

39 changes: 39 additions & 0 deletions externals/nrf52/Make.defs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
############################################################################
# nrf52/Make.defs
#
# Copyright 2022 Sony Semiconductor Solutions Corporation
#
# 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 Sony Semiconductor Solutions Corporation 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.
#
############################################################################

ifeq ($(CONFIG_EXTERNALS_NRF52),y)
CONFIGURED_APPS += nrf52
endif

64 changes: 64 additions & 0 deletions externals/nrf52/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
############################################################################
# externals/nrf52/Makefile
#
# Copyright 2022 Sony Semiconductor Solutions Corporation
#
# 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 Sony Semiconductor Solutions Corporation nor
# the names of its contributors may be used to endorse or promote
# products derived from this software without specific prior written
# permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
############################################################################

-include $(APPDIR)/Make.defs
-include $(SDKDIR)/Make.defs

BIN = libnrf52$(LIBEXT)

NRF52_ROOT = nRF5_SDK_17.1.0_ddde560


NRF52_SER_DIRS := $(shell find $(NRF52_ROOT)/components/serialization -type d)
NRF52_SD_DIRS := $(shell find $(NRF52_ROOT)/components/softdevice -type d)
NRF52_MOD_DIRS := $(shell find $(NRF52_ROOT)/modules -type d)

#NRF52_DIRS := $(NRF52_SER_DIRS) $(NRF52_SD_DIRS) $(NRF52_MOD_DIRS)

NRF52_DIRS := $(shell find $(NRF52_ROOT) -type d)
NRF52_SRCS := $(foreach dir, $(NRF52_DIRS), $(wildcard $(dir)/*.c))
NRF52_OBJS := $(NRF52_SRCS:.c=.o)

CSRCS := $(NRF52_SRCS)
CFLAGS += -DBLE_STACK_SUPPORT_REQD -DNRF_SD_BLE_API_VERSION=$(BLE_API_VERSION) -DSVCALL_AS_NORMAL_FUNCTION -DBLE_SUPPORT_BLE5 -std=c99
CFLAGS += -DBLE_ENABLE_NORDIC_ORIGINAL
CFLAGS += -DNOT_USE_NRF_SECTION

CFLAGS += $(addprefix "-I", $(NRF52_DIRS))

VPATH := $(NRF52_DIRS)
ROOTDEPPATH := $(foreach dir,$(NRF52_DIRS), --dep-path $(dir))

include $(APPDIR)/Application.mk
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,18 @@
#include "nrf_queue.h"
#include "app_util_platform.h"

#if NRF_QUEUE_CONFIG_LOG_ENABLED
#define NRF_LOG_LEVEL NRF_QUEUE_CONFIG_LOG_LEVEL
#define NRF_LOG_INIT_FILTER_LEVEL NRF_QUEUE_CONFIG_LOG_INIT_FILTER_LEVEL
#define NRF_LOG_INFO_COLOR NRF_QUEUE_CONFIG_INFO_COLOR
#define NRF_LOG_DEBUG_COLOR NRF_QUEUE_CONFIG_DEBUG_COLOR
//#define BLE_DBGPRT_ENABLE
#ifdef BLE_DBGPRT_ENABLE
#include <stdio.h>
#define NRF_LOG_INST_WARNING printf
#define NRF_LOG_INST_DEBUG(...)
#else
#define NRF_LOG_LEVEL 0
#endif // NRF_QUEUE_CONFIG_LOG_ENABLED
#include "nrf_log.h"
#define NRF_LOG_INST_WARNING(...)
#define NRF_LOG_INST_DEBUG(...)
#endif

#define __STATIC_INLINE static __inline


NRF_SECTION_DEF(nrf_queue, nrf_queue_t);

Expand Down Expand Up @@ -394,8 +397,6 @@ size_t nrf_queue_in(nrf_queue_t const * p_queue,
ASSERT(p_queue != NULL);
ASSERT(p_data != NULL);

size_t req_element_count = element_count;

if (element_count == 0)
{
return 0;
Expand Down Expand Up @@ -502,7 +503,7 @@ size_t nrf_queue_out(nrf_queue_t const * p_queue,
ASSERT(p_queue != NULL);
ASSERT(p_data != NULL);

size_t req_element_count = element_count;
//size_t req_element_count = element_count;

if (element_count == 0)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ typedef struct
#if NRF_QUEUE_CLI_CMDS
const char * p_name; //!< Pointer to string with queue name.
#endif
NRF_LOG_INSTANCE_PTR_DECLARE(p_log) //!< Pointer to instance of the logger object (Conditionally compiled).
nrf_log_module_dynamic_data_t * p_log; //!< Pointer to instance of the logger object (Conditionally compiled).
} nrf_queue_t;

#if NRF_QUEUE_CLI_CMDS
Expand Down
Loading

0 comments on commit 2f089e1

Please sign in to comment.