Nordic nrf51 sdk sources. Mirrored from https://github.com/ARMmbed/nrf51-sdk.

Dependents:   nRF51822 nRF51822

Committer:
vcoubard
Date:
Thu Apr 07 17:37:56 2016 +0100
Revision:
28:041dac1366b2
Parent:
20:a90c48eb1d30
Child:
29:286940b7ee5a
Synchronized with git rev 012b8118
Author: Liyou Zhou
Pull in files from sdk 10.0

Who changed what in which revision?

UserRevisionLine numberNew contents of line
vcoubard 28:041dac1366b2 1 /* Copyright (c) 2013 Nordic Semiconductor. All Rights Reserved.
vcoubard 28:041dac1366b2 2 *
vcoubard 28:041dac1366b2 3 * The information contained herein is property of Nordic Semiconductor ASA.
vcoubard 28:041dac1366b2 4 * Terms and conditions of usage are described in detail in NORDIC
vcoubard 28:041dac1366b2 5 * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
vcoubard 28:041dac1366b2 6 *
vcoubard 28:041dac1366b2 7 * Licensees are granted free, non-transferable use of the information. NO
vcoubard 28:041dac1366b2 8 * WARRANTY of ANY KIND is provided. This heading must NOT be removed from
vcoubard 28:041dac1366b2 9 * the file.
vcoubard 28:041dac1366b2 10 *
Vincent Coubard 0:f2542974c862 11 */
Vincent Coubard 0:f2542974c862 12
Vincent Coubard 0:f2542974c862 13 /**@file
Vincent Coubard 0:f2542974c862 14 *
Vincent Coubard 0:f2542974c862 15 * @defgroup nrf_dfu Device Firmware Update API.
Vincent Coubard 0:f2542974c862 16 * @{
Vincent Coubard 0:f2542974c862 17 *
Vincent Coubard 0:f2542974c862 18 * @brief Device Firmware Update module interface.
Vincent Coubard 0:f2542974c862 19 */
Vincent Coubard 0:f2542974c862 20
Vincent Coubard 0:f2542974c862 21 #ifndef DFU_H__
Vincent Coubard 0:f2542974c862 22 #define DFU_H__
Vincent Coubard 0:f2542974c862 23
vcoubard 1:ebc0e0ef0a11 24 #include <dfu_types.h>
Vincent Coubard 0:f2542974c862 25 #include <stdbool.h>
Vincent Coubard 0:f2542974c862 26 #include <stdint.h>
Vincent Coubard 0:f2542974c862 27
Vincent Coubard 0:f2542974c862 28
Vincent Coubard 0:f2542974c862 29 /**@brief DFU event callback for asynchronous calls.
Vincent Coubard 0:f2542974c862 30 *
Vincent Coubard 0:f2542974c862 31 * @param[in] packet Packet type for which this callback is related. START_PACKET, DATA_PACKET.
Vincent Coubard 0:f2542974c862 32 * @param[in] result Operation result code. NRF_SUCCESS when a queued operation was successful.
Vincent Coubard 0:f2542974c862 33 * @param[in] p_data Pointer to the data to which the operation is related.
Vincent Coubard 0:f2542974c862 34 */
Vincent Coubard 0:f2542974c862 35 typedef void (*dfu_callback_t)(uint32_t packet, uint32_t result, uint8_t * p_data);
Vincent Coubard 0:f2542974c862 36
Vincent Coubard 0:f2542974c862 37 /**@brief Function for initializing the Device Firmware Update module.
Vincent Coubard 0:f2542974c862 38 *
Vincent Coubard 0:f2542974c862 39 * @return NRF_SUCCESS on success, an error_code otherwise.
Vincent Coubard 0:f2542974c862 40 */
Vincent Coubard 0:f2542974c862 41 uint32_t dfu_init(void);
Vincent Coubard 0:f2542974c862 42
Vincent Coubard 0:f2542974c862 43 /**@brief Function for registering a callback listener for \ref dfu_data_pkt_handle callbacks.
Vincent Coubard 0:f2542974c862 44 *
Vincent Coubard 0:f2542974c862 45 * @param[in] callback_handler Callback handler for receiving DFU events on completed operations
Vincent Coubard 0:f2542974c862 46 * of DFU packets.
Vincent Coubard 0:f2542974c862 47 */
Vincent Coubard 0:f2542974c862 48 void dfu_register_callback(dfu_callback_t callback_handler);
Vincent Coubard 0:f2542974c862 49
Vincent Coubard 0:f2542974c862 50 /**@brief Function for setting the DFU image size.
Vincent Coubard 0:f2542974c862 51 *
Vincent Coubard 0:f2542974c862 52 * @details Function sets the DFU image size. This function must be called when an update is started
Vincent Coubard 0:f2542974c862 53 * in order to notify the DFU of the new image size. If multiple images are to be
Vincent Coubard 0:f2542974c862 54 * transferred within the same update context then this function must be called with size
Vincent Coubard 0:f2542974c862 55 * information for each image being transfered.
Vincent Coubard 0:f2542974c862 56 * If an image type is not being transfered, e.g. SoftDevice but no Application , then the
Vincent Coubard 0:f2542974c862 57 * image size for application must be zero.
Vincent Coubard 0:f2542974c862 58 *
Vincent Coubard 0:f2542974c862 59 * @param[in] p_packet Pointer to the DFU packet containing information on DFU update process to
Vincent Coubard 0:f2542974c862 60 * be started.
Vincent Coubard 0:f2542974c862 61 *
Vincent Coubard 0:f2542974c862 62 * @return NRF_SUCCESS on success, an error_code otherwise.
Vincent Coubard 0:f2542974c862 63 */
Vincent Coubard 0:f2542974c862 64 uint32_t dfu_start_pkt_handle(dfu_update_packet_t * p_packet);
Vincent Coubard 0:f2542974c862 65
Vincent Coubard 0:f2542974c862 66 /**@brief Function for handling DFU data packets.
Vincent Coubard 0:f2542974c862 67 *
Vincent Coubard 0:f2542974c862 68 * @param[in] p_packet Pointer to the DFU packet.
Vincent Coubard 0:f2542974c862 69 *
Vincent Coubard 0:f2542974c862 70 * @return NRF_SUCCESS on success, an error_code otherwise.
Vincent Coubard 0:f2542974c862 71 */
Vincent Coubard 0:f2542974c862 72 uint32_t dfu_data_pkt_handle(dfu_update_packet_t * p_packet);
Vincent Coubard 0:f2542974c862 73
Vincent Coubard 0:f2542974c862 74 /**@brief Function for handling DFU init packets.
Vincent Coubard 0:f2542974c862 75 *
Vincent Coubard 0:f2542974c862 76 * @return NRF_SUCCESS on success, an error_code otherwise.
Vincent Coubard 0:f2542974c862 77 */
Vincent Coubard 0:f2542974c862 78 uint32_t dfu_init_pkt_handle(dfu_update_packet_t * p_packet);
Vincent Coubard 0:f2542974c862 79
Vincent Coubard 0:f2542974c862 80 /**@brief Function for validating a transferred image after the transfer has completed.
Vincent Coubard 0:f2542974c862 81 *
Vincent Coubard 0:f2542974c862 82 * @return NRF_SUCCESS on success, an error_code otherwise.
Vincent Coubard 0:f2542974c862 83 */
Vincent Coubard 0:f2542974c862 84 uint32_t dfu_image_validate(void);
Vincent Coubard 0:f2542974c862 85
Vincent Coubard 0:f2542974c862 86 /**@brief Function for activating the transfered image after validation has successfully completed.
Vincent Coubard 0:f2542974c862 87 *
Vincent Coubard 0:f2542974c862 88 * @return NRF_SUCCESS on success, an error_code otherwise.
Vincent Coubard 0:f2542974c862 89 */
Vincent Coubard 0:f2542974c862 90 uint32_t dfu_image_activate(void);
Vincent Coubard 0:f2542974c862 91
Vincent Coubard 0:f2542974c862 92 /**@brief Function for reseting the current update procedure and return to initial state.
Vincent Coubard 0:f2542974c862 93 *
Vincent Coubard 0:f2542974c862 94 * @details This function call will result in a system reset to ensure correct system behavior.
Vincent Coubard 0:f2542974c862 95 * The reset will might be scheduled to execute at a later point in time to ensure pending
Vincent Coubard 0:f2542974c862 96 * flash operations has completed.
Vincent Coubard 0:f2542974c862 97 */
Vincent Coubard 0:f2542974c862 98 void dfu_reset(void);
Vincent Coubard 0:f2542974c862 99
Vincent Coubard 0:f2542974c862 100 /**@brief Function for validating that new bootloader has been correctly installed.
Vincent Coubard 0:f2542974c862 101 *
Vincent Coubard 0:f2542974c862 102 * @return NRF_SUCCESS if install was successful. NRF_ERROR_NULL if the images differs.
Vincent Coubard 0:f2542974c862 103 */
Vincent Coubard 0:f2542974c862 104 uint32_t dfu_bl_image_validate(void);
Vincent Coubard 0:f2542974c862 105
Vincent Coubard 0:f2542974c862 106 /**@brief Function for validating that new SoftDevicehas been correctly installed.
Vincent Coubard 0:f2542974c862 107 *
Vincent Coubard 0:f2542974c862 108 * @return NRF_SUCCESS if install was successful. NRF_ERROR_NULL if the images differs.
Vincent Coubard 0:f2542974c862 109 */
Vincent Coubard 0:f2542974c862 110 uint32_t dfu_sd_image_validate(void);
Vincent Coubard 0:f2542974c862 111
Vincent Coubard 0:f2542974c862 112 /**@brief Function for swapping existing bootloader with newly received.
Vincent Coubard 0:f2542974c862 113 *
Vincent Coubard 0:f2542974c862 114 * @return NRF_SUCCESS on succesfull swapping. For error code please refer to
Vincent Coubard 0:f2542974c862 115 * \ref sd_mbr_command_copy_bl_t.
Vincent Coubard 0:f2542974c862 116 */
Vincent Coubard 0:f2542974c862 117 uint32_t dfu_bl_image_swap(void);
Vincent Coubard 0:f2542974c862 118
Vincent Coubard 0:f2542974c862 119 /**@brief Function for swapping existing SoftDevice with newly received.
Vincent Coubard 0:f2542974c862 120 *
Vincent Coubard 0:f2542974c862 121 * @return NRF_SUCCESS on succesfull swapping. For error code please refer to
Vincent Coubard 0:f2542974c862 122 * \ref sd_mbr_command_copy_sd_t.
Vincent Coubard 0:f2542974c862 123 */
Vincent Coubard 0:f2542974c862 124 uint32_t dfu_sd_image_swap(void);
Vincent Coubard 0:f2542974c862 125
Vincent Coubard 0:f2542974c862 126 /**@brief Function for handling DFU init packet complete.
Vincent Coubard 0:f2542974c862 127 *
Vincent Coubard 0:f2542974c862 128 * @return NRF_SUCCESS on success, an error_code otherwise.
Vincent Coubard 0:f2542974c862 129 */
Vincent Coubard 0:f2542974c862 130 uint32_t dfu_init_pkt_complete(void);
Vincent Coubard 0:f2542974c862 131
Vincent Coubard 0:f2542974c862 132 #endif // DFU_H__
Vincent Coubard 0:f2542974c862 133
vcoubard 1:ebc0e0ef0a11 134 /** @} */