mirror of
https://gitee.com/muyuchl/nrf51_2in13_epd.git
synced 2025-12-15 10:18:13 +08:00
copy project from century 2in6 esl project
This commit is contained in:
@@ -0,0 +1,111 @@
|
||||
/**
|
||||
* Copyright (c) 2013 - 2017, 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 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 __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifdef ANT_STACK_SUPPORT_REQD
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdint.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
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // ANT_STACK_HANDLER_TYPES_H__
|
||||
|
||||
/** @} */
|
||||
188
COMPONENTS/softdevice/common/softdevice_handler/app_ram_base.h
Normal file
188
COMPONENTS/softdevice/common/softdevice_handler/app_ram_base.h
Normal file
@@ -0,0 +1,188 @@
|
||||
/**
|
||||
* Copyright (c) 2013 - 2017, 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.
|
||||
*
|
||||
*/
|
||||
|
||||
// ble_enable param app_ram_base
|
||||
|
||||
#ifndef APP_RAM_BASE_H__
|
||||
#define APP_RAM_BASE_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef S130
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_0_PERIPH_LINKS_0_SEC_COUNT_0_VS_UUID_COUNT_1_MID_BW 0x20001870
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_0_PERIPH_LINKS_0_SEC_COUNT_0_VS_UUID_COUNT_10_MID_BW 0x20001900
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_0_PERIPH_LINKS_1_SEC_COUNT_0_VS_UUID_COUNT_1_MID_BW 0x20001fe8
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_0_PERIPH_LINKS_1_SEC_COUNT_0_VS_UUID_COUNT_10_MID_BW 0x20002078
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_1_PERIPH_LINKS_0_SEC_COUNT_0_VS_UUID_COUNT_1_MID_BW 0x20001ce0
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_1_PERIPH_LINKS_0_SEC_COUNT_0_VS_UUID_COUNT_10_MID_BW 0x20001d70
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_1_PERIPH_LINKS_0_SEC_COUNT_1_VS_UUID_COUNT_1_MID_BW 0x20001eb0
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_1_PERIPH_LINKS_0_SEC_COUNT_1_VS_UUID_COUNT_10_MID_BW 0x20001f40
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_1_PERIPH_LINKS_1_SEC_COUNT_0_VS_UUID_COUNT_1_MID_BW 0x20002418
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_1_PERIPH_LINKS_1_SEC_COUNT_0_VS_UUID_COUNT_10_MID_BW 0x200024a8
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_1_PERIPH_LINKS_1_SEC_COUNT_1_VS_UUID_COUNT_1_MID_BW 0x200025e0
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_1_PERIPH_LINKS_1_SEC_COUNT_1_VS_UUID_COUNT_10_MID_BW 0x20002670
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_2_PERIPH_LINKS_0_SEC_COUNT_0_VS_UUID_COUNT_1_MID_BW 0x20002110
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_2_PERIPH_LINKS_0_SEC_COUNT_0_VS_UUID_COUNT_10_MID_BW 0x200021a0
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_2_PERIPH_LINKS_0_SEC_COUNT_1_VS_UUID_COUNT_1_MID_BW 0x200022d8
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_2_PERIPH_LINKS_0_SEC_COUNT_1_VS_UUID_COUNT_10_MID_BW 0x20002368
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_2_PERIPH_LINKS_1_SEC_COUNT_0_VS_UUID_COUNT_1_MID_BW 0x20002840
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_2_PERIPH_LINKS_1_SEC_COUNT_0_VS_UUID_COUNT_10_MID_BW 0x200028d0
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_2_PERIPH_LINKS_1_SEC_COUNT_1_VS_UUID_COUNT_1_MID_BW 0x20002a10
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_2_PERIPH_LINKS_1_SEC_COUNT_1_VS_UUID_COUNT_10_MID_BW 0x20002aa0
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_3_PERIPH_LINKS_0_SEC_COUNT_0_VS_UUID_COUNT_1_MID_BW 0x20002538
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_3_PERIPH_LINKS_0_SEC_COUNT_0_VS_UUID_COUNT_10_MID_BW 0x200025c8
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_3_PERIPH_LINKS_0_SEC_COUNT_1_VS_UUID_COUNT_1_MID_BW 0x20002708
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_3_PERIPH_LINKS_0_SEC_COUNT_1_VS_UUID_COUNT_10_MID_BW 0x20002798
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_3_PERIPH_LINKS_1_SEC_COUNT_0_VS_UUID_COUNT_1_MID_BW 0x20002c70
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_3_PERIPH_LINKS_1_SEC_COUNT_0_VS_UUID_COUNT_10_MID_BW 0x20002d00
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_3_PERIPH_LINKS_1_SEC_COUNT_1_VS_UUID_COUNT_1_MID_BW 0x20002e40
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_3_PERIPH_LINKS_1_SEC_COUNT_1_VS_UUID_COUNT_10_MID_BW 0x20002ed0
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_4_PERIPH_LINKS_0_SEC_COUNT_0_VS_UUID_COUNT_1_MID_BW 0x20002968
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_4_PERIPH_LINKS_0_SEC_COUNT_0_VS_UUID_COUNT_10_MID_BW 0x200029f8
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_4_PERIPH_LINKS_0_SEC_COUNT_1_VS_UUID_COUNT_1_MID_BW 0x20002b30
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_4_PERIPH_LINKS_0_SEC_COUNT_1_VS_UUID_COUNT_10_MID_BW 0x20002bc0
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_4_PERIPH_LINKS_1_SEC_COUNT_0_VS_UUID_COUNT_1_MID_BW 0x200030a0
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_4_PERIPH_LINKS_1_SEC_COUNT_0_VS_UUID_COUNT_10_MID_BW 0x20003130
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_4_PERIPH_LINKS_1_SEC_COUNT_1_VS_UUID_COUNT_1_MID_BW 0x20003268
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_4_PERIPH_LINKS_1_SEC_COUNT_1_VS_UUID_COUNT_10_MID_BW 0x200032f8
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_5_PERIPH_LINKS_0_SEC_COUNT_0_VS_UUID_COUNT_1_MID_BW 0x20002d98
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_5_PERIPH_LINKS_0_SEC_COUNT_0_VS_UUID_COUNT_10_MID_BW 0x20002e28
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_5_PERIPH_LINKS_0_SEC_COUNT_1_VS_UUID_COUNT_1_MID_BW 0x20002f60
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_5_PERIPH_LINKS_0_SEC_COUNT_1_VS_UUID_COUNT_10_MID_BW 0x20002ff0
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_5_PERIPH_LINKS_1_SEC_COUNT_0_VS_UUID_COUNT_1_MID_BW 0x200034c8
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_5_PERIPH_LINKS_1_SEC_COUNT_0_VS_UUID_COUNT_10_MID_BW 0x20003558
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_5_PERIPH_LINKS_1_SEC_COUNT_1_VS_UUID_COUNT_1_MID_BW 0x20003698
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_5_PERIPH_LINKS_1_SEC_COUNT_1_VS_UUID_COUNT_10_MID_BW 0x20003728
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_6_PERIPH_LINKS_0_SEC_COUNT_0_VS_UUID_COUNT_1_MID_BW 0x200031c0
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_6_PERIPH_LINKS_0_SEC_COUNT_0_VS_UUID_COUNT_10_MID_BW 0x20003250
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_6_PERIPH_LINKS_0_SEC_COUNT_1_VS_UUID_COUNT_1_MID_BW 0x20003390
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_6_PERIPH_LINKS_0_SEC_COUNT_1_VS_UUID_COUNT_10_MID_BW 0x20003420
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_6_PERIPH_LINKS_1_SEC_COUNT_0_VS_UUID_COUNT_1_MID_BW 0x200038f8
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_6_PERIPH_LINKS_1_SEC_COUNT_0_VS_UUID_COUNT_10_MID_BW 0x20003988
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_6_PERIPH_LINKS_1_SEC_COUNT_1_VS_UUID_COUNT_1_MID_BW 0x20003ac0
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_6_PERIPH_LINKS_1_SEC_COUNT_1_VS_UUID_COUNT_10_MID_BW 0x20003b50
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_7_PERIPH_LINKS_0_SEC_COUNT_0_VS_UUID_COUNT_1_MID_BW 0x200035f0
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_7_PERIPH_LINKS_0_SEC_COUNT_0_VS_UUID_COUNT_10_MID_BW 0x20003680
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_7_PERIPH_LINKS_0_SEC_COUNT_1_VS_UUID_COUNT_1_MID_BW 0x200037b8
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_7_PERIPH_LINKS_0_SEC_COUNT_1_VS_UUID_COUNT_10_MID_BW 0x20003848
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_7_PERIPH_LINKS_1_SEC_COUNT_0_VS_UUID_COUNT_1_MID_BW 0x20003d28
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_7_PERIPH_LINKS_1_SEC_COUNT_0_VS_UUID_COUNT_10_MID_BW 0x20003db8
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_7_PERIPH_LINKS_1_SEC_COUNT_1_VS_UUID_COUNT_1_MID_BW 0x20003ef0
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_7_PERIPH_LINKS_1_SEC_COUNT_1_VS_UUID_COUNT_10_MID_BW 0x20003f80
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_8_PERIPH_LINKS_0_SEC_COUNT_0_VS_UUID_COUNT_1_MID_BW 0x20003a18
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_8_PERIPH_LINKS_0_SEC_COUNT_0_VS_UUID_COUNT_10_MID_BW 0x20003aa8
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_8_PERIPH_LINKS_0_SEC_COUNT_1_VS_UUID_COUNT_1_MID_BW 0x20003be8
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_8_PERIPH_LINKS_0_SEC_COUNT_1_VS_UUID_COUNT_10_MID_BW 0x20003c78
|
||||
#elif defined(S132) || defined(S332)
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_0_PERIPH_LINKS_0_SEC_COUNT_0_VS_UUID_COUNT_1_MID_BW 0x20001930
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_0_PERIPH_LINKS_0_SEC_COUNT_0_VS_UUID_COUNT_10_MID_BW 0x200019c0
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_0_PERIPH_LINKS_1_SEC_COUNT_0_VS_UUID_COUNT_1_MID_BW 0x20002128
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_0_PERIPH_LINKS_1_SEC_COUNT_0_VS_UUID_COUNT_10_MID_BW 0x200021b8
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_1_PERIPH_LINKS_0_SEC_COUNT_0_VS_UUID_COUNT_1_MID_BW 0x20001e18
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_1_PERIPH_LINKS_0_SEC_COUNT_0_VS_UUID_COUNT_10_MID_BW 0x20001ea8
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_1_PERIPH_LINKS_0_SEC_COUNT_1_VS_UUID_COUNT_1_MID_BW 0x20001fe8
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_1_PERIPH_LINKS_0_SEC_COUNT_1_VS_UUID_COUNT_10_MID_BW 0x20002078
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_1_PERIPH_LINKS_1_SEC_COUNT_0_VS_UUID_COUNT_1_MID_BW 0x200025d0
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_1_PERIPH_LINKS_1_SEC_COUNT_0_VS_UUID_COUNT_10_MID_BW 0x20002660
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_1_PERIPH_LINKS_1_SEC_COUNT_1_VS_UUID_COUNT_1_MID_BW 0x20002798
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_1_PERIPH_LINKS_1_SEC_COUNT_1_VS_UUID_COUNT_10_MID_BW 0x20002828
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_2_PERIPH_LINKS_0_SEC_COUNT_0_VS_UUID_COUNT_1_MID_BW 0x200022c0
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_2_PERIPH_LINKS_0_SEC_COUNT_0_VS_UUID_COUNT_10_MID_BW 0x20002350
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_2_PERIPH_LINKS_0_SEC_COUNT_1_VS_UUID_COUNT_1_MID_BW 0x20002490
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_2_PERIPH_LINKS_0_SEC_COUNT_1_VS_UUID_COUNT_10_MID_BW 0x20002520
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_2_PERIPH_LINKS_1_SEC_COUNT_0_VS_UUID_COUNT_1_MID_BW 0x20002a78
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_2_PERIPH_LINKS_1_SEC_COUNT_0_VS_UUID_COUNT_10_MID_BW 0x20002b08
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_2_PERIPH_LINKS_1_SEC_COUNT_1_VS_UUID_COUNT_1_MID_BW 0x20002c40
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_2_PERIPH_LINKS_1_SEC_COUNT_1_VS_UUID_COUNT_10_MID_BW 0x20002cd0
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_3_PERIPH_LINKS_0_SEC_COUNT_0_VS_UUID_COUNT_1_MID_BW 0x20002768
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_3_PERIPH_LINKS_0_SEC_COUNT_0_VS_UUID_COUNT_10_MID_BW 0x200027f8
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_3_PERIPH_LINKS_0_SEC_COUNT_1_VS_UUID_COUNT_1_MID_BW 0x20002938
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_3_PERIPH_LINKS_0_SEC_COUNT_1_VS_UUID_COUNT_10_MID_BW 0x200029c8
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_3_PERIPH_LINKS_1_SEC_COUNT_0_VS_UUID_COUNT_1_MID_BW 0x20002f20
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_3_PERIPH_LINKS_1_SEC_COUNT_0_VS_UUID_COUNT_10_MID_BW 0x20002fb0
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_3_PERIPH_LINKS_1_SEC_COUNT_1_VS_UUID_COUNT_1_MID_BW 0x200030e8
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_3_PERIPH_LINKS_1_SEC_COUNT_1_VS_UUID_COUNT_10_MID_BW 0x20003178
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_4_PERIPH_LINKS_0_SEC_COUNT_0_VS_UUID_COUNT_1_MID_BW 0x20002c10
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_4_PERIPH_LINKS_0_SEC_COUNT_0_VS_UUID_COUNT_10_MID_BW 0x20002ca0
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_4_PERIPH_LINKS_0_SEC_COUNT_1_VS_UUID_COUNT_1_MID_BW 0x20002de0
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_4_PERIPH_LINKS_0_SEC_COUNT_1_VS_UUID_COUNT_10_MID_BW 0x20002e70
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_4_PERIPH_LINKS_1_SEC_COUNT_0_VS_UUID_COUNT_1_MID_BW 0x200033c8
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_4_PERIPH_LINKS_1_SEC_COUNT_0_VS_UUID_COUNT_10_MID_BW 0x20003458
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_4_PERIPH_LINKS_1_SEC_COUNT_1_VS_UUID_COUNT_1_MID_BW 0x20003590
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_4_PERIPH_LINKS_1_SEC_COUNT_1_VS_UUID_COUNT_10_MID_BW 0x20003620
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_5_PERIPH_LINKS_0_SEC_COUNT_0_VS_UUID_COUNT_1_MID_BW 0x200030b8
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_5_PERIPH_LINKS_0_SEC_COUNT_0_VS_UUID_COUNT_10_MID_BW 0x20003148
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_5_PERIPH_LINKS_0_SEC_COUNT_1_VS_UUID_COUNT_1_MID_BW 0x20003288
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_5_PERIPH_LINKS_0_SEC_COUNT_1_VS_UUID_COUNT_10_MID_BW 0x20003318
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_5_PERIPH_LINKS_1_SEC_COUNT_0_VS_UUID_COUNT_1_MID_BW 0x20003870
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_5_PERIPH_LINKS_1_SEC_COUNT_0_VS_UUID_COUNT_10_MID_BW 0x20003900
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_5_PERIPH_LINKS_1_SEC_COUNT_1_VS_UUID_COUNT_1_MID_BW 0x20003a38
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_5_PERIPH_LINKS_1_SEC_COUNT_1_VS_UUID_COUNT_10_MID_BW 0x20003ac8
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_6_PERIPH_LINKS_0_SEC_COUNT_0_VS_UUID_COUNT_1_MID_BW 0x20003560
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_6_PERIPH_LINKS_0_SEC_COUNT_0_VS_UUID_COUNT_10_MID_BW 0x200035f0
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_6_PERIPH_LINKS_0_SEC_COUNT_1_VS_UUID_COUNT_1_MID_BW 0x20003730
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_6_PERIPH_LINKS_0_SEC_COUNT_1_VS_UUID_COUNT_10_MID_BW 0x200037c0
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_6_PERIPH_LINKS_1_SEC_COUNT_0_VS_UUID_COUNT_1_MID_BW 0x20003d18
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_6_PERIPH_LINKS_1_SEC_COUNT_0_VS_UUID_COUNT_10_MID_BW 0x20003da8
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_6_PERIPH_LINKS_1_SEC_COUNT_1_VS_UUID_COUNT_1_MID_BW 0x20003ee0
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_6_PERIPH_LINKS_1_SEC_COUNT_1_VS_UUID_COUNT_10_MID_BW 0x20003f70
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_7_PERIPH_LINKS_0_SEC_COUNT_0_VS_UUID_COUNT_1_MID_BW 0x20003a08
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_7_PERIPH_LINKS_0_SEC_COUNT_0_VS_UUID_COUNT_10_MID_BW 0x20003a98
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_7_PERIPH_LINKS_0_SEC_COUNT_1_VS_UUID_COUNT_1_MID_BW 0x20003bd8
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_7_PERIPH_LINKS_0_SEC_COUNT_1_VS_UUID_COUNT_10_MID_BW 0x20003c68
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_7_PERIPH_LINKS_1_SEC_COUNT_0_VS_UUID_COUNT_1_MID_BW 0x200041c0
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_7_PERIPH_LINKS_1_SEC_COUNT_0_VS_UUID_COUNT_10_MID_BW 0x20004250
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_7_PERIPH_LINKS_1_SEC_COUNT_1_VS_UUID_COUNT_1_MID_BW 0x20004388
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_7_PERIPH_LINKS_1_SEC_COUNT_1_VS_UUID_COUNT_10_MID_BW 0x20004418
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_8_PERIPH_LINKS_0_SEC_COUNT_0_VS_UUID_COUNT_1_MID_BW 0x20003eb0
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_8_PERIPH_LINKS_0_SEC_COUNT_0_VS_UUID_COUNT_10_MID_BW 0x20003f40
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_8_PERIPH_LINKS_0_SEC_COUNT_1_VS_UUID_COUNT_1_MID_BW 0x20004080
|
||||
#define APP_RAM_BASE_CENTRAL_LINKS_8_PERIPH_LINKS_0_SEC_COUNT_1_VS_UUID_COUNT_10_MID_BW 0x20004110
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // APP_RAM_BASE_H__
|
||||
@@ -0,0 +1,111 @@
|
||||
/**
|
||||
* Copyright (c) 2013 - 2017, 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 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"
|
||||
#include "sdk_config.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/** @brief Default Maximum ATT MTU size.
|
||||
*
|
||||
* This define should be defined in the sdk_config.h file to override the default.
|
||||
*/
|
||||
#ifndef NRF_BLE_GATT_MAX_MTU_SIZE
|
||||
#define NRF_BLE_GATT_MAX_MTU_SIZE GATT_MTU_SIZE_DEFAULT
|
||||
#endif
|
||||
|
||||
#define BLE_STACK_EVT_MSG_BUF_SIZE (sizeof(ble_evt_t) + (NRF_BLE_GATT_MAX_MTU_SIZE)) /**< 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
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // BLE_STACK_HANDLER_TYPES_H__
|
||||
|
||||
/** @} */
|
||||
@@ -0,0 +1,587 @@
|
||||
/**
|
||||
* Copyright (c) 2012 - 2017, 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 "softdevice_handler.h"
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "nrf.h"
|
||||
#include "nrf_assert.h"
|
||||
#include "nrf_soc.h"
|
||||
#include "nrf_nvic.h"
|
||||
#include "sdk_common.h"
|
||||
|
||||
#if NRF_MODULE_ENABLED(CLOCK)
|
||||
#include "nrf_drv_clock.h"
|
||||
#endif // NRF_MODULE_ENABLED(CLOCK)
|
||||
#include "app_error.h"
|
||||
|
||||
#if NRF_MODULE_ENABLED(RNG)
|
||||
#include "nrf_drv_rng.h"
|
||||
#endif // NRF_MODULE_ENABLED(RNG)
|
||||
|
||||
#define NRF_LOG_MODULE_NAME "SDH"
|
||||
#include "nrf_log.h"
|
||||
#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
|
||||
|
||||
#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
|
||||
|
||||
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. */
|
||||
static volatile bool m_suspended; /**< Current state of the event handler. */
|
||||
#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 definitions are 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 NRF_MODULE_ENABLED(CLOCK)
|
||||
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)
|
||||
{
|
||||
if (m_suspended)
|
||||
{
|
||||
// Cancel pulling next event if event handler was suspended by user.
|
||||
return;
|
||||
}
|
||||
|
||||
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 (NRF_MODULE_ENABLED(CLOCK) && defined(SOFTDEVICE_PRESENT))
|
||||
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)
|
||||
{
|
||||
if (m_suspended)
|
||||
{
|
||||
// Cancel pulling next event if event handler was suspended by user.
|
||||
return;
|
||||
}
|
||||
|
||||
// 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)
|
||||
{
|
||||
if (m_suspended)
|
||||
{
|
||||
// Cancel pulling next event if event handler was suspended by user.
|
||||
return;
|
||||
}
|
||||
|
||||
// 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_is_enabled(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;
|
||||
|
||||
// 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 (NRF_MODULE_ENABLED(CLOCK) && defined(SOFTDEVICE_PRESENT))
|
||||
bool power_clock_isr_enabled = nrf_drv_common_irq_enable_check(POWER_CLOCK_IRQn);
|
||||
if (power_clock_isr_enabled)
|
||||
{
|
||||
NVIC_DisableIRQ(POWER_CLOCK_IRQn);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if (NRF_MODULE_ENABLED(RNG) && defined(SOFTDEVICE_PRESENT))
|
||||
bool rng_isr_enabled = nrf_drv_common_irq_enable_check(RNG_IRQn);
|
||||
if (rng_isr_enabled)
|
||||
{
|
||||
NVIC_DisableIRQ(RNG_IRQn);
|
||||
}
|
||||
#endif
|
||||
#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)
|
||||
{
|
||||
|
||||
#if (NRF_MODULE_ENABLED(RNG) && defined(SOFTDEVICE_PRESENT))
|
||||
if (rng_isr_enabled)
|
||||
{
|
||||
NVIC_EnableIRQ(RNG_IRQn);
|
||||
}
|
||||
#endif
|
||||
#if (NRF_MODULE_ENABLED(CLOCK) && defined(SOFTDEVICE_PRESENT))
|
||||
if (power_clock_isr_enabled)
|
||||
{
|
||||
NVIC_EnableIRQ(POWER_CLOCK_IRQn);
|
||||
}
|
||||
#endif
|
||||
return err_code;
|
||||
}
|
||||
|
||||
m_softdevice_enabled = true;
|
||||
#if (NRF_MODULE_ENABLED(CLOCK) && defined(SOFTDEVICE_PRESENT))
|
||||
nrf_drv_clock_on_sd_enable();
|
||||
#endif
|
||||
|
||||
// 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();
|
||||
if (err_code == NRF_SUCCESS)
|
||||
{
|
||||
m_softdevice_enabled = false;
|
||||
|
||||
#if (NRF_MODULE_ENABLED(CLOCK) && defined(SOFTDEVICE_PRESENT))
|
||||
nrf_drv_clock_on_sd_disable();
|
||||
#endif
|
||||
|
||||
#if (NRF_MODULE_ENABLED(RNG) && defined(SOFTDEVICE_PRESENT))
|
||||
nrf_drv_rng_on_sd_disable();
|
||||
#endif
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
void softdevice_handler_suspend()
|
||||
{
|
||||
#ifdef SOFTDEVICE_PRESENT
|
||||
ret_code_t err_code = sd_nvic_DisableIRQ((IRQn_Type)SOFTDEVICE_EVT_IRQ);
|
||||
APP_ERROR_CHECK(err_code);
|
||||
#else
|
||||
NVIC_DisableIRQ(SOFTDEVICE_EVT_IRQ);
|
||||
#endif
|
||||
m_suspended = true;
|
||||
return;
|
||||
}
|
||||
|
||||
void softdevice_handler_resume()
|
||||
{
|
||||
if (!m_suspended) return;
|
||||
m_suspended = false;
|
||||
|
||||
#ifdef SOFTDEVICE_PRESENT
|
||||
ret_code_t err_code;
|
||||
|
||||
// Force calling ISR again to make sure that events not pulled previously
|
||||
// has been processed.
|
||||
err_code = sd_nvic_SetPendingIRQ((IRQn_Type)SOFTDEVICE_EVT_IRQ);
|
||||
APP_ERROR_CHECK(err_code);
|
||||
err_code = sd_nvic_EnableIRQ((IRQn_Type)SOFTDEVICE_EVT_IRQ);
|
||||
APP_ERROR_CHECK(err_code);
|
||||
#else
|
||||
NVIC_SetPendingIRQ((IRQn_Type)SOFTDEVICE_EVT_IRQ);
|
||||
NVIC_EnableIRQ(SOFTDEVICE_EVT_IRQ);
|
||||
#endif
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
bool softdevice_handler_is_suspended()
|
||||
{
|
||||
return m_suspended;
|
||||
}
|
||||
|
||||
#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;
|
||||
}
|
||||
|
||||
|
||||
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 (NRF52) || 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*/
|
||||
|
||||
/*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)
|
||||
{
|
||||
NRF_LOG_WARNING("RAM START ADDR 0x%x should be adjusted to 0x%x\r\n",
|
||||
ram_start,
|
||||
sd_req_ram_start);
|
||||
NRF_LOG_WARNING("RAM SIZE should be adjusted to 0x%x \r\n",
|
||||
ram_end_address_get() - sd_req_ram_start);
|
||||
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;
|
||||
NRF_LOG_DEBUG("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 (app_ram_base != ram_start)
|
||||
{
|
||||
NRF_LOG_WARNING("sd_ble_enable: RAM start should be adjusted to 0x%x\r\n",
|
||||
app_ram_base);
|
||||
NRF_LOG_WARNING("RAM size should be adjusted to 0x%x \r\n",
|
||||
ram_end_address_get() - app_ram_base);
|
||||
}
|
||||
else if (err_code != NRF_SUCCESS)
|
||||
{
|
||||
NRF_LOG_ERROR("sd_ble_enable: error 0x%x\r\n", err_code);
|
||||
}
|
||||
return err_code;
|
||||
#else
|
||||
return NRF_SUCCESS;
|
||||
#endif //defined(S130) || defined(S132) || defined(S332)
|
||||
|
||||
}
|
||||
/*lint -restore*/
|
||||
|
||||
#endif //BLE_STACK_SUPPORT_REQD
|
||||
@@ -0,0 +1,262 @@
|
||||
/**
|
||||
* Copyright (c) 2013 - 2017, 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 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"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#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. */
|
||||
|
||||
|
||||
|
||||
/** @brief Macro for checking the RAM requirement of the SoftDevice. */
|
||||
#define CHECK_RAM_START_ADDR(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 \
|
||||
{ \
|
||||
static uint32_t BLE_EVT_BUFFER[CEIL_DIV(BLE_STACK_EVT_MSG_BUF_SIZE, sizeof(uint32_t))]; \
|
||||
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_is_enabled(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 suspending the event handler.
|
||||
*
|
||||
* @details When event handler is disabled, no new events are pulled from SoftDevice.
|
||||
* Application can suspend pulling incoming events when its event queue is full.
|
||||
*/
|
||||
void softdevice_handler_suspend(void);
|
||||
|
||||
/**@brief Function for re-enabling the event handler after suspending.
|
||||
*/
|
||||
void softdevice_handler_resume(void);
|
||||
|
||||
/**@brief Function for retrieving the information about the event handler state
|
||||
*
|
||||
* @retval false Event handler is active.
|
||||
* @retval true Event handler is suspended and events from SD will not be pulled.
|
||||
*/
|
||||
bool softdevice_handler_is_suspended(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 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
|
||||
// Functions for connecting the Stack Event Handler to the scheduler:
|
||||
/**@cond NO_DOXYGEN */
|
||||
void intern_softdevice_events_execute(void);
|
||||
|
||||
|
||||
/**@endcond */
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // SOFTDEVICE_HANDLER_H__
|
||||
|
||||
/** @} */
|
||||
@@ -0,0 +1,54 @@
|
||||
/**
|
||||
* Copyright (c) 2015 - 2017, 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 "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,61 @@
|
||||
/**
|
||||
* Copyright (c) 2014 - 2017, 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef SOFTDEVICE_HANDLER_APPSH_H
|
||||
#define SOFTDEVICE_HANDLER_APPSH_H
|
||||
|
||||
#include "softdevice_handler.h"
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#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);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif //SOFTDEVICE_HANDLER_APPSH_H
|
||||
Reference in New Issue
Block a user