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