remove dependency on legacy softdevice_handler
add ble and soc task hanlder to main.c
This commit is contained in:
parent
bf787c7364
commit
b8bf0c9eae
@ -20,9 +20,7 @@
|
||||
#include "nrf_gpio.h"
|
||||
#include "app_util.h"
|
||||
#include "app_error.h"
|
||||
#include "softdevice_handler.h"
|
||||
#include "ble_stack_handler_types.h"
|
||||
//#include "ble_advdata.h"
|
||||
|
||||
#include "ble_l2cap.h"
|
||||
#include "ble_gap.h"
|
||||
#include "ble_gatt.h"
|
||||
@ -982,7 +980,7 @@ static void on_ble_evt(ble_evt_t * p_ble_evt)
|
||||
*
|
||||
* @param[in] p_ble_evt S110 SoftDevice event.
|
||||
*/
|
||||
static void ble_evt_dispatch(ble_evt_t * p_ble_evt)
|
||||
/*static*/ void ble_evt_dispatch(ble_evt_t * p_ble_evt)
|
||||
{
|
||||
ble_conn_params_on_ble_evt(p_ble_evt);
|
||||
ble_dfu_on_ble_evt(&m_dfu, p_ble_evt);
|
||||
@ -1103,9 +1101,6 @@ uint32_t dfu_transport_ble_update_start(void)
|
||||
|
||||
leds_init();
|
||||
|
||||
err_code = softdevice_ble_evt_handler_set(ble_evt_dispatch);
|
||||
VERIFY_SUCCESS(err_code);
|
||||
|
||||
dfu_register_callback(dfu_cb_handler);
|
||||
|
||||
err_code = hci_mem_pool_open();
|
||||
|
@ -1,73 +0,0 @@
|
||||
/* 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__
|
||||
|
||||
/** @} */
|
@ -1,176 +0,0 @@
|
||||
/* 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
|
@ -1,64 +0,0 @@
|
||||
/* 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__
|
||||
|
||||
/** @} */
|
@ -1,492 +0,0 @@
|
||||
/* 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
|
@ -1,215 +0,0 @@
|
||||
/* 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__
|
||||
|
||||
/** @} */
|
@ -1,26 +0,0 @@
|
||||
/* 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);
|
||||
}
|
@ -1,24 +0,0 @@
|
||||
/* 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
|
120
src/main.c
120
src/main.c
@ -40,6 +40,7 @@
|
||||
|
||||
#include "nrf.h"
|
||||
#include "nrf_soc.h"
|
||||
#include "nrf_nvic.h"
|
||||
#include "app_error.h"
|
||||
#include "nrf_gpio.h"
|
||||
#include "ble.h"
|
||||
@ -50,12 +51,6 @@
|
||||
#include "nrf_error.h"
|
||||
#include "boards.h"
|
||||
|
||||
#include "softdevice_handler_appsh.h"
|
||||
//#include "nrf_sdh.h"
|
||||
//#include "nrf_sdh_ble.h"
|
||||
//#include "nrf_sdh_soc.h"
|
||||
|
||||
|
||||
#include "pstorage_platform.h"
|
||||
#include "nrf_mbr.h"
|
||||
//#include "nrf_log.h"
|
||||
@ -222,19 +217,10 @@ void blinky_ota_disconneted(void)
|
||||
isOTAConnected = false;
|
||||
}
|
||||
|
||||
|
||||
/**@brief Function for dispatching a BLE stack event to all modules with a BLE stack event handler.
|
||||
*
|
||||
* @details This function is called from the scheduler in the main loop after a BLE stack
|
||||
* event has been received.
|
||||
*
|
||||
* @param[in] p_ble_evt Bluetooth stack event.
|
||||
*/
|
||||
static void sys_evt_dispatch(uint32_t event)
|
||||
static void nrf_error_cb(uint32_t id, uint32_t pc, uint32_t info)
|
||||
{
|
||||
pstorage_sys_event_handler(event);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**@brief Function for initializing the BLE stack.
|
||||
*
|
||||
@ -247,7 +233,18 @@ static void sys_evt_dispatch(uint32_t event)
|
||||
static uint32_t ble_stack_init(bool init_softdevice)
|
||||
{
|
||||
uint32_t err_code;
|
||||
nrf_clock_lf_cfg_t clock_lf_cfg =
|
||||
if (init_softdevice)
|
||||
{
|
||||
sd_mbr_command_t com = { .command = SD_MBR_COMMAND_INIT_SD };
|
||||
err_code = sd_mbr_command(&com);
|
||||
APP_ERROR_CHECK(err_code);
|
||||
}
|
||||
|
||||
err_code = sd_softdevice_vector_table_base_set(BOOTLOADER_REGION_START);
|
||||
APP_ERROR_CHECK(err_code);
|
||||
|
||||
// Enable Softdevice
|
||||
nrf_clock_lf_cfg_t clock_cfg =
|
||||
{
|
||||
#if 0
|
||||
.source = NRF_CLOCK_LF_SRC_RC,
|
||||
@ -262,18 +259,9 @@ static uint32_t ble_stack_init(bool init_softdevice)
|
||||
#endif
|
||||
};
|
||||
|
||||
if (init_softdevice)
|
||||
{
|
||||
sd_mbr_command_t com = { .command = SD_MBR_COMMAND_INIT_SD };
|
||||
err_code = sd_mbr_command(&com);
|
||||
APP_ERROR_CHECK(err_code);
|
||||
}
|
||||
|
||||
err_code = sd_softdevice_vector_table_base_set(BOOTLOADER_REGION_START);
|
||||
APP_ERROR_CHECK(err_code);
|
||||
|
||||
// equivalent to nrf_sdh_enable_request()
|
||||
SOFTDEVICE_HANDLER_APPSH_INIT(&clock_lf_cfg, true);
|
||||
APP_ERROR_CHECK( sd_softdevice_enable(&clock_cfg, nrf_error_cb) );
|
||||
sd_nvic_EnableIRQ(SD_EVT_IRQn);
|
||||
|
||||
/*------------- Configure BLE params -------------*/
|
||||
extern uint32_t __data_start__[]; // defined in linker
|
||||
@ -313,9 +301,6 @@ static uint32_t ble_stack_init(bool init_softdevice)
|
||||
err_code = sd_ble_enable(&ram_start);
|
||||
VERIFY_SUCCESS(err_code);
|
||||
|
||||
err_code = softdevice_sys_evt_handler_set(sys_evt_dispatch);
|
||||
VERIFY_SUCCESS(err_code);
|
||||
|
||||
return err_code;
|
||||
}
|
||||
|
||||
@ -411,6 +396,8 @@ int main(void)
|
||||
|
||||
// DFU + FRESET are pressed --> OTA
|
||||
_ota_update = _ota_update || ( button_pressed(BOOTLOADER_BUTTON) && button_pressed(FRESET_BUTTON) ) ;
|
||||
|
||||
_ota_update = 1;
|
||||
|
||||
#ifdef BOARD_METRO52
|
||||
led_pin_init(LED_BLUE);
|
||||
@ -560,3 +547,72 @@ uint32_t tusb_hal_millis(void)
|
||||
{
|
||||
return ( ( ((uint64_t)app_timer_cnt_get())*1000*(APP_TIMER_CONFIG_RTC_FREQUENCY+1)) / APP_TIMER_CLOCK_FREQ );
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* SoftDevice Event handler
|
||||
*------------------------------------------------------------------*/
|
||||
|
||||
void ada_ble_task(void* evt_data, uint16_t evt_size);
|
||||
void ada_soc_task(void* evt_data, uint16_t evt_size);
|
||||
|
||||
void SD_EVT_IRQHandler(void)
|
||||
{
|
||||
// Use App Scheduler to defer handling code in non-isr context
|
||||
app_sched_event_put(NULL, 0, ada_ble_task);
|
||||
app_sched_event_put(NULL, 0, ada_soc_task);
|
||||
}
|
||||
|
||||
void ada_ble_hanlder(ble_evt_t* evt)
|
||||
{
|
||||
// from dfu_transport_ble
|
||||
extern void ble_evt_dispatch(ble_evt_t * p_ble_evt);
|
||||
|
||||
ble_evt_dispatch(evt);
|
||||
}
|
||||
|
||||
void ada_ble_task(void* evt_data, uint16_t evt_size)
|
||||
{
|
||||
(void) evt_data;
|
||||
(void) evt_size;
|
||||
|
||||
// TODO Should check alignment 4
|
||||
__ALIGN(4) uint8_t ev_buf[ BLE_EVT_LEN_MAX(BLEGATT_ATT_MTU_MAX) ];
|
||||
|
||||
uint32_t err = NRF_SUCCESS;
|
||||
|
||||
// Until no pending events
|
||||
while( NRF_ERROR_NOT_FOUND != err )
|
||||
{
|
||||
uint16_t ev_len = BLE_EVT_LEN_MAX(BLEGATT_ATT_MTU_MAX);
|
||||
|
||||
// Get BLE Event
|
||||
err = sd_ble_evt_get(ev_buf, &ev_len);
|
||||
|
||||
// Handle valid event, ignore error
|
||||
if( NRF_SUCCESS == err)
|
||||
{
|
||||
ada_ble_hanlder( (ble_evt_t*) ev_buf );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ada_soc_task(void* evt_data, uint16_t evt_size)
|
||||
{
|
||||
(void) evt_data;
|
||||
(void) evt_size;
|
||||
|
||||
uint32_t soc_evt;
|
||||
uint32_t err = NRF_SUCCESS;
|
||||
|
||||
// until no more pending events
|
||||
while ( NRF_ERROR_NOT_FOUND != err )
|
||||
{
|
||||
err = sd_evt_get(&soc_evt);
|
||||
|
||||
if (NRF_SUCCESS == err)
|
||||
{
|
||||
// Flash is the only soc event
|
||||
pstorage_sys_event_handler(soc_evt);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -114,9 +114,6 @@ C_SOURCE_FILES += $(SDK_PATH)/ble/ble_services/ble_dis/ble_dis.c
|
||||
C_SOURCE_FILES += $(SDK_PATH)/drivers_nrf/pstorage/pstorage_raw.c
|
||||
C_SOURCE_FILES += $(SDK_PATH)/toolchain/system_nrf52840.c
|
||||
|
||||
C_SOURCE_FILES += $(SD_PATH)/common/softdevice_handler/softdevice_handler.c
|
||||
C_SOURCE_FILES += $(SD_PATH)/common/softdevice_handler/softdevice_handler_appsh.c
|
||||
|
||||
#C_SOURCE_FILES += $(SRC_PATH)/tusb_descriptors.c
|
||||
|
||||
#C_SOURCE_FILES += $(TUSB_PATH)/portable/nordic/nrf5x/dcd_nrf5x.c
|
||||
@ -157,7 +154,6 @@ INC_PATHS += -I$(SDK_PATH)/drivers_nrf/power
|
||||
INC_PATHS += -I$(SDK_PATH)/drivers_nrf/usbd
|
||||
|
||||
INC_PATHS += -I$(SD_PATH)/common
|
||||
INC_PATHS += -I$(SD_PATH)/common/softdevice_handler/
|
||||
INC_PATHS += -I$(SD_PATH)/$(SD_NAME)/headers
|
||||
INC_PATHS += -I$(SD_PATH)/$(SD_NAME)/headers/nrf52
|
||||
|
||||
|
@ -19,7 +19,7 @@
|
||||
arm_target_device_name="nRF52840_xxAA"
|
||||
arm_target_interface_type="SWD"
|
||||
c_preprocessor_definitions="NRF52840_XXAA;__nRF_FAMILY;ARM_MATH_CM4;FLASH_PLACEMENT=1;NO_VTOR_CONFIG;BOARD_FEATHER52840;BOOTLOADER_VERSION=0x06000001;S140;CONFIG_GPIO_AS_PINRESET;BLE_STACK_SUPPORT_REQD;SWI_DISABLE0;SOFTDEVICE_PRESENT;FLOAT_ABI_HARD;DFU_APP_DATA_RESERVED=7*4096"
|
||||
c_user_include_directories="$(TusbDir)/hw/cmsis/Include;$(TusbDir)/hw;$(TusbDir)/tinyusb;$(SdkDir);$(SdkDir)/device;$(SdkDir)/toolchain;$(SdkDir)/drivers_nrf/hal;$(SdkDir)/drivers_nrf/systick;$(SdkDir)/drivers_nrf/uart;$(SdkDir)/drivers_nrf/usbd;$(SdkDir)/drivers_nrf/common;$(SdkDir)/drivers_nrf/delay;$(SdkDir)/drivers_nrf/power;$(SdkDir)/drivers_nrf/clock;$(SdkDir)/drivers_nrf/pstorage;$(SdkDir)/external/fprintf;$(SdkDir)/libraries/util;$(SdkDir)/libraries/strerror;$(SdkDir)/libraries/atomic;$(SdkDir)/libraries/balloc;$(SdkDir)/libraries/experimental_log/src;$(SdkDir)/libraries/experimental_log;$(SdkDir)/libraries/experimental_section_vars;$(SdkDir)/libraries/experimental_memobj;$(SdkDir)/libraries/timer;$(SdkDir)/libraries/scheduler;$(SdkDir)/libraries/crc16;$(SdkDir)/libraries/util;$(SdkDir)/libraries/hci/config;$(SdkDir)/libraries/uart;$(SdkDir)/libraries/hci;$(SdkDir)/libraries/bootloader_dfu;$(SdkDir)/libraries/bootloader_dfu/hci_transport;$(SdkDir)/ble/common/;$(SdkDir)/ble/ble_services/ble_dfu;$(SdkDir)/ble/ble_services/ble_dis;$(SdDir)/s140/headers;$(SdDir)/s140/headers/nrf52;$(SdDir)/common/softdevice_handler;../"
|
||||
c_user_include_directories="$(TusbDir)/hw/cmsis/Include;$(TusbDir)/hw;$(TusbDir)/tinyusb;$(SdkDir);$(SdkDir)/device;$(SdkDir)/toolchain;$(SdkDir)/drivers_nrf/hal;$(SdkDir)/drivers_nrf/systick;$(SdkDir)/drivers_nrf/uart;$(SdkDir)/drivers_nrf/usbd;$(SdkDir)/drivers_nrf/common;$(SdkDir)/drivers_nrf/delay;$(SdkDir)/drivers_nrf/power;$(SdkDir)/drivers_nrf/clock;$(SdkDir)/drivers_nrf/pstorage;$(SdkDir)/external/fprintf;$(SdkDir)/libraries/util;$(SdkDir)/libraries/strerror;$(SdkDir)/libraries/atomic;$(SdkDir)/libraries/balloc;$(SdkDir)/libraries/experimental_log/src;$(SdkDir)/libraries/experimental_log;$(SdkDir)/libraries/experimental_section_vars;$(SdkDir)/libraries/experimental_memobj;$(SdkDir)/libraries/timer;$(SdkDir)/libraries/scheduler;$(SdkDir)/libraries/crc16;$(SdkDir)/libraries/util;$(SdkDir)/libraries/hci/config;$(SdkDir)/libraries/uart;$(SdkDir)/libraries/hci;$(SdkDir)/libraries/bootloader_dfu;$(SdkDir)/libraries/bootloader_dfu/hci_transport;$(SdkDir)/ble/common/;$(SdkDir)/ble/ble_services/ble_dfu;$(SdkDir)/ble/ble_services/ble_dis;$(SdDir)/s140/headers;$(SdDir)/s140/headers/nrf52;../"
|
||||
debug_register_definition_file="$(ProjectDir)/nrf52840_Registers.xml"
|
||||
debug_target_connection="J-Link"
|
||||
gcc_entry_point="Reset_Handler"
|
||||
@ -283,17 +283,7 @@
|
||||
linker_section_placement_file="flash_placement.xml" />
|
||||
<folder Name="softdevice">
|
||||
<folder Name="6.0.0">
|
||||
<folder Name="common">
|
||||
<folder Name="softdevice_handler">
|
||||
<file file_name="../../softdevice/6.0.0/common/softdevice_handler/ant_stack_handler_types.h" />
|
||||
<file file_name="../../softdevice/6.0.0/common/softdevice_handler/app_ram_base.h" />
|
||||
<file file_name="../../softdevice/6.0.0/common/softdevice_handler/ble_stack_handler_types.h" />
|
||||
<file file_name="../../softdevice/6.0.0/common/softdevice_handler/softdevice_handler.c" />
|
||||
<file file_name="../../softdevice/6.0.0/common/softdevice_handler/softdevice_handler.h" />
|
||||
<file file_name="../../softdevice/6.0.0/common/softdevice_handler/softdevice_handler_appsh.c" />
|
||||
<file file_name="../../softdevice/6.0.0/common/softdevice_handler/softdevice_handler_appsh.h" />
|
||||
</folder>
|
||||
</folder>
|
||||
<folder Name="common" />
|
||||
<folder Name="mbr">
|
||||
<folder Name="nrf52840">
|
||||
<folder Name="headers">
|
||||
|
Loading…
Reference in New Issue
Block a user