Rob Kluin / nRF51822

Fork of nRF51822 by Nordic Semiconductor

Committer:
rgrover1
Date:
Fri Jun 19 15:55:35 2015 +0100
Revision:
346:14b090482fd2
Parent:
345:dfde56236c36
Child:
361:d2405f5a4853
Synchronized with git rev bb88aaad
Author: Rohit Grover
renamed BLEDevice to BLE

Who changed what in which revision?

UserRevisionLine numberNew contents of line
rgrover1 346:14b090482fd2 1 /*
rgrover1 346:14b090482fd2 2 * Copyright (c) Nordic Semiconductor ASA
rgrover1 346:14b090482fd2 3 * All rights reserved.
rgrover1 346:14b090482fd2 4 *
rgrover1 346:14b090482fd2 5 * Redistribution and use in source and binary forms, with or without modification,
rgrover1 346:14b090482fd2 6 * are permitted provided that the following conditions are met:
rgrover1 346:14b090482fd2 7 *
rgrover1 346:14b090482fd2 8 * 1. Redistributions of source code must retain the above copyright notice, this
rgrover1 346:14b090482fd2 9 * list of conditions and the following disclaimer.
rgrover1 346:14b090482fd2 10 *
rgrover1 346:14b090482fd2 11 * 2. Redistributions in binary form must reproduce the above copyright notice, this
rgrover1 346:14b090482fd2 12 * list of conditions and the following disclaimer in the documentation and/or
rgrover1 346:14b090482fd2 13 * other materials provided with the distribution.
rgrover1 346:14b090482fd2 14 *
rgrover1 346:14b090482fd2 15 * 3. Neither the name of Nordic Semiconductor ASA nor the names of other
rgrover1 346:14b090482fd2 16 * contributors to this software may be used to endorse or promote products
rgrover1 346:14b090482fd2 17 * derived from this software without specific prior written permission.
rgrover1 346:14b090482fd2 18 *
rgrover1 346:14b090482fd2 19 *
rgrover1 346:14b090482fd2 20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
rgrover1 346:14b090482fd2 21 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
rgrover1 346:14b090482fd2 22 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
rgrover1 346:14b090482fd2 23 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
rgrover1 346:14b090482fd2 24 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
rgrover1 346:14b090482fd2 25 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
rgrover1 346:14b090482fd2 26 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
rgrover1 346:14b090482fd2 27 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
rgrover1 346:14b090482fd2 28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
rgrover1 346:14b090482fd2 29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
rgrover1 346:14b090482fd2 30 *
rgrover1 346:14b090482fd2 31 */
rgrover1 346:14b090482fd2 32
rgrover1 346:14b090482fd2 33 /**@file
rgrover1 346:14b090482fd2 34 *
rgrover1 346:14b090482fd2 35 * @defgroup nrf_dfu Device Firmware Update API.
rgrover1 346:14b090482fd2 36 * @{
rgrover1 346:14b090482fd2 37 *
rgrover1 346:14b090482fd2 38 * @brief Device Firmware Update module interface.
rgrover1 346:14b090482fd2 39 */
rgrover1 346:14b090482fd2 40
rgrover1 346:14b090482fd2 41 #ifndef DFU_H__
rgrover1 346:14b090482fd2 42 #define DFU_H__
rgrover1 346:14b090482fd2 43
rgrover1 346:14b090482fd2 44 #include "dfu_types.h"
rgrover1 346:14b090482fd2 45 #include <stdbool.h>
rgrover1 346:14b090482fd2 46 #include <stdint.h>
rgrover1 346:14b090482fd2 47
rgrover1 346:14b090482fd2 48
rgrover1 346:14b090482fd2 49 /**@brief DFU event callback for asynchronous calls.
rgrover1 346:14b090482fd2 50 *
rgrover1 346:14b090482fd2 51 * @param[in] packet Packet type for which this callback is related. START_PACKET, DATA_PACKET.
rgrover1 346:14b090482fd2 52 * @param[in] result Operation result code. NRF_SUCCESS when a queued operation was successful.
rgrover1 346:14b090482fd2 53 * @param[in] p_data Pointer to the data to which the operation is related.
rgrover1 346:14b090482fd2 54 */
rgrover1 346:14b090482fd2 55 typedef void (*dfu_callback_t)(uint32_t packet, uint32_t result, uint8_t * p_data);
rgrover1 346:14b090482fd2 56
rgrover1 346:14b090482fd2 57 /**@brief Function for initializing the Device Firmware Update module.
rgrover1 346:14b090482fd2 58 *
rgrover1 346:14b090482fd2 59 * @return NRF_SUCCESS on success, an error_code otherwise.
rgrover1 346:14b090482fd2 60 */
rgrover1 346:14b090482fd2 61 uint32_t dfu_init(void);
rgrover1 346:14b090482fd2 62
rgrover1 346:14b090482fd2 63 /**@brief Function for registering a callback listener for \ref dfu_data_pkt_handle callbacks.
rgrover1 346:14b090482fd2 64 *
rgrover1 346:14b090482fd2 65 * @param[in] callback_handler Callback handler for receiving DFU events on completed operations
rgrover1 346:14b090482fd2 66 * of DFU packets.
rgrover1 346:14b090482fd2 67 */
rgrover1 346:14b090482fd2 68 void dfu_register_callback(dfu_callback_t callback_handler);
rgrover1 346:14b090482fd2 69
rgrover1 346:14b090482fd2 70 /**@brief Function for setting the DFU image size.
rgrover1 346:14b090482fd2 71 *
rgrover1 346:14b090482fd2 72 * @details Function sets the DFU image size. This function must be called when an update is started
rgrover1 346:14b090482fd2 73 * in order to notify the DFU of the new image size. If multiple images are to be
rgrover1 346:14b090482fd2 74 * transferred within the same update context then this function must be called with size
rgrover1 346:14b090482fd2 75 * information for each image being transfered.
rgrover1 346:14b090482fd2 76 * If an image type is not being transfered, e.g. SoftDevice but no Application , then the
rgrover1 346:14b090482fd2 77 * image size for application must be zero.
rgrover1 346:14b090482fd2 78 *
rgrover1 346:14b090482fd2 79 * @param[in] p_packet Pointer to the DFU packet containing information on DFU update process to
rgrover1 346:14b090482fd2 80 * be started.
rgrover1 346:14b090482fd2 81 *
rgrover1 346:14b090482fd2 82 * @return NRF_SUCCESS on success, an error_code otherwise.
rgrover1 346:14b090482fd2 83 */
rgrover1 346:14b090482fd2 84 uint32_t dfu_start_pkt_handle(dfu_update_packet_t * p_packet);
rgrover1 346:14b090482fd2 85
rgrover1 346:14b090482fd2 86 /**@brief Function for handling DFU data packets.
rgrover1 346:14b090482fd2 87 *
rgrover1 346:14b090482fd2 88 * @param[in] p_packet Pointer to the DFU packet.
rgrover1 346:14b090482fd2 89 *
rgrover1 346:14b090482fd2 90 * @return NRF_SUCCESS on success, an error_code otherwise.
rgrover1 346:14b090482fd2 91 */
rgrover1 346:14b090482fd2 92 uint32_t dfu_data_pkt_handle(dfu_update_packet_t * p_packet);
rgrover1 346:14b090482fd2 93
rgrover1 346:14b090482fd2 94 /**@brief Function for handling DFU init packets.
rgrover1 346:14b090482fd2 95 *
rgrover1 346:14b090482fd2 96 * @return NRF_SUCCESS on success, an error_code otherwise.
rgrover1 346:14b090482fd2 97 */
rgrover1 346:14b090482fd2 98 uint32_t dfu_init_pkt_handle(dfu_update_packet_t * p_packet);
rgrover1 346:14b090482fd2 99
rgrover1 346:14b090482fd2 100 /**@brief Function for validating a transferred image after the transfer has completed.
rgrover1 346:14b090482fd2 101 *
rgrover1 346:14b090482fd2 102 * @return NRF_SUCCESS on success, an error_code otherwise.
rgrover1 346:14b090482fd2 103 */
rgrover1 346:14b090482fd2 104 uint32_t dfu_image_validate(void);
rgrover1 346:14b090482fd2 105
rgrover1 346:14b090482fd2 106 /**@brief Function for activating the transfered image after validation has successfully completed.
rgrover1 346:14b090482fd2 107 *
rgrover1 346:14b090482fd2 108 * @return NRF_SUCCESS on success, an error_code otherwise.
rgrover1 346:14b090482fd2 109 */
rgrover1 346:14b090482fd2 110 uint32_t dfu_image_activate(void);
rgrover1 346:14b090482fd2 111
rgrover1 346:14b090482fd2 112 /**@brief Function for reseting the current update procedure and return to initial state.
rgrover1 346:14b090482fd2 113 *
rgrover1 346:14b090482fd2 114 * @details This function call will result in a system reset to ensure correct system behavior.
rgrover1 346:14b090482fd2 115 * The reset will might be scheduled to execute at a later point in time to ensure pending
rgrover1 346:14b090482fd2 116 * flash operations has completed.
rgrover1 346:14b090482fd2 117 */
rgrover1 346:14b090482fd2 118 void dfu_reset(void);
rgrover1 346:14b090482fd2 119
rgrover1 346:14b090482fd2 120 /**@brief Function for validating that new bootloader has been correctly installed.
rgrover1 346:14b090482fd2 121 *
rgrover1 346:14b090482fd2 122 * @return NRF_SUCCESS if install was successful. NRF_ERROR_NULL if the images differs.
rgrover1 346:14b090482fd2 123 */
rgrover1 346:14b090482fd2 124 uint32_t dfu_bl_image_validate(void);
rgrover1 346:14b090482fd2 125
rgrover1 346:14b090482fd2 126 /**@brief Function for validating that new SoftDevicehas been correctly installed.
rgrover1 346:14b090482fd2 127 *
rgrover1 346:14b090482fd2 128 * @return NRF_SUCCESS if install was successful. NRF_ERROR_NULL if the images differs.
rgrover1 346:14b090482fd2 129 */
rgrover1 346:14b090482fd2 130 uint32_t dfu_sd_image_validate(void);
rgrover1 346:14b090482fd2 131
rgrover1 346:14b090482fd2 132 /**@brief Function for swapping existing bootloader with newly received.
rgrover1 346:14b090482fd2 133 *
rgrover1 346:14b090482fd2 134 * @return NRF_SUCCESS on succesfull swapping. For error code please refer to
rgrover1 346:14b090482fd2 135 * \ref sd_mbr_command_copy_bl_t.
rgrover1 346:14b090482fd2 136 */
rgrover1 346:14b090482fd2 137 uint32_t dfu_bl_image_swap(void);
rgrover1 346:14b090482fd2 138
rgrover1 346:14b090482fd2 139 /**@brief Function for swapping existing SoftDevice with newly received.
rgrover1 346:14b090482fd2 140 *
rgrover1 346:14b090482fd2 141 * @return NRF_SUCCESS on succesfull swapping. For error code please refer to
rgrover1 346:14b090482fd2 142 * \ref sd_mbr_command_copy_sd_t.
rgrover1 346:14b090482fd2 143 */
rgrover1 346:14b090482fd2 144 uint32_t dfu_sd_image_swap(void);
rgrover1 346:14b090482fd2 145
rgrover1 346:14b090482fd2 146 /**@brief Function for handling DFU init packet complete.
rgrover1 346:14b090482fd2 147 *
rgrover1 346:14b090482fd2 148 * @return NRF_SUCCESS on success, an error_code otherwise.
rgrover1 346:14b090482fd2 149 */
rgrover1 346:14b090482fd2 150 uint32_t dfu_init_pkt_complete(void);
rgrover1 346:14b090482fd2 151
rgrover1 346:14b090482fd2 152 #endif // DFU_H__
rgrover1 346:14b090482fd2 153
rgrover1 346:14b090482fd2 154 /** @} */