nRF5 SDK: SoftDevice

SoftDevices

Protocol Role Chip SoftDevice
Bluetooth Low Energy Peripheral
  • nRF51422
  • nRF51822
S110
  • nRF52810
  • nRF52832
S112
  • nRF52833
S113
Central or Peripheral
  • nRF51422
  • nRF51822
S120
Central and Peripheral
  • nRF51422
  • nRF51822
S130
  • nRF52832
S132
  • nRF52833
  • nRF52840
S140
ANT  
  • nRF51422
S210
  • nRF52832
S212
Bluetooth Low Energy and ANT Peripheral
  • nRF51422
S310
Peripheral and Broadcaster
  • nRF52810
S312
All roles
  • nRF52832
S332
  • nRF52840
S340

ARM Assembly

SVCALL(SD_BLE_ENABLE,
       uint32_t,
       sd_ble_enable(uint32_t * p_app_ram_base)
);

#define SVCALL(number, return_type, signature)          \
  static return_type signature                          \
  {                                                     \
    __asm(                                              \
        "svc %0\n"                                      \
        "bx r14" : : "I" (GCC_CAST_CPP number) : "r0"   \
    ); 

ARM GCC Inline Assembler Kochbuch
ARM GCC Inline Assembler Cookbook
GCC Extended Asm – Assembler Instructions with C Expression Operands
ARM GCC Inline Assembler Cookbook (PDF)
Writing inline assembly code

Stack Trace

sd_softdevice_enable()

components\libraries\util\app_error_weak.c
void app_error_fault_handler(uint32_t id, uint32_t pc, uint32_t info)

nrf_sdm.h   uint32_t     sd_softdevice_enable(&clock_lf_cfg, app_error_fault_handler)
nrf_sdh.c   ret_code_t   nrf_sdh_enable_request(void)
main.c      void         ble_stack_init(void)
main.c      int          main(void)

ble_evt_handler()

Specifying Attributes of Variables – section
Analyzing the Linker Map file with a little help from the ELF and the DWARF
github.com/govind-mukundan/MapViewer, A windows application to view and analyze information from the linker generated Map file


static nrf_sdh_ble_evt_observer_t m_ble_observer
__attribute__ ((section(".sdh_ble_observers3")))
__attribute__((used)) = {
    .handler   = ble_evt_handler,
    .p_context = NULL
}

components\libraries\experimental_section_vars\nrf_section.h
============================================================

section_name = sdh_ble_observers3
section_var  = static nrf_sdh_ble_evt_observer_t m_ble_observer

#define NRF_SECTION_ITEM_REGISTER(section_name, section_var) \
    section_var __attribute__ ((section("." STRINGIFY(section_name)))) __attribute__((used))


components\libraries\experimental_section_vars\nrf_section_iter.h
=================================================================

#define NRF_SECTION_SET_ITEM_REGISTER(_name, _priority, _var)
    NRF_SECTION_ITEM_REGISTER(CONCAT_2(_name, _priority), _var)

components\softdevice\common\nrf_sdh_ble.h
==========================================

                             _name    = m_ble_observer
                             _prio    = 3
                             _handler = ble_evt_handler,
                             _context = NULL
#define NRF_SDH_BLE_OBSERVER(_name, _prio, _handler, _context)
NRF_SECTION_SET_ITEM_REGISTER(
    sdh_ble_observers,
    _prio,
    static nrf_sdh_ble_evt_observer_t _name
) =
{
    .handler   = _handler,
    .p_context = _context
}

main.c
======

#define APP_BLE_OBSERVER_PRIO           3

// Register a handler for BLE events.
NRF_SDH_BLE_OBSERVER(m_ble_observer, APP_BLE_OBSERVER_PRIO, ble_evt_handler, NULL);

on_adv_evt()

/\*\*<[a-zA-Z .\\@_]*\*/
[,]?[ ]*/\*\*<[a-zA-Z ();,.\\@_]*\*/

ble_advertising_t    p_advertising->adv_handle
ble_advertising_t    p_advertising->evt_handler
ble_advertising_t    p_advertising->error_handler

uint32_t sd_ble_gap_adv_set_configure(...)
uint32_t ble_advertising_init(...)
void     advertising_init() -> init.evt_handler = on_adv_evt
int      main(void)

static void on_adv_evt(ble_adv_evt_t ble_adv_evt)
static void ble_evt_handler(ble_evt_t const * p_ble_evt, void * p_context)

typedef enum {
  BLE_ADV_EVT_IDLE
  BLE_ADV_EVT_DIRECTED_HIGH_DUTY
  BLE_ADV_EVT_DIRECTED
  BLE_ADV_EVT_FAST
  BLE_ADV_EVT_SLOW
  BLE_ADV_EVT_FAST_WHITELIST
  BLE_ADV_EVT_SLOW_WHITELIST
  BLE_ADV_EVT_WHITELIST_REQUEST
  BLE_ADV_EVT_PEER_ADDR_REQUEST
} ble_adv_evt_t;

enum BLE_GAP_EVTS {
  BLE_GAP_EVT_CONNECTED
  BLE_GAP_EVT_DISCONNECTED
  BLE_GAP_EVT_CONN_PARAM_UPDATE
  BLE_GAP_EVT_SEC_PARAMS_REQUEST
  BLE_GAP_EVT_SEC_INFO_REQUEST
  BLE_GAP_EVT_PASSKEY_DISPLAY
  BLE_GAP_EVT_KEY_PRESSED
  BLE_GAP_EVT_AUTH_KEY_REQUEST
  BLE_GAP_EVT_LESC_DHKEY_REQUEST
  BLE_GAP_EVT_AUTH_STATUS
  BLE_GAP_EVT_CONN_SEC_UPDATE
  BLE_GAP_EVT_TIMEOUT
  BLE_GAP_EVT_RSSI_CHANGED
  BLE_GAP_EVT_ADV_REPORT
  BLE_GAP_EVT_SEC_REQUEST
  BLE_GAP_EVT_CONN_PARAM_UPDATE_REQUEST
  BLE_GAP_EVT_SCAN_REQ_REPORT
  BLE_GAP_EVT_PHY_UPDATE_REQUEST
  BLE_GAP_EVT_PHY_UPDATE
  BLE_GAP_EVT_DATA_LENGTH_UPDATE_REQUEST
  BLE_GAP_EVT_DATA_LENGTH_UPDATE
  BLE_GAP_EVT_QOS_CHANNEL_SURVEY_REPORT
  BLE_GAP_EVT_ADV_SET_TERMINATED
};

enum BLE_GATTC_EVTS {
  BLE_GATTC_EVT_PRIM_SRVC_DISC_RSP = BLE_GATTC_EVT_BASE
  BLE_GATTC_EVT_REL_DISC_RSP
  BLE_GATTC_EVT_CHAR_DISC_RSP
  BLE_GATTC_EVT_DESC_DISC_RSP
  BLE_GATTC_EVT_ATTR_INFO_DISC_RSP
  BLE_GATTC_EVT_CHAR_VAL_BY_UUID_READ_RSP
  BLE_GATTC_EVT_READ_RSP
  BLE_GATTC_EVT_CHAR_VALS_READ_RSP
  BLE_GATTC_EVT_WRITE_RSP
  BLE_GATTC_EVT_HVX
  BLE_GATTC_EVT_EXCHANGE_MTU_RSP
  BLE_GATTC_EVT_TIMEOUT
  BLE_GATTC_EVT_WRITE_CMD_TX_COMPLETE
};

S132

uint32_t sd_ble_enable(uint32_t * p_app_ram_base)
uint32_t sd_ble_cfg_set(uint32_t cfg_id, ble_cfg_t const * p_cfg, uint32_t app_ram_base)
uint32_t sd_ble_evt_get(uint8_t *p_dest, uint16_t *p_len)
uint32_t sd_ble_uuid_vs_add(ble_uuid128_t const *p_vs_uuid, uint8_t *p_uuid_type)
uint32_t sd_ble_uuid_vs_remove(uint8_t *p_uuid_type)
uint32_t sd_ble_uuid_decode(uint8_t uuid_le_len, uint8_t const *p_uuid_le, ble_uuid_t *p_uuid)
uint32_t sd_ble_uuid_encode(ble_uuid_t const *p_uuid, uint8_t *p_uuid_le_len, uint8_t *p_uuid_le)
uint32_t sd_ble_version_get(ble_version_t *p_version)
uint32_t sd_ble_user_mem_reply(uint16_t conn_handle, ble_user_mem_block_t const *p_block)
uint32_t sd_ble_opt_set(uint32_t opt_id, ble_opt_t const *p_opt)
uint32_t sd_ble_opt_get(uint32_t opt_id, ble_opt_t *p_opt)
uint32_t sd_ble_gap_addr_set(ble_gap_addr_t const *p_addr)
uint32_t sd_ble_gap_addr_get(ble_gap_addr_t *p_addr)
uint32_t sd_ble_gap_adv_addr_get(uint8_t adv_handle, ble_gap_addr_t *p_addr)
uint32_t sd_ble_gap_whitelist_set(ble_gap_addr_t const * const * pp_wl_addrs, uint8_t len)
uint32_t sd_ble_gap_device_identities_set(ble_gap_id_key_t const * const * pp_id_keys, ble_gap_irk_t const * const * pp_local_irks, uint8_t len)
uint32_t sd_ble_gap_privacy_set(ble_gap_privacy_params_t const *p_privacy_params)
uint32_t sd_ble_gap_privacy_get(ble_gap_privacy_params_t *p_privacy_params)
uint32_t sd_ble_gap_adv_set_configure(uint8_t *p_adv_handle, ble_gap_adv_data_t const *p_adv_data, ble_gap_adv_params_t const *p_adv_params)
uint32_t sd_ble_gap_adv_start(uint8_t adv_handle, uint8_t conn_cfg_tag)
uint32_t sd_ble_gap_adv_stop(uint8_t adv_handle)
uint32_t sd_ble_gap_conn_param_update(uint16_t conn_handle, ble_gap_conn_params_t const *p_conn_params)
uint32_t sd_ble_gap_disconnect(uint16_t conn_handle, uint8_t hci_status_code)
uint32_t sd_ble_gap_tx_power_set(uint8_t role, uint16_t handle, int8_t tx_power)
uint32_t sd_ble_gap_appearance_set(uint16_t appearance)
uint32_t sd_ble_gap_appearance_get(uint16_t *p_appearance)
uint32_t sd_ble_gap_ppcp_set(ble_gap_conn_params_t const *p_conn_params)
uint32_t sd_ble_gap_ppcp_get(ble_gap_conn_params_t *p_conn_params)
uint32_t sd_ble_gap_device_name_set(ble_gap_conn_sec_mode_t const *p_write_perm, uint8_t const *p_dev_name, uint16_t len)
uint32_t sd_ble_gap_device_name_get(uint8_t *p_dev_name, uint16_t *p_len)
uint32_t sd_ble_gap_authenticate(uint16_t conn_handle, ble_gap_sec_params_t const *p_sec_params)
uint32_t sd_ble_gap_sec_params_reply(uint16_t conn_handle, uint8_t sec_status, ble_gap_sec_params_t const *p_sec_params, ble_gap_sec_keyset_t const *p_sec_keyset)
uint32_t sd_ble_gap_auth_key_reply(uint16_t conn_handle, uint8_t key_type, uint8_t const *p_key)
uint32_t sd_ble_gap_lesc_dhkey_reply(uint16_t conn_handle, ble_gap_lesc_dhkey_t const *p_dhkey)
uint32_t sd_ble_gap_keypress_notify(uint16_t conn_handle, uint8_t kp_not)
uint32_t sd_ble_gap_lesc_oob_data_get(uint16_t conn_handle, ble_gap_lesc_p256_pk_t const *p_pk_own, ble_gap_lesc_oob_data_t *p_oobd_own)
uint32_t sd_ble_gap_lesc_oob_data_set(uint16_t conn_handle, ble_gap_lesc_oob_data_t const *p_oobd_own, ble_gap_lesc_oob_data_t const *p_oobd_peer)
uint32_t sd_ble_gap_encrypt(uint16_t conn_handle, ble_gap_master_id_t const *p_master_id, ble_gap_enc_info_t const *p_enc_info)
uint32_t sd_ble_gap_sec_info_reply(uint16_t conn_handle, ble_gap_enc_info_t const *p_enc_info, ble_gap_irk_t const *p_id_info, ble_gap_sign_info_t const *p_sign_info)
uint32_t sd_ble_gap_conn_sec_get(uint16_t conn_handle, ble_gap_conn_sec_t *p_conn_sec)
uint32_t sd_ble_gap_rssi_start(uint16_t conn_handle, uint8_t threshold_dbm, uint8_t skip_count)
uint32_t sd_ble_gap_rssi_stop(uint16_t conn_handle)
uint32_t sd_ble_gap_rssi_get(uint16_t conn_handle, int8_t *p_rssi, uint8_t *p_ch_index)
uint32_t sd_ble_gap_scan_start(ble_gap_scan_params_t const *p_scan_params, ble_data_t const * p_adv_report_buffer)
uint32_t sd_ble_gap_scan_stop(void)
uint32_t sd_ble_gap_connect(ble_gap_addr_t const *p_peer_addr, ble_gap_scan_params_t const *p_scan_params, ble_gap_conn_params_t const *p_conn_params, uint8_t conn_cfg_tag)
uint32_t sd_ble_gap_connect_cancel(void)
uint32_t sd_ble_gap_phy_update(uint16_t conn_handle, ble_gap_phys_t const *p_gap_phys)
uint32_t sd_ble_gap_data_length_update(uint16_t conn_handle, ble_gap_data_length_params_t const *p_dl_params, ble_gap_data_length_limitation_t *p_dl_limitation)
uint32_t sd_ble_gap_qos_channel_survey_start(uint32_t interval_us)
uint32_t sd_ble_gap_qos_channel_survey_stop(void)
uint32_t sd_ble_gattc_primary_services_discover(uint16_t conn_handle, uint16_t start_handle, ble_uuid_t const *p_srvc_uuid)
uint32_t sd_ble_gattc_relationships_discover(uint16_t conn_handle, ble_gattc_handle_range_t const *p_handle_range)
uint32_t sd_ble_gattc_characteristics_discover(uint16_t conn_handle, ble_gattc_handle_range_t const *p_handle_range)
uint32_t sd_ble_gattc_descriptors_discover(uint16_t conn_handle, ble_gattc_handle_range_t const *p_handle_range)
uint32_t sd_ble_gattc_char_value_by_uuid_read(uint16_t conn_handle, ble_uuid_t const *p_uuid, ble_gattc_handle_range_t const *p_handle_range)
uint32_t sd_ble_gattc_read(uint16_t conn_handle, uint16_t handle, uint16_t offset)
uint32_t sd_ble_gattc_char_values_read(uint16_t conn_handle, uint16_t const *p_handles, uint16_t handle_count)
uint32_t sd_ble_gattc_write(uint16_t conn_handle, ble_gattc_write_params_t const *p_write_params)
uint32_t sd_ble_gattc_hv_confirm(uint16_t conn_handle, uint16_t handle)
uint32_t sd_ble_gattc_attr_info_discover(uint16_t conn_handle, ble_gattc_handle_range_t const * p_handle_range)
uint32_t sd_ble_gattc_exchange_mtu_request(uint16_t conn_handle, uint16_t client_rx_mtu)
uint32_t sd_ble_gatts_service_add(uint8_t type, ble_uuid_t const *p_uuid, uint16_t *p_handle)
uint32_t sd_ble_gatts_include_add(uint16_t service_handle, uint16_t inc_srvc_handle, uint16_t *p_include_handle)
uint32_t sd_ble_gatts_characteristic_add(uint16_t service_handle, ble_gatts_char_md_t const *p_char_md, ble_gatts_attr_t const *p_attr_char_value, ble_gatts_char_handles_t *p_handles)
uint32_t sd_ble_gatts_descriptor_add(uint16_t char_handle, ble_gatts_attr_t const *p_attr, uint16_t *p_handle)
uint32_t sd_ble_gatts_value_set(uint16_t conn_handle, uint16_t handle, ble_gatts_value_t *p_value)
uint32_t sd_ble_gatts_value_get(uint16_t conn_handle, uint16_t handle, ble_gatts_value_t *p_value)
uint32_t sd_ble_gatts_hvx(uint16_t conn_handle, ble_gatts_hvx_params_t const *p_hvx_params)
uint32_t sd_ble_gatts_service_changed(uint16_t conn_handle, uint16_t start_handle, uint16_t end_handle)
uint32_t sd_ble_gatts_rw_authorize_reply(uint16_t conn_handle, ble_gatts_rw_authorize_reply_params_t const *p_rw_authorize_reply_params)
uint32_t sd_ble_gatts_sys_attr_set(uint16_t conn_handle, uint8_t const *p_sys_attr_data, uint16_t len, uint32_t flags)
uint32_t sd_ble_gatts_sys_attr_get(uint16_t conn_handle, uint8_t *p_sys_attr_data, uint16_t *p_len, uint32_t flags)
uint32_t sd_ble_gatts_initial_user_handle_get(uint16_t *p_handle)
uint32_t sd_ble_gatts_attr_get(uint16_t handle, ble_uuid_t * p_uuid, ble_gatts_attr_md_t * p_md)
uint32_t sd_ble_gatts_exchange_mtu_reply(uint16_t conn_handle, uint16_t server_rx_mtu)
uint32_t sd_ble_l2cap_ch_setup(uint16_t conn_handle, uint16_t *p_local_cid, ble_l2cap_ch_setup_params_t const *p_params)
uint32_t sd_ble_l2cap_ch_release(uint16_t conn_handle, uint16_t local_cid)
uint32_t sd_ble_l2cap_ch_rx(uint16_t conn_handle, uint16_t local_cid, ble_data_t const *p_sdu_buf)
uint32_t sd_ble_l2cap_ch_tx(uint16_t conn_handle, uint16_t local_cid, ble_data_t const *p_sdu_buf)
uint32_t sd_ble_l2cap_ch_flow_control(uint16_t conn_handle, uint16_t local_cid, uint16_t credits, uint16_t *p_credits)
uint32_t sd_mbr_command(sd_mbr_command_t* param)
uint32_t sd_softdevice_enable(nrf_clock_lf_cfg_t const * p_clock_lf_cfg, nrf_fault_handler_t fault_handler)
uint32_t sd_softdevice_disable(void)
uint32_t sd_softdevice_is_enabled(uint8_t * p_softdevice_enabled)
uint32_t sd_softdevice_vector_table_base_set(uint32_t address)
uint32_t sd_mutex_new(nrf_mutex_t * p_mutex)
uint32_t sd_mutex_acquire(nrf_mutex_t * p_mutex)
uint32_t sd_mutex_release(nrf_mutex_t * p_mutex)
uint32_t sd_rand_application_pool_capacity_get(uint8_t * p_pool_capacity)
uint32_t sd_rand_application_bytes_available_get(uint8_t * p_bytes_available)
uint32_t sd_rand_application_vector_get(uint8_t * p_buff, uint8_t length)
uint32_t sd_power_reset_reason_get(uint32_t * p_reset_reason)
uint32_t sd_power_reset_reason_clr(uint32_t reset_reason_clr_msk)
uint32_t sd_power_mode_set(uint8_t power_mode)
uint32_t sd_power_system_off(void)
uint32_t sd_power_pof_enable(uint8_t pof_enable)
uint32_t sd_power_pof_threshold_set(uint8_t threshold)
uint32_t sd_power_ram_power_set(uint8_t index, uint32_t ram_powerset)
uint32_t sd_power_ram_power_clr(uint8_t index, uint32_t ram_powerclr)
uint32_t sd_power_ram_power_get(uint8_t index, uint32_t * p_ram_power)
uint32_t sd_power_gpregret_set(uint32_t gpregret_id, uint32_t gpregret_msk)
uint32_t sd_power_gpregret_clr(uint32_t gpregret_id, uint32_t gpregret_msk)
uint32_t sd_power_gpregret_get(uint32_t gpregret_id, uint32_t *p_gpregret)
uint32_t sd_power_dcdc_mode_set(uint8_t dcdc_mode)
uint32_t sd_clock_hfclk_request(void)
uint32_t sd_clock_hfclk_release(void)
uint32_t sd_clock_hfclk_is_running(uint32_t * p_is_running)
uint32_t sd_app_evt_wait(void)
uint32_t sd_ppi_channel_enable_get(uint32_t * p_channel_enable)
uint32_t sd_ppi_channel_enable_set(uint32_t channel_enable_set_msk)
uint32_t sd_ppi_channel_enable_clr(uint32_t channel_enable_clr_msk)
uint32_t sd_ppi_channel_assign(uint8_t channel_num, const volatile void * evt_endpoint, const volatile void * task_endpoint)
uint32_t sd_ppi_group_task_enable(uint8_t group_num)
uint32_t sd_ppi_group_task_disable(uint8_t group_num)
uint32_t sd_ppi_group_assign(uint8_t group_num, uint32_t channel_msk)
uint32_t sd_ppi_group_get(uint8_t group_num, uint32_t * p_channel_msk)
uint32_t sd_radio_notification_cfg_set(uint8_t type, uint8_t distance)
uint32_t sd_ecb_block_encrypt(nrf_ecb_hal_data_t * p_ecb_data)
uint32_t sd_ecb_blocks_encrypt(uint8_t block_count, nrf_ecb_hal_data_block_t * p_data_blocks)
uint32_t sd_evt_get(uint32_t * p_evt_id)
uint32_t sd_temp_get(int32_t * p_temp)
uint32_t sd_flash_write(uint32_t * p_dst, uint32_t const * p_src, uint32_t size)
uint32_t sd_flash_page_erase(uint32_t page_number)
uint32_t sd_flash_protect(uint32_t block_cfg0, uint32_t block_cfg1, uint32_t block_cfg2, uint32_t block_cfg3)
uint32_t sd_radio_session_open(nrf_radio_signal_callback_t p_radio_signal_callback)
uint32_t sd_radio_session_close(void)
uint32_t sd_radio_request(nrf_radio_request_t const * p_request)
uint32_t sd_protected_register_write(volatile uint32_t * p_register, uint32_t value)
a
b

Leave a Reply

Your email address will not be published. Required fields are marked *