You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by st...@apache.org on 2016/07/27 23:13:55 UTC

[26/51] [partial] incubator-mynewt-core git commit: add stm32 and nordic sdks based on new structure

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/f06c2d2b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/libraries/ant_fs/antfs.h
----------------------------------------------------------------------
diff --git a/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/libraries/ant_fs/antfs.h b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/libraries/ant_fs/antfs.h
new file mode 100644
index 0000000..4cb17fc
--- /dev/null
+++ b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/libraries/ant_fs/antfs.h
@@ -0,0 +1,350 @@
+/*
+This software is subject to the license described in the license.txt file included with this software distribution.
+You may not use this file except in compliance with this license.
+Copyright \ufffd Dynastream Innovations Inc. 2012
+All rights reserved.
+*/
+
+/**@file
+ * @brief The ANT-FS client protocol interface.
+ * This file is based on implementation originally made by Dynastream Innovations Inc. - August 2012
+ * @defgroup ant_fs_client_main ANT-FS client device simulator
+ * @{
+ * @ingroup ant_sdk_utils
+ *
+ * @brief The ANT-FS client device simulator.
+ *
+ * @note The ANT-FS Network Key is available for ANT+ Adopters. Please refer to http://thisisant.com to become an ANT+ Adopter and access the key.
+ */
+
+#ifndef ANTFS_H__
+#define ANTFS_H__
+
+#include <stdint.h>
+#include <stdbool.h>
+#include "defines.h"
+#include "antfs_config.h"
+
+#define ANTFS_VERSION_MAJOR               1u                                                                                             /**< Version major number. */
+#define ANTFS_VERSION_MINOR               0                                                                                              /**< Version minor number. */
+#define ANTFS_VERSION_ITERATION           0                                                                                              /**< Version iteration. */
+#define ANTFS_VERSION_TYPE                'R'                                                                                            /**< Version type is release. */
+#define ANTFS_VERSION_SPEC                '0.AK'                                                                                         /**< Version of the ANT-FS Technology Specification. */
+#define ANTFS_DIR_STRUCT_VERSION          1u                                                                                             /**< Version of the directory file structure. */
+#define ANTFS_VERSION_DATE                20090522u                                                                                      /**< Version date. */
+
+// ANT-FS options.
+#define ANTFS_NETWORK_NUMBER              0                                                                                              /**< ANT-FS Network Number. */
+#define ANTFS_CHANNEL                     0                                                                                              /**< ANT Channel Number. */
+#define ANTFS_LINK_FREQ                   50u                                                                                            /**< RF Frequency (+2400MHz). */
+#define ANTFS_PAIRING_TIMEOUT             120u                                                                                           /**< Pairing timeout (time the UI will wait for a response to the pairing request before switching to the link layer, in seconds). */
+#define ANTFS_LINK_COMMAND_TIMEOUT        10u                                                                                            /**< Command timeout (time the client will wait without receiving any commands before switching to the link layer, in seconds). */
+#define ANTFS_TRANS_TYPE                  5u                                                                                             /**< ANT-FS Transmission Type. */
+#define ANTFS_CHANNEL_TYPE                CHANNEL_TYPE_MASTER                                                                            /**< ANT-FS Client Channel Type. */
+#define ANTFS_BEACON_PERIOD_STATUS        BEACON_PERIOD_4_HZ                                                                             /**< ANT-FS Beacon Message Period. */
+#define ANTFS_TRANSMIT_POWER              3u                                                                                             /**< ANT Transmit Power (0dBm). */
+#define ANTFS_CUSTOM_TRANSMIT_POWER       0u                                                                                             /**< ANT Custom Transmit Power (0dBm). */
+#define ANTFS_AUTH_STRING_MAX             255u                                                                                           /**< Maximum size of authentication strings (passkey/friendly name). */
+#define ANTFS_PASSKEY_SIZE                16u                                                                                            /**< Passkey size. */
+#define ANTFS_FRIENDLY_NAME_MAX           16u                                                                                            /**< Maximum size of friendly name received from host. */
+#define ANTFS_REMOTE_FRIENDLY_NAME_MAX    16u                                                                                            /**< Maximum size of client's friendly name. */
+
+// Beacon definitions.
+#define BEACON_PERIOD_SHIFT               0x00                                                                                           /**< Shift value for masking out beacon period. */
+#define BEACON_PERIOD_MASK                (0x07u << BEACON_PERIOD_SHIFT)                                                                 /**< Beacon period bitmask. */
+#define BEACON_PERIOD_0_5_HZ              (0x00  << BEACON_PERIOD_SHIFT)                                                                 /**< Value for 0,5Hz beacon period. */
+#define BEACON_PERIOD_1_HZ                (0x01u << BEACON_PERIOD_SHIFT)                                                                 /**< Value for 1Hz beacon period. */
+#define BEACON_PERIOD_2_HZ                (0x02u << BEACON_PERIOD_SHIFT)                                                                 /**< Value for 2Hz beacon period. */
+#define BEACON_PERIOD_4_HZ                (0x03u << BEACON_PERIOD_SHIFT)                                                                 /**< Value for 4Hz beacon period. */
+#define BEACON_PERIOD_8_HZ                (0x04u << BEACON_PERIOD_SHIFT)                                                                 /**< Value for 8Hz beacon period. */
+#define PAIRING_AVAILABLE_FLAG_SHIFT      0x03u                                                                                          /**< Shift value for masking out pairing enabled bit. */
+#define PAIRING_AVAILABLE_FLAG_MASK       (0x01u << PAIRING_AVAILABLE_FLAG_SHIFT)                                                        /**< Pairing enabled bitmask. */
+#define UPLOAD_ENABLED_FLAG_SHIFT         0x04u                                                                                          /**< Shift value for masking out upload enabled bit. */
+#define UPLOAD_ENABLED_FLAG_MASK          (0x01u << UPLOAD_ENABLED_FLAG_SHIFT)                                                           /**< Upload enabled bitmask. */
+#define DATA_AVAILABLE_FLAG_SHIFT         0x05u                                                                                          /**< Shift value for masking out data available bit. */
+#define DATA_AVAILABLE_FLAG_MASK          (0x01u << DATA_AVAILABLE_FLAG_SHIFT)                                                           /**< Data available bitmask. */
+
+// Build the default beacon settings.
+#if defined (ANTFS_AUTH_TYPE_PAIRING)
+   #define ANTFS_PAIRING_BIT              PAIRING_AVAILABLE_FLAG_MASK                                                                    /**< Build pairing enabled default beacon setting. */
+#else
+   #define ANTFS_PAIRING_BIT              0x00u                                                                                          /**< Build pairing disabled default beacon setting. */
+#endif // ANTFS_INCLUDE_PAIRING
+#if defined (ANTFS_INCLUDE_UPLOAD)
+   #define ANTFS_UPLOAD_BIT               UPLOAD_ENABLED_FLAG_MASK                                                                       /**< Build upload enabled default beacon setting. */
+#else
+   #define ANTFS_UPLOAD_BIT               0x00u                                                                                          /**< Build upload disabled default beacon setting. */
+#endif // ANTFS_INCLUDE_UPLOAD
+
+#define ANTFS_DEFAULT_BEACON              (ANTFS_BEACON_PERIOD_STATUS | ANTFS_UPLOAD_BIT | ANTFS_PAIRING_BIT | DATA_AVAILABLE_FLAG_MASK) /**< Define the default beacon setting. */
+
+// Download/Upload responses.
+#define RESPONSE_MESSAGE_OK               0x00u                                                                                          /**< Download request ok. */
+#define RESPONSE_MESSAGE_NOT_EXIST        0x01u                                                                                          /**< File does not exist. */
+#define RESPONSE_MESSAGE_NOT_AVAILABLE    0x02u                                                                                          /**< File can not be read/written to (download/upload respectively). */
+#define RESPONSE_INVALID_OPERATION        0x04u                                                                                          /**< Request invalid. */
+// Download responses.
+#define RESPONSE_MESSAGE_NOT_READY        0x03u                                                                                          /**< Not ready to download. */
+#define RESPONSE_INVALID_CRC              0x05u                                                                                          /**< CRC incorrect. */
+// Upload responses.
+#define RESPONSE_MESSAGE_NOT_ENOUGH_SPACE 0x03u                                                                                          /**< Not enough space to to complete write. */
+#define RESPONSE_MESSAGE_UPLOAD_NOT_READY 0x05u                                                                                          /**< Not ready to upload */
+// Upload/Erase responses.
+#define RESPONSE_MESSAGE_FAIL             0x01u                                                                                          /**< Data File Index does not exist / Erase failed. */
+
+// Directory general file flags.
+#define ANTFS_DIR_READ_MASK               0x80u                                                                                          /**< Read (can download). */
+#define ANTFS_DIR_WRITE_MASK              0x40u                                                                                          /**< Write (can upload). */
+#define ANTFS_DIR_ERASE_MASK              0x20u                                                                                          /**< Erase (can erase). */
+#define ANTFS_DIR_ARCHIVE_MASK            0x10u                                                                                          /**< Archive (has been downloaded). */
+#define ANTFS_DIR_APPEND_MASK             0x08u                                                                                          /**< Append (can append to file only). */
+
+#define ANTFS_MAX_FILE_SIZE               0xFFFFFFFFu                                                                                    /**< Maximum file size, as specified by directory structure. */
+#define ANTFS_BURST_BLOCK_SIZE            16u                                                                                            /**< Size of each block of burst data that the client attempts to send when it processes a data request event. */
+
+/**@brief ANT-FS beacon status. */
+typedef union
+{
+    uint32_t        status;                                     /**< Beacon status byte 1. */
+
+    struct
+    {
+        uint32_t    link_period         : 3;                    /**< Beacon period (0.5 - 8 Hz). */
+        bool        is_pairing_enabled  : 1;                    /**< Pairing is enabled/disabled. */
+        bool        is_upload_enabled   : 1;                    /**< Upload is enabled/disabled. */
+        bool        is_data_available   : 1;                    /**< Data is available for download / no data available. */
+        bool        reserved            : 2;                    /**< Reserved. */
+    } parameters;
+} antfs_beacon_status_byte1_t;
+
+// ANT-FS states.
+typedef enum
+{
+    ANTFS_STATE_OFF,                                            /**< Off state. */
+    ANTFS_STATE_INIT,                                           /**< Init state. */
+    ANTFS_STATE_LINK,                                           /**< Link state. */
+    ANTFS_STATE_AUTH,                                           /**< Authenticate state. */
+    ANTFS_STATE_TRANS                                           /**< Transport state. */
+} antfs_state_t;
+
+// ANT-FS link layer substates.
+typedef enum
+{
+    ANTFS_LINK_SUBSTATE_NONE                                    /**< None state. */
+} antfs_link_substate_t;
+
+// ANT-FS authenticate layer substates. */
+typedef enum
+{
+    ANTFS_AUTH_SUBSTATE_NONE,                                   /**< None state. */
+    ANTFS_AUTH_SUBSTATE_PAIR,                                   /**< Pairing state. */
+    ANTFS_AUTH_SUBSTATE_PASSKEY,                                /**< Passkey state. */
+    ANTFS_AUTH_SUBSTATE_ACCEPT,                                 /**< Authenticate accept state. */
+    ANTFS_AUTH_SUBSTATE_REJECT                                  /**< Authenticate reject state. */
+} antfs_authenticate_substate_t;
+
+// ANT-FS transport layer substates. */
+typedef enum
+{
+    ANTFS_TRANS_SUBSTATE_NONE,                                  /**< None state. */
+    ANTFS_TRANS_SUBSTATE_VERIFY_CRC,                            /**< Verify CRC state. */
+    ANTFS_TRANS_SUBSTATE_DOWNLOADING,                           /**< Downloading state. */
+    ANTFS_TRANS_SUBSTATE_UPLOAD_WAIT_FOR_DATA,                  /**< Wait for upload data request state. */
+    ANTFS_TRANS_SUBSTATE_UPLOADING,                             /**< Ready / receiving upload data state. */
+    ANTFS_TRANS_SUBSTATE_UPLOAD_RESUME                          /**< RX failure upon receiving upload data state. */
+} antfs_transport_substate_t;
+
+// ANT-FS Events.
+typedef enum
+{
+    ANTFS_EVENT_PAIRING_REQUEST =       0xB0,                   /**< Pairing request event. */
+    ANTFS_EVENT_PAIRING_TIMEOUT =       0xB1,                   /**< Pairing timeout event. */
+    ANTFS_EVENT_OPEN_COMPLETE =         0xB2,                   /**< Channel setup complete event. */
+    ANTFS_EVENT_CLOSE_COMPLETE =        0xB4,                   /**< Channel closed event. */
+    ANTFS_EVENT_LINK =                  0xB6,                   /**< Enter link layer event. */
+    ANTFS_EVENT_AUTH =                  0xB7,                   /**< Enter authenticate layer event. */
+    ANTFS_EVENT_TRANS =                 0xB8,                   /**< Enter transport layer event. */
+    ANTFS_EVENT_DOWNLOAD_REQUEST =      0xB9,                   /**< Download request event. */
+    ANTFS_EVENT_DOWNLOAD_REQUEST_DATA = 0xBA,                   /**< Download request data event. */
+    ANTFS_EVENT_DOWNLOAD_START  =       0xBB,                   /**< Download started event. */
+    ANTFS_EVENT_DOWNLOAD_COMPLETE =     0xBC,                   /**< Download completed event. */
+    ANTFS_EVENT_DOWNLOAD_FAIL =         0xBD,                   /**< Download failed event. */
+    ANTFS_EVENT_UPLOAD_REQUEST =        0xBE,                   /**< Upload request event. */
+    ANTFS_EVENT_UPLOAD_DATA =           0xBF,                   /**< Upload data available for read event. */
+    ANTFS_EVENT_UPLOAD_START  =         0xC0,                   /**< Upload begin event. */
+    ANTFS_EVENT_UPLOAD_COMPLETE =       0xC1,                   /**< Upload completed event. */
+    ANTFS_EVENT_UPLOAD_FAIL =           0xC2,                   /**< Upload process failed event. */
+    ANTFS_EVENT_ERASE_REQUEST =         0xC3                    /**< Erase request event. */
+} antfs_event_t;
+
+/**@brief ANT-FS <-> application event communication object. */
+typedef struct
+{
+    antfs_event_t event;                                        /**< ANT-FS event. */
+    uint16_t      file_index;                                   /**< File index (download/upload/erase). */
+    uint32_t      offset;                                       /**< Current offset (download/upload). */
+    uint32_t      bytes;                                        /**< Number of bytes in block (download/upload). */
+    uint16_t      crc;                                          /**< Current CRC (upload). */
+    uint8_t       data[8];                                      /**< Block of data (upload). */
+} antfs_event_return_t;
+
+/**@brief ANT-FS parameters. */
+typedef struct
+{
+    uint32_t                    client_serial_number;           /**< Client serial number. */
+    uint16_t                    beacon_device_type;             /**< Client device type. */
+    uint16_t                    beacon_device_manufacturing_id; /**< Client manufacturing ID. */
+    uint8_t                     beacon_frequency;               /**< Beacon RF Frequency. */
+    antfs_beacon_status_byte1_t beacon_status_byte1;            /**< Beacon status byte 1. */
+    const uint8_t *             p_pass_key;                     /**< Pass Key. */
+    const uint8_t *             p_remote_friendly_name;         /**< Friendly Name. */
+} antfs_params_t;
+
+/**@brief ANT-FS directory header. */
+typedef struct
+{
+    uint8_t  version;                                           /**< Version of the directory file structure. */
+    uint8_t  length;                                            /**< Length of each structure, in bytes. */
+    uint8_t  time_format;                                       /**< Defines how system keeps track of date/time stamps. */
+    uint8_t  reserved01;
+    uint8_t  reserved02;
+    uint8_t  reserved03;
+    uint8_t  reserved04;
+    uint8_t  reserved05;
+    uint32_t system_time;                                       /**< Number of seconds elapsed since system power up. */
+    uint32_t date;                                              /**< Number of seconds elapsed since 00:00 hrs Dec 31, 1989. If system time is unknown, used as counter. */
+} antfs_dir_header_t;
+
+/**@brief ANT-FS directory entry. */
+typedef struct
+{
+    uint16_t data_file_index;                                   /**< Data file index. */
+    uint8_t  file_data_type;                                    /**< File data type. */
+    uint8_t  user_defined1;                                     /**< Identifier, first byte (structure defined by data type). */
+    uint16_t user_defined2;                                     /**< Identifier, last two bytes (structure defined by data type). */
+    uint8_t  user_flags;                                        /**< File data type specific flags (bits defined by data type). */
+    uint8_t  general_flags;                                     /**< Bit mapped flags of flag permissions. */
+    uint32_t file_size_in_bytes;                                /**< File size, in bytes. */
+    uint32_t date;                                              /**< Number of seconds elapsed since 00:00 hrs Dec 31, 1980, if supported. */
+} antfs_dir_struct_t;
+
+/**@brief ANT-FS download/upload request context. */
+typedef struct
+{
+    ulong_union_t  file_size;                                   /**< Size of a file to download when reading, or the size of a partially completed upload when writing. */
+    uint32_t       max_file_size;                               /**< The maximum size of the file specified, this is the file size when reading, and the maximum allowed file size when writing. */
+    ulong_union_t  max_burst_block_size;                        /**< Maximum burst block size. */
+    ushort_union_t file_index;                                  /**< File index. */
+    uint16_t       file_crc;                                    /**< CRC (uploads). */
+} antfs_request_info_t;
+
+/**@brief The burst wait handler can be configured by the application to customize the code that is
+ * executed while waiting for the burst busy flag. */
+typedef void(*antfs_burst_wait_handler_t)(void);
+
+/**@brief Function for setting initial ANT-FS configuration parameters.
+ *
+ * @param[in] p_params                 The initial ANT-FS configuration parameters.
+ * @param[in] burst_wait_handler       Burst wait handler.
+ */
+void antfs_init(const antfs_params_t * const p_params,
+                antfs_burst_wait_handler_t burst_wait_handler);
+
+/**@brief Function for getting host name if received.
+ *
+ * @return Pointer to host name buffer if a host name was recieved, NULL otherwise.
+ */
+const char * antfs_hostname_get(void);
+
+/**@brief Function for transmitting a response to a pairing request issued by ANT-FS host.
+ *
+ * @param[in] accept              The pairing response, true if pairing accepted.
+ *
+ * @retval true  Operation success. Response to a pairing request was transmitted.
+ * @retval false Operation failure. Not in pairing mode or pairing not supported by the
+ *               implementation.
+ */
+bool antfs_pairing_resp_transmit(bool accept);
+
+/**@brief Function for doing calculations prior downloading the data to the ANT-FS host.
+ *
+ * Function does the necessary pre processing calculations, which are required prior downloading the
+ * data, and also transmits the download request response right away in case of the download request
+ * was rejected or there is no data to send.
+ *
+ * @param[in] response            The download request response code.
+ * @param[in] p_request_info      ANT-FS request info structure.
+ */
+void antfs_download_req_resp_prepare(uint8_t response,
+                                             const antfs_request_info_t * const p_request_info);
+
+/**@brief Function for downloading requested data.
+ *
+ * @param[in] index               Index of the current file downloaded.
+ * @param[in] offset              Offset specified by client.
+ * @param[in] num_bytes           Number of bytes requested to be transmitted from the buffer.
+ * @param[in] p_message           Data buffer to be transmitted.
+ *
+ * @return Number of data bytes transmitted.
+ */
+uint32_t antfs_input_data_download(uint16_t index,
+                                   uint32_t offset,
+                                   uint32_t num_bytes,
+                                   const uint8_t * const p_message);
+
+/**@brief Function for transmitting upload request response to a upload request command by ANT-FS
+ *        host.
+ *
+ * @param[in] response            The upload response code.
+ * @param[in] p_request_info      ANT-FS request info structure.
+ *
+ * @retval true  Operation success. Response to upload request command was transmitted.
+ * @retval false Operation failure. Upload not supported by the implementation or not in correct
+ *                                  state or application is sending a response for a different file
+ *                                  than requested.
+ */
+bool antfs_upload_req_resp_transmit(uint8_t response,
+                                            const antfs_request_info_t * const p_request_info);
+
+/**@brief Function for transmitting upload data response to a upload data command by ANT-FS host.
+ *
+ * @param[in] data_upload_success The upload response code, true for success.
+ *
+ * @retval true  Operation success. Response to upload data command was transmitted.
+ * @retval false Operation failure. Upload not supported by the implementation or not in correct
+ *                                  state.
+ */
+bool antfs_upload_data_resp_transmit(bool data_upload_success);
+
+/**@brief Function for transmitting erase response to a erase request.
+ *
+ * @param[in] response            The erase response code.
+ */
+void antfs_erase_req_resp_transmit(uint8_t response);
+
+/**@brief Function for extracting possible pending ANT-FS event.
+ *
+ * @param[out] p_event            The output event structure.
+ *
+ * @retval true  Operation success. Pending ANT-FS event available and it was copied to the output
+ *                                  event structure.
+ * @retval false Operation failure. No pending ANT-FS event available.
+ */
+bool antfs_event_extract(antfs_event_return_t * const p_event);
+
+/**@brief Function for processing ANT events and data received from the ANT-FS channel.
+ *
+ * @param[in] p_message           The message buffer containing the message received from the ANT-FS
+ *                                channel.
+ */
+void antfs_message_process(uint8_t * p_message);
+
+/**@brief Function for setting up the ANT-FS channel.
+ */
+void antfs_channel_setup(void);
+
+#endif // ANTFS_H__
+
+/**
+ *@}
+ **/

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/f06c2d2b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/libraries/ant_fs/crc.c
----------------------------------------------------------------------
diff --git a/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/libraries/ant_fs/crc.c b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/libraries/ant_fs/crc.c
new file mode 100644
index 0000000..9a1aa75
--- /dev/null
+++ b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/libraries/ant_fs/crc.c
@@ -0,0 +1,55 @@
+/*
+This software is subject to the license described in the license.txt file included with this software distribution.
+You may not use this file except in compliance with this license.
+Copyright \ufffd Dynastream Innovations Inc. 2012
+All rights reserved.
+*/
+
+#include "crc.h"
+#include "compiler_abstraction.h"
+
+
+/**@brief Function for updating the current CRC-16 value for a single byte input.
+ *
+ * @param[in] current_crc The current calculated CRC-16 value.
+ * @param[in] byte        The input data byte for the computation.
+ *
+ * @return The updated CRC-16 value, based on the input supplied.
+ */
+static __INLINE uint16_t crc16_get(uint16_t current_crc, uint8_t byte)
+{
+    static const uint16_t crc16_table[16] =
+    {
+        0x0000, 0xCC01, 0xD801, 0x1400, 0xF001, 0x3C00, 0x2800, 0xE401,
+        0xA001, 0x6C00, 0x7800, 0xB401, 0x5000, 0x9C01, 0x8801, 0x4400
+    };
+
+    uint16_t temp;
+
+    // Compute checksum of lower four bits of a byte.
+    temp         = crc16_table[current_crc & 0xF];
+    current_crc  = (current_crc >> 4u) & 0x0FFFu;
+    current_crc  = current_crc ^ temp ^ crc16_table[byte & 0xF];
+
+    // Now compute checksum of upper four bits of a byte.
+    temp         = crc16_table[current_crc & 0xF];
+    current_crc  = (current_crc >> 4u) & 0x0FFFu;
+    current_crc  = current_crc ^ temp ^ crc16_table[(byte >> 4u) & 0xF];
+
+    return current_crc;
+}
+
+
+uint16_t crc_crc16_update(uint16_t current_crc, const volatile void * p_data, uint32_t size)
+{
+    uint8_t * p_block = (uint8_t *)p_data;
+
+    while (size != 0)
+    {
+        current_crc = crc16_get(current_crc, *p_block);
+        p_block++;
+        size--;
+    }
+
+   return current_crc;
+}

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/f06c2d2b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/libraries/ant_fs/crc.h
----------------------------------------------------------------------
diff --git a/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/libraries/ant_fs/crc.h b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/libraries/ant_fs/crc.h
new file mode 100644
index 0000000..54eb774
--- /dev/null
+++ b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/libraries/ant_fs/crc.h
@@ -0,0 +1,42 @@
+/*
+This software is subject to the license described in the license.txt file included with this software distribution.
+You may not use this file except in compliance with this license.
+Copyright \ufffd Dynastream Innovations Inc. 2012
+All rights reserved.
+*/
+
+/** @file
+ * @brief The CRC-16 interface.
+ * This file is based on implementation originally made by Dynastream Innovations Inc. - August 2012
+ * @defgroup ant_fs_client_main ANT-FS client device simulator
+ * @{
+ * @ingroup nrf_ant_fs_client
+ *
+ * @brief The ANT-FS client device simulator.
+ *
+ */
+
+#ifndef CRC_H__
+#define CRC_H__
+
+#include <stdint.h>
+
+/**@brief Function for calculating CRC-16 in blocks.
+ *
+ * Feed each consecutive data block into this function, along with the current value of current_crc
+ * as returned by the previous call of this function. The first call of this function should pass
+ * the initial value (usually 0) of the crc in current_crc.
+
+ * @param[in] current_crc The current calculated CRC-16 value.
+ * @param[in] p_data      The input data block for computation.
+ * @param[in] size        The size of the input data block in bytes.
+ *
+ * @return The updated CRC-16 value, based on the input supplied.
+ */
+uint16_t crc_crc16_update(uint16_t current_crc, const volatile void * p_data, uint32_t size);
+
+#endif // CRC_H__
+
+/**
+ *@}
+ **/

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/f06c2d2b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/libraries/ant_fs/defines.h
----------------------------------------------------------------------
diff --git a/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/libraries/ant_fs/defines.h b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/libraries/ant_fs/defines.h
new file mode 100644
index 0000000..8420747
--- /dev/null
+++ b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/libraries/ant_fs/defines.h
@@ -0,0 +1,60 @@
+/*
+This software is subject to the license described in the license.txt file included with this software distribution.
+You may not use this file except in compliance with this license.
+Copyright \ufffd Dynastream Innovations Inc. 2012
+All rights reserved.
+*/
+
+/**@file
+ * @brief Definitions.
+ * This file is based on implementation originally made by Dynastream Innovations Inc. - August 2012
+ * @defgroup ant_fs_client_main ANT-FS client device simulator
+ * @{
+ * @ingroup nrf_ant_fs_client
+ *
+ * @brief The ANT-FS client device simulator.
+ *
+ */
+
+#ifndef DEFINES_H__
+#define DEFINES_H__
+
+#include <stdint.h>
+
+#define MAX_ULONG 0xFFFFFFFFu                 /**< The Max value for the type. */
+
+/**@brief uint16_t type presentation as an union. */
+typedef union
+{
+    uint16_t data;                            /**< The data content. */
+
+    struct
+    {
+        uint8_t low;                          /**< The low byte of the data content. */
+        uint8_t high;                         /**< The high byte of the data content. */
+    } bytes;
+} ushort_union_t;
+
+/**@brief uint32_t type presentation as an union. */
+typedef union
+{
+    uint32_t data;                            /**< The data content as a single variable. */
+    uint8_t  data_bytes[sizeof(uint32_t)];    /**< The data content as a byte array. */
+
+    struct
+    {
+        // The least significant byte of the uint32_t in this structure is referenced by byte0.
+        uint8_t byte0;                        /**< Byte 0 of the data content. */
+        uint8_t byte1;                        /**< Byte 1 of the data content. */
+        uint8_t byte2;                        /**< Byte 2 of the data content. */
+        uint8_t byte3;                        /**< Byte 3 of the data content. */
+    } bytes;
+} ulong_union_t;
+
+#define APP_TIMER_PRESCALER 0                 /**< Value of the RTC1 PRESCALER register. */
+
+#endif // DEFINES_H__
+
+/**
+ *@}
+ **/

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/f06c2d2b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/libraries/bootloader_dfu/ble_transport/hci_mem_pool_internal.h
----------------------------------------------------------------------
diff --git a/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/libraries/bootloader_dfu/ble_transport/hci_mem_pool_internal.h b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/libraries/bootloader_dfu/ble_transport/hci_mem_pool_internal.h
new file mode 100644
index 0000000..945365e
--- /dev/null
+++ b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/libraries/bootloader_dfu/ble_transport/hci_mem_pool_internal.h
@@ -0,0 +1,32 @@
+/* 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 memory_pool_internal Memory Pool Internal
+ * @{
+ * @ingroup memory_pool
+ *
+ * @brief Memory pool internal definitions
+ */
+ 
+#ifndef MEM_POOL_INTERNAL_H__
+#define MEM_POOL_INTERNAL_H__
+
+#define TX_BUF_SIZE       4u    /**< TX buffer size in bytes. */
+#define RX_BUF_SIZE       32u   /**< RX buffer size in bytes. */
+
+#define RX_BUF_QUEUE_SIZE 8u    /**< RX buffer element size. */
+
+#endif // MEM_POOL_INTERNAL_H__
+ 
+/** @} */

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/f06c2d2b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/libraries/bootloader_dfu/bootloader.c
----------------------------------------------------------------------
diff --git a/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/libraries/bootloader_dfu/bootloader.c b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/libraries/bootloader_dfu/bootloader.c
new file mode 100644
index 0000000..2bb696f
--- /dev/null
+++ b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/libraries/bootloader_dfu/bootloader.c
@@ -0,0 +1,382 @@
+/* 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.
+ *
+ */
+
+#include "bootloader.h"
+#include "bootloader_types.h"
+#include "bootloader_util.h"
+#include "bootloader_settings.h"
+#include "dfu.h"
+#include "dfu_transport.h"
+#include "nrf.h"
+#include "app_error.h"
+#include "nrf_sdm.h"
+#include "nrf_mbr.h"
+#include "nordic_common.h"
+#include "crc16.h"
+#include "pstorage.h"
+#include "app_scheduler.h"
+#include "nrf_delay.h"
+#include "sdk_common.h"
+
+#define IRQ_ENABLED             0x01                    /**< Field identifying if an interrupt is enabled. */
+#define MAX_NUMBER_INTERRUPTS   32                      /**< Maximum number of interrupts available. */
+
+/**@brief Enumeration for specifying current bootloader status.
+ */
+typedef enum
+{
+    BOOTLOADER_UPDATING,                                /**< Bootloader status for indicating that an update is in progress. */
+    BOOTLOADER_SETTINGS_SAVING,                         /**< Bootloader status for indicating that saving of bootloader settings is in progress. */
+    BOOTLOADER_COMPLETE,                                /**< Bootloader status for indicating that all operations for the update procedure has completed and it is safe to reset the system. */
+    BOOTLOADER_TIMEOUT,                                 /**< Bootloader status field for indicating that a timeout has occured and current update process should be aborted. */
+    BOOTLOADER_RESET,                                   /**< Bootloader status field for indicating that a reset has been requested and current update process should be aborted. */
+} bootloader_status_t;
+
+static pstorage_handle_t        m_bootsettings_handle;  /**< Pstorage handle to use for registration and identifying the bootloader module on subsequent calls to the pstorage module for load and store of bootloader setting in flash. */
+static bootloader_status_t      m_update_status;        /**< Current update status for the bootloader module to ensure correct behaviour when updating settings and when update completes. */
+
+/**@brief   Function for handling callbacks from pstorage module.
+ *
+ * @details Handles pstorage results for clear and storage operation. For detailed description of
+ *          the parameters provided with the callback, please refer to \ref pstorage_ntf_cb_t.
+ */
+static void pstorage_callback_handler(pstorage_handle_t * p_handle,
+                                      uint8_t             op_code,
+                                      uint32_t            result,
+                                      uint8_t           * p_data,
+                                      uint32_t            data_len)
+{
+    // If we are in BOOTLOADER_SETTINGS_SAVING state and we receive an PSTORAGE_STORE_OP_CODE
+    // response then settings has been saved and update has completed.
+    if ((m_update_status == BOOTLOADER_SETTINGS_SAVING) && (op_code == PSTORAGE_STORE_OP_CODE))
+    {
+        m_update_status = BOOTLOADER_COMPLETE;
+    }
+
+    APP_ERROR_CHECK(result);
+}
+
+
+/**@brief   Function for waiting for events.
+ *
+ * @details This function will place the chip in low power mode while waiting for events from
+ *          the SoftDevice or other peripherals. When interrupted by an event, it will call the
+ *          @ref app_sched_execute function to process the received event. This function will return
+ *          when the final state of the firmware update is reached OR when a tear down is in
+ *          progress.
+ */
+static void wait_for_events(void)
+{
+    for (;;)
+    {
+        // Wait in low power state for any events.
+        uint32_t err_code = sd_app_evt_wait();
+        APP_ERROR_CHECK(err_code);
+
+        // Event received. Process it from the scheduler.
+        app_sched_execute();
+
+        if ((m_update_status == BOOTLOADER_COMPLETE) ||
+            (m_update_status == BOOTLOADER_TIMEOUT)  ||
+            (m_update_status == BOOTLOADER_RESET))
+        {
+            // When update has completed or a timeout/reset occured we will return.
+            return;
+        }
+    }
+}
+
+
+bool bootloader_app_is_valid(uint32_t app_addr)
+{
+    const bootloader_settings_t * p_bootloader_settings;
+
+    // There exists an application in CODE region 1.
+    if (*((uint32_t *)app_addr) == EMPTY_FLASH_MASK)
+    {
+        return false;
+    }
+
+    bool success = false;
+
+    bootloader_util_settings_get(&p_bootloader_settings);
+
+    // The application in CODE region 1 is flagged as valid during update.
+    if (p_bootloader_settings->bank_0 == BANK_VALID_APP)
+    {
+        uint16_t image_crc = 0;
+
+        // A stored crc value of 0 indicates that CRC checking is not used.
+        if (p_bootloader_settings->bank_0_crc != 0)
+        {
+            image_crc = crc16_compute((uint8_t *)DFU_BANK_0_REGION_START,
+                                      p_bootloader_settings->bank_0_size,
+                                      NULL);
+        }
+
+        success = (image_crc == p_bootloader_settings->bank_0_crc);
+    }
+
+    return success;
+}
+
+
+static void bootloader_settings_save(bootloader_settings_t * p_settings)
+{
+    uint32_t err_code = pstorage_clear(&m_bootsettings_handle, sizeof(bootloader_settings_t));
+    APP_ERROR_CHECK(err_code);
+
+    err_code = pstorage_store(&m_bootsettings_handle,
+                              (uint8_t *)p_settings,
+                              sizeof(bootloader_settings_t),
+                              0);
+    APP_ERROR_CHECK(err_code);
+}
+
+
+void bootloader_dfu_update_process(dfu_update_status_t update_status)
+{
+    static bootloader_settings_t  settings;
+    const bootloader_settings_t * p_bootloader_settings;
+
+    bootloader_util_settings_get(&p_bootloader_settings);
+
+    if (update_status.status_code == DFU_UPDATE_APP_COMPLETE)
+    {
+        settings.bank_0_crc  = update_status.app_crc;
+        settings.bank_0_size = update_status.app_size;
+        settings.bank_0      = BANK_VALID_APP;
+        settings.bank_1      = BANK_INVALID_APP;
+
+        m_update_status      = BOOTLOADER_SETTINGS_SAVING;
+        bootloader_settings_save(&settings);
+    }
+    else if (update_status.status_code == DFU_UPDATE_SD_COMPLETE)
+    {
+        settings.bank_0_crc     = update_status.app_crc;
+        settings.bank_0_size    = update_status.sd_size + 
+                                  update_status.bl_size + 
+                                  update_status.app_size;
+        settings.bank_0         = BANK_VALID_SD;
+        settings.bank_1         = BANK_INVALID_APP;
+        settings.sd_image_size  = update_status.sd_size;
+        settings.bl_image_size  = update_status.bl_size;
+        settings.app_image_size = update_status.app_size;
+        settings.sd_image_start = update_status.sd_image_start;
+
+        m_update_status         = BOOTLOADER_SETTINGS_SAVING;
+        bootloader_settings_save(&settings);
+    }
+    else if (update_status.status_code == DFU_UPDATE_BOOT_COMPLETE)
+    {
+        settings.bank_0         = p_bootloader_settings->bank_0;
+        settings.bank_0_crc     = p_bootloader_settings->bank_0_crc;
+        settings.bank_0_size    = p_bootloader_settings->bank_0_size;
+        settings.bank_1         = BANK_VALID_BOOT;
+        settings.sd_image_size  = update_status.sd_size;
+        settings.bl_image_size  = update_status.bl_size;
+        settings.app_image_size = update_status.app_size;
+
+        m_update_status         = BOOTLOADER_SETTINGS_SAVING;
+        bootloader_settings_save(&settings);
+    }
+    else if (update_status.status_code == DFU_UPDATE_SD_SWAPPED)
+    {
+        if (p_bootloader_settings->bank_0 == BANK_VALID_SD)
+        {
+            settings.bank_0_crc     = 0;
+            settings.bank_0_size    = 0;
+            settings.bank_0         = BANK_INVALID_APP;
+        }
+        // This handles cases where SoftDevice was not updated, hence bank0 keeps its settings.
+        else
+        {
+            settings.bank_0         = p_bootloader_settings->bank_0;
+            settings.bank_0_crc     = p_bootloader_settings->bank_0_crc;
+            settings.bank_0_size    = p_bootloader_settings->bank_0_size;
+        }
+
+        settings.bank_1         = BANK_INVALID_APP;
+        settings.sd_image_size  = 0;
+        settings.bl_image_size  = 0;
+        settings.app_image_size = 0;
+
+        m_update_status         = BOOTLOADER_SETTINGS_SAVING;
+        bootloader_settings_save(&settings);
+    }
+    else if (update_status.status_code == DFU_TIMEOUT)
+    {
+        // Timeout has occurred. Close the connection with the DFU Controller.
+        uint32_t err_code = dfu_transport_close();
+        APP_ERROR_CHECK(err_code);
+
+        m_update_status = BOOTLOADER_TIMEOUT;
+    }
+    else if (update_status.status_code == DFU_BANK_0_ERASED)
+    {
+        settings.bank_0_crc  = 0;
+        settings.bank_0_size = 0;
+        settings.bank_0      = BANK_INVALID_APP;
+        settings.bank_1      = p_bootloader_settings->bank_1;
+
+        bootloader_settings_save(&settings);
+    }
+    else if (update_status.status_code == DFU_RESET)
+    {
+        m_update_status = BOOTLOADER_RESET;
+    }
+    else
+    {
+        // No implementation needed.
+    }
+}
+
+
+uint32_t bootloader_init(void)
+{
+    uint32_t                err_code;
+    pstorage_module_param_t storage_params = {.cb = pstorage_callback_handler};
+
+    err_code = pstorage_init();
+    VERIFY_SUCCESS(err_code);
+
+    m_bootsettings_handle.block_id = BOOTLOADER_SETTINGS_ADDRESS;
+    err_code = pstorage_register(&storage_params, &m_bootsettings_handle);
+
+    return err_code;
+}
+
+
+uint32_t bootloader_dfu_start(void)
+{
+    uint32_t err_code;
+
+    // Clear swap if banked update is used.
+    err_code = dfu_init(); 
+    VERIFY_SUCCESS(err_code);
+
+    err_code = dfu_transport_update_start();
+
+    wait_for_events();
+
+    return err_code;
+}
+
+
+/**@brief Function for disabling all interrupts before jumping from bootloader to application.
+ */
+static void interrupts_disable(void)
+{
+    uint32_t interrupt_setting_mask;
+    uint32_t irq = 0; // We start from first interrupt, i.e. interrupt 0.
+
+    // Fetch the current interrupt settings.
+    interrupt_setting_mask = NVIC->ISER[0];
+
+    for (; irq < MAX_NUMBER_INTERRUPTS; irq++)
+    {
+        if (interrupt_setting_mask & (IRQ_ENABLED << irq))
+        {
+            // The interrupt was enabled, and hence disable it.
+            NVIC_DisableIRQ((IRQn_Type)irq);
+        }
+    }
+}
+
+
+void bootloader_app_start(uint32_t app_addr)
+{
+    // If the applications CRC has been checked and passed, the magic number will be written and we
+    // can start the application safely.
+    uint32_t err_code = sd_softdevice_disable();
+    APP_ERROR_CHECK(err_code);
+
+    interrupts_disable();
+
+    err_code = sd_softdevice_vector_table_base_set(CODE_REGION_1_START);
+    APP_ERROR_CHECK(err_code);
+
+    bootloader_util_app_start(CODE_REGION_1_START);
+}
+
+
+bool bootloader_dfu_sd_in_progress(void)
+{
+    const bootloader_settings_t * p_bootloader_settings;
+
+    bootloader_util_settings_get(&p_bootloader_settings);
+
+    if (p_bootloader_settings->bank_0 == BANK_VALID_SD ||
+        p_bootloader_settings->bank_1 == BANK_VALID_BOOT)
+    {
+        return true;
+    }
+
+    return false;
+}
+
+
+uint32_t bootloader_dfu_sd_update_continue(void)
+{
+    uint32_t err_code;
+
+    if ((dfu_sd_image_validate() == NRF_SUCCESS) &&
+        (dfu_bl_image_validate() == NRF_SUCCESS))
+    {
+        return NRF_SUCCESS;
+    }
+
+    // Ensure that flash operations are not executed within the first 100 ms seconds to allow
+    // a debugger to be attached.
+    nrf_delay_ms(100);
+
+    err_code = dfu_sd_image_swap();
+    APP_ERROR_CHECK(err_code);
+
+    err_code = dfu_sd_image_validate();
+    APP_ERROR_CHECK(err_code);
+
+    err_code = dfu_bl_image_swap();
+    APP_ERROR_CHECK(err_code);
+
+    return err_code;
+}
+
+
+uint32_t bootloader_dfu_sd_update_finalize(void)
+{
+    dfu_update_status_t update_status = {DFU_UPDATE_SD_SWAPPED, };
+
+    bootloader_dfu_update_process(update_status);
+
+    wait_for_events();
+
+    return NRF_SUCCESS;
+}
+
+
+void bootloader_settings_get(bootloader_settings_t * const p_settings)
+{
+    const bootloader_settings_t *  p_bootloader_settings;
+
+    bootloader_util_settings_get(&p_bootloader_settings);
+
+    p_settings->bank_0         = p_bootloader_settings->bank_0;
+    p_settings->bank_0_crc     = p_bootloader_settings->bank_0_crc;
+    p_settings->bank_0_size    = p_bootloader_settings->bank_0_size;
+    p_settings->bank_1         = p_bootloader_settings->bank_1;
+    p_settings->sd_image_size  = p_bootloader_settings->sd_image_size;
+    p_settings->bl_image_size  = p_bootloader_settings->bl_image_size;
+    p_settings->app_image_size = p_bootloader_settings->app_image_size;
+    p_settings->sd_image_start = p_bootloader_settings->sd_image_start;
+}
+

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/f06c2d2b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/libraries/bootloader_dfu/bootloader.h
----------------------------------------------------------------------
diff --git a/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/libraries/bootloader_dfu/bootloader.h b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/libraries/bootloader_dfu/bootloader.h
new file mode 100644
index 0000000..900c98f
--- /dev/null
+++ b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/libraries/bootloader_dfu/bootloader.h
@@ -0,0 +1,97 @@
+/* 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 nrf_bootloader Bootloader API.
+ * @{     
+ *
+ * @brief Bootloader module interface.
+ */
+
+#ifndef BOOTLOADER_H__
+#define BOOTLOADER_H__
+
+#include <stdbool.h>
+#include <stdint.h>
+#include "bootloader_types.h"
+#include <dfu_types.h>
+
+/**@brief Function for initializing the Bootloader.
+ * 
+ * @retval     NRF_SUCCESS If bootloader was succesfully initialized. 
+ */
+uint32_t bootloader_init(void);
+
+/**@brief Function for validating application region in flash.
+ * 
+ * @param[in]  app_addr      Address to the region in flash where the application is stored.
+ * 
+ * @retval     true          If Application region is valid.
+ * @retval     false         If Application region is not valid.
+ */
+bool bootloader_app_is_valid(uint32_t app_addr);
+
+/**@brief Function for starting the Device Firmware Update.
+ * 
+ * @retval     NRF_SUCCESS If new application image was successfully transferred.
+ */
+uint32_t bootloader_dfu_start(void);
+
+/**@brief Function for exiting bootloader and booting into application.
+ *
+ * @details This function will disable SoftDevice and all interrupts before jumping to application.
+ *          The SoftDevice vector table base for interrupt forwarding will be set the application
+ *          address.
+ *
+ * @param[in]  app_addr      Address to the region where the application is stored.
+ */
+void bootloader_app_start(uint32_t app_addr);
+
+/**@brief Function for retrieving the bootloader settings.
+ *
+ * @param[out] p_settings    A copy of the current bootloader settings is returned in the structure
+ *                           provided.
+ */
+void bootloader_settings_get(bootloader_settings_t * const p_settings);
+
+/**@brief Function for processing DFU status update.
+ *
+ * @param[in]  update_status DFU update status.
+ */
+void bootloader_dfu_update_process(dfu_update_status_t update_status);
+
+/**@brief Function getting state of SoftDevice update in progress.
+ *        After a successfull SoftDevice transfer the system restarts in orderto disable SoftDevice
+ *        and complete the update.
+ *
+ * @retval     true          A SoftDevice update is in progress. This indicates that second stage 
+ *                           of a SoftDevice update procedure can be initiated.
+ * @retval     false         No SoftDevice update is in progress.
+ */
+bool bootloader_dfu_sd_in_progress(void);
+
+/**@brief Function for continuing the Device Firmware Update of a SoftDevice.
+ * 
+ * @retval     NRF_SUCCESS If the final stage of SoftDevice update was successful. 
+ */
+uint32_t bootloader_dfu_sd_update_continue(void);
+
+/**@brief Function for finalizing the Device Firmware Update of a SoftDevice.
+ * 
+ * @retval     NRF_SUCCESS If the final stage of SoftDevice update was successful. 
+ */
+uint32_t bootloader_dfu_sd_update_finalize(void);
+
+#endif // BOOTLOADER_H__
+
+/**@} */

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/f06c2d2b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/libraries/bootloader_dfu/bootloader_settings.c
----------------------------------------------------------------------
diff --git a/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/libraries/bootloader_dfu/bootloader_settings.c b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/libraries/bootloader_dfu/bootloader_settings.c
new file mode 100644
index 0000000..bdb20ce
--- /dev/null
+++ b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/libraries/bootloader_dfu/bootloader_settings.c
@@ -0,0 +1,63 @@
+/* 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.
+ *
+ */
+
+#include "bootloader_settings.h"
+#include <stdint.h>
+#include <dfu_types.h>
+
+#if defined ( __CC_ARM )
+
+uint8_t  m_boot_settings[CODE_PAGE_SIZE]    __attribute__((at(BOOTLOADER_SETTINGS_ADDRESS))) __attribute__((used));                 /**< This variable reserves a codepage for bootloader specific settings, to ensure the compiler doesn't locate any code or variables at his location. */
+uint32_t m_uicr_bootloader_start_address    __attribute__((at(NRF_UICR_BOOT_START_ADDRESS))) = BOOTLOADER_REGION_START;             /**< This variable makes the linker script write the bootloader start address to the UICR register. This value will be written in the HEX file and thus written to UICR when the bootloader is flashed into the chip. */
+
+#elif defined ( __GNUC__ )
+
+uint8_t m_boot_settings[CODE_PAGE_SIZE] __attribute__ ((section(".bootloaderSettings")));                                           /**< This variable reserves a codepage for bootloader specific settings, to ensure the compiler doesn't locate any code or variables at his location. */
+volatile uint32_t m_uicr_bootloader_start_address  __attribute__ ((section(".uicrBootStartAddress"))) = BOOTLOADER_REGION_START;    /**< This variable ensures that the linker script will write the bootloader start address to the UICR register. This value will be written in the HEX file and thus written to UICR when the bootloader is flashed into the chip. */
+
+#elif defined ( __ICCARM__ )
+
+__no_init uint8_t m_boot_settings[CODE_PAGE_SIZE] @ BOOTLOADER_SETTINGS_ADDRESS;                                                    /**< This variable reserves a codepage for bootloader specific settings, to ensure the compiler doesn't locate any code or variables at his location. */
+__root    const uint32_t m_uicr_bootloader_start_address @ NRF_UICR_BOOT_START_ADDRESS = BOOTLOADER_REGION_START;                   /**< This variable ensures that the linker script will write the bootloader start address to the UICR register. This value will be written in the HEX file and thus written to UICR when the bootloader is flashed into the chip. */
+
+#endif
+
+#if defined ( NRF52 )
+#if defined ( __CC_ARM )
+
+uint8_t m_mbr_params_page[CODE_PAGE_SIZE]   __attribute__((at(BOOTLOADER_MBR_PARAMS_PAGE_ADDRESS))) __attribute__((used));          /**< This variable reserves a codepage for mbr parameters, to ensure the compiler doesn't locate any code or variables at his location. */
+uint32_t m_uicr_mbr_params_page_address     __attribute__((at(NRF_UICR_MBR_PARAMS_PAGE_ADDRESS))) 
+                                                = BOOTLOADER_MBR_PARAMS_PAGE_ADDRESS;                                               /**< This variable makes the linker script write the mbr parameters page address to the UICR register. This value will be written in the HEX file and thus written to the UICR when the bootloader is flashed into the chip */
+
+#elif defined (__GNUC__ )
+
+uint8_t m_mbr_params_page[CODE_PAGE_SIZE]           __attribute__ ((section(".mbrParamsPage")));                                    /**< This variable reserves a codepage for mbr parameters, to ensure the compiler doesn't locate any code or variables at his location. */
+volatile uint32_t m_uicr_mbr_params_page_address    __attribute__ ((section(".uicrMbrParamsPageAddress")))
+                                                = BOOTLOADER_MBR_PARAMS_PAGE_ADDRESS;                                               /**< This variable makes the linker script write the mbr parameters page address to the UICR register. This value will be written in the HEX file and thus written to the UICR when the bootloader is flashed into the chip */
+
+#elif defined (__ICCARM__ )
+
+__no_init uint8_t m_mbr_params_page[CODE_PAGE_SIZE]     @ BOOTLOADER_MBR_PARAMS_PAGE_ADDRESS;                                       /**< This variable reserves a codepage for bootloader specific settings, to ensure the compiler doesn't locate any code or variables at his location. */
+__root    const uint32_t m_uicr_mbr_params_page_address @ NRF_UICR_MBR_PARAMS_PAGE_ADDRESS = BOOTLOADER_MBR_PARAMS_PAGE_ADDRESS;    /**< This variable ensures that the linker script will write the bootloader start address to the UICR register. This value will be written in the HEX file and thus written to UICR when the bootloader is flashed into the chip. */
+
+#endif
+#endif //defined ( NRF52 )
+
+
+void bootloader_util_settings_get(const bootloader_settings_t ** pp_bootloader_settings)
+{
+    // Read only pointer to bootloader settings in flash. 
+    bootloader_settings_t const * const p_bootloader_settings =
+        (bootloader_settings_t *)&m_boot_settings[0];        
+
+    *pp_bootloader_settings = p_bootloader_settings;
+}

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/f06c2d2b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/libraries/bootloader_dfu/bootloader_settings.h
----------------------------------------------------------------------
diff --git a/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/libraries/bootloader_dfu/bootloader_settings.h b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/libraries/bootloader_dfu/bootloader_settings.h
new file mode 100644
index 0000000..27e05d3
--- /dev/null
+++ b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/libraries/bootloader_dfu/bootloader_settings.h
@@ -0,0 +1,35 @@
+/* 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.
+ *
+ */
+
+ /**@file
+ *
+ * @defgroup nrf_bootloader_settings Bootloader settings API.
+ * @{     
+ *  
+ * @brief Bootloader settings module interface.
+ */
+ 
+#ifndef BOOTLOADER_SETTINGS_H__
+#define BOOTLOADER_SETTINGS_H__
+
+#include <stdint.h>
+#include "bootloader_types.h"
+
+/**@brief Function for getting the bootloader settings.
+ * 
+ * @param[out] pp_bootloader_settings Bootloader settings. 
+ */
+void bootloader_util_settings_get(const bootloader_settings_t ** pp_bootloader_settings);
+
+#endif // BOOTLOADER_SETTINGS_H__
+
+/**@} */

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/f06c2d2b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/libraries/bootloader_dfu/bootloader_types.h
----------------------------------------------------------------------
diff --git a/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/libraries/bootloader_dfu/bootloader_types.h b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/libraries/bootloader_dfu/bootloader_types.h
new file mode 100644
index 0000000..a6ce32d
--- /dev/null
+++ b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/libraries/bootloader_dfu/bootloader_types.h
@@ -0,0 +1,59 @@
+/* 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 nrf_bootloader_types Types and definitions.
+ * @{     
+ *  
+ * @ingroup nrf_bootloader
+ * 
+ * @brief Bootloader module type and definitions.
+ */
+ 
+#ifndef BOOTLOADER_TYPES_H__
+#define BOOTLOADER_TYPES_H__
+
+#include <stdint.h>
+
+#define BOOTLOADER_DFU_START 0xB1
+
+#define BOOTLOADER_SVC_APP_DATA_PTR_GET 0x02
+
+/**@brief DFU Bank state code, which indicates wether the bank contains: A valid image, invalid image, or an erased flash.
+  */
+typedef enum
+{
+    BANK_VALID_APP   = 0x01,
+    BANK_VALID_SD    = 0xA5,
+    BANK_VALID_BOOT  = 0xAA,
+    BANK_ERASED      = 0xFE,
+    BANK_INVALID_APP = 0xFF,
+} bootloader_bank_code_t;
+
+/**@brief Structure holding bootloader settings for application and bank data.
+ */
+typedef struct
+{
+    bootloader_bank_code_t bank_0;          /**< Variable to store if bank 0 contains a valid application. */
+    uint16_t               bank_0_crc;      /**< If bank is valid, this field will contain a valid CRC of the total image. */
+    bootloader_bank_code_t bank_1;          /**< Variable to store if bank 1 has been erased/prepared for new image. Bank 1 is only used in Banked Update scenario. */
+    uint32_t               bank_0_size;     /**< Size of active image in bank0 if present, otherwise 0. */
+    uint32_t               sd_image_size;   /**< Size of SoftDevice image in bank0 if bank_0 code is BANK_VALID_SD. */
+    uint32_t               bl_image_size;   /**< Size of Bootloader image in bank0 if bank_0 code is BANK_VALID_SD. */
+    uint32_t               app_image_size;  /**< Size of Application image in bank0 if bank_0 code is BANK_VALID_SD. */
+    uint32_t               sd_image_start;  /**< Location in flash where SoftDevice image is stored for SoftDevice update. */
+} bootloader_settings_t;
+
+#endif // BOOTLOADER_TYPES_H__ 
+
+/**@} */

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/f06c2d2b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/libraries/bootloader_dfu/bootloader_util.c
----------------------------------------------------------------------
diff --git a/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/libraries/bootloader_dfu/bootloader_util.c b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/libraries/bootloader_dfu/bootloader_util.c
new file mode 100644
index 0000000..0a8a213
--- /dev/null
+++ b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/libraries/bootloader_dfu/bootloader_util.c
@@ -0,0 +1,152 @@
+/* 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.
+ *
+ */
+
+#include "bootloader_util.h"
+#include <stdint.h>
+#include <string.h>
+
+
+/**
+ * @brief Function for aborting current application/bootloader jump to to other app/bootloader.
+ *
+ * @details This functions will use the address provide to swap the stack pointer and then load 
+ *          the address of the reset handler to be executed. It will check current system mode 
+ *          (thread/handler) and if in thread mode it will reset into other application.
+ *          If in handler mode \ref isr_abort will be executed to ensure correct exit of handler 
+ *          mode and jump into reset handler of other application.
+ *
+ * @param[in]  start_addr  Start address of other application. This address must point to the 
+               initial stack pointer of the application.
+ *
+ * @note This function will never return but issue a reset into provided application.
+ */
+#if defined ( __CC_ARM )
+__asm static void bootloader_util_reset(uint32_t start_addr)
+{
+    LDR   R5, [R0]              ; Get App initial MSP for bootloader.
+    MSR   MSP, R5               ; Set the main stack pointer to the applications MSP.
+    LDR   R0, [R0, #0x04]       ; Load Reset handler into R0. This will be first argument to branch instruction (BX).
+
+    MOVS  R4, #0xFF             ; Load ones to R4.
+    SXTB  R4, R4                ; Sign extend R4 to obtain 0xFFFFFFFF instead of 0xFF.
+    MRS   R5, IPSR              ; Load IPSR to R5 to check for handler or thread mode.
+    CMP   R5, #0x00             ; Compare, if 0 then we are in thread mode and can continue to reset handler of bootloader.
+    BNE   isr_abort             ; If not zero we need to exit current ISR and jump to reset handler of bootloader.
+
+    MOV   LR, R4                ; Clear the link register and set to ones to ensure no return, R4 = 0xFFFFFFFF.
+    BX    R0                    ; Branch to reset handler of bootloader.
+
+isr_abort
+                                ; R4 contains ones from line above. Will be popped as R12 when exiting ISR (Cleaning up the registers).
+    MOV   R5, R4                ; Fill with ones before jumping to reset handling. We be popped as LR when exiting ISR. Ensures no return to application.
+    MOV   R6, R0                ; Move address of reset handler to R6. Will be popped as PC when exiting ISR. Ensures the reset handler will be executed when exist ISR.
+    MOVS  r7, #0x21             ; Move MSB reset value of xPSR to R7. Will be popped as xPSR when exiting ISR. xPSR is 0x21000000 thus MSB is 0x21.
+    REV   r7, r7                ; Reverse byte order to put 0x21 as MSB.
+    PUSH  {r4-r7}               ; Push everything to new stack to allow interrupt handler to fetch it on exiting the ISR.
+
+    MOVS  R4, #0x00             ; Fill with zeros before jumping to reset handling. We be popped as R0 when exiting ISR (Cleaning up of the registers).
+    MOVS  R5, #0x00             ; Fill with zeros before jumping to reset handling. We be popped as R1 when exiting ISR (Cleaning up of the registers).
+    MOVS  R6, #0x00             ; Fill with zeros before jumping to reset handling. We be popped as R2 when exiting ISR (Cleaning up of the registers).
+    MOVS  R7, #0x00             ; Fill with zeros before jumping to reset handling. We be popped as R3 when exiting ISR (Cleaning up of the registers).
+    PUSH  {r4-r7}               ; Push zeros (R4-R7) to stack to prepare for exiting the interrupt routine.
+
+    MOVS  R0, #0xF9             ; Move the execution return command into register, 0xFFFFFFF9.
+    SXTB  R0, R0                ; Sign extend R0 to obtain 0xFFFFFFF9 instead of 0xF9.
+    BX    R0                    ; No return - Handler mode will be exited. Stack will be popped and execution will continue in reset handler initializing other application.
+    ALIGN
+}
+#elif defined ( __GNUC__ )
+static inline void bootloader_util_reset(uint32_t start_addr)
+{
+    __asm volatile(
+        "ldr   r0, [%0]\t\n"            // Get App initial MSP for bootloader.
+        "msr   msp, r0\t\n"             // Set the main stack pointer to the applications MSP.
+        "ldr   r0, [%0, #0x04]\t\n"     // Load Reset handler into R0.
+
+        "movs  r4, #0xFF\t\n"           // Move ones to R4.
+        "sxtb  r4, r4\t\n"              // Sign extend R4 to obtain 0xFFFFFFFF instead of 0xFF.
+
+        "mrs   r5, IPSR\t\n"            // Load IPSR to R5 to check for handler or thread mode.
+        "cmp   r5, #0x00\t\n"           // Compare, if 0 then we are in thread mode and can continue to reset handler of bootloader.
+        "bne   isr_abort\t\n"           // If not zero we need to exit current ISR and jump to reset handler of bootloader.
+
+        "mov   lr, r4\t\n"              // Clear the link register and set to ones to ensure no return.
+        "bx    r0\t\n"                  // Branch to reset handler of bootloader.
+
+        "isr_abort:  \t\n"
+
+        "mov   r5, r4\t\n"              // Fill with ones before jumping to reset handling. Will be popped as LR when exiting ISR. Ensures no return to application.
+        "mov   r6, r0\t\n"              // Move address of reset handler to R6. Will be popped as PC when exiting ISR. Ensures the reset handler will be executed when exist ISR.
+        "movs  r7, #0x21\t\n"           // Move MSB reset value of xPSR to R7. Will be popped as xPSR when exiting ISR. xPSR is 0x21000000 thus MSB is 0x21.
+        "rev   r7, r7\t\n"              // Reverse byte order to put 0x21 as MSB.
+        "push  {r4-r7}\t\n"             // Push everything to new stack to allow interrupt handler to fetch it on exiting the ISR.
+
+        "movs  r4, #0x00\t\n"           // Fill with zeros before jumping to reset handling. We be popped as R0 when exiting ISR (Cleaning up of the registers).
+        "movs  r5, #0x00\t\n"           // Fill with zeros before jumping to reset handling. We be popped as R1 when exiting ISR (Cleaning up of the registers).
+        "movs  r6, #0x00\t\n"           // Fill with zeros before jumping to reset handling. We be popped as R2 when exiting ISR (Cleaning up of the registers).
+        "movs  r7, #0x00\t\n"           // Fill with zeros before jumping to reset handling. We be popped as R3 when exiting ISR (Cleaning up of the registers).
+        "push  {r4-r7}\t\n"             // Push zeros (R4-R7) to stack to prepare for exiting the interrupt routine.
+
+        "movs  r0, #0xF9\t\n"           // Move the execution return command into register, 0xFFFFFFF9.
+        "sxtb  r0, r0\t\n"              // Sign extend R0 to obtain 0xFFFFFFF9 instead of 0xF9.
+        "bx    r0\t\n"                  // No return - Handler mode will be exited. Stack will be popped and execution will continue in reset handler initializing other application.
+        ".align\t\n"
+        :: "r" (start_addr)             // Argument list for the gcc assembly. start_addr is %0.
+        :  "r0", "r4", "r5", "r6", "r7" // List of register maintained manually.
+    );
+}
+#elif defined ( __ICCARM__ )
+static inline void bootloader_util_reset(uint32_t start_addr)
+{
+    asm("ldr   r5, [%0]\n"                    // Get App initial MSP for bootloader.
+        "msr   msp, r5\n"                     // Set the main stack pointer to the applications MSP.
+        "ldr   r0, [%0, #0x04]\n"             // Load Reset handler into R0.
+
+        "movs  r4, #0x00\n"                   // Load zero into R4.
+        "mvns  r4, r4\n"                      // Invert R4 to ensure it contain ones.
+
+        "mrs   r5, IPSR\n"                    // Load IPSR to R5 to check for handler or thread mode 
+        "cmp   r5, #0x00\n"                   // Compare, if 0 then we are in thread mode and can continue to reset handler of bootloader.
+        "bne.n isr_abort\n"                   // If not zero we need to exit current ISR and jump to reset handler of bootloader.
+
+        "mov   lr, r4\n"                      // Clear the link register and set to ones to ensure no return.
+        "bx    r0\n"                          // Branch to reset handler of bootloader.
+
+        "isr_abort: \n"
+                                              // R4 contains ones from line above. We be popped as R12 when exiting ISR (Cleaning up the registers).
+        "mov   r5, r4\n"                      // Fill with ones before jumping to reset handling. Will be popped as LR when exiting ISR. Ensures no return to application.
+        "mov   r6, r0\n"                      // Move address of reset handler to R6. Will be popped as PC when exiting ISR. Ensures the reset handler will be executed when exist ISR.
+        "movs  r7, #0x21\n"                   // Move MSB reset value of xPSR to R7. Will be popped as xPSR when exiting ISR. xPSR is 0x21000000 thus MSB is 0x21.
+        "rev   r7, r7\n"                      // Reverse byte order to put 0x21 as MSB.
+        "push  {r4-r7}\n"                     // Push everything to new stack to allow interrupt handler to fetch it on exiting the ISR.
+
+        "movs  r4, #0x00\n"                   // Fill with zeros before jumping to reset handling. We be popped as R0 when exiting ISR (Cleaning up of the registers).
+        "movs  r5, #0x00\n"                   // Fill with zeros before jumping to reset handling. We be popped as R1 when exiting ISR (Cleaning up of the registers).
+        "movs  r6, #0x00\n"                   // Fill with zeros before jumping to reset handling. We be popped as R2 when exiting ISR (Cleaning up of the registers).
+        "movs  r7, #0x00\n"                   // Fill with zeros before jumping to reset handling. We be popped as R3 when exiting ISR (Cleaning up of the registers).
+        "push  {r4-r7}\n"                     // Push zeros (R4-R7) to stack to prepare for exiting the interrupt routine.
+
+        "movs  r0, #0x06\n"                   // Load 0x06 into R6 to prepare for exec return command.
+        "mvns  r0, r0\n"                      // Invert 0x06 to obtain EXEC_RETURN, 0xFFFFFFF9.
+        "bx    r0\n"                          // No return - Handler mode will be exited. Stack will be popped and execution will continue in reset handler initializing other application.
+        :: "r" (start_addr)                   // Argument list for the IAR assembly. start_addr is %0.
+        :  "r0", "r4", "r5", "r6", "r7");     // List of register maintained manually.
+}
+#else
+#error Compiler not supported.
+#endif
+
+
+void bootloader_util_app_start(uint32_t start_addr)
+{
+    bootloader_util_reset(start_addr);
+}

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/f06c2d2b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/libraries/bootloader_dfu/bootloader_util.h
----------------------------------------------------------------------
diff --git a/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/libraries/bootloader_dfu/bootloader_util.h b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/libraries/bootloader_dfu/bootloader_util.h
new file mode 100644
index 0000000..aefd764
--- /dev/null
+++ b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/libraries/bootloader_dfu/bootloader_util.h
@@ -0,0 +1,38 @@
+/* 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 nrf_bootloader_util Bootloader util API.
+ * @{     
+ *  
+ * @brief Bootloader util module interface.
+ */
+ 
+#ifndef BOOTLOADER_UTIL_H__
+#define BOOTLOADER_UTIL_H__
+
+#include <stdint.h>
+#include "bootloader_types.h"
+
+/**@brief Function for starting the application (or bootloader) at the provided address.
+ * 
+ * @param[in]  start_addr             Start address.
+ *
+ * @note This function will never retrun. Instead it will reset into the application of the 
+ *       provided address.
+ */
+void bootloader_util_app_start(uint32_t start_addr);
+
+#endif // BOOTLOADER_UTIL_H__
+
+/**@} */

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/f06c2d2b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/libraries/bootloader_dfu/dfu.h
----------------------------------------------------------------------
diff --git a/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/libraries/bootloader_dfu/dfu.h b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/libraries/bootloader_dfu/dfu.h
new file mode 100644
index 0000000..8916b7a
--- /dev/null
+++ b/hw/mcu/nordic/src/ext/nRF5_SDK_11.0.0_89a8197/components/libraries/bootloader_dfu/dfu.h
@@ -0,0 +1,134 @@
+/* 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 nrf_dfu Device Firmware Update API.
+ * @{     
+ *
+ * @brief Device Firmware Update module interface.
+ */
+
+#ifndef DFU_H__
+#define DFU_H__
+
+#include <dfu_types.h>
+#include <stdbool.h>
+#include <stdint.h>
+
+
+/**@brief DFU event callback for asynchronous calls.
+ *
+ * @param[in] packet  Packet type for which this callback is related. START_PACKET, DATA_PACKET.
+ * @param[in] result  Operation result code. NRF_SUCCESS when a queued operation was successful.
+ * @param[in] p_data  Pointer to the data to which the operation is related.
+ */
+typedef void (*dfu_callback_t)(uint32_t packet, uint32_t  result, uint8_t * p_data);
+
+/**@brief Function for initializing the Device Firmware Update module.
+ * 
+ * @return    NRF_SUCCESS on success, an error_code otherwise.
+ */
+uint32_t dfu_init(void);
+
+/**@brief Function for registering a callback listener for \ref dfu_data_pkt_handle callbacks.
+ *
+ * @param[in] callback_handler  Callback handler for receiving DFU events on completed operations
+ *                              of DFU packets.
+ */
+void dfu_register_callback(dfu_callback_t callback_handler);
+
+/**@brief Function for setting the DFU image size. 
+ *
+ * @details Function sets the DFU image size. This function must be called when an update is started 
+ *          in order to notify the DFU of the new image size. If multiple images are to be 
+ *          transferred within the same update context then this function must be called with size 
+ *          information for each image being transfered.
+ *          If an image type is not being transfered, e.g. SoftDevice but no Application , then the
+ *          image size for application must be zero.
+ * 
+ * @param[in] p_packet   Pointer to the DFU packet containing information on DFU update process to
+ *                       be started.
+ *
+ * @return    NRF_SUCCESS on success, an error_code otherwise.
+ */
+uint32_t dfu_start_pkt_handle(dfu_update_packet_t * p_packet);
+
+/**@brief Function for handling DFU data packets.
+ *
+ * @param[in] p_packet   Pointer to the DFU packet.
+ *
+ * @return    NRF_SUCCESS on success, an error_code otherwise.
+ */
+uint32_t dfu_data_pkt_handle(dfu_update_packet_t * p_packet);
+
+/**@brief Function for handling DFU init packets.
+ *
+ * @return    NRF_SUCCESS on success, an error_code otherwise.
+ */
+uint32_t dfu_init_pkt_handle(dfu_update_packet_t * p_packet);
+
+/**@brief Function for validating a transferred image after the transfer has completed.
+ * 
+ * @return    NRF_SUCCESS on success, an error_code otherwise.
+ */
+uint32_t dfu_image_validate(void);
+
+/**@brief Function for activating the transfered image after validation has successfully completed.
+ *
+ * @return    NRF_SUCCESS on success, an error_code otherwise.
+ */
+uint32_t dfu_image_activate(void);
+
+/**@brief Function for reseting the current update procedure and return to initial state.
+ *        
+ * @details This function call will result in a system reset to ensure correct system behavior.
+ *          The reset will might be scheduled to execute at a later point in time to ensure pending 
+ *          flash operations has completed.
+ */
+void dfu_reset(void);
+
+/**@brief Function for validating that new bootloader has been correctly installed.
+ *        
+ * @return NRF_SUCCESS if install was successful. NRF_ERROR_NULL if the images differs.
+ */
+uint32_t dfu_bl_image_validate(void);
+
+/**@brief Function for validating that new SoftDevicehas been correctly installed.
+ *        
+ * @return NRF_SUCCESS if install was successful. NRF_ERROR_NULL if the images differs.
+ */
+uint32_t dfu_sd_image_validate(void);
+
+/**@brief Function for swapping existing bootloader with newly received.
+ *        
+ * @return NRF_SUCCESS on succesfull swapping. For error code please refer to 
+ *         \ref sd_mbr_command_copy_bl_t.
+ */
+uint32_t dfu_bl_image_swap(void);
+
+/**@brief Function for swapping existing SoftDevice with newly received.
+ *        
+ * @return NRF_SUCCESS on succesfull swapping. For error code please refer to 
+ *         \ref sd_mbr_command_copy_sd_t.
+ */
+uint32_t dfu_sd_image_swap(void);
+
+/**@brief Function for handling DFU init packet complete.
+ *
+ * @return    NRF_SUCCESS on success, an error_code otherwise.
+ */
+uint32_t dfu_init_pkt_complete(void);
+
+#endif // DFU_H__
+
+/** @} */