The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.

Dependents:   hello SerialTestv11 SerialTestv12 Sierpinski ... more

mbed 2

This is the mbed 2 library. If you'd like to learn about Mbed OS please see the mbed-os docs.

Committer:
AnnaBridge
Date:
Wed Feb 20 20:53:29 2019 +0000
Revision:
172:65be27845400
Parent:
171:3a7713b1edbc
mbed library release version 165

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Kojto 148:fd96258d940d 1 /*
Kojto 148:fd96258d940d 2 * Copyright (c) 2014 Nordic Semiconductor ASA
Kojto 148:fd96258d940d 3 * All rights reserved.
Kojto 148:fd96258d940d 4 *
Kojto 148:fd96258d940d 5 * Redistribution and use in source and binary forms, with or without modification,
Kojto 148:fd96258d940d 6 * are permitted provided that the following conditions are met:
Kojto 148:fd96258d940d 7 *
Kojto 148:fd96258d940d 8 * 1. Redistributions of source code must retain the above copyright notice, this list
Kojto 148:fd96258d940d 9 * of conditions and the following disclaimer.
Kojto 148:fd96258d940d 10 *
Kojto 148:fd96258d940d 11 * 2. Redistributions in binary form, except as embedded into a Nordic Semiconductor ASA
Kojto 148:fd96258d940d 12 * integrated circuit in a product or a software update for such product, must reproduce
Kojto 148:fd96258d940d 13 * the above copyright notice, this list of conditions and the following disclaimer in
Kojto 148:fd96258d940d 14 * the documentation and/or other materials provided with the distribution.
Kojto 148:fd96258d940d 15 *
Kojto 148:fd96258d940d 16 * 3. Neither the name of Nordic Semiconductor ASA nor the names of its contributors may be
Kojto 148:fd96258d940d 17 * used to endorse or promote products derived from this software without specific prior
Kojto 148:fd96258d940d 18 * written permission.
Kojto 148:fd96258d940d 19 *
Kojto 148:fd96258d940d 20 * 4. This software, with or without modification, must only be used with a
Kojto 148:fd96258d940d 21 * Nordic Semiconductor ASA integrated circuit.
Kojto 148:fd96258d940d 22 *
Kojto 148:fd96258d940d 23 * 5. Any software provided in binary or object form under this license must not be reverse
Kojto 148:fd96258d940d 24 * engineered, decompiled, modified and/or disassembled.
Kojto 148:fd96258d940d 25 *
Kojto 148:fd96258d940d 26 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
Kojto 148:fd96258d940d 27 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
Kojto 148:fd96258d940d 28 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
Kojto 148:fd96258d940d 29 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
Kojto 148:fd96258d940d 30 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
Kojto 148:fd96258d940d 31 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
Kojto 148:fd96258d940d 32 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
Kojto 148:fd96258d940d 33 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
Kojto 148:fd96258d940d 34 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
Kojto 148:fd96258d940d 35 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Kojto 148:fd96258d940d 36 *
Kojto 148:fd96258d940d 37 */
Kojto 148:fd96258d940d 38
Kojto 148:fd96258d940d 39
Kojto 148:fd96258d940d 40 /** @file
Kojto 148:fd96258d940d 41 *
Kojto 148:fd96258d940d 42 * @defgroup nrf_dfu_ble_svc DFU BLE SVC
Kojto 148:fd96258d940d 43 * @{
Kojto 148:fd96258d940d 44 *
Kojto 148:fd96258d940d 45 * @brief DFU BLE SVC in bootloader. The DFU BLE SuperVisor Calls allow an application to execute
Kojto 148:fd96258d940d 46 * functions in the installed bootloader.
Kojto 148:fd96258d940d 47 *
Kojto 148:fd96258d940d 48 * @details This module implements handling of SuperVisor Calls in the bootloader.
Kojto 148:fd96258d940d 49 * SuperVisor Calls allow for an application to execute calls into the bootloader.
Kojto 148:fd96258d940d 50 * Currently, it is possible to exchange bonding information (like keys) from the
Kojto 148:fd96258d940d 51 * application to a bootloader supporting DFU OTA using BLE, so the update process can be
Kojto 148:fd96258d940d 52 * done through an already existing bond.
Kojto 148:fd96258d940d 53 *
Kojto 148:fd96258d940d 54 * @note The application must make sure that all SuperVisor Calls (SVC) are forwarded to the
Kojto 148:fd96258d940d 55 * bootloader to ensure correct behavior. Forwarding of SVCs to the bootloader is
Kojto 148:fd96258d940d 56 * done using the SoftDevice SVC @ref sd_softdevice_vector_table_base_set with the value
Kojto 148:fd96258d940d 57 * present in @c NRF_UICR->NRFFW[0].
Kojto 148:fd96258d940d 58 */
Kojto 148:fd96258d940d 59
Kojto 148:fd96258d940d 60 #ifndef DFU_BLE_SVC_H__
Kojto 148:fd96258d940d 61 #define DFU_BLE_SVC_H__
Kojto 148:fd96258d940d 62
Kojto 148:fd96258d940d 63 #include "nrf_svc.h"
Kojto 148:fd96258d940d 64 #include <stdint.h>
Kojto 148:fd96258d940d 65 #include "nrf_ble_gap.h"
Kojto 148:fd96258d940d 66 #include "nrf.h"
Kojto 148:fd96258d940d 67 #include "nrf_soc.h"
Kojto 148:fd96258d940d 68 #include "nrf_error_sdm.h"
Kojto 148:fd96258d940d 69
Kojto 148:fd96258d940d 70 #define BOOTLOADER_SVC_BASE 0x0 /**< The number of the lowest SVC number reserved for the bootloader. */
Kojto 148:fd96258d940d 71 #define SYSTEM_SERVICE_ATT_SIZE 8 /**< Size of the system service attribute length including CRC-16 at the end. */
Kojto 148:fd96258d940d 72
Kojto 148:fd96258d940d 73 /**@brief The SVC numbers used by the SVC functions in the SoC library. */
Kojto 148:fd96258d940d 74 enum BOOTLOADER_SVCS
Kojto 148:fd96258d940d 75 {
Kojto 148:fd96258d940d 76 DFU_BLE_SVC_PEER_DATA_SET = BOOTLOADER_SVC_BASE, /**< SVC number for the setting of peer data call. */
Kojto 148:fd96258d940d 77 BOOTLOADER_SVC_LAST
Kojto 148:fd96258d940d 78 };
Kojto 148:fd96258d940d 79
Kojto 148:fd96258d940d 80 /**@brief DFU Peer data structure.
Kojto 148:fd96258d940d 81 *
Kojto 148:fd96258d940d 82 * @details This structure contains peer data needed for connection to a bonded device during DFU.
Kojto 148:fd96258d940d 83 * The peer data must be provided by the application to the bootloader during buttonless
Kojto 148:fd96258d940d 84 * update. See @ref dfu_ble_svc_peer_data_set. It contains bond information about the
Kojto 148:fd96258d940d 85 * desired DFU peer.
Kojto 148:fd96258d940d 86 */
Kojto 148:fd96258d940d 87 typedef struct
Kojto 148:fd96258d940d 88 {
Kojto 148:fd96258d940d 89 ble_gap_addr_t addr; /**< BLE GAP address of the device that initiated the DFU process. */
Kojto 148:fd96258d940d 90 ble_gap_irk_t irk; /**< IRK of the device that initiated the DFU process if this device uses Private Resolvable Addresses. */
Kojto 148:fd96258d940d 91 ble_gap_enc_key_t enc_key; /**< Encryption key structure containing encrypted diversifier and LTK for re-establishing the bond. */
Kojto 148:fd96258d940d 92 uint8_t sys_serv_attr[SYSTEM_SERVICE_ATT_SIZE]; /**< System service attributes for restoring of Service Changed Indication setting in DFU mode. */
Kojto 148:fd96258d940d 93 } dfu_ble_peer_data_t;
Kojto 148:fd96258d940d 94
Kojto 148:fd96258d940d 95 /**@brief SVC Function for setting peer data containing address, IRK, and LTK to establish bonded
Kojto 148:fd96258d940d 96 * connection in DFU mode.
Kojto 148:fd96258d940d 97 *
Kojto 148:fd96258d940d 98 * @param[in] p_peer_data Pointer to the peer data containing keys for the connection.
Kojto 148:fd96258d940d 99 *
Kojto 148:fd96258d940d 100 * @retval NRF_ERROR_NULL If a NULL pointer was provided as argument.
Kojto 148:fd96258d940d 101 * @retval NRF_SUCCESS If the function completed successfully.
Kojto 148:fd96258d940d 102 */
Kojto 148:fd96258d940d 103 SVCALL(DFU_BLE_SVC_PEER_DATA_SET, uint32_t, dfu_ble_svc_peer_data_set(dfu_ble_peer_data_t * p_peer_data));
Kojto 148:fd96258d940d 104
Kojto 148:fd96258d940d 105 #endif // DFU_BLE_SVC_H__
Kojto 148:fd96258d940d 106
Kojto 148:fd96258d940d 107 /** @} */