update s140 to 6.0.0
This commit is contained in:
430
softdevice/6.0.0/common/nrf_sdh.c
Normal file
430
softdevice/6.0.0/common/nrf_sdh.c
Normal file
@ -0,0 +1,430 @@
|
||||
/**
|
||||
* Copyright (c) 2017 - 2018, Nordic Semiconductor ASA
|
||||
*
|
||||
* 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, except as embedded into a Nordic
|
||||
* Semiconductor ASA integrated circuit in a product or a software update for
|
||||
* such product, 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 Nordic Semiconductor ASA nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* 4. This software, with or without modification, must only be used with a
|
||||
* Nordic Semiconductor ASA integrated circuit.
|
||||
*
|
||||
* 5. Any software provided in binary form under this license must not be reverse
|
||||
* engineered, decompiled, modified and/or disassembled.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
|
||||
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA 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 "sdk_common.h"
|
||||
#if NRF_MODULE_ENABLED(NRF_SDH)
|
||||
|
||||
#include "nrf_sdh.h"
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "nrf_sdm.h"
|
||||
#include "nrf_nvic.h"
|
||||
#include "sdk_config.h"
|
||||
#include "app_error.h"
|
||||
#include "app_util_platform.h"
|
||||
|
||||
|
||||
#define NRF_LOG_MODULE_NAME nrf_sdh
|
||||
#if NRF_SDH_LOG_ENABLED
|
||||
#define NRF_LOG_LEVEL NRF_SDH_LOG_LEVEL
|
||||
#define NRF_LOG_INFO_COLOR NRF_SDH_INFO_COLOR
|
||||
#define NRF_LOG_DEBUG_COLOR NRF_SDH_DEBUG_COLOR
|
||||
#else
|
||||
#define NRF_LOG_LEVEL 0
|
||||
#endif // NRF_SDH_LOG_ENABLED
|
||||
#include "nrf_log.h"
|
||||
NRF_LOG_MODULE_REGISTER();
|
||||
|
||||
|
||||
// Validate configuration options.
|
||||
|
||||
#if (NRF_SDH_DISPATCH_MODEL == NRF_SDH_DISPATCH_MODEL_APPSH)
|
||||
#if (!APP_SCHEDULER_ENABLED)
|
||||
#error app_scheduler is required when NRF_SDH_DISPATCH_MODEL is set to NRF_SDH_DISPATCH_MODEL_APPSH
|
||||
#endif
|
||||
#include "app_scheduler.h"
|
||||
#endif
|
||||
|
||||
#if ( (NRF_SDH_CLOCK_LF_SRC == NRF_CLOCK_LF_SRC_RC) \
|
||||
&& (NRF_SDH_CLOCK_LF_ACCURACY != NRF_CLOCK_LF_ACCURACY_500_PPM))
|
||||
#warning Please select NRF_CLOCK_LF_ACCURACY_500_PPM when using NRF_CLOCK_LF_SRC_RC
|
||||
#endif
|
||||
|
||||
|
||||
// Create section "sdh_req_observers".
|
||||
NRF_SECTION_SET_DEF(sdh_req_observers, nrf_sdh_req_observer_t, NRF_SDH_REQ_OBSERVER_PRIO_LEVELS);
|
||||
|
||||
// Create section "sdh_state_observers".
|
||||
NRF_SECTION_SET_DEF(sdh_state_observers, nrf_sdh_state_observer_t, NRF_SDH_STATE_OBSERVER_PRIO_LEVELS);
|
||||
|
||||
// Create section "sdh_stack_observers".
|
||||
NRF_SECTION_SET_DEF(sdh_stack_observers, nrf_sdh_stack_observer_t, NRF_SDH_STACK_OBSERVER_PRIO_LEVELS);
|
||||
|
||||
|
||||
static bool m_nrf_sdh_enabled; /**< Variable to indicate whether the SoftDevice is enabled. */
|
||||
static bool m_nrf_sdh_suspended; /**< Variable to indicate whether this module is suspended. */
|
||||
static bool m_nrf_sdh_continue; /**< Variable to indicate whether enable/disable process was started. */
|
||||
|
||||
|
||||
/**@brief Function for notifying request observers.
|
||||
*
|
||||
* @param[in] evt Type of request event.
|
||||
*/
|
||||
static ret_code_t sdh_request_observer_notify(nrf_sdh_req_evt_t req)
|
||||
{
|
||||
nrf_section_iter_t iter;
|
||||
|
||||
NRF_LOG_DEBUG("State request: 0x%08X", req);
|
||||
|
||||
for (nrf_section_iter_init(&iter, &sdh_req_observers);
|
||||
nrf_section_iter_get(&iter) != NULL;
|
||||
nrf_section_iter_next(&iter))
|
||||
{
|
||||
nrf_sdh_req_observer_t * p_observer;
|
||||
nrf_sdh_req_evt_handler_t handler;
|
||||
|
||||
p_observer = (nrf_sdh_req_observer_t *) nrf_section_iter_get(&iter);
|
||||
handler = p_observer->handler;
|
||||
|
||||
if (handler(req, p_observer->p_context))
|
||||
{
|
||||
NRF_LOG_DEBUG("Notify observer 0x%08X => ready", p_observer);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Process is stopped.
|
||||
NRF_LOG_DEBUG("Notify observer 0x%08X => blocking", p_observer);
|
||||
return NRF_ERROR_BUSY;
|
||||
}
|
||||
}
|
||||
return NRF_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**@brief Function for stage request observers.
|
||||
*
|
||||
* @param[in] evt Type of stage event.
|
||||
*/
|
||||
static void sdh_state_observer_notify(nrf_sdh_state_evt_t evt)
|
||||
{
|
||||
nrf_section_iter_t iter;
|
||||
|
||||
NRF_LOG_DEBUG("State change: 0x%08X", evt);
|
||||
|
||||
for (nrf_section_iter_init(&iter, &sdh_state_observers);
|
||||
nrf_section_iter_get(&iter) != NULL;
|
||||
nrf_section_iter_next(&iter))
|
||||
{
|
||||
nrf_sdh_state_observer_t * p_observer;
|
||||
nrf_sdh_state_evt_handler_t handler;
|
||||
|
||||
p_observer = (nrf_sdh_state_observer_t *) nrf_section_iter_get(&iter);
|
||||
handler = p_observer->handler;
|
||||
|
||||
handler(evt, p_observer->p_context);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void softdevices_evt_irq_enable(void)
|
||||
{
|
||||
#ifdef SOFTDEVICE_PRESENT
|
||||
ret_code_t ret_code = sd_nvic_EnableIRQ((IRQn_Type)SD_EVT_IRQn);
|
||||
APP_ERROR_CHECK(ret_code);
|
||||
#else
|
||||
// In case of serialization, NVIC must be accessed directly.
|
||||
NVIC_EnableIRQ(SD_EVT_IRQn);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
static void softdevice_evt_irq_disable(void)
|
||||
{
|
||||
#ifdef SOFTDEVICE_PRESENT
|
||||
ret_code_t ret_code = sd_nvic_DisableIRQ((IRQn_Type)SD_EVT_IRQn);
|
||||
APP_ERROR_CHECK(ret_code);
|
||||
#else
|
||||
// In case of serialization, NVIC must be accessed directly.
|
||||
NVIC_DisableIRQ(SD_EVT_IRQn);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
#ifndef S140
|
||||
static void swi_interrupt_priority_workaround(void)
|
||||
{
|
||||
// The priority of SoftDevice SWI SD_EVT_IRQn and RADIO_NOTIFICATION_IRQn in
|
||||
// S132 v5.0.0, S112 v5.0.0, S212 v5.0.0 and S332 v5.0.0 is set to 6.
|
||||
// Change it to APP_IRQ_PRIORITY_LOWEST (7) so that they do not preempt peripherals' interrupts.
|
||||
|
||||
#ifdef SOFTDEVICE_PRESENT
|
||||
ret_code_t ret_code;
|
||||
ret_code = sd_nvic_SetPriority(SD_EVT_IRQn, APP_IRQ_PRIORITY_LOWEST);
|
||||
APP_ERROR_CHECK(ret_code);
|
||||
ret_code = sd_nvic_SetPriority(RADIO_NOTIFICATION_IRQn, APP_IRQ_PRIORITY_LOWEST);
|
||||
APP_ERROR_CHECK(ret_code);
|
||||
#else
|
||||
// In case of serialization, NVIC must be accessed directly.
|
||||
NVIC_SetPriority(SD_EVT_IRQn, APP_IRQ_PRIORITY_LOWEST);
|
||||
NVIC_SetPriority(RADIO_NOTIFICATION_IRQn, APP_IRQ_PRIORITY_LOWEST);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
ret_code_t nrf_sdh_enable_request(void)
|
||||
{
|
||||
ret_code_t ret_code;
|
||||
|
||||
if (m_nrf_sdh_enabled)
|
||||
{
|
||||
return NRF_ERROR_INVALID_STATE;
|
||||
}
|
||||
|
||||
m_nrf_sdh_continue = true;
|
||||
|
||||
// Notify observers about SoftDevice enable request.
|
||||
if (sdh_request_observer_notify(NRF_SDH_EVT_ENABLE_REQUEST) == NRF_ERROR_BUSY)
|
||||
{
|
||||
// Enable process was stopped.
|
||||
return NRF_SUCCESS;
|
||||
}
|
||||
|
||||
// Notify observers about starting SoftDevice enable process.
|
||||
sdh_state_observer_notify(NRF_SDH_EVT_STATE_ENABLE_PREPARE);
|
||||
|
||||
nrf_clock_lf_cfg_t const clock_lf_cfg =
|
||||
{
|
||||
.source = NRF_SDH_CLOCK_LF_SRC,
|
||||
.rc_ctiv = NRF_SDH_CLOCK_LF_RC_CTIV,
|
||||
.rc_temp_ctiv = NRF_SDH_CLOCK_LF_RC_TEMP_CTIV,
|
||||
.accuracy = NRF_SDH_CLOCK_LF_ACCURACY
|
||||
};
|
||||
|
||||
CRITICAL_REGION_ENTER();
|
||||
#ifdef ANT_LICENSE_KEY
|
||||
ret_code = sd_softdevice_enable(&clock_lf_cfg, app_error_fault_handler, ANT_LICENSE_KEY);
|
||||
#else
|
||||
ret_code = sd_softdevice_enable(&clock_lf_cfg, app_error_fault_handler);
|
||||
#endif
|
||||
m_nrf_sdh_enabled = (ret_code == NRF_SUCCESS);
|
||||
CRITICAL_REGION_EXIT();
|
||||
|
||||
if (ret_code != NRF_SUCCESS)
|
||||
{
|
||||
return ret_code;
|
||||
}
|
||||
|
||||
m_nrf_sdh_continue = false;
|
||||
m_nrf_sdh_suspended = false;
|
||||
|
||||
#ifndef S140
|
||||
// Set the interrupt priority after enabling the SoftDevice, since
|
||||
// sd_softdevice_enable() sets the SoftDevice interrupt priority.
|
||||
swi_interrupt_priority_workaround();
|
||||
#endif
|
||||
|
||||
// Enable event interrupt.
|
||||
// Interrupt priority has already been set by the stack.
|
||||
softdevices_evt_irq_enable();
|
||||
|
||||
// Notify observers about a finished SoftDevice enable process.
|
||||
sdh_state_observer_notify(NRF_SDH_EVT_STATE_ENABLED);
|
||||
|
||||
return NRF_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
ret_code_t nrf_sdh_disable_request(void)
|
||||
{
|
||||
ret_code_t ret_code;
|
||||
|
||||
if (!m_nrf_sdh_enabled)
|
||||
{
|
||||
return NRF_ERROR_INVALID_STATE;
|
||||
}
|
||||
|
||||
m_nrf_sdh_continue = true;
|
||||
|
||||
// Notify observers about SoftDevice disable request.
|
||||
if (sdh_request_observer_notify(NRF_SDH_EVT_DISABLE_REQUEST) == NRF_ERROR_BUSY)
|
||||
{
|
||||
// Disable process was stopped.
|
||||
return NRF_SUCCESS;
|
||||
}
|
||||
|
||||
// Notify observers about starting SoftDevice disable process.
|
||||
sdh_state_observer_notify(NRF_SDH_EVT_STATE_DISABLE_PREPARE);
|
||||
|
||||
CRITICAL_REGION_ENTER();
|
||||
ret_code = sd_softdevice_disable();
|
||||
m_nrf_sdh_enabled = false;
|
||||
CRITICAL_REGION_EXIT();
|
||||
|
||||
if (ret_code != NRF_SUCCESS)
|
||||
{
|
||||
return ret_code;
|
||||
}
|
||||
|
||||
m_nrf_sdh_continue = false;
|
||||
|
||||
softdevice_evt_irq_disable();
|
||||
|
||||
// Notify observers about a finished SoftDevice enable process.
|
||||
sdh_state_observer_notify(NRF_SDH_EVT_STATE_DISABLED);
|
||||
|
||||
return NRF_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
ret_code_t nrf_sdh_request_continue(void)
|
||||
{
|
||||
if (!m_nrf_sdh_continue)
|
||||
{
|
||||
return NRF_ERROR_INVALID_STATE;
|
||||
}
|
||||
|
||||
if (m_nrf_sdh_enabled)
|
||||
{
|
||||
return nrf_sdh_disable_request();
|
||||
}
|
||||
else
|
||||
{
|
||||
return nrf_sdh_enable_request();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool nrf_sdh_is_enabled(void)
|
||||
{
|
||||
return m_nrf_sdh_enabled;
|
||||
}
|
||||
|
||||
|
||||
void nrf_sdh_suspend(void)
|
||||
{
|
||||
if (!m_nrf_sdh_enabled)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
softdevice_evt_irq_disable();
|
||||
m_nrf_sdh_suspended = true;
|
||||
}
|
||||
|
||||
|
||||
void nrf_sdh_resume(void)
|
||||
{
|
||||
if ((!m_nrf_sdh_suspended) || (!m_nrf_sdh_enabled))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Force calling ISR again to make sure that events not previously pulled have been processed.
|
||||
#ifdef SOFTDEVICE_PRESENT
|
||||
ret_code_t ret_code = sd_nvic_SetPendingIRQ((IRQn_Type)SD_EVT_IRQn);
|
||||
APP_ERROR_CHECK(ret_code);
|
||||
#else
|
||||
NVIC_SetPendingIRQ((IRQn_Type)SD_EVT_IRQn);
|
||||
#endif
|
||||
|
||||
softdevices_evt_irq_enable();
|
||||
|
||||
m_nrf_sdh_suspended = false;
|
||||
}
|
||||
|
||||
|
||||
bool nrf_sdh_is_suspended(void)
|
||||
{
|
||||
return (!m_nrf_sdh_enabled) || (m_nrf_sdh_suspended);
|
||||
}
|
||||
|
||||
|
||||
void nrf_sdh_evts_poll(void)
|
||||
{
|
||||
nrf_section_iter_t iter;
|
||||
|
||||
// Notify observers about pending SoftDevice event.
|
||||
for (nrf_section_iter_init(&iter, &sdh_stack_observers);
|
||||
nrf_section_iter_get(&iter) != NULL;
|
||||
nrf_section_iter_next(&iter))
|
||||
{
|
||||
nrf_sdh_stack_observer_t * p_observer;
|
||||
nrf_sdh_stack_evt_handler_t handler;
|
||||
|
||||
p_observer = (nrf_sdh_stack_observer_t *) nrf_section_iter_get(&iter);
|
||||
handler = p_observer->handler;
|
||||
|
||||
handler(p_observer->p_context);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#if (NRF_SDH_DISPATCH_MODEL == NRF_SDH_DISPATCH_MODEL_INTERRUPT)
|
||||
|
||||
void SD_EVT_IRQHandler(void)
|
||||
{
|
||||
nrf_sdh_evts_poll();
|
||||
}
|
||||
|
||||
#elif (NRF_SDH_DISPATCH_MODEL == NRF_SDH_DISPATCH_MODEL_APPSH)
|
||||
|
||||
/**@brief Function for polling SoftDevice events.
|
||||
*
|
||||
* @note This function is compatible with @ref app_sched_event_handler_t.
|
||||
*
|
||||
* @param[in] p_event_data Pointer to the event data.
|
||||
* @param[in] event_size Size of the event data.
|
||||
*/
|
||||
static void appsh_events_poll(void * p_event_data, uint16_t event_size)
|
||||
{
|
||||
UNUSED_PARAMETER(p_event_data);
|
||||
UNUSED_PARAMETER(event_size);
|
||||
|
||||
nrf_sdh_evts_poll();
|
||||
}
|
||||
|
||||
|
||||
void SD_EVT_IRQHandler(void)
|
||||
{
|
||||
ret_code_t ret_code = app_sched_event_put(NULL, 0, appsh_events_poll);
|
||||
APP_ERROR_CHECK(ret_code);
|
||||
}
|
||||
|
||||
#elif (NRF_SDH_DISPATCH_MODEL == NRF_SDH_DISPATCH_MODEL_POLLING)
|
||||
|
||||
#else
|
||||
|
||||
#error "Unknown SoftDevice handler dispatch model."
|
||||
|
||||
#endif // NRF_SDH_DISPATCH_MODEL
|
||||
|
||||
#endif // NRF_MODULE_ENABLED(NRF_SDH)
|
305
softdevice/6.0.0/common/nrf_sdh.h
Normal file
305
softdevice/6.0.0/common/nrf_sdh.h
Normal file
@ -0,0 +1,305 @@
|
||||
/**
|
||||
* Copyright (c) 2017 - 2018, Nordic Semiconductor ASA
|
||||
*
|
||||
* 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, except as embedded into a Nordic
|
||||
* Semiconductor ASA integrated circuit in a product or a software update for
|
||||
* such product, 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 Nordic Semiconductor ASA nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* 4. This software, with or without modification, must only be used with a
|
||||
* Nordic Semiconductor ASA integrated circuit.
|
||||
*
|
||||
* 5. Any software provided in binary form under this license must not be reverse
|
||||
* engineered, decompiled, modified and/or disassembled.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
|
||||
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA 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
|
||||
*
|
||||
* @defgroup nrf_sdh SoftDevice Handler
|
||||
* @{
|
||||
* @ingroup app_common
|
||||
* @brief API for initializing and disabling the SoftDevice.
|
||||
*/
|
||||
|
||||
#ifndef NRF_SDH_H__
|
||||
#define NRF_SDH_H__
|
||||
|
||||
#include <stdbool.h>
|
||||
#include "sdk_config.h"
|
||||
#include "sdk_errors.h"
|
||||
#include "nrf_section_iter.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @name Softdevice Handler dispatch models
|
||||
* @{
|
||||
* @ingroup nrf_sdh */
|
||||
|
||||
/**@brief SoftDevice events are passed to the application from the interrupt context. */
|
||||
#define NRF_SDH_DISPATCH_MODEL_INTERRUPT 0
|
||||
|
||||
/**@brief SoftDevice events are passed to the application using @ref app_scheduler.
|
||||
*
|
||||
* @note @ref app_scheduler must be initialized before enabling the SoftDevice handler.
|
||||
*/
|
||||
#define NRF_SDH_DISPATCH_MODEL_APPSH 1
|
||||
|
||||
/**@brief SoftDevice events are polled manually using @ref nrf_sdh_evts_poll().
|
||||
*
|
||||
* @note In this mode, a user application can also implement SD_EVT_IRQHandler() to receive a
|
||||
* notification about incoming events.
|
||||
*/
|
||||
#define NRF_SDH_DISPATCH_MODEL_POLLING 2
|
||||
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @name SoftDevice Handler state change requests
|
||||
* @{
|
||||
* @ingroup nrf_sdh */
|
||||
|
||||
/**@brief SoftDevice Handler state requests. */
|
||||
typedef enum
|
||||
{
|
||||
NRF_SDH_EVT_ENABLE_REQUEST, //!< Request to enable the SoftDevice.
|
||||
NRF_SDH_EVT_DISABLE_REQUEST, //!< Request to disable the SoftDevice.
|
||||
} nrf_sdh_req_evt_t;
|
||||
|
||||
/**@brief SoftDevice Handler state request handler.
|
||||
*
|
||||
* @retval true If ready for the SoftDevice to change state.
|
||||
* @retval false If not ready for the SoftDevice to change state.
|
||||
* If false is returned, the state change is aborted.
|
||||
*/
|
||||
typedef bool (*nrf_sdh_req_evt_handler_t)(nrf_sdh_req_evt_t request, void * p_context);
|
||||
|
||||
/**@brief SoftDevice Handler state request observer. */
|
||||
typedef struct
|
||||
{
|
||||
nrf_sdh_req_evt_handler_t handler; //!< Request handler.
|
||||
void * p_context; //!< A parameter to the handler function.
|
||||
} const nrf_sdh_req_observer_t;
|
||||
|
||||
/**@brief Macro for registering a SoftDevice state change request observer.
|
||||
*
|
||||
* An observer of SoftDevice state change requests receives requests to change the state of the
|
||||
* SoftDevice from enabled to disabled and vice versa. These requests may or may not be acknowledged
|
||||
* by the observer, depending on the value returned by its request handler function. Thus, a
|
||||
* request observer has the capability to defer the change of state of the SoftDevice. If it does
|
||||
* so, it has the responsibility to call @ref nrf_sdh_request_continue when it is ready to let the
|
||||
* SoftDevice change its state. If such capability is not necessary and you only need to be informed
|
||||
* about changes of the SoftDevice state, use the @ref NRF_SDH_STATE_OBSERVER macro instead.
|
||||
*
|
||||
* @note This macro places the observer in a section named "sdh_req_observers".
|
||||
*
|
||||
* @param[in] _observer Name of the observer.
|
||||
* @param[in] _prio Priority of the observer's event handler.
|
||||
* The smaller the number, the higher the priority.
|
||||
* @hideinitializer
|
||||
*/
|
||||
#define NRF_SDH_REQUEST_OBSERVER(_observer, _prio) \
|
||||
STATIC_ASSERT(NRF_SDH_ENABLED, "NRF_SDH_ENABLED not set!"); \
|
||||
STATIC_ASSERT(_prio < NRF_SDH_REQ_OBSERVER_PRIO_LEVELS, "Priority level unavailable."); \
|
||||
/*lint -esym(528,*_observer) -esym(529,*_observer) : Symbol not referenced. */ \
|
||||
NRF_SECTION_SET_ITEM_REGISTER(sdh_req_observers, _prio, nrf_sdh_req_observer_t const _observer)
|
||||
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @name SoftDevice Handler state events
|
||||
* @{
|
||||
* @ingroup nrf_sdh */
|
||||
|
||||
/**@brief SoftDevice Handler state events. */
|
||||
typedef enum
|
||||
{
|
||||
NRF_SDH_EVT_STATE_ENABLE_PREPARE, //!< SoftDevice is going to be enabled.
|
||||
NRF_SDH_EVT_STATE_ENABLED, //!< SoftDevice is enabled.
|
||||
NRF_SDH_EVT_STATE_DISABLE_PREPARE, //!< SoftDevice is going to be disabled.
|
||||
NRF_SDH_EVT_STATE_DISABLED, //!< SoftDevice is disabled.
|
||||
} nrf_sdh_state_evt_t;
|
||||
|
||||
/**@brief SoftDevice Handler state event handler. */
|
||||
typedef void (*nrf_sdh_state_evt_handler_t)(nrf_sdh_state_evt_t state, void * p_context);
|
||||
|
||||
/**@brief SoftDevice Handler state observer. */
|
||||
typedef struct
|
||||
{
|
||||
nrf_sdh_state_evt_handler_t handler; //!< State event handler.
|
||||
void * p_context; //!< A parameter to the event handler.
|
||||
} const nrf_sdh_state_observer_t;
|
||||
|
||||
/**@brief Macro for registering a SoftDevice state observer.
|
||||
*
|
||||
* A SoftDevice state observer receives events when the SoftDevice state has changed or is
|
||||
* about to change. These events are only meant to inform the state observer, which, contrary
|
||||
* to a state change request observer, does not have the capability to defer the change of state.
|
||||
* If such capability is required, use the @ref NRF_SDH_REQUEST_OBSERVER macro instead.
|
||||
*
|
||||
* This macro places the observer in a section named "sdh_state_observers".
|
||||
*
|
||||
* @param[in] _observer Name of the observer.
|
||||
* @param[in] _prio Priority of the observer's event handler.
|
||||
* The smaller the number, the higher the priority.
|
||||
* @hideinitializer
|
||||
*/
|
||||
#define NRF_SDH_STATE_OBSERVER(_observer, _prio) \
|
||||
STATIC_ASSERT(NRF_SDH_ENABLED, "NRF_SDH_ENABLED not set!"); \
|
||||
STATIC_ASSERT(_prio < NRF_SDH_STATE_OBSERVER_PRIO_LEVELS, "Priority level unavailable."); \
|
||||
/*lint -esym(528,*_observer) -esym(529,*_observer) : Symbol not referenced. */ \
|
||||
NRF_SECTION_SET_ITEM_REGISTER(sdh_state_observers, _prio, static nrf_sdh_state_observer_t const _observer)
|
||||
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @name SoftDevice stack events
|
||||
* @{
|
||||
* @ingroup nrf_sdh */
|
||||
|
||||
/**@brief SoftDevice stack event handler. */
|
||||
typedef void (*nrf_sdh_stack_evt_handler_t)(void * p_evt);
|
||||
|
||||
/**@brief SoftDevice stack event observer. */
|
||||
typedef struct
|
||||
{
|
||||
nrf_sdh_stack_evt_handler_t handler; //!< SoftDevice event handler.
|
||||
void * p_context; //!< A parameter to the event handler.
|
||||
} const nrf_sdh_stack_observer_t;
|
||||
|
||||
/**@brief Macro for registering a SoftDevice stack events observer.
|
||||
*
|
||||
* A SoftDevice stack event observer receives all events from the SoftDevice. These events can be
|
||||
* either BLE, ANT, or SoC events. If you need to receive BLE, ANT, or SoC events separately, use the
|
||||
* @ref NRF_SDH_BLE_OBSERVER, @ref NRF_SDH_ANT_OBSERVER, or @ref NRF_SDH_SOC_OBSERVER macros
|
||||
* respectively.
|
||||
*
|
||||
* @note This macro places the observer in a section named "sdh_stack_observers".
|
||||
*
|
||||
* @param[in] _observer Name of the observer.
|
||||
* @param[in] _prio Priority of the observer's event handler.
|
||||
* The smaller the number, the higher the priority.
|
||||
** @hideinitializer
|
||||
*/
|
||||
#define NRF_SDH_STACK_OBSERVER(_observer, _prio) \
|
||||
STATIC_ASSERT(NRF_SDH_ENABLED, "NRF_SDH_ENABLED not set!"); \
|
||||
STATIC_ASSERT(_prio < NRF_SDH_STACK_OBSERVER_PRIO_LEVELS, "Priority level unavailable."); \
|
||||
/*lint -esym(528,*_observer) -esym(529,*_observer) : Symbol not referenced. */ \
|
||||
NRF_SECTION_SET_ITEM_REGISTER(sdh_stack_observers, _prio, static nrf_sdh_stack_observer_t const _observer)
|
||||
|
||||
/** @} */
|
||||
|
||||
/**@brief Function for requesting to enable the SoftDevice.
|
||||
*
|
||||
* This function issues a @ref NRF_SDH_EVT_ENABLE_REQUEST request to all observers that
|
||||
* were registered using the @ref NRF_SDH_REQUEST_OBSERVER macro. The observers may or
|
||||
* may not acknowledge the request. If all observers acknowledge the request, the
|
||||
* SoftDevice will be enabled. Otherwise, the process will be stopped and the observers
|
||||
* that did not acknowledge have the responsibility to restart it by calling
|
||||
* @ref nrf_sdh_request_continue when they are ready for the SoftDevice to change state.
|
||||
*
|
||||
* @retval NRF_SUCCESS The process is started.
|
||||
* @retval NRF_ERROR_INVALID_STATE The SoftDevice is already enabled.
|
||||
*/
|
||||
ret_code_t nrf_sdh_enable_request(void);
|
||||
|
||||
|
||||
/**@brief Function for requesting to disable the SoftDevice.
|
||||
*
|
||||
* This function issues a @ref NRF_SDH_EVT_DISABLE_REQUEST request to all observers that
|
||||
* were registered using the @ref NRF_SDH_REQUEST_OBSERVER macro. The observers may or
|
||||
* may not acknowledge the request. If all observers acknowledge the request, the
|
||||
* SoftDevice will be disabled. Otherwise, the process will be stopped and the observers
|
||||
* that did not acknowledge have the responsibility to restart it by calling
|
||||
* @ref nrf_sdh_request_continue when they are ready for the SoftDevice to change state.
|
||||
*
|
||||
* @retval NRF_SUCCESS The process is started.
|
||||
* @retval NRF_ERROR_INVALID_STATE The SoftDevice is already disabled.
|
||||
*/
|
||||
ret_code_t nrf_sdh_disable_request(void);
|
||||
|
||||
|
||||
/**@brief Function for restarting the SoftDevice Enable/Disable process.
|
||||
*
|
||||
* Modules which did not acknowledge a @ref NRF_SDH_EVT_ENABLE_REQUEST or
|
||||
* @ref NRF_SDH_EVT_DISABLE_REQUEST request must call this function to restart the
|
||||
* SoftDevice state change process.
|
||||
*
|
||||
* @retval NRF_SUCCESS The process is restarted.
|
||||
* @retval NRF_ERROR_INVALID_STATE No state change request was pending.
|
||||
*/
|
||||
ret_code_t nrf_sdh_request_continue(void);
|
||||
|
||||
|
||||
/**@brief Function for retrieving the SoftDevice state.
|
||||
*
|
||||
* @retval true If the SoftDevice is enabled.
|
||||
* @retval false If the SoftDevice is disabled.
|
||||
*/
|
||||
bool nrf_sdh_is_enabled(void);
|
||||
|
||||
|
||||
/**@brief Function for stopping the incoming stack events.
|
||||
*
|
||||
* This function disables the SoftDevice interrupt. To resume polling for events,
|
||||
* call @ref nrf_sdh_resume.
|
||||
*/
|
||||
void nrf_sdh_suspend(void);
|
||||
|
||||
|
||||
/**@brief Function for resuming polling incoming events from the SoftDevice. */
|
||||
void nrf_sdh_resume(void);
|
||||
|
||||
|
||||
/**@brief Function for retrieving the information about the module state.
|
||||
*
|
||||
* @retval true The SoftDevice handler is paused, and it will not fetch events from the stack.
|
||||
* @retval false The SoftDevice handler is running, and it will fetch and dispatch events from
|
||||
* the stack to the registered stack observers.
|
||||
*/
|
||||
bool nrf_sdh_is_suspended(void);
|
||||
|
||||
|
||||
/**@brief Function for polling stack events from the SoftDevice.
|
||||
*
|
||||
* The events are passed to the application using the registered event handlers.
|
||||
*
|
||||
* @note @ref NRF_SDH_DISPATCH_MODEL_POLLING must be selected to use this function.
|
||||
*/
|
||||
void nrf_sdh_evts_poll(void);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // NRF_SDH_H__
|
||||
|
||||
/** @} */
|
324
softdevice/6.0.0/common/nrf_sdh_ble.c
Normal file
324
softdevice/6.0.0/common/nrf_sdh_ble.c
Normal file
@ -0,0 +1,324 @@
|
||||
/**
|
||||
* Copyright (c) 2017 - 2018, Nordic Semiconductor ASA
|
||||
*
|
||||
* 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, except as embedded into a Nordic
|
||||
* Semiconductor ASA integrated circuit in a product or a software update for
|
||||
* such product, 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 Nordic Semiconductor ASA nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* 4. This software, with or without modification, must only be used with a
|
||||
* Nordic Semiconductor ASA integrated circuit.
|
||||
*
|
||||
* 5. Any software provided in binary form under this license must not be reverse
|
||||
* engineered, decompiled, modified and/or disassembled.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
|
||||
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA 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 "sdk_common.h"
|
||||
#if NRF_MODULE_ENABLED(NRF_SDH_BLE)
|
||||
|
||||
#include "nrf_sdh_ble.h"
|
||||
|
||||
#include "nrf_sdh.h"
|
||||
#include "app_error.h"
|
||||
#include "nrf_strerror.h"
|
||||
|
||||
|
||||
#define NRF_LOG_MODULE_NAME nrf_sdh_ble
|
||||
#if NRF_SDH_BLE_LOG_ENABLED
|
||||
#define NRF_LOG_LEVEL NRF_SDH_BLE_LOG_LEVEL
|
||||
#define NRF_LOG_INFO_COLOR NRF_SDH_BLE_INFO_COLOR
|
||||
#define NRF_LOG_DEBUG_COLOR NRF_SDH_BLE_DEBUG_COLOR
|
||||
#else
|
||||
#define NRF_LOG_LEVEL 0
|
||||
#endif // NRF_SDH_BLE_LOG_ENABLED
|
||||
#include "nrf_log.h"
|
||||
NRF_LOG_MODULE_REGISTER();
|
||||
|
||||
|
||||
// Create section set "sdh_ble_observers".
|
||||
NRF_SECTION_SET_DEF(sdh_ble_observers, nrf_sdh_ble_evt_observer_t, NRF_SDH_BLE_OBSERVER_PRIO_LEVELS);
|
||||
|
||||
|
||||
//lint -save -e10 -e19 -e40 -e27 Illegal character (0x24)
|
||||
#if defined(__CC_ARM)
|
||||
extern uint32_t Image$$RW_IRAM1$$Base;
|
||||
uint32_t const * const m_ram_start = &Image$$RW_IRAM1$$Base;
|
||||
#elif defined(__ICCARM__)
|
||||
extern uint32_t __ICFEDIT_region_RAM_start__;
|
||||
uint32_t const * const m_ram_start = &__ICFEDIT_region_RAM_start__;
|
||||
#elif defined(__SES_ARM)
|
||||
extern uint32_t __app_ram_start__;
|
||||
uint32_t const * const m_ram_start = &__app_ram_start__;
|
||||
#elif defined(__GNUC__)
|
||||
extern uint32_t __data_start__;
|
||||
uint32_t const * const m_ram_start = &__data_start__;
|
||||
#endif
|
||||
//lint -restore
|
||||
|
||||
#define RAM_START 0x20000000
|
||||
#define APP_RAM_START (uint32_t)m_ram_start
|
||||
|
||||
|
||||
static bool m_stack_is_enabled;
|
||||
|
||||
|
||||
ret_code_t nrf_sdh_ble_app_ram_start_get(uint32_t * p_app_ram_start)
|
||||
{
|
||||
if (p_app_ram_start == NULL)
|
||||
{
|
||||
return NRF_ERROR_NULL;
|
||||
}
|
||||
|
||||
*p_app_ram_start = APP_RAM_START;
|
||||
|
||||
return NRF_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
ret_code_t nrf_sdh_ble_default_cfg_set(uint8_t conn_cfg_tag, uint32_t * p_ram_start)
|
||||
{
|
||||
uint32_t ret_code;
|
||||
|
||||
ret_code = nrf_sdh_ble_app_ram_start_get(p_ram_start);
|
||||
if (ret_code != NRF_SUCCESS)
|
||||
{
|
||||
return ret_code;
|
||||
}
|
||||
|
||||
#ifdef S112
|
||||
STATIC_ASSERT(NRF_SDH_BLE_CENTRAL_LINK_COUNT == 0, "When using s112, NRF_SDH_BLE_CENTRAL_LINK_COUNT must be 0.");
|
||||
#endif
|
||||
|
||||
// Overwrite some of the default settings of the BLE stack.
|
||||
// If any of the calls to sd_ble_cfg_set() fail, log the error but carry on so that
|
||||
// wrong RAM settings can be caught by nrf_sdh_ble_enable() and a meaningful error
|
||||
// message will be printed to the user suggesting the correct value.
|
||||
ble_cfg_t ble_cfg;
|
||||
|
||||
#if (NRF_SDH_BLE_TOTAL_LINK_COUNT != 0)
|
||||
// Configure the connection count.
|
||||
memset(&ble_cfg, 0, sizeof(ble_cfg));
|
||||
ble_cfg.conn_cfg.conn_cfg_tag = conn_cfg_tag;
|
||||
ble_cfg.conn_cfg.params.gap_conn_cfg.conn_count = NRF_SDH_BLE_TOTAL_LINK_COUNT;
|
||||
ble_cfg.conn_cfg.params.gap_conn_cfg.event_length = NRF_SDH_BLE_GAP_EVENT_LENGTH;
|
||||
|
||||
ret_code = sd_ble_cfg_set(BLE_CONN_CFG_GAP, &ble_cfg, *p_ram_start);
|
||||
if (ret_code != NRF_SUCCESS)
|
||||
{
|
||||
NRF_LOG_ERROR("sd_ble_cfg_set() returned %s when attempting to set BLE_CONN_CFG_GAP.",
|
||||
nrf_strerror_get(ret_code));
|
||||
}
|
||||
|
||||
// Configure the connection roles.
|
||||
memset(&ble_cfg, 0, sizeof(ble_cfg));
|
||||
ble_cfg.gap_cfg.role_count_cfg.periph_role_count = NRF_SDH_BLE_PERIPHERAL_LINK_COUNT;
|
||||
#ifndef S112
|
||||
ble_cfg.gap_cfg.role_count_cfg.central_role_count = NRF_SDH_BLE_CENTRAL_LINK_COUNT;
|
||||
ble_cfg.gap_cfg.role_count_cfg.central_sec_count = MIN(NRF_SDH_BLE_CENTRAL_LINK_COUNT,
|
||||
BLE_GAP_ROLE_COUNT_CENTRAL_SEC_DEFAULT);
|
||||
#endif
|
||||
|
||||
ret_code = sd_ble_cfg_set(BLE_GAP_CFG_ROLE_COUNT, &ble_cfg, *p_ram_start);
|
||||
if (ret_code != NRF_SUCCESS)
|
||||
{
|
||||
NRF_LOG_ERROR("sd_ble_cfg_set() returned %s when attempting to set BLE_GAP_CFG_ROLE_COUNT.",
|
||||
nrf_strerror_get(ret_code));
|
||||
}
|
||||
|
||||
// Configure the maximum ATT MTU.
|
||||
#if (NRF_SDH_BLE_GATT_MAX_MTU_SIZE != 23)
|
||||
memset(&ble_cfg, 0x00, sizeof(ble_cfg));
|
||||
ble_cfg.conn_cfg.conn_cfg_tag = conn_cfg_tag;
|
||||
ble_cfg.conn_cfg.params.gatt_conn_cfg.att_mtu = NRF_SDH_BLE_GATT_MAX_MTU_SIZE;
|
||||
|
||||
ret_code = sd_ble_cfg_set(BLE_CONN_CFG_GATT, &ble_cfg, *p_ram_start);
|
||||
if (ret_code != NRF_SUCCESS)
|
||||
{
|
||||
NRF_LOG_ERROR("sd_ble_cfg_set() returned %s when attempting to set BLE_CONN_CFG_GATT.",
|
||||
nrf_strerror_get(ret_code));
|
||||
}
|
||||
#endif // NRF_SDH_BLE_GATT_MAX_MTU_SIZE != 23
|
||||
#endif // NRF_SDH_BLE_TOTAL_LINK_COUNT != 0
|
||||
|
||||
// Configure number of custom UUIDS.
|
||||
memset(&ble_cfg, 0, sizeof(ble_cfg));
|
||||
ble_cfg.common_cfg.vs_uuid_cfg.vs_uuid_count = NRF_SDH_BLE_VS_UUID_COUNT;
|
||||
|
||||
ret_code = sd_ble_cfg_set(BLE_COMMON_CFG_VS_UUID, &ble_cfg, *p_ram_start);
|
||||
if (ret_code != NRF_SUCCESS)
|
||||
{
|
||||
NRF_LOG_ERROR("sd_ble_cfg_set() returned %s when attempting to set BLE_COMMON_CFG_VS_UUID.",
|
||||
nrf_strerror_get(ret_code));
|
||||
}
|
||||
|
||||
// Configure the GATTS attribute table.
|
||||
memset(&ble_cfg, 0x00, sizeof(ble_cfg));
|
||||
ble_cfg.gatts_cfg.attr_tab_size.attr_tab_size = NRF_SDH_BLE_GATTS_ATTR_TAB_SIZE;
|
||||
|
||||
ret_code = sd_ble_cfg_set(BLE_GATTS_CFG_ATTR_TAB_SIZE, &ble_cfg, *p_ram_start);
|
||||
if (ret_code != NRF_SUCCESS)
|
||||
{
|
||||
NRF_LOG_ERROR("sd_ble_cfg_set() returned %s when attempting to set BLE_GATTS_CFG_ATTR_TAB_SIZE.",
|
||||
nrf_strerror_get(ret_code));
|
||||
}
|
||||
|
||||
// Configure Service Changed characteristic.
|
||||
memset(&ble_cfg, 0x00, sizeof(ble_cfg));
|
||||
ble_cfg.gatts_cfg.service_changed.service_changed = NRF_SDH_BLE_SERVICE_CHANGED;
|
||||
|
||||
ret_code = sd_ble_cfg_set(BLE_GATTS_CFG_SERVICE_CHANGED, &ble_cfg, *p_ram_start);
|
||||
if (ret_code != NRF_SUCCESS)
|
||||
{
|
||||
NRF_LOG_ERROR("sd_ble_cfg_set() returned %s when attempting to set BLE_GATTS_CFG_SERVICE_CHANGED.",
|
||||
nrf_strerror_get(ret_code));
|
||||
}
|
||||
|
||||
return NRF_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**@brief Function for finding the end address of the RAM. */
|
||||
static uint32_t ram_end_address_get(void)
|
||||
{
|
||||
uint32_t ram_total_size;
|
||||
|
||||
#ifdef NRF51
|
||||
uint32_t block_size = NRF_FICR->SIZERAMBLOCKS;
|
||||
ram_total_size = block_size * NRF_FICR->NUMRAMBLOCK;
|
||||
#else
|
||||
ram_total_size = NRF_FICR->INFO.RAM * 1024;
|
||||
#endif
|
||||
|
||||
return RAM_START + ram_total_size;
|
||||
}
|
||||
|
||||
|
||||
ret_code_t nrf_sdh_ble_enable(uint32_t * const p_app_ram_start)
|
||||
{
|
||||
// Start of RAM, obtained from linker symbol.
|
||||
uint32_t const app_ram_start_link = *p_app_ram_start;
|
||||
|
||||
ret_code_t ret_code = sd_ble_enable(p_app_ram_start);
|
||||
if (*p_app_ram_start > app_ram_start_link)
|
||||
{
|
||||
NRF_LOG_WARNING("Insufficient RAM allocated for the SoftDevice.");
|
||||
|
||||
NRF_LOG_WARNING("Change the RAM start location from 0x%x to 0x%x.",
|
||||
app_ram_start_link, *p_app_ram_start);
|
||||
NRF_LOG_WARNING("Maximum RAM size for application is 0x%x.",
|
||||
ram_end_address_get() - (*p_app_ram_start));
|
||||
}
|
||||
else
|
||||
{
|
||||
NRF_LOG_DEBUG("RAM starts at 0x%x", app_ram_start_link);
|
||||
if (*p_app_ram_start != app_ram_start_link)
|
||||
{
|
||||
NRF_LOG_DEBUG("RAM start location can be adjusted to 0x%x.", *p_app_ram_start);
|
||||
|
||||
NRF_LOG_DEBUG("RAM size for application can be adjusted to 0x%x.",
|
||||
ram_end_address_get() - (*p_app_ram_start));
|
||||
}
|
||||
}
|
||||
|
||||
if (ret_code == NRF_SUCCESS)
|
||||
{
|
||||
m_stack_is_enabled = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
NRF_LOG_ERROR("sd_ble_enable() returned %s.", nrf_strerror_get(ret_code));
|
||||
}
|
||||
|
||||
return ret_code;
|
||||
}
|
||||
|
||||
|
||||
/**@brief Function for polling BLE events.
|
||||
*
|
||||
* @param[in] p_context Context of the observer.
|
||||
*/
|
||||
static void nrf_sdh_ble_evts_poll(void * p_context)
|
||||
{
|
||||
UNUSED_VARIABLE(p_context);
|
||||
|
||||
ret_code_t ret_code;
|
||||
|
||||
if (!m_stack_is_enabled)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
while (true)
|
||||
{
|
||||
/*lint -save -e(587) */
|
||||
__ALIGN(4) uint8_t evt_buffer[NRF_SDH_BLE_EVT_BUF_SIZE];
|
||||
/*lint -restore */
|
||||
|
||||
ble_evt_t * p_ble_evt;
|
||||
uint16_t evt_len = (uint16_t)sizeof(evt_buffer);
|
||||
|
||||
ret_code = sd_ble_evt_get(evt_buffer, &evt_len);
|
||||
if (ret_code != NRF_SUCCESS)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
p_ble_evt = (ble_evt_t *)evt_buffer;
|
||||
|
||||
NRF_LOG_DEBUG("BLE event: 0x%x.", p_ble_evt->header.evt_id);
|
||||
|
||||
// Forward the event to BLE observers.
|
||||
nrf_section_iter_t iter;
|
||||
for (nrf_section_iter_init(&iter, &sdh_ble_observers);
|
||||
nrf_section_iter_get(&iter) != NULL;
|
||||
nrf_section_iter_next(&iter))
|
||||
{
|
||||
nrf_sdh_ble_evt_observer_t * p_observer;
|
||||
nrf_sdh_ble_evt_handler_t handler;
|
||||
|
||||
p_observer = (nrf_sdh_ble_evt_observer_t *)nrf_section_iter_get(&iter);
|
||||
handler = p_observer->handler;
|
||||
|
||||
handler(p_ble_evt, p_observer->p_context);
|
||||
}
|
||||
}
|
||||
|
||||
if (ret_code != NRF_ERROR_NOT_FOUND)
|
||||
{
|
||||
APP_ERROR_HANDLER(ret_code);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
NRF_SDH_STACK_OBSERVER(m_nrf_sdh_ble_evts_poll, NRF_SDH_BLE_STACK_OBSERVER_PRIO) =
|
||||
{
|
||||
.handler = nrf_sdh_ble_evts_poll,
|
||||
.p_context = NULL,
|
||||
};
|
||||
|
||||
#endif // NRF_MODULE_ENABLED(NRF_SDH_BLE)
|
184
softdevice/6.0.0/common/nrf_sdh_ble.h
Normal file
184
softdevice/6.0.0/common/nrf_sdh_ble.h
Normal file
@ -0,0 +1,184 @@
|
||||
/**
|
||||
* Copyright (c) 2017 - 2018, Nordic Semiconductor ASA
|
||||
*
|
||||
* 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, except as embedded into a Nordic
|
||||
* Semiconductor ASA integrated circuit in a product or a software update for
|
||||
* such product, 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 Nordic Semiconductor ASA nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* 4. This software, with or without modification, must only be used with a
|
||||
* Nordic Semiconductor ASA integrated circuit.
|
||||
*
|
||||
* 5. Any software provided in binary form under this license must not be reverse
|
||||
* engineered, decompiled, modified and/or disassembled.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
|
||||
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA 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
|
||||
*
|
||||
* @defgroup nrf_sdh_ble BLE support in SoftDevice Handler
|
||||
* @{
|
||||
* @ingroup nrf_sdh
|
||||
* @brief This file contains the declarations of types and functions required for BLE stack
|
||||
* support.
|
||||
*/
|
||||
|
||||
#ifndef NRF_SDH_BLE_H__
|
||||
#define NRF_SDH_BLE_H__
|
||||
|
||||
#include "app_util.h"
|
||||
#include "ble.h"
|
||||
#include "nrf_section_iter.h"
|
||||
#include "sdk_config.h"
|
||||
#include "sdk_errors.h"
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** @brief Size of the buffer for a BLE event. */
|
||||
#define NRF_SDH_BLE_EVT_BUF_SIZE BLE_EVT_LEN_MAX(NRF_SDH_BLE_GATT_MAX_MTU_SIZE)
|
||||
|
||||
|
||||
#if !(defined(__LINT__))
|
||||
/**@brief Macro for registering @ref nrf_sdh_soc_evt_observer_t. Modules that want to be
|
||||
* notified about SoC events must register the handler using this macro.
|
||||
*
|
||||
* @details This macro places the observer in a section named "sdh_soc_observers".
|
||||
*
|
||||
* @param[in] _name Observer name.
|
||||
* @param[in] _prio Priority of the observer event handler.
|
||||
* The smaller the number, the higher the priority.
|
||||
* @param[in] _handler BLE event handler.
|
||||
* @param[in] _context Parameter to the event handler.
|
||||
* @hideinitializer
|
||||
*/
|
||||
#define NRF_SDH_BLE_OBSERVER(_name, _prio, _handler, _context) \
|
||||
STATIC_ASSERT(NRF_SDH_BLE_ENABLED, "NRF_SDH_BLE_ENABLED not set!"); \
|
||||
STATIC_ASSERT(_prio < NRF_SDH_BLE_OBSERVER_PRIO_LEVELS, "Priority level unavailable."); \
|
||||
NRF_SECTION_SET_ITEM_REGISTER(sdh_ble_observers, _prio, static nrf_sdh_ble_evt_observer_t _name) = \
|
||||
{ \
|
||||
.handler = _handler, \
|
||||
.p_context = _context \
|
||||
}
|
||||
|
||||
/**@brief Macro for registering an array of @ref nrf_sdh_ble_evt_observer_t.
|
||||
* Modules that want to be notified about SoC events must register the handler using
|
||||
* this macro.
|
||||
*
|
||||
* Each observer's handler will be dispatched an event with its relative context from @p _context.
|
||||
* This macro places the observer in a section named "sdh_ble_observers".
|
||||
*
|
||||
* @param[in] _name Observer name.
|
||||
* @param[in] _prio Priority of the observer event handler.
|
||||
* The smaller the number, the higher the priority.
|
||||
* @param[in] _handler BLE event handler.
|
||||
* @param[in] _context An array of parameters to the event handler.
|
||||
* @param[in] _cnt Number of observers to register.
|
||||
* @hideinitializer
|
||||
*/
|
||||
#define NRF_SDH_BLE_OBSERVERS(_name, _prio, _handler, _context, _cnt) \
|
||||
STATIC_ASSERT(NRF_SDH_BLE_ENABLED, "NRF_SDH_BLE_ENABLED not set!"); \
|
||||
STATIC_ASSERT(_prio < NRF_SDH_BLE_OBSERVER_PRIO_LEVELS, "Priority level unavailable."); \
|
||||
NRF_SECTION_SET_ITEM_REGISTER(sdh_ble_observers, _prio, static nrf_sdh_ble_evt_observer_t _name[_cnt]) = \
|
||||
{ \
|
||||
MACRO_REPEAT_FOR(_cnt, HANDLER_SET, _handler, _context) \
|
||||
}
|
||||
|
||||
#if !(defined(DOXYGEN))
|
||||
#define HANDLER_SET(_idx, _handler, _context) \
|
||||
{ \
|
||||
.handler = _handler, \
|
||||
.p_context = _context[_idx], \
|
||||
},
|
||||
#endif
|
||||
|
||||
#else // __LINT__
|
||||
|
||||
/* Swallow semicolons */
|
||||
/*lint -save -esym(528, *) -esym(529, *) : Symbol not referenced. */
|
||||
#define NRF_SDH_BLE_OBSERVER(A, B, C, D) static int semicolon_swallow_##A
|
||||
#define NRF_SDH_BLE_OBSERVERS(A, B, C, D, E) static int semicolon_swallow_##A
|
||||
/*lint -restore */
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/**@brief BLE stack event handler. */
|
||||
typedef void (*nrf_sdh_ble_evt_handler_t)(ble_evt_t const * p_ble_evt, void * p_context);
|
||||
|
||||
/**@brief BLE event observer. */
|
||||
typedef struct
|
||||
{
|
||||
nrf_sdh_ble_evt_handler_t handler; //!< BLE event handler.
|
||||
void * p_context; //!< A parameter to the event handler.
|
||||
} const nrf_sdh_ble_evt_observer_t;
|
||||
|
||||
|
||||
/**@brief Function for retrieving the address of the start of application's RAM.
|
||||
*
|
||||
* @param[out] p_app_ram_start Address of the start of application's RAM.
|
||||
*
|
||||
* @retval NRF_SUCCESS If the address was successfully retrieved.
|
||||
* @retval NRF_ERROR_NULL If @p p_app_ram_start was @c NULL.
|
||||
*/
|
||||
ret_code_t nrf_sdh_ble_app_ram_start_get(uint32_t * p_app_ram_start);
|
||||
|
||||
|
||||
/**@brief Set the default BLE stack configuration.
|
||||
*
|
||||
* This function configures the BLE stack with the settings specified in the
|
||||
* SoftDevice handler BLE configuration. The following configurations will be set:
|
||||
* - Number of peripheral links
|
||||
* - Number of central links
|
||||
* - ATT MTU size (for the given connection)
|
||||
* - Vendor specific UUID count
|
||||
* - GATTS Attribute table size
|
||||
* - Service changed
|
||||
*
|
||||
* @param[in] conn_cfg_tag The connection to configure.
|
||||
* @param[out] p_ram_start Application RAM start address.
|
||||
*/
|
||||
ret_code_t nrf_sdh_ble_default_cfg_set(uint8_t conn_cfg_tag, uint32_t * p_ram_start);
|
||||
|
||||
|
||||
/**@brief Function for configuring and enabling the BLE stack.
|
||||
*
|
||||
* @param[in] p_app_ram_start Address of the start of application's RAM.
|
||||
*/
|
||||
ret_code_t nrf_sdh_ble_enable(uint32_t * p_app_ram_start);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // NRF_SDH_BLE_H__
|
||||
|
||||
/** @} */
|
118
softdevice/6.0.0/common/nrf_sdh_soc.c
Normal file
118
softdevice/6.0.0/common/nrf_sdh_soc.c
Normal file
@ -0,0 +1,118 @@
|
||||
/**
|
||||
* Copyright (c) 2017 - 2018, Nordic Semiconductor ASA
|
||||
*
|
||||
* 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, except as embedded into a Nordic
|
||||
* Semiconductor ASA integrated circuit in a product or a software update for
|
||||
* such product, 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 Nordic Semiconductor ASA nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* 4. This software, with or without modification, must only be used with a
|
||||
* Nordic Semiconductor ASA integrated circuit.
|
||||
*
|
||||
* 5. Any software provided in binary form under this license must not be reverse
|
||||
* engineered, decompiled, modified and/or disassembled.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
|
||||
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA 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 "sdk_common.h"
|
||||
#if NRF_MODULE_ENABLED(NRF_SDH_SOC)
|
||||
|
||||
#include "nrf_sdh_soc.h"
|
||||
|
||||
#include "nrf_sdh.h"
|
||||
#include "nrf_soc.h"
|
||||
#include "app_error.h"
|
||||
|
||||
|
||||
#define NRF_LOG_MODULE_NAME nrf_sdh_soc
|
||||
#if NRF_SDH_SOC_LOG_ENABLED
|
||||
#define NRF_LOG_LEVEL NRF_SDH_SOC_LOG_LEVEL
|
||||
#define NRF_LOG_INFO_COLOR NRF_SDH_SOC_INFO_COLOR
|
||||
#define NRF_LOG_DEBUG_COLOR NRF_SDH_SOC_DEBUG_COLOR
|
||||
#else
|
||||
#define NRF_LOG_LEVEL 0
|
||||
#endif // NRF_SDH_SOC_LOG_ENABLED
|
||||
#include "nrf_log.h"
|
||||
NRF_LOG_MODULE_REGISTER();
|
||||
|
||||
|
||||
// Create section set "sdh_soc_observers".
|
||||
NRF_SECTION_SET_DEF(sdh_soc_observers, nrf_sdh_soc_evt_observer_t, NRF_SDH_SOC_OBSERVER_PRIO_LEVELS);
|
||||
|
||||
|
||||
/**@brief Function for polling SoC events.
|
||||
*
|
||||
* @param[in] p_context Context of the observer.
|
||||
*/
|
||||
static void nrf_sdh_soc_evts_poll(void * p_context)
|
||||
{
|
||||
ret_code_t ret_code;
|
||||
|
||||
UNUSED_VARIABLE(p_context);
|
||||
|
||||
while (true)
|
||||
{
|
||||
uint32_t evt_id;
|
||||
|
||||
ret_code = sd_evt_get(&evt_id);
|
||||
if (ret_code != NRF_SUCCESS)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
NRF_LOG_DEBUG("SoC event: 0x%x.", evt_id);
|
||||
|
||||
// Forward the event to SoC observers.
|
||||
nrf_section_iter_t iter;
|
||||
for (nrf_section_iter_init(&iter, &sdh_soc_observers);
|
||||
nrf_section_iter_get(&iter) != NULL;
|
||||
nrf_section_iter_next(&iter))
|
||||
{
|
||||
nrf_sdh_soc_evt_observer_t * p_observer;
|
||||
nrf_sdh_soc_evt_handler_t handler;
|
||||
|
||||
p_observer = (nrf_sdh_soc_evt_observer_t *) nrf_section_iter_get(&iter);
|
||||
handler = p_observer->handler;
|
||||
|
||||
handler(evt_id, p_observer->p_context);
|
||||
}
|
||||
}
|
||||
|
||||
if (ret_code != NRF_ERROR_NOT_FOUND)
|
||||
{
|
||||
APP_ERROR_HANDLER(ret_code);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
NRF_SDH_STACK_OBSERVER(m_nrf_sdh_soc_evts_poll, NRF_SDH_SOC_STACK_OBSERVER_PRIO) =
|
||||
{
|
||||
.handler = nrf_sdh_soc_evts_poll,
|
||||
.p_context = NULL,
|
||||
};
|
||||
|
||||
#endif // NRF_MODULE_ENABLED(NRF_SDH_SOC)
|
143
softdevice/6.0.0/common/nrf_sdh_soc.h
Normal file
143
softdevice/6.0.0/common/nrf_sdh_soc.h
Normal file
@ -0,0 +1,143 @@
|
||||
/**
|
||||
* Copyright (c) 2017 - 2018, Nordic Semiconductor ASA
|
||||
*
|
||||
* 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, except as embedded into a Nordic
|
||||
* Semiconductor ASA integrated circuit in a product or a software update for
|
||||
* such product, 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 Nordic Semiconductor ASA nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* 4. This software, with or without modification, must only be used with a
|
||||
* Nordic Semiconductor ASA integrated circuit.
|
||||
*
|
||||
* 5. Any software provided in binary form under this license must not be reverse
|
||||
* engineered, decompiled, modified and/or disassembled.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
|
||||
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA 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
|
||||
*
|
||||
* @defgroup nrf_sdh_soc SoC support in SoftDevice Handler
|
||||
* @{
|
||||
* @ingroup nrf_sdh
|
||||
* @brief This file contains the declarations of types and functions required for SoftDevice Handler
|
||||
* SoC support.
|
||||
*/
|
||||
|
||||
#ifndef NRF_SDH_SOC_H__
|
||||
#define NRF_SDH_SOC_H__
|
||||
|
||||
#include "sdk_common.h"
|
||||
#include "nrf_section_iter.h"
|
||||
#include "nrf_soc.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
#if !(defined(__LINT__))
|
||||
/**@brief Macro for registering @ref nrf_sdh_soc_evt_observer_t. Modules that want to be
|
||||
* notified about SoC events must register the handler using this macro.
|
||||
*
|
||||
* @details This macro places the observer in a section named "sdh_soc_observers".
|
||||
*
|
||||
* @param[in] _name Observer name.
|
||||
* @param[in] _prio Priority of the observer event handler.
|
||||
* The smaller the number, the higher the priority.
|
||||
* @param[in] _handler SoC event handler.
|
||||
* @param[in] _context Parameter to the event handler.
|
||||
* @hideinitializer
|
||||
*/
|
||||
#define NRF_SDH_SOC_OBSERVER(_name, _prio, _handler, _context) \
|
||||
STATIC_ASSERT(NRF_SDH_SOC_ENABLED, "NRF_SDH_SOC_ENABLED not set!"); \
|
||||
STATIC_ASSERT(_prio < NRF_SDH_SOC_OBSERVER_PRIO_LEVELS, "Priority level unavailable."); \
|
||||
NRF_SECTION_SET_ITEM_REGISTER(sdh_soc_observers, _prio, static nrf_sdh_soc_evt_observer_t _name) = \
|
||||
{ \
|
||||
.handler = _handler, \
|
||||
.p_context = _context \
|
||||
}
|
||||
|
||||
/**@brief Macro for registering an array of @ref nrf_sdh_soc_evt_observer_t.
|
||||
* Modules that want to be notified about SoC events must register the handler using
|
||||
* this macro.
|
||||
*
|
||||
* Each observer's handler will be dispatched an event with its relative context from @p _context.
|
||||
* This macro places the observer in a section named "sdh_soc_observers".
|
||||
*
|
||||
* @param[in] _name Observer name.
|
||||
* @param[in] _prio Priority of the observer event handler.
|
||||
* The smaller the number, the higher the priority.
|
||||
* @param[in] _handler SoC event handler.
|
||||
* @param[in] _context An array of parameters to the event handler.
|
||||
* @param[in] _cnt Number of observers to register.
|
||||
* @hideinitializer
|
||||
*/
|
||||
#define NRF_SDH_SOC_EVENT_OBSERVERS(_name, _prio, _handler, _context, _cnt) \
|
||||
STATIC_ASSERT(NRF_SDH_SOC_ENABLED, "NRF_SDH_SOC_ENABLED not set!"); \
|
||||
STATIC_ASSERT(_prio < NRF_SDH_SOC_OBSERVER_PRIO_LEVELS, "Priority level unavailable."); \
|
||||
NRF_SECTION_SET_ITEM_REGISTER(sdh_soc_observers, _prio, static nrf_sdh_soc_evt_observer_t _name[_cnt]) = \
|
||||
{ \
|
||||
MACRO_REPEAT_FOR(_cnt, HANDLER_SET, _handler, _context) \
|
||||
}
|
||||
|
||||
#if !(defined(DOXYGEN))
|
||||
#define HANDLER_SET(_idx, _handler, _context) \
|
||||
{ \
|
||||
.handler = _handler, \
|
||||
.p_context = _context[_idx], \
|
||||
},
|
||||
#endif
|
||||
|
||||
#else // __LINT__
|
||||
|
||||
/* Swallow semicolons */
|
||||
/*lint -save -esym(528, *) -esym(529, *) : Symbol not referenced. */
|
||||
#define NRF_SDH_SOC_OBSERVER(A, B, C, D) static int semicolon_swallow_##A
|
||||
#define NRF_SDH_SOC_OBSERVERS(A, B, C, D, E) static int semicolon_swallow_##A
|
||||
/*lint -restore */
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/**@brief SoC event handler. */
|
||||
typedef void (*nrf_sdh_soc_evt_handler_t) (uint32_t evt_id, void * p_context);
|
||||
|
||||
/**@brief SoC event observer. */
|
||||
typedef struct
|
||||
{
|
||||
nrf_sdh_soc_evt_handler_t handler; //!< SoC event handler.
|
||||
void * p_context; //!< A parameter to the event handler.
|
||||
} const nrf_sdh_soc_evt_observer_t;
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // NRF_SDH_SOC_H__
|
||||
|
||||
/** @} */
|
@ -0,0 +1,73 @@
|
||||
/* Copyright (c) 2013 Nordic Semiconductor. All Rights Reserved.
|
||||
*
|
||||
* The information contained herein is property of Nordic Semiconductor ASA.
|
||||
* Terms and conditions of usage are described in detail in NORDIC
|
||||
* SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
|
||||
*
|
||||
* Licensees are granted free, non-transferable use of the information. NO
|
||||
* WARRANTY of ANY KIND is provided. This heading must NOT be removed from
|
||||
* the file.
|
||||
*
|
||||
*/
|
||||
|
||||
/**@file
|
||||
*
|
||||
* @defgroup ant_stack_handler_types Types definitions for ANT support in SoftDevice handler.
|
||||
* @{
|
||||
* @ingroup softdevice_handler
|
||||
* @brief This file contains the declarations of types required for ANT stack support. These
|
||||
* types will be defined when the preprocessor define ANT_STACK_SUPPORT_REQD is defined.
|
||||
*/
|
||||
|
||||
#ifndef ANT_STACK_HANDLER_TYPES_H__
|
||||
#define ANT_STACK_HANDLER_TYPES_H__
|
||||
|
||||
#ifdef ANT_STACK_SUPPORT_REQD
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#define ANT_STACK_EVT_MSG_BUF_SIZE 32 /**< Size of ANT event message buffer. This will be provided to the SoftDevice while fetching an event. */
|
||||
#define ANT_STACK_EVT_STRUCT_SIZE (sizeof(ant_evt_t)) /**< Size of the @ref ant_evt_t structure. This will be used by the @ref softdevice_handler to internal event buffer size needed. */
|
||||
|
||||
/**@brief ANT stack event type. */
|
||||
typedef struct
|
||||
{
|
||||
union
|
||||
{
|
||||
uint32_t ulForceAlign; ///< force the evt_buffer to be 4-byte aligned, required for some casting to ANT_MESSAGE.
|
||||
uint8_t evt_buffer[ANT_STACK_EVT_MSG_BUF_SIZE]; ///< Event message buffer.
|
||||
} msg;
|
||||
uint8_t channel; ///< Channel number.
|
||||
uint8_t event; ///< Event code.
|
||||
} ant_evt_t;
|
||||
|
||||
/**@brief Application ANT stack event handler type. */
|
||||
typedef void (*ant_evt_handler_t) (ant_evt_t * p_ant_evt);
|
||||
|
||||
/**@brief Function for registering for ANT events.
|
||||
*
|
||||
* @details The application should use this function to register for receiving ANT events from
|
||||
* the SoftDevice. If the application does not call this function, then any ANT event
|
||||
* that may be generated by the SoftDevice will NOT be fetched. Once the application has
|
||||
* registered for the events, it is not possible to possible to cancel the registration.
|
||||
* However, it is possible to register a different function for handling the events at
|
||||
* any point of time.
|
||||
*
|
||||
* @param[in] ant_evt_handler Function to be called for each received ANT event.
|
||||
*
|
||||
* @retval NRF_SUCCESS Successful registration.
|
||||
* @retval NRF_ERROR_NULL Null pointer provided as input.
|
||||
*/
|
||||
uint32_t softdevice_ant_evt_handler_set(ant_evt_handler_t ant_evt_handler);
|
||||
|
||||
#else
|
||||
|
||||
// The ANT Stack support is not required.
|
||||
|
||||
#define ANT_STACK_EVT_STRUCT_SIZE 0 /**< Since the ANT stack support is not required, this is equated to 0, so that the @ref softdevice_handler.h can compute the internal event buffer size without having to care for ANT events.*/
|
||||
|
||||
#endif // ANT_STACK_SUPPORT_REQD
|
||||
|
||||
#endif // ANT_STACK_HANDLER_TYPES_H__
|
||||
|
||||
/** @} */
|
176
softdevice/6.0.0/common/softdevice_handler/app_ram_base.h
Normal file
176
softdevice/6.0.0/common/softdevice_handler/app_ram_base.h
Normal file
@ -0,0 +1,176 @@
|
||||
/* Copyright (c) 2013 Nordic Semiconductor. All Rights Reserved.
|
||||
*
|
||||
* The information contained herein is property of Nordic Semiconductor ASA.
|
||||
* Terms and conditions of usage are described in detail in NORDIC
|
||||
* SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
|
||||
*
|
||||
* Licensees are granted free, non-transferable use of the information. NO
|
||||
* WARRANTY of ANY KIND is provided. This heading must NOT be removed from
|
||||
* the file.
|
||||
*
|
||||
*/
|
||||
|
||||
// ble_enable param app_ram_base
|
||||
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_0_PERIPH_LINKS_0_SEC_COUNT_0_MID_BW 0x20001870
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_0_PERIPH_LINKS_0_SEC_COUNT_0_MID_BW 0x20001870
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_0_PERIPH_LINKS_1_SEC_COUNT_0_MID_BW 0x20001fe8
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_0_PERIPH_LINKS_1_SEC_COUNT_0_MID_BW 0x20001fe8
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_1_PERIPH_LINKS_0_SEC_COUNT_0_MID_BW 0x20001ce0
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_1_PERIPH_LINKS_0_SEC_COUNT_0_LOW_BW 0x20001c98
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_1_PERIPH_LINKS_0_SEC_COUNT_1_MID_BW 0x20001eb0
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_1_PERIPH_LINKS_0_SEC_COUNT_1_LOW_BW 0x20001e68
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_1_PERIPH_LINKS_1_SEC_COUNT_0_MID_BW 0x20002418
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_1_PERIPH_LINKS_1_SEC_COUNT_0_LOW_BW 0x200023d0
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_1_PERIPH_LINKS_1_SEC_COUNT_1_MID_BW 0x200025e0
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_1_PERIPH_LINKS_1_SEC_COUNT_1_LOW_BW 0x200025a0
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_2_PERIPH_LINKS_0_SEC_COUNT_0_MID_BW 0x20002110
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_2_PERIPH_LINKS_0_SEC_COUNT_0_LOW_BW 0x20002080
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_2_PERIPH_LINKS_0_SEC_COUNT_1_MID_BW 0x200022d8
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_2_PERIPH_LINKS_0_SEC_COUNT_1_LOW_BW 0x20002250
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_2_PERIPH_LINKS_0_SEC_COUNT_2_MID_BW 0x200024a8
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_2_PERIPH_LINKS_0_SEC_COUNT_2_LOW_BW 0x20002418
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_2_PERIPH_LINKS_1_SEC_COUNT_0_MID_BW 0x20002840
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_2_PERIPH_LINKS_1_SEC_COUNT_0_LOW_BW 0x200027b8
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_2_PERIPH_LINKS_1_SEC_COUNT_1_MID_BW 0x20002a10
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_2_PERIPH_LINKS_1_SEC_COUNT_1_LOW_BW 0x20002980
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_2_PERIPH_LINKS_1_SEC_COUNT_2_MID_BW 0x20002bd8
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_2_PERIPH_LINKS_1_SEC_COUNT_2_LOW_BW 0x20002b50
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_3_PERIPH_LINKS_0_SEC_COUNT_0_MID_BW 0x20002538
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_3_PERIPH_LINKS_0_SEC_COUNT_0_LOW_BW 0x20002468
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_3_PERIPH_LINKS_0_SEC_COUNT_1_MID_BW 0x20002708
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_3_PERIPH_LINKS_0_SEC_COUNT_1_LOW_BW 0x20002638
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_3_PERIPH_LINKS_0_SEC_COUNT_2_MID_BW 0x200028d0
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_3_PERIPH_LINKS_0_SEC_COUNT_2_LOW_BW 0x20002800
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_3_PERIPH_LINKS_0_SEC_COUNT_3_MID_BW 0x20002aa0
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_3_PERIPH_LINKS_0_SEC_COUNT_3_LOW_BW 0x200029d0
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_3_PERIPH_LINKS_1_SEC_COUNT_0_MID_BW 0x20002c70
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_3_PERIPH_LINKS_1_SEC_COUNT_0_LOW_BW 0x20002ba0
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_3_PERIPH_LINKS_1_SEC_COUNT_1_MID_BW 0x20002e40
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_3_PERIPH_LINKS_1_SEC_COUNT_1_LOW_BW 0x20002d68
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_3_PERIPH_LINKS_1_SEC_COUNT_2_MID_BW 0x20003008
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_3_PERIPH_LINKS_1_SEC_COUNT_2_LOW_BW 0x20002f38
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_3_PERIPH_LINKS_1_SEC_COUNT_3_MID_BW 0x200031d8
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_3_PERIPH_LINKS_1_SEC_COUNT_3_LOW_BW 0x20003100
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_4_PERIPH_LINKS_0_SEC_COUNT_0_MID_BW 0x20002968
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_4_PERIPH_LINKS_0_SEC_COUNT_0_LOW_BW 0x20002850
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_4_PERIPH_LINKS_0_SEC_COUNT_1_MID_BW 0x20002b30
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_4_PERIPH_LINKS_0_SEC_COUNT_1_LOW_BW 0x20002a18
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_4_PERIPH_LINKS_0_SEC_COUNT_2_MID_BW 0x20002d00
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_4_PERIPH_LINKS_0_SEC_COUNT_2_LOW_BW 0x20002be8
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_4_PERIPH_LINKS_0_SEC_COUNT_3_MID_BW 0x20002ec8
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_4_PERIPH_LINKS_0_SEC_COUNT_3_LOW_BW 0x20002db0
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_4_PERIPH_LINKS_0_SEC_COUNT_4_MID_BW 0x20003098
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_4_PERIPH_LINKS_0_SEC_COUNT_4_LOW_BW 0x20002f80
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_4_PERIPH_LINKS_1_SEC_COUNT_0_MID_BW 0x200030a0
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_4_PERIPH_LINKS_1_SEC_COUNT_0_LOW_BW 0x20002f88
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_4_PERIPH_LINKS_1_SEC_COUNT_1_MID_BW 0x20003268
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_4_PERIPH_LINKS_1_SEC_COUNT_1_LOW_BW 0x20003150
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_4_PERIPH_LINKS_1_SEC_COUNT_2_MID_BW 0x20003438
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_4_PERIPH_LINKS_1_SEC_COUNT_2_LOW_BW 0x20003320
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_4_PERIPH_LINKS_1_SEC_COUNT_3_MID_BW 0x20003600
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_4_PERIPH_LINKS_1_SEC_COUNT_3_LOW_BW 0x200034e8
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_4_PERIPH_LINKS_1_SEC_COUNT_4_MID_BW 0x200037d0
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_4_PERIPH_LINKS_1_SEC_COUNT_4_LOW_BW 0x200036b8
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_5_PERIPH_LINKS_0_SEC_COUNT_0_MID_BW 0x20002d98
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_5_PERIPH_LINKS_0_SEC_COUNT_0_LOW_BW 0x20002c38
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_5_PERIPH_LINKS_0_SEC_COUNT_1_MID_BW 0x20002f60
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_5_PERIPH_LINKS_0_SEC_COUNT_1_LOW_BW 0x20002e00
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_5_PERIPH_LINKS_0_SEC_COUNT_2_MID_BW 0x20003130
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_5_PERIPH_LINKS_0_SEC_COUNT_2_LOW_BW 0x20002fd0
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_5_PERIPH_LINKS_0_SEC_COUNT_3_MID_BW 0x200032f8
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_5_PERIPH_LINKS_0_SEC_COUNT_3_LOW_BW 0x20003198
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_5_PERIPH_LINKS_0_SEC_COUNT_4_MID_BW 0x200034c8
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_5_PERIPH_LINKS_0_SEC_COUNT_4_LOW_BW 0x20003368
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_5_PERIPH_LINKS_0_SEC_COUNT_5_MID_BW 0x20003690
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_5_PERIPH_LINKS_0_SEC_COUNT_5_LOW_BW 0x20003530
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_5_PERIPH_LINKS_1_SEC_COUNT_0_MID_BW 0x200034c8
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_5_PERIPH_LINKS_1_SEC_COUNT_0_LOW_BW 0x20003370
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_5_PERIPH_LINKS_1_SEC_COUNT_1_MID_BW 0x20003698
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_5_PERIPH_LINKS_1_SEC_COUNT_1_LOW_BW 0x20003538
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_5_PERIPH_LINKS_1_SEC_COUNT_2_MID_BW 0x20003860
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_5_PERIPH_LINKS_1_SEC_COUNT_2_LOW_BW 0x20003708
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_5_PERIPH_LINKS_1_SEC_COUNT_3_MID_BW 0x20003a30
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_5_PERIPH_LINKS_1_SEC_COUNT_3_LOW_BW 0x200038d0
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_5_PERIPH_LINKS_1_SEC_COUNT_4_MID_BW 0x20003bf8
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_5_PERIPH_LINKS_1_SEC_COUNT_4_LOW_BW 0x20003aa0
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_5_PERIPH_LINKS_1_SEC_COUNT_5_MID_BW 0x20003dc8
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_5_PERIPH_LINKS_1_SEC_COUNT_5_LOW_BW 0x20003c68
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_6_PERIPH_LINKS_0_SEC_COUNT_0_MID_BW 0x200031c0
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_6_PERIPH_LINKS_0_SEC_COUNT_0_LOW_BW 0x20003020
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_6_PERIPH_LINKS_0_SEC_COUNT_1_MID_BW 0x20003390
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_6_PERIPH_LINKS_0_SEC_COUNT_1_LOW_BW 0x200031e8
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_6_PERIPH_LINKS_0_SEC_COUNT_2_MID_BW 0x20003558
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_6_PERIPH_LINKS_0_SEC_COUNT_2_LOW_BW 0x200033b8
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_6_PERIPH_LINKS_0_SEC_COUNT_3_MID_BW 0x20003728
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_6_PERIPH_LINKS_0_SEC_COUNT_3_LOW_BW 0x20003580
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_6_PERIPH_LINKS_0_SEC_COUNT_4_MID_BW 0x200038f0
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_6_PERIPH_LINKS_0_SEC_COUNT_4_LOW_BW 0x20003750
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_6_PERIPH_LINKS_0_SEC_COUNT_5_MID_BW 0x20003ac0
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_6_PERIPH_LINKS_0_SEC_COUNT_5_LOW_BW 0x20003918
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_6_PERIPH_LINKS_0_SEC_COUNT_6_MID_BW 0x20003c88
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_6_PERIPH_LINKS_0_SEC_COUNT_6_LOW_BW 0x20003ae8
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_6_PERIPH_LINKS_1_SEC_COUNT_0_MID_BW 0x200038f8
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_6_PERIPH_LINKS_1_SEC_COUNT_0_LOW_BW 0x20003750
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_6_PERIPH_LINKS_1_SEC_COUNT_1_MID_BW 0x20003ac0
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_6_PERIPH_LINKS_1_SEC_COUNT_1_LOW_BW 0x20003920
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_6_PERIPH_LINKS_1_SEC_COUNT_2_MID_BW 0x20003c90
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_6_PERIPH_LINKS_1_SEC_COUNT_2_LOW_BW 0x20003ae8
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_6_PERIPH_LINKS_1_SEC_COUNT_3_MID_BW 0x20003e58
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_6_PERIPH_LINKS_1_SEC_COUNT_3_LOW_BW 0x20003cb8
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_6_PERIPH_LINKS_1_SEC_COUNT_4_MID_BW 0x20004028
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_6_PERIPH_LINKS_1_SEC_COUNT_4_LOW_BW 0x20003e80
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_6_PERIPH_LINKS_1_SEC_COUNT_5_MID_BW 0x200041f0
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_6_PERIPH_LINKS_1_SEC_COUNT_5_LOW_BW 0x20004050
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_6_PERIPH_LINKS_1_SEC_COUNT_6_MID_BW 0x200043c0
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_6_PERIPH_LINKS_1_SEC_COUNT_6_LOW_BW 0x20004218
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_7_PERIPH_LINKS_0_SEC_COUNT_0_MID_BW 0x200035f0
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_7_PERIPH_LINKS_0_SEC_COUNT_0_LOW_BW 0x20003408
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_7_PERIPH_LINKS_0_SEC_COUNT_1_MID_BW 0x200037b8
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_7_PERIPH_LINKS_0_SEC_COUNT_1_LOW_BW 0x200035d0
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_7_PERIPH_LINKS_0_SEC_COUNT_2_MID_BW 0x20003988
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_7_PERIPH_LINKS_0_SEC_COUNT_2_LOW_BW 0x200037a0
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_7_PERIPH_LINKS_0_SEC_COUNT_3_MID_BW 0x20003b50
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_7_PERIPH_LINKS_0_SEC_COUNT_3_LOW_BW 0x20003968
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_7_PERIPH_LINKS_0_SEC_COUNT_4_MID_BW 0x20003d20
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_7_PERIPH_LINKS_0_SEC_COUNT_4_LOW_BW 0x20003b38
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_7_PERIPH_LINKS_0_SEC_COUNT_5_MID_BW 0x20003ee8
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_7_PERIPH_LINKS_0_SEC_COUNT_5_LOW_BW 0x20003d00
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_7_PERIPH_LINKS_0_SEC_COUNT_6_MID_BW 0x200040b8
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_7_PERIPH_LINKS_0_SEC_COUNT_6_LOW_BW 0x20003ed0
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_7_PERIPH_LINKS_0_SEC_COUNT_7_MID_BW 0x20004280
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_7_PERIPH_LINKS_0_SEC_COUNT_7_LOW_BW 0x20004098
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_7_PERIPH_LINKS_1_SEC_COUNT_0_MID_BW 0x20003d28
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_7_PERIPH_LINKS_1_SEC_COUNT_0_LOW_BW 0x20003b38
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_7_PERIPH_LINKS_1_SEC_COUNT_1_MID_BW 0x20003ef0
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_7_PERIPH_LINKS_1_SEC_COUNT_1_LOW_BW 0x20003d08
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_7_PERIPH_LINKS_1_SEC_COUNT_2_MID_BW 0x200040c0
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_7_PERIPH_LINKS_1_SEC_COUNT_2_LOW_BW 0x20003ed0
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_7_PERIPH_LINKS_1_SEC_COUNT_3_MID_BW 0x20004288
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_7_PERIPH_LINKS_1_SEC_COUNT_3_LOW_BW 0x200040a0
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_7_PERIPH_LINKS_1_SEC_COUNT_4_MID_BW 0x20004458
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_7_PERIPH_LINKS_1_SEC_COUNT_4_LOW_BW 0x20004268
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_7_PERIPH_LINKS_1_SEC_COUNT_5_MID_BW 0x20004620
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_7_PERIPH_LINKS_1_SEC_COUNT_5_LOW_BW 0x20004438
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_7_PERIPH_LINKS_1_SEC_COUNT_6_MID_BW 0x200047f0
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_7_PERIPH_LINKS_1_SEC_COUNT_6_LOW_BW 0x20004600
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_7_PERIPH_LINKS_1_SEC_COUNT_7_MID_BW 0x200049b8
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_7_PERIPH_LINKS_1_SEC_COUNT_7_LOW_BW 0x200047d0
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_8_PERIPH_LINKS_0_SEC_COUNT_0_MID_BW 0x20003a18
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_8_PERIPH_LINKS_0_SEC_COUNT_0_LOW_BW 0x200037e8
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_8_PERIPH_LINKS_0_SEC_COUNT_1_MID_BW 0x20003be8
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_8_PERIPH_LINKS_0_SEC_COUNT_1_LOW_BW 0x200039b8
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_8_PERIPH_LINKS_0_SEC_COUNT_2_MID_BW 0x20003db0
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_8_PERIPH_LINKS_0_SEC_COUNT_2_LOW_BW 0x20003b80
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_8_PERIPH_LINKS_0_SEC_COUNT_3_MID_BW 0x20003f80
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_8_PERIPH_LINKS_0_SEC_COUNT_3_LOW_BW 0x20003d50
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_8_PERIPH_LINKS_0_SEC_COUNT_4_MID_BW 0x20004148
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_8_PERIPH_LINKS_0_SEC_COUNT_4_LOW_BW 0x20003f18
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_8_PERIPH_LINKS_0_SEC_COUNT_5_MID_BW 0x20004318
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_8_PERIPH_LINKS_0_SEC_COUNT_5_LOW_BW 0x200040e8
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_8_PERIPH_LINKS_0_SEC_COUNT_6_MID_BW 0x200044e0
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_8_PERIPH_LINKS_0_SEC_COUNT_6_LOW_BW 0x200042b0
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_8_PERIPH_LINKS_0_SEC_COUNT_7_MID_BW 0x200046b0
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_8_PERIPH_LINKS_0_SEC_COUNT_7_LOW_BW 0x20004480
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_8_PERIPH_LINKS_0_SEC_COUNT_8_MID_BW 0x20004878
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_8_PERIPH_LINKS_0_SEC_COUNT_8_LOW_BW 0x20004648
|
@ -0,0 +1,64 @@
|
||||
/* Copyright (c) 2013 Nordic Semiconductor. All Rights Reserved.
|
||||
*
|
||||
* The information contained herein is property of Nordic Semiconductor ASA.
|
||||
* Terms and conditions of usage are described in detail in NORDIC
|
||||
* SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
|
||||
*
|
||||
* Licensees are granted free, non-transferable use of the information. NO
|
||||
* WARRANTY of ANY KIND is provided. This heading must NOT be removed from
|
||||
* the file.
|
||||
*
|
||||
*/
|
||||
|
||||
/**@file
|
||||
*
|
||||
* @defgroup ble_stack_handler_types Types definitions for BLE support in SoftDevice handler.
|
||||
* @{
|
||||
* @ingroup softdevice_handler
|
||||
* @brief This file contains the declarations of types required for BLE stack support. These
|
||||
* types will be defined when the preprocessor define BLE_STACK_SUPPORT_REQD is defined.
|
||||
*/
|
||||
|
||||
#ifndef BLE_STACK_HANDLER_TYPES_H__
|
||||
#define BLE_STACK_HANDLER_TYPES_H__
|
||||
|
||||
#ifdef BLE_STACK_SUPPORT_REQD
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "ble.h"
|
||||
#include "nrf_sdm.h"
|
||||
#include "app_error.h"
|
||||
#include "app_util.h"
|
||||
|
||||
#define BLE_STACK_EVT_MSG_BUF_SIZE (sizeof(ble_evt_t) + (GATT_MTU_SIZE_DEFAULT)) /**< Size of BLE event message buffer. This will be provided to the SoftDevice while fetching an event. */
|
||||
#define BLE_STACK_HANDLER_SCHED_EVT_SIZE 0 /**< The size of the scheduler event used by SoftDevice handler when passing BLE events using the @ref app_scheduler. */
|
||||
|
||||
/**@brief Application stack event handler type. */
|
||||
typedef void (*ble_evt_handler_t) (ble_evt_t * p_ble_evt);
|
||||
|
||||
/**@brief Function for registering for BLE events.
|
||||
*
|
||||
* @details The application should use this function to register for receiving BLE events from
|
||||
* the SoftDevice. If the application does not call this function, then any BLE event
|
||||
* that may be generated by the SoftDevice will NOT be fetched. Once the application has
|
||||
* registered for the events, it is not possible to cancel the registration.
|
||||
* However, it is possible to register a different function for handling the events at
|
||||
* any point of time.
|
||||
*
|
||||
* @param[in] ble_evt_handler Function to be called for each received BLE event.
|
||||
*
|
||||
* @retval NRF_SUCCESS Successful registration.
|
||||
* @retval NRF_ERROR_NULL Null pointer provided as input.
|
||||
*/
|
||||
uint32_t softdevice_ble_evt_handler_set(ble_evt_handler_t ble_evt_handler);
|
||||
|
||||
#else
|
||||
|
||||
#define BLE_STACK_EVT_MSG_BUF_SIZE 0 /**< Since the BLE stack support is not required, this is equated to 0, so that the @ref softdevice_handler.h can compute the internal event buffer size without having to care for BLE events.*/
|
||||
#define BLE_STACK_HANDLER_SCHED_EVT_SIZE 0
|
||||
|
||||
#endif // BLE_STACK_SUPPORT_REQD
|
||||
|
||||
#endif // BLE_STACK_HANDLER_TYPES_H__
|
||||
|
||||
/** @} */
|
492
softdevice/6.0.0/common/softdevice_handler/softdevice_handler.c
Normal file
492
softdevice/6.0.0/common/softdevice_handler/softdevice_handler.c
Normal file
@ -0,0 +1,492 @@
|
||||
/* Copyright (c) 2012 Nordic Semiconductor. All Rights Reserved.
|
||||
*
|
||||
* The information contained herein is property of Nordic Semiconductor ASA.
|
||||
* Terms and conditions of usage are described in detail in NORDIC
|
||||
* SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
|
||||
*
|
||||
* Licensees are granted free, non-transferable use of the information. NO
|
||||
* WARRANTY of ANY KIND is provided. This heading must NOT be removed from
|
||||
* the file.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "softdevice_handler.h"
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "nordic_common.h"
|
||||
#include "app_error.h"
|
||||
#include "nrf_assert.h"
|
||||
#include "nrf_nvic.h"
|
||||
#include "nrf.h"
|
||||
#include "nrf_log.h"
|
||||
#include "sdk_common.h"
|
||||
#include "sdk_config.h"
|
||||
#if CLOCK_ENABLED
|
||||
#include "nrf_drv_clock.h"
|
||||
#endif
|
||||
|
||||
#if defined(ANT_STACK_SUPPORT_REQD) && defined(BLE_STACK_SUPPORT_REQD)
|
||||
#include "ant_interface.h"
|
||||
#elif defined(ANT_STACK_SUPPORT_REQD)
|
||||
#include "ant_interface.h"
|
||||
#elif defined(BLE_STACK_SUPPORT_REQD)
|
||||
#include "ble.h"
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(NRF_LOG_USES_RTT) && NRF_LOG_USES_RTT == 1
|
||||
#define SD_HANDLER_LOG(...) NRF_LOG_PRINTF(__VA_ARGS__)
|
||||
#else
|
||||
#define SD_HANDLER_LOG(...)
|
||||
#endif
|
||||
|
||||
#if defined(NRF_LOG_USES_RTT) && NRF_LOG_USES_RTT == 1
|
||||
#define SD_HANDLER_LOG_INIT() NRF_LOG_INIT()
|
||||
#else
|
||||
#define SD_HANDLER_LOG_INIT()
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#define RAM_START_ADDRESS 0x20000000
|
||||
#define SOFTDEVICE_EVT_IRQ SD_EVT_IRQn /**< SoftDevice Event IRQ number. Used for both protocol events and SoC events. */
|
||||
#define SOFTDEVICE_EVT_IRQHandler SD_EVT_IRQHandler
|
||||
#define RAM_TOTAL_SIZE ((NRF_FICR->INFO.RAM)*1024)
|
||||
#define RAM_END_ADDRESS (RAM_START_ADDRESS + RAM_TOTAL_SIZE)
|
||||
|
||||
|
||||
#define SOFTDEVICE_VS_UUID_COUNT 0
|
||||
#define SOFTDEVICE_GATTS_ATTR_TAB_SIZE BLE_GATTS_ATTR_TAB_SIZE_DEFAULT
|
||||
#define SOFTDEVICE_GATTS_SRV_CHANGED 0
|
||||
#define SOFTDEVICE_PERIPH_CONN_COUNT 1
|
||||
#define SOFTDEVICE_CENTRAL_CONN_COUNT 4
|
||||
#define SOFTDEVICE_CENTRAL_SEC_COUNT 1
|
||||
|
||||
/* Global nvic state instance, required by nrf_nvic.h */
|
||||
nrf_nvic_state_t nrf_nvic_state;
|
||||
|
||||
static softdevice_evt_schedule_func_t m_evt_schedule_func; /**< Pointer to function for propagating SoftDevice events to the scheduler. */
|
||||
|
||||
static volatile bool m_softdevice_enabled = false; /**< Variable to indicate whether the SoftDevice is enabled. */
|
||||
|
||||
#ifdef BLE_STACK_SUPPORT_REQD
|
||||
// The following three definitions is needed only if BLE events are needed to be pulled from the stack.
|
||||
static uint8_t * mp_ble_evt_buffer; /**< Buffer for receiving BLE events from the SoftDevice. */
|
||||
static uint16_t m_ble_evt_buffer_size; /**< Size of BLE event buffer. */
|
||||
static ble_evt_handler_t m_ble_evt_handler; /**< Application event handler for handling BLE events. */
|
||||
#endif
|
||||
|
||||
#ifdef ANT_STACK_SUPPORT_REQD
|
||||
// The following two definition is needed only if ANT events are needed to be pulled from the stack.
|
||||
static ant_evt_t m_ant_evt_buffer; /**< Buffer for receiving ANT events from the SoftDevice. */
|
||||
static ant_evt_handler_t m_ant_evt_handler; /**< Application event handler for handling ANT events. */
|
||||
#endif
|
||||
|
||||
static sys_evt_handler_t m_sys_evt_handler; /**< Application event handler for handling System (SOC) events. */
|
||||
|
||||
|
||||
/**@brief Callback function for asserts in the SoftDevice.
|
||||
*
|
||||
* @details A pointer to this function will be passed to the SoftDevice. This function will be
|
||||
* called by the SoftDevice if certain unrecoverable errors occur within the
|
||||
* application or SoftDevice.
|
||||
*
|
||||
* See @ref nrf_fault_handler_t for more details.
|
||||
*
|
||||
* @param[in] id Fault identifier. See @ref NRF_FAULT_IDS.
|
||||
* @param[in] pc The program counter of the instruction that triggered the fault.
|
||||
* @param[in] info Optional additional information regarding the fault. Refer to each fault
|
||||
* identifier for details.
|
||||
*/
|
||||
void softdevice_fault_handler(uint32_t id, uint32_t pc, uint32_t info)
|
||||
{
|
||||
app_error_fault_handler(id, pc, info);
|
||||
}
|
||||
|
||||
|
||||
void intern_softdevice_events_execute(void)
|
||||
{
|
||||
if (!m_softdevice_enabled)
|
||||
{
|
||||
// SoftDevice not enabled. This can be possible if the SoftDevice was enabled by the
|
||||
// application without using this module's API (i.e softdevice_handler_init)
|
||||
|
||||
return;
|
||||
}
|
||||
#if CLOCK_ENABLED
|
||||
bool no_more_soc_evts = false;
|
||||
#else
|
||||
bool no_more_soc_evts = (m_sys_evt_handler == NULL);
|
||||
#endif
|
||||
#ifdef BLE_STACK_SUPPORT_REQD
|
||||
bool no_more_ble_evts = (m_ble_evt_handler == NULL);
|
||||
#endif
|
||||
#ifdef ANT_STACK_SUPPORT_REQD
|
||||
bool no_more_ant_evts = (m_ant_evt_handler == NULL);
|
||||
#endif
|
||||
|
||||
for (;;)
|
||||
{
|
||||
uint32_t err_code;
|
||||
|
||||
if (!no_more_soc_evts)
|
||||
{
|
||||
uint32_t evt_id;
|
||||
|
||||
// Pull event from SOC.
|
||||
err_code = sd_evt_get(&evt_id);
|
||||
|
||||
if (err_code == NRF_ERROR_NOT_FOUND)
|
||||
{
|
||||
no_more_soc_evts = true;
|
||||
}
|
||||
else if (err_code != NRF_SUCCESS)
|
||||
{
|
||||
APP_ERROR_HANDLER(err_code);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Call application's SOC event handler.
|
||||
#if CLOCK_ENABLED
|
||||
nrf_drv_clock_on_soc_event(evt_id);
|
||||
if (m_sys_evt_handler)
|
||||
{
|
||||
m_sys_evt_handler(evt_id);
|
||||
}
|
||||
#else
|
||||
m_sys_evt_handler(evt_id);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef BLE_STACK_SUPPORT_REQD
|
||||
// Fetch BLE Events.
|
||||
if (!no_more_ble_evts)
|
||||
{
|
||||
// Pull event from stack
|
||||
uint16_t evt_len = m_ble_evt_buffer_size;
|
||||
|
||||
err_code = sd_ble_evt_get(mp_ble_evt_buffer, &evt_len);
|
||||
if (err_code == NRF_ERROR_NOT_FOUND)
|
||||
{
|
||||
no_more_ble_evts = true;
|
||||
}
|
||||
else if (err_code != NRF_SUCCESS)
|
||||
{
|
||||
APP_ERROR_HANDLER(err_code);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Call application's BLE stack event handler.
|
||||
m_ble_evt_handler((ble_evt_t *)mp_ble_evt_buffer);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef ANT_STACK_SUPPORT_REQD
|
||||
// Fetch ANT Events.
|
||||
if (!no_more_ant_evts)
|
||||
{
|
||||
// Pull event from stack
|
||||
err_code = sd_ant_event_get(&m_ant_evt_buffer.channel,
|
||||
&m_ant_evt_buffer.event,
|
||||
m_ant_evt_buffer.msg.evt_buffer);
|
||||
if (err_code == NRF_ERROR_NOT_FOUND)
|
||||
{
|
||||
no_more_ant_evts = true;
|
||||
}
|
||||
else if (err_code != NRF_SUCCESS)
|
||||
{
|
||||
APP_ERROR_HANDLER(err_code);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Call application's ANT stack event handler.
|
||||
m_ant_evt_handler(&m_ant_evt_buffer);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (no_more_soc_evts)
|
||||
{
|
||||
// There are no remaining System (SOC) events to be fetched from the SoftDevice.
|
||||
#if defined(ANT_STACK_SUPPORT_REQD) && defined(BLE_STACK_SUPPORT_REQD)
|
||||
// Check if there are any remaining BLE and ANT events.
|
||||
if (no_more_ble_evts && no_more_ant_evts)
|
||||
{
|
||||
break;
|
||||
}
|
||||
#elif defined(BLE_STACK_SUPPORT_REQD)
|
||||
// Check if there are any remaining BLE events.
|
||||
if (no_more_ble_evts)
|
||||
{
|
||||
break;
|
||||
}
|
||||
#elif defined(ANT_STACK_SUPPORT_REQD)
|
||||
// Check if there are any remaining ANT events.
|
||||
if (no_more_ant_evts)
|
||||
{
|
||||
break;
|
||||
}
|
||||
#else
|
||||
// No need to check for BLE or ANT events since there is no support for BLE and ANT
|
||||
// required.
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool softdevice_handler_isEnabled(void)
|
||||
{
|
||||
return m_softdevice_enabled;
|
||||
}
|
||||
|
||||
uint32_t softdevice_handler_init(nrf_clock_lf_cfg_t * p_clock_lf_cfg,
|
||||
void * p_ble_evt_buffer,
|
||||
uint16_t ble_evt_buffer_size,
|
||||
softdevice_evt_schedule_func_t evt_schedule_func)
|
||||
{
|
||||
uint32_t err_code;
|
||||
|
||||
SD_HANDLER_LOG_INIT();
|
||||
|
||||
// Save configuration.
|
||||
#if defined (BLE_STACK_SUPPORT_REQD)
|
||||
// Check that buffer is not NULL.
|
||||
if (p_ble_evt_buffer == NULL)
|
||||
{
|
||||
return NRF_ERROR_INVALID_PARAM;
|
||||
}
|
||||
|
||||
// Check that buffer is correctly aligned.
|
||||
if (!is_word_aligned(p_ble_evt_buffer))
|
||||
{
|
||||
return NRF_ERROR_INVALID_PARAM;
|
||||
}
|
||||
|
||||
mp_ble_evt_buffer = (uint8_t *)p_ble_evt_buffer;
|
||||
m_ble_evt_buffer_size = ble_evt_buffer_size;
|
||||
#else
|
||||
// The variables p_ble_evt_buffer and ble_evt_buffer_size is not needed if BLE Stack support
|
||||
// is not required.
|
||||
UNUSED_PARAMETER(p_ble_evt_buffer);
|
||||
UNUSED_PARAMETER(ble_evt_buffer_size);
|
||||
#endif
|
||||
|
||||
m_evt_schedule_func = evt_schedule_func;
|
||||
|
||||
// Initialize SoftDevice.
|
||||
#if defined(S212) || defined(S332)
|
||||
err_code = sd_softdevice_enable(p_clock_lf_cfg, softdevice_fault_handler, ANT_LICENSE_KEY);
|
||||
#else
|
||||
err_code = sd_softdevice_enable(p_clock_lf_cfg, softdevice_fault_handler);
|
||||
#endif
|
||||
if (err_code != NRF_SUCCESS)
|
||||
{
|
||||
return err_code;
|
||||
}
|
||||
|
||||
m_softdevice_enabled = true;
|
||||
|
||||
// Enable BLE event interrupt (interrupt priority has already been set by the stack).
|
||||
#ifdef SOFTDEVICE_PRESENT
|
||||
return sd_nvic_EnableIRQ((IRQn_Type)SOFTDEVICE_EVT_IRQ);
|
||||
#else
|
||||
//In case of Serialization NVIC must be accessed directly.
|
||||
NVIC_EnableIRQ(SOFTDEVICE_EVT_IRQ);
|
||||
return NRF_SUCCESS;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
uint32_t softdevice_handler_sd_disable(void)
|
||||
{
|
||||
uint32_t err_code = sd_softdevice_disable();
|
||||
|
||||
m_softdevice_enabled = !(err_code == NRF_SUCCESS);
|
||||
|
||||
return err_code;
|
||||
}
|
||||
|
||||
|
||||
#ifdef BLE_STACK_SUPPORT_REQD
|
||||
uint32_t softdevice_ble_evt_handler_set(ble_evt_handler_t ble_evt_handler)
|
||||
{
|
||||
VERIFY_PARAM_NOT_NULL(ble_evt_handler);
|
||||
|
||||
m_ble_evt_handler = ble_evt_handler;
|
||||
|
||||
return NRF_SUCCESS;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef ANT_STACK_SUPPORT_REQD
|
||||
uint32_t softdevice_ant_evt_handler_set(ant_evt_handler_t ant_evt_handler)
|
||||
{
|
||||
VERIFY_PARAM_NOT_NULL(ant_evt_handler);
|
||||
|
||||
m_ant_evt_handler = ant_evt_handler;
|
||||
|
||||
return NRF_SUCCESS;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
uint32_t softdevice_sys_evt_handler_set(sys_evt_handler_t sys_evt_handler)
|
||||
{
|
||||
VERIFY_PARAM_NOT_NULL(sys_evt_handler);
|
||||
|
||||
m_sys_evt_handler = sys_evt_handler;
|
||||
|
||||
return NRF_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**@brief Function for handling the Application's BLE Stack events interrupt.
|
||||
*
|
||||
* @details This function is called whenever an event is ready to be pulled.
|
||||
*/
|
||||
void SOFTDEVICE_EVT_IRQHandler(void)
|
||||
{
|
||||
if (m_evt_schedule_func != NULL)
|
||||
{
|
||||
uint32_t err_code = m_evt_schedule_func();
|
||||
APP_ERROR_CHECK(err_code);
|
||||
}
|
||||
else
|
||||
{
|
||||
intern_softdevice_events_execute();
|
||||
}
|
||||
}
|
||||
|
||||
#if 0 // S132 v500 change API
|
||||
#if defined(BLE_STACK_SUPPORT_REQD)
|
||||
uint32_t softdevice_enable_get_default_config(uint8_t central_links_count,
|
||||
uint8_t periph_links_count,
|
||||
ble_enable_params_t * p_ble_enable_params)
|
||||
{
|
||||
memset(p_ble_enable_params, 0, sizeof(ble_enable_params_t));
|
||||
p_ble_enable_params->common_enable_params.vs_uuid_count = 1;
|
||||
p_ble_enable_params->gatts_enable_params.attr_tab_size = SOFTDEVICE_GATTS_ATTR_TAB_SIZE;
|
||||
p_ble_enable_params->gatts_enable_params.service_changed = SOFTDEVICE_GATTS_SRV_CHANGED;
|
||||
p_ble_enable_params->gap_enable_params.periph_conn_count = periph_links_count;
|
||||
p_ble_enable_params->gap_enable_params.central_conn_count = central_links_count;
|
||||
if (p_ble_enable_params->gap_enable_params.central_conn_count != 0)
|
||||
{
|
||||
p_ble_enable_params->gap_enable_params.central_sec_count = SOFTDEVICE_CENTRAL_SEC_COUNT;
|
||||
}
|
||||
|
||||
return NRF_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
#if defined(NRF_LOG_USES_RTT) && NRF_LOG_USES_RTT == 1
|
||||
static inline uint32_t ram_total_size_get(void)
|
||||
{
|
||||
#ifdef NRF51
|
||||
uint32_t size_ram_blocks = (uint32_t)NRF_FICR->SIZERAMBLOCKS;
|
||||
uint32_t total_ram_size = size_ram_blocks;
|
||||
total_ram_size = total_ram_size*(NRF_FICR->NUMRAMBLOCK);
|
||||
return total_ram_size;
|
||||
#elif defined(NRF52832_XXAA) || defined(NRF52840_XXAA)
|
||||
return RAM_TOTAL_SIZE;
|
||||
#endif /* NRF51 */
|
||||
}
|
||||
|
||||
/*lint --e{528} -save suppress 528: symbol not referenced */
|
||||
/**@brief Function for finding the end address of the RAM.
|
||||
*
|
||||
* @retval ram_end_address Address of the end of the RAM.
|
||||
*/
|
||||
static inline uint32_t ram_end_address_get(void)
|
||||
{
|
||||
uint32_t ram_end_address = (uint32_t)RAM_START_ADDRESS;
|
||||
ram_end_address+= ram_total_size_get();
|
||||
return ram_end_address;
|
||||
}
|
||||
/*lint -restore*/
|
||||
#endif //ENABLE_DEBUG_LOG_SUPPORT
|
||||
|
||||
/*lint --e{10} --e{19} --e{27} --e{40} --e{529} -save suppress Error 27: Illegal character */
|
||||
uint32_t sd_check_ram_start(uint32_t sd_req_ram_start)
|
||||
{
|
||||
#if (defined(S130) || defined(S132) || defined(S332))
|
||||
#if defined ( __CC_ARM )
|
||||
extern uint32_t Image$$RW_IRAM1$$Base;
|
||||
const volatile uint32_t ram_start = (uint32_t) &Image$$RW_IRAM1$$Base;
|
||||
#elif defined ( __ICCARM__ )
|
||||
extern uint32_t __ICFEDIT_region_RAM_start__;
|
||||
volatile uint32_t ram_start = (uint32_t) &__ICFEDIT_region_RAM_start__;
|
||||
#elif defined ( __GNUC__ )
|
||||
extern uint32_t __data_start__;
|
||||
volatile uint32_t ram_start = (uint32_t) &__data_start__;
|
||||
#endif//__CC_ARM
|
||||
if (ram_start != sd_req_ram_start)
|
||||
{
|
||||
#if defined(NRF_LOG_USES_RTT) && NRF_LOG_USES_RTT == 1
|
||||
uint32_t app_ram_size= ram_end_address_get();
|
||||
SD_HANDLER_LOG("RAM START ADDR 0x%x should be adjusted to 0x%x\r\n",
|
||||
ram_start,
|
||||
sd_req_ram_start);
|
||||
app_ram_size -= sd_req_ram_start;
|
||||
SD_HANDLER_LOG("RAM SIZE should be adjusted to 0x%x \r\n",
|
||||
app_ram_size);
|
||||
#endif //NRF_LOG_USES_RTT
|
||||
return NRF_SUCCESS;
|
||||
}
|
||||
#endif//defined(S130) || defined(S132) || defined(S332)
|
||||
return NRF_SUCCESS;
|
||||
}
|
||||
|
||||
uint32_t softdevice_enable(ble_enable_params_t * p_ble_enable_params)
|
||||
{
|
||||
#if (defined(S130) || defined(S132) || defined(S332))
|
||||
uint32_t err_code;
|
||||
uint32_t app_ram_base;
|
||||
|
||||
#if defined ( __CC_ARM )
|
||||
extern uint32_t Image$$RW_IRAM1$$Base;
|
||||
const volatile uint32_t ram_start = (uint32_t) &Image$$RW_IRAM1$$Base;
|
||||
#elif defined ( __ICCARM__ )
|
||||
extern uint32_t __ICFEDIT_region_RAM_start__;
|
||||
volatile uint32_t ram_start = (uint32_t) &__ICFEDIT_region_RAM_start__;
|
||||
#elif defined ( __GNUC__ )
|
||||
extern uint32_t __data_start__;
|
||||
volatile uint32_t ram_start = (uint32_t) &__data_start__;
|
||||
#endif
|
||||
|
||||
app_ram_base = ram_start;
|
||||
SD_HANDLER_LOG("sd_ble_enable: RAM START at 0x%x\r\n",
|
||||
app_ram_base);
|
||||
err_code = sd_ble_enable(p_ble_enable_params, &app_ram_base);
|
||||
|
||||
#if defined(NRF_LOG_USES_RTT) && NRF_LOG_USES_RTT == 1
|
||||
if (app_ram_base != ram_start)
|
||||
{
|
||||
uint32_t app_ram_size= ram_end_address_get();
|
||||
SD_HANDLER_LOG("sd_ble_enable: app_ram_base should be adjusted to 0x%x\r\n",
|
||||
app_ram_base);
|
||||
app_ram_size -= app_ram_base;
|
||||
SD_HANDLER_LOG("ram size should be adjusted to 0x%x \r\n",
|
||||
app_ram_size);
|
||||
}
|
||||
else if (err_code != NRF_SUCCESS)
|
||||
{
|
||||
SD_HANDLER_LOG("sd_ble_enable: error 0x%x\r\n", err_code);
|
||||
while(1);
|
||||
}
|
||||
#endif // NRF_LOG_USES_RTT
|
||||
return err_code;
|
||||
#else
|
||||
return NRF_SUCCESS;
|
||||
#endif //defined(S130) || defined(S132) || defined(S332)
|
||||
|
||||
}
|
||||
/*lint -restore*/
|
||||
#endif
|
||||
|
||||
#endif //BLE_STACK_SUPPORT_REQD
|
215
softdevice/6.0.0/common/softdevice_handler/softdevice_handler.h
Normal file
215
softdevice/6.0.0/common/softdevice_handler/softdevice_handler.h
Normal file
@ -0,0 +1,215 @@
|
||||
/* Copyright (c) 2013 Nordic Semiconductor. All Rights Reserved.
|
||||
*
|
||||
* The information contained herein is property of Nordic Semiconductor ASA.
|
||||
* Terms and conditions of usage are described in detail in NORDIC
|
||||
* SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
|
||||
*
|
||||
* Licensees are granted free, non-transferable use of the information. NO
|
||||
* WARRANTY of ANY KIND is provided. This heading must NOT be removed from
|
||||
* the file.
|
||||
*
|
||||
*/
|
||||
|
||||
/** @file
|
||||
*
|
||||
* @defgroup softdevice_handler SoftDevice Event Handler
|
||||
* @{
|
||||
* @ingroup app_common
|
||||
* @brief API for initializing and disabling the SoftDevice
|
||||
*
|
||||
* @details This API contains the functions and defines exposed by the @ref lib_softdevice_handler.
|
||||
* For more information on the library and how the application should use it, please refer
|
||||
* @ref lib_softdevice_handler.
|
||||
*
|
||||
* @note Use the USE_SCHEDULER parameter of the SOFTDEVICE_HANDLER_INIT() macro to select if
|
||||
* the @ref app_scheduler is to be used or not.
|
||||
*
|
||||
* @note Even if the scheduler is not used, softdevice_handler.h will include app_scheduler.h.
|
||||
* So when compiling, app_scheduler.h must be available in one of the compiler include
|
||||
* paths.
|
||||
*/
|
||||
|
||||
#ifndef SOFTDEVICE_HANDLER_H__
|
||||
#define SOFTDEVICE_HANDLER_H__
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "nordic_common.h"
|
||||
#include "nrf_sdm.h"
|
||||
#include "app_error.h"
|
||||
#include "app_util.h"
|
||||
#include "ble_stack_handler_types.h"
|
||||
#include "ant_stack_handler_types.h"
|
||||
#if defined(BLE_STACK_SUPPORT_REQD)
|
||||
#include "ble.h"
|
||||
#endif
|
||||
#include "app_ram_base.h"
|
||||
#define SOFTDEVICE_SCHED_EVT_SIZE 0 /**< Size of button events being passed through the scheduler (is to be used for computing the maximum size of scheduler events). For SoftDevice events, this size is 0, since the events are being pulled in the event handler. */
|
||||
#define SYS_EVT_MSG_BUF_SIZE sizeof(uint32_t) /**< Size of System (SOC) event message buffer. */
|
||||
|
||||
|
||||
#define CHECK_RAM_START_ADDR_INTERN(CENTRAL_LINK_COUNT, PERIPHERAL_LINK_COUNT) \
|
||||
do{ \
|
||||
uint32_t app_ram_start_addr = APP_RAM_BASE_CENTRAL_LINKS_##CENTRAL_LINK_COUNT##_PERIPH_LINKS_##PERIPHERAL_LINK_COUNT##_SEC_COUNT_0_MID_BW; \
|
||||
err_code = sd_check_ram_start(app_ram_start_addr); \
|
||||
APP_ERROR_CHECK(err_code); \
|
||||
} while (0)
|
||||
|
||||
/** @brief Macro for checking the RAM requirement of the SoftDevice */
|
||||
#define CHECK_RAM_START_ADDR(C_LINK_CNT, P_LINK_CNT) CHECK_RAM_START_ADDR_INTERN(C_LINK_CNT, P_LINK_CNT)
|
||||
|
||||
|
||||
/**@brief Function for checking the RAM requirement of the SoftDevice.
|
||||
*
|
||||
* @details Call this function to check if the project settings have the correct RAM start address in respect to what the SoftDevice requires.
|
||||
*
|
||||
* @note This function is called using the CHECK_RAM_START_ADDR_INTERN macro and should not be called directly.
|
||||
*/
|
||||
uint32_t sd_check_ram_start(uint32_t sd_req_ram_start);
|
||||
|
||||
/**@brief Type of function for passing events from the stack handler module to the scheduler. */
|
||||
typedef uint32_t (*softdevice_evt_schedule_func_t) (void);
|
||||
|
||||
/**@brief Application System (SOC) event handler type. */
|
||||
typedef void (*sys_evt_handler_t) (uint32_t evt_id);
|
||||
|
||||
|
||||
/**@brief Macro for initializing the stack event handler.
|
||||
*
|
||||
* @details It will handle dimensioning and allocation of the memory buffer required for reading
|
||||
* events from the stack, making sure the buffer is correctly aligned. It will also
|
||||
* connect the stack event handler to the scheduler/RTOS (if specified).
|
||||
*
|
||||
* @param[in] CLOCK_SOURCE Low frequency clock source and accuracy (type nrf_clock_lf_cfg_t_t,
|
||||
* see sd_softdevice_enable() for details).
|
||||
* @param[in] EVT_HANDLER scheduler/RTOS event handler function.
|
||||
*
|
||||
* @note Since this macro allocates a buffer, it must only be called once (it is OK to call it
|
||||
* several times as long as it is from the same location, that is to do a
|
||||
* reinitialization).
|
||||
*/
|
||||
/*lint -emacro(506, SOFTDEVICE_HANDLER_INIT) */ /* Suppress "Constant value Boolean */
|
||||
#define SOFTDEVICE_HANDLER_INIT(CLOCK_SOURCE, \
|
||||
EVT_HANDLER) \
|
||||
do \
|
||||
{ \
|
||||
__ALIGN(4) static uint8_t BLE_EVT_BUFFER[ BLE_EVT_LEN_MAX(BLE_GATT_ATT_MTU_DEFAULT) ]; \
|
||||
uint32_t ERR_CODE; \
|
||||
ERR_CODE = softdevice_handler_init((CLOCK_SOURCE), \
|
||||
BLE_EVT_BUFFER, \
|
||||
sizeof(BLE_EVT_BUFFER), \
|
||||
EVT_HANDLER); \
|
||||
APP_ERROR_CHECK(ERR_CODE); \
|
||||
} while (0)
|
||||
|
||||
/**
|
||||
* @brief Function for retrieving the information about SD state
|
||||
*
|
||||
* The information about current state of softdevice.
|
||||
* @retval false SD is not initialized and SD commands should not be called.
|
||||
* @retval true SD is already initialized
|
||||
*/
|
||||
bool softdevice_handler_isEnabled(void);
|
||||
|
||||
/**@brief Function for initializing the stack handler module.
|
||||
*
|
||||
* @details Enables the SoftDevice and the stack event interrupt handler.
|
||||
*
|
||||
* @note This function must be called before calling any function in the SoftDevice API.
|
||||
*
|
||||
* @note Normally initialization should be done using the SOFTDEVICE_HANDLER_INIT() macro,
|
||||
* as that will both allocate the event buffer, and also align the buffer correctly.
|
||||
*
|
||||
* @param[in] p_clock_lf_cfg Low frequency clock source to be used by the SoftDevice.
|
||||
* @param[in] p_ble_evt_buffer Buffer for holding one BLE stack event. Since heap is not being
|
||||
* used, this buffer must be provided by the application. The
|
||||
* buffer must be large enough to hold the biggest stack event the
|
||||
* application is supposed to handle. The buffer must be aligned to
|
||||
* a 4 byte boundary. This parameter is unused if BLE stack support
|
||||
* is not required.
|
||||
* @param[in] ble_evt_buffer_size Size of SoftDevice BLE event buffer. This parameter is unused if
|
||||
* BLE stack support is not required.
|
||||
* @param[in] evt_schedule_func Function for passing events to the scheduler. Point to
|
||||
* ble_ant_stack_evt_schedule() to connect to the scheduler.
|
||||
* Set to NULL to make the stack handler module call the event
|
||||
* handler directly from the stack event interrupt handler.
|
||||
*
|
||||
* @retval NRF_SUCCESS Successful initialization.
|
||||
* @retval NRF_ERROR_INVALID_PARAM Invalid parameter (buffer not aligned to a 4 byte
|
||||
* boundary) or NULL.
|
||||
*/
|
||||
uint32_t softdevice_handler_init(nrf_clock_lf_cfg_t * p_clock_lf_cfg,
|
||||
void * p_ble_evt_buffer,
|
||||
uint16_t ble_evt_buffer_size,
|
||||
softdevice_evt_schedule_func_t evt_schedule_func);
|
||||
|
||||
|
||||
/**@brief Function for disabling the SoftDevice.
|
||||
*
|
||||
* @details This function will disable the SoftDevice. It will also update the internal state
|
||||
* of this module.
|
||||
*/
|
||||
uint32_t softdevice_handler_sd_disable(void);
|
||||
|
||||
/**@brief Function for registering for System (SOC) events.
|
||||
*
|
||||
* @details The application should use this function to register for receiving System (SOC)
|
||||
* events from the SoftDevice. If the application does not call this function, then any
|
||||
* System (SOC) events that may be generated by the SoftDevice will NOT be fetched. Once
|
||||
* the application has registered for the events, it is not possible to possible to
|
||||
* cancel the registration. However, it is possible to register a different function for
|
||||
* handling the events at any point of time.
|
||||
*
|
||||
* @param[in] sys_evt_handler Function to be called for each received System (SOC) event.
|
||||
*
|
||||
* @retval NRF_SUCCESS Successful registration.
|
||||
* @retval NRF_ERROR_NULL Null pointer provided as input.
|
||||
*/
|
||||
uint32_t softdevice_sys_evt_handler_set(sys_evt_handler_t sys_evt_handler);
|
||||
|
||||
#if 0 // S132 v500 change API
|
||||
#if defined(BLE_STACK_SUPPORT_REQD)
|
||||
/**@brief Function for fetching the default enable parameters for the SoftDevice.
|
||||
*
|
||||
* @details The default enable parameters will work for most projects in the SDK.
|
||||
* They are not optimized with regards to RAM use. This function is meant as a way to abstract the
|
||||
* details of p_ble_enable_params needed by @ref softdevice_enable. You might want to tweak
|
||||
* the struct returned by this function or fill in the entire ble_enable_params_t
|
||||
* instead of fetching it from this function.
|
||||
*
|
||||
* @param[in] central_links_count Number of central links used by the application.
|
||||
* @param[in] periph_links_count Number of peripheral links used by the application.
|
||||
* @param[out] p_ble_enable_params Default ble_enable_params_t to be used by @ref softdevice_enable.
|
||||
*
|
||||
* @retval NRF_SUCCESS If the operation was successful.
|
||||
*/
|
||||
uint32_t softdevice_enable_get_default_config(uint8_t central_links_count,
|
||||
uint8_t periph_links_count,
|
||||
ble_enable_params_t * p_ble_enable_params);
|
||||
|
||||
/**@brief Function for enabling the SoftDevice.
|
||||
*
|
||||
* @details This function calls the @ref sd_ble_enable SVC call. It has been abstracted to give
|
||||
* feedback on the app_ram_base. If the app_ram_base is too low, this function will
|
||||
* return an error. Using a app_ram_base that is too high will not fail, but will
|
||||
* result in RAM that is never used. If the DEBUG macro is enabled, this
|
||||
* function will provide the correct app_ram_base as mandated by the SoftDevice.
|
||||
* This is useful to tweak the RAM use of your application.
|
||||
*
|
||||
* @param[in] p_ble_enable_params Parameters for configuring links and bandwidths.
|
||||
*
|
||||
* @retval NRF_SUCCESS If the operation was successful.
|
||||
*/
|
||||
uint32_t softdevice_enable(ble_enable_params_t * p_ble_enable_params);
|
||||
#endif //BLE_STACK_SUPPORT_REQD
|
||||
#endif
|
||||
|
||||
// Functions for connecting the Stack Event Handler to the scheduler:
|
||||
/**@cond NO_DOXYGEN */
|
||||
void intern_softdevice_events_execute(void);
|
||||
|
||||
|
||||
/**@endcond */
|
||||
|
||||
#endif // SOFTDEVICE_HANDLER_H__
|
||||
|
||||
/** @} */
|
@ -0,0 +1,26 @@
|
||||
/* Copyright (c) 2015 Nordic Semiconductor. All Rights Reserved.
|
||||
*
|
||||
* The information contained herein is property of Nordic Semiconductor ASA.
|
||||
* Terms and conditions of usage are described in detail in NORDIC
|
||||
* SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
|
||||
*
|
||||
* Licensees are granted free, non-transferable use of the information. NO
|
||||
* WARRANTY of ANY KIND is provided. This heading must NOT be removed from
|
||||
* the file.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "softdevice_handler_appsh.h"
|
||||
#include "app_scheduler.h"
|
||||
#include <string.h>
|
||||
|
||||
void softdevice_evt_get(void * p_event_data, uint16_t event_size)
|
||||
{
|
||||
APP_ERROR_CHECK_BOOL(event_size == 0);
|
||||
intern_softdevice_events_execute();
|
||||
}
|
||||
|
||||
uint32_t softdevice_evt_schedule(void)
|
||||
{
|
||||
return app_sched_event_put(NULL, 0, softdevice_evt_get);
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
/* Copyright (c) 2014 Nordic Semiconductor. All Rights Reserved.
|
||||
*
|
||||
* The information contained herein is property of Nordic Semiconductor ASA.
|
||||
* Terms and conditions of usage are described in detail in NORDIC
|
||||
* SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
|
||||
*
|
||||
* Licensees are granted free, non-transferable use of the information. NO
|
||||
* WARRANTY of ANY KIND is provided. This heading must NOT be removed from
|
||||
* the file.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef SOFTDEVICE_HANDLER_APPSH_H
|
||||
#define SOFTDEVICE_HANDLER_APPSH_H
|
||||
|
||||
#include "softdevice_handler.h"
|
||||
#include <stdint.h>
|
||||
|
||||
#define SOFTDEVICE_HANDLER_APPSH_INIT(CLOCK_SOURCE,USE_SCHEDULER) \
|
||||
SOFTDEVICE_HANDLER_INIT(CLOCK_SOURCE,(USE_SCHEDULER) ? softdevice_evt_schedule : NULL)
|
||||
|
||||
uint32_t softdevice_evt_schedule(void);
|
||||
|
||||
#endif //SOFTDEVICE_HANDLER_APPSH_H
|
Reference in New Issue
Block a user