The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.
Dependents: hello SerialTestv11 SerialTestv12 Sierpinski ... more
mbed 2
This is the mbed 2 library. If you'd like to learn about Mbed OS please see the mbed-os docs.
TARGET_VBLUNO51/TOOLCHAIN_IAR/dfu_bank_internal.h@171:3a7713b1edbc, 2018-11-08 (annotated)
- Committer:
- AnnaBridge
- Date:
- Thu Nov 08 11:45:42 2018 +0000
- Revision:
- 171:3a7713b1edbc
- Parent:
- TARGET_VBLUNO51/TARGET_NORDIC/TARGET_NRF5x/TARGET_SDK_11/libraries/bootloader_dfu/dfu_bank_internal.h@169:a7c7b631e539
mbed library. Release version 164
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
AnnaBridge | 143:86740a56073b | 1 | /* |
AnnaBridge | 143:86740a56073b | 2 | * Copyright (c) 2014 Nordic Semiconductor ASA |
AnnaBridge | 143:86740a56073b | 3 | * All rights reserved. |
AnnaBridge | 143:86740a56073b | 4 | * |
AnnaBridge | 143:86740a56073b | 5 | * Redistribution and use in source and binary forms, with or without modification, |
AnnaBridge | 143:86740a56073b | 6 | * are permitted provided that the following conditions are met: |
AnnaBridge | 143:86740a56073b | 7 | * |
AnnaBridge | 143:86740a56073b | 8 | * 1. Redistributions of source code must retain the above copyright notice, this list |
AnnaBridge | 143:86740a56073b | 9 | * of conditions and the following disclaimer. |
AnnaBridge | 143:86740a56073b | 10 | * |
AnnaBridge | 143:86740a56073b | 11 | * 2. Redistributions in binary form, except as embedded into a Nordic Semiconductor ASA |
AnnaBridge | 143:86740a56073b | 12 | * integrated circuit in a product or a software update for such product, must reproduce |
AnnaBridge | 143:86740a56073b | 13 | * the above copyright notice, this list of conditions and the following disclaimer in |
AnnaBridge | 143:86740a56073b | 14 | * the documentation and/or other materials provided with the distribution. |
AnnaBridge | 143:86740a56073b | 15 | * |
AnnaBridge | 143:86740a56073b | 16 | * 3. Neither the name of Nordic Semiconductor ASA nor the names of its contributors may be |
AnnaBridge | 143:86740a56073b | 17 | * used to endorse or promote products derived from this software without specific prior |
AnnaBridge | 143:86740a56073b | 18 | * written permission. |
AnnaBridge | 143:86740a56073b | 19 | * |
AnnaBridge | 143:86740a56073b | 20 | * 4. This software, with or without modification, must only be used with a |
AnnaBridge | 143:86740a56073b | 21 | * Nordic Semiconductor ASA integrated circuit. |
AnnaBridge | 143:86740a56073b | 22 | * |
AnnaBridge | 143:86740a56073b | 23 | * 5. Any software provided in binary or object form under this license must not be reverse |
AnnaBridge | 143:86740a56073b | 24 | * engineered, decompiled, modified and/or disassembled. |
AnnaBridge | 143:86740a56073b | 25 | * |
AnnaBridge | 143:86740a56073b | 26 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND |
AnnaBridge | 143:86740a56073b | 27 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
AnnaBridge | 143:86740a56073b | 28 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
AnnaBridge | 143:86740a56073b | 29 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR |
AnnaBridge | 143:86740a56073b | 30 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
AnnaBridge | 143:86740a56073b | 31 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
AnnaBridge | 143:86740a56073b | 32 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON |
AnnaBridge | 143:86740a56073b | 33 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
AnnaBridge | 143:86740a56073b | 34 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
AnnaBridge | 143:86740a56073b | 35 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
AnnaBridge | 143:86740a56073b | 36 | * |
AnnaBridge | 143:86740a56073b | 37 | */ |
AnnaBridge | 143:86740a56073b | 38 | |
AnnaBridge | 143:86740a56073b | 39 | |
AnnaBridge | 143:86740a56073b | 40 | /**@file |
AnnaBridge | 143:86740a56073b | 41 | * |
AnnaBridge | 143:86740a56073b | 42 | * @defgroup dfu_bank_internal Device Firmware Update internal header for bank handling in DFU. |
AnnaBridge | 143:86740a56073b | 43 | * @{ |
AnnaBridge | 143:86740a56073b | 44 | * |
AnnaBridge | 143:86740a56073b | 45 | * @brief Device Firmware Update Bank handling module interface. |
AnnaBridge | 143:86740a56073b | 46 | * |
AnnaBridge | 143:86740a56073b | 47 | * @details This header is intended for shared definition and functions between single and dual bank |
AnnaBridge | 143:86740a56073b | 48 | * implementations used for DFU support. It is not supposed to be used for external access |
AnnaBridge | 143:86740a56073b | 49 | * to the DFU module. |
AnnaBridge | 143:86740a56073b | 50 | * |
AnnaBridge | 143:86740a56073b | 51 | */ |
AnnaBridge | 143:86740a56073b | 52 | #ifndef DFU_BANK_INTERNAL_H__ |
AnnaBridge | 143:86740a56073b | 53 | #define DFU_BANK_INTERNAL_H__ |
AnnaBridge | 143:86740a56073b | 54 | |
AnnaBridge | 143:86740a56073b | 55 | #include <dfu_types.h> |
AnnaBridge | 143:86740a56073b | 56 | |
AnnaBridge | 143:86740a56073b | 57 | /**@brief States of the DFU state machine. */ |
AnnaBridge | 143:86740a56073b | 58 | typedef enum |
AnnaBridge | 143:86740a56073b | 59 | { |
AnnaBridge | 143:86740a56073b | 60 | DFU_STATE_INIT_ERROR, /**< State for: dfu_init(...) error. */ |
AnnaBridge | 143:86740a56073b | 61 | DFU_STATE_IDLE, /**< State for: idle. */ |
AnnaBridge | 143:86740a56073b | 62 | DFU_STATE_PREPARING, /**< State for: preparing, indicates that the flash is being erased and no data packets can be processed. */ |
AnnaBridge | 143:86740a56073b | 63 | DFU_STATE_RDY, /**< State for: ready. */ |
AnnaBridge | 143:86740a56073b | 64 | DFU_STATE_RX_INIT_PKT, /**< State for: receiving initialization packet. */ |
AnnaBridge | 143:86740a56073b | 65 | DFU_STATE_RX_DATA_PKT, /**< State for: receiving data packet. */ |
AnnaBridge | 143:86740a56073b | 66 | DFU_STATE_VALIDATE, /**< State for: validate. */ |
AnnaBridge | 143:86740a56073b | 67 | DFU_STATE_WAIT_4_ACTIVATE /**< State for: waiting for dfu_image_activate(). */ |
AnnaBridge | 143:86740a56073b | 68 | } dfu_state_t; |
AnnaBridge | 143:86740a56073b | 69 | |
AnnaBridge | 143:86740a56073b | 70 | #define APP_TIMER_PRESCALER 0 /**< Value of the RTC1 PRESCALER register. */ |
AnnaBridge | 143:86740a56073b | 71 | #define DFU_TIMEOUT_INTERVAL APP_TIMER_TICKS(120000, APP_TIMER_PRESCALER) /**< DFU timeout interval in units of timer ticks. */ |
AnnaBridge | 143:86740a56073b | 72 | |
AnnaBridge | 143:86740a56073b | 73 | #define IS_UPDATING_SD(START_PKT) ((START_PKT).dfu_update_mode & DFU_UPDATE_SD) /**< Macro for determining if a SoftDevice update is ongoing. */ |
AnnaBridge | 143:86740a56073b | 74 | #define IS_UPDATING_BL(START_PKT) ((START_PKT).dfu_update_mode & DFU_UPDATE_BL) /**< Macro for determining if a Bootloader update is ongoing. */ |
AnnaBridge | 143:86740a56073b | 75 | #define IS_UPDATING_APP(START_PKT) ((START_PKT).dfu_update_mode & DFU_UPDATE_APP) /**< Macro for determining if a Application update is ongoing. */ |
AnnaBridge | 143:86740a56073b | 76 | #define IMAGE_WRITE_IN_PROGRESS() (m_data_received > 0) /**< Macro for determining if an image write is in progress. */ |
AnnaBridge | 143:86740a56073b | 77 | #define IS_WORD_SIZED(SIZE) ((SIZE & (sizeof(uint32_t) - 1)) == 0) /**< Macro for checking that the provided is word sized. */ |
AnnaBridge | 143:86740a56073b | 78 | |
AnnaBridge | 143:86740a56073b | 79 | /**@cond NO_DOXYGEN */ |
AnnaBridge | 143:86740a56073b | 80 | static uint32_t m_data_received; /**< Amount of received data. */ |
AnnaBridge | 143:86740a56073b | 81 | /**@endcond */ |
AnnaBridge | 143:86740a56073b | 82 | |
AnnaBridge | 143:86740a56073b | 83 | /**@brief Type definition of function used for preparing of the bank before receiving of a |
AnnaBridge | 143:86740a56073b | 84 | * software image. |
AnnaBridge | 143:86740a56073b | 85 | * |
AnnaBridge | 143:86740a56073b | 86 | * @param[in] image_size Size of software image being received. |
AnnaBridge | 143:86740a56073b | 87 | */ |
AnnaBridge | 143:86740a56073b | 88 | typedef void (*dfu_bank_prepare_t)(uint32_t image_size); |
AnnaBridge | 143:86740a56073b | 89 | |
AnnaBridge | 143:86740a56073b | 90 | /**@brief Type definition of function used for handling clear complete of the bank before |
AnnaBridge | 143:86740a56073b | 91 | * receiving of a software image. |
AnnaBridge | 143:86740a56073b | 92 | */ |
AnnaBridge | 143:86740a56073b | 93 | typedef void (*dfu_bank_cleared_t)(void); |
AnnaBridge | 143:86740a56073b | 94 | |
AnnaBridge | 143:86740a56073b | 95 | /**@brief Type definition of function used for activating of the software image received. |
AnnaBridge | 143:86740a56073b | 96 | * |
AnnaBridge | 143:86740a56073b | 97 | * @return NRF_SUCCESS If the image has been successfully activated any other NRF_ERROR code in |
AnnaBridge | 143:86740a56073b | 98 | * case of a failure. |
AnnaBridge | 143:86740a56073b | 99 | */ |
AnnaBridge | 143:86740a56073b | 100 | typedef uint32_t (*dfu_bank_activate_t)(void); |
AnnaBridge | 143:86740a56073b | 101 | |
AnnaBridge | 143:86740a56073b | 102 | /**@brief Structure for holding of function pointers for needed prepare and activate procedure for |
AnnaBridge | 143:86740a56073b | 103 | * the requested update procedure. |
AnnaBridge | 143:86740a56073b | 104 | */ |
AnnaBridge | 143:86740a56073b | 105 | typedef struct |
AnnaBridge | 143:86740a56073b | 106 | { |
AnnaBridge | 143:86740a56073b | 107 | dfu_bank_prepare_t prepare; /**< Function pointer to the prepare function called on start of update procedure. */ |
AnnaBridge | 143:86740a56073b | 108 | dfu_bank_cleared_t cleared; /**< Function pointer to the cleared function called after prepare function completes. */ |
AnnaBridge | 143:86740a56073b | 109 | dfu_bank_activate_t activate; /**< Function pointer to the activate function called on finalizing the update procedure. */ |
AnnaBridge | 143:86740a56073b | 110 | } dfu_bank_func_t; |
AnnaBridge | 143:86740a56073b | 111 | |
AnnaBridge | 143:86740a56073b | 112 | #endif // DFU_BANK_INTERNAL_H__ |
AnnaBridge | 143:86740a56073b | 113 | |
AnnaBridge | 143:86740a56073b | 114 | /** @} */ |