Nordic nrf51 sdk sources. Mirrored from https://github.com/ARMmbed/nrf51-sdk.
source/nordic_sdk/components/libraries/bootloader_dfu/dfu_bank_internal.h@28:041dac1366b2, 2016-04-07 (annotated)
- 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?
User | Revision | Line number | New contents of line |
---|---|---|---|
vcoubard | 28:041dac1366b2 | 1 | /* Copyright (c) 2014 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 dfu_bank_internal Device Firmware Update internal header for bank handling in DFU. |
Vincent Coubard |
0:f2542974c862 | 16 | * @{ |
Vincent Coubard |
0:f2542974c862 | 17 | * |
Vincent Coubard |
0:f2542974c862 | 18 | * @brief Device Firmware Update Bank handling module interface. |
Vincent Coubard |
0:f2542974c862 | 19 | * |
Vincent Coubard |
0:f2542974c862 | 20 | * @details This header is intended for shared definition and functions between single and dual bank |
Vincent Coubard |
0:f2542974c862 | 21 | * implementations used for DFU support. It is not supposed to be used for external access |
Vincent Coubard |
0:f2542974c862 | 22 | * to the DFU module. |
Vincent Coubard |
0:f2542974c862 | 23 | * |
Vincent Coubard |
0:f2542974c862 | 24 | */ |
Vincent Coubard |
0:f2542974c862 | 25 | #ifndef DFU_BANK_INTERNAL_H__ |
Vincent Coubard |
0:f2542974c862 | 26 | #define DFU_BANK_INTERNAL_H__ |
Vincent Coubard |
0:f2542974c862 | 27 | |
vcoubard | 1:ebc0e0ef0a11 | 28 | #include <dfu_types.h> |
Vincent Coubard |
0:f2542974c862 | 29 | |
Vincent Coubard |
0:f2542974c862 | 30 | /**@brief States of the DFU state machine. */ |
Vincent Coubard |
0:f2542974c862 | 31 | typedef enum |
Vincent Coubard |
0:f2542974c862 | 32 | { |
Vincent Coubard |
0:f2542974c862 | 33 | DFU_STATE_INIT_ERROR, /**< State for: dfu_init(...) error. */ |
Vincent Coubard |
0:f2542974c862 | 34 | DFU_STATE_IDLE, /**< State for: idle. */ |
Vincent Coubard |
0:f2542974c862 | 35 | DFU_STATE_PREPARING, /**< State for: preparing, indicates that the flash is being erased and no data packets can be processed. */ |
Vincent Coubard |
0:f2542974c862 | 36 | DFU_STATE_RDY, /**< State for: ready. */ |
Vincent Coubard |
0:f2542974c862 | 37 | DFU_STATE_RX_INIT_PKT, /**< State for: receiving initialization packet. */ |
Vincent Coubard |
0:f2542974c862 | 38 | DFU_STATE_RX_DATA_PKT, /**< State for: receiving data packet. */ |
Vincent Coubard |
0:f2542974c862 | 39 | DFU_STATE_VALIDATE, /**< State for: validate. */ |
Vincent Coubard |
0:f2542974c862 | 40 | DFU_STATE_WAIT_4_ACTIVATE /**< State for: waiting for dfu_image_activate(). */ |
Vincent Coubard |
0:f2542974c862 | 41 | } dfu_state_t; |
Vincent Coubard |
0:f2542974c862 | 42 | |
Vincent Coubard |
0:f2542974c862 | 43 | #define APP_TIMER_PRESCALER 0 /**< Value of the RTC1 PRESCALER register. */ |
Vincent Coubard |
0:f2542974c862 | 44 | #define DFU_TIMEOUT_INTERVAL APP_TIMER_TICKS(120000, APP_TIMER_PRESCALER) /**< DFU timeout interval in units of timer ticks. */ |
Vincent Coubard |
0:f2542974c862 | 45 | |
Vincent Coubard |
0:f2542974c862 | 46 | #define IS_UPDATING_SD(START_PKT) ((START_PKT).dfu_update_mode & DFU_UPDATE_SD) /**< Macro for determining if a SoftDevice update is ongoing. */ |
Vincent Coubard |
0:f2542974c862 | 47 | #define IS_UPDATING_BL(START_PKT) ((START_PKT).dfu_update_mode & DFU_UPDATE_BL) /**< Macro for determining if a Bootloader update is ongoing. */ |
Vincent Coubard |
0:f2542974c862 | 48 | #define IS_UPDATING_APP(START_PKT) ((START_PKT).dfu_update_mode & DFU_UPDATE_APP) /**< Macro for determining if a Application update is ongoing. */ |
Vincent Coubard |
0:f2542974c862 | 49 | #define IMAGE_WRITE_IN_PROGRESS() (m_data_received > 0) /**< Macro for determining if an image write is in progress. */ |
Vincent Coubard |
0:f2542974c862 | 50 | #define IS_WORD_SIZED(SIZE) ((SIZE & (sizeof(uint32_t) - 1)) == 0) /**< Macro for checking that the provided is word sized. */ |
Vincent Coubard |
0:f2542974c862 | 51 | |
Vincent Coubard |
0:f2542974c862 | 52 | /**@cond NO_DOXYGEN */ |
Vincent Coubard |
0:f2542974c862 | 53 | static uint32_t m_data_received; /**< Amount of received data. */ |
Vincent Coubard |
0:f2542974c862 | 54 | /**@endcond */ |
Vincent Coubard |
0:f2542974c862 | 55 | |
Vincent Coubard |
0:f2542974c862 | 56 | /**@brief Type definition of function used for preparing of the bank before receiving of a |
Vincent Coubard |
0:f2542974c862 | 57 | * software image. |
Vincent Coubard |
0:f2542974c862 | 58 | * |
Vincent Coubard |
0:f2542974c862 | 59 | * @param[in] image_size Size of software image being received. |
Vincent Coubard |
0:f2542974c862 | 60 | */ |
Vincent Coubard |
0:f2542974c862 | 61 | typedef void (*dfu_bank_prepare_t)(uint32_t image_size); |
Vincent Coubard |
0:f2542974c862 | 62 | |
Vincent Coubard |
0:f2542974c862 | 63 | /**@brief Type definition of function used for handling clear complete of the bank before |
Vincent Coubard |
0:f2542974c862 | 64 | * receiving of a software image. |
Vincent Coubard |
0:f2542974c862 | 65 | */ |
Vincent Coubard |
0:f2542974c862 | 66 | typedef void (*dfu_bank_cleared_t)(void); |
Vincent Coubard |
0:f2542974c862 | 67 | |
Vincent Coubard |
0:f2542974c862 | 68 | /**@brief Type definition of function used for activating of the software image received. |
Vincent Coubard |
0:f2542974c862 | 69 | * |
Vincent Coubard |
0:f2542974c862 | 70 | * @return NRF_SUCCESS If the image has been successfully activated any other NRF_ERROR code in |
Vincent Coubard |
0:f2542974c862 | 71 | * case of a failure. |
Vincent Coubard |
0:f2542974c862 | 72 | */ |
Vincent Coubard |
0:f2542974c862 | 73 | typedef uint32_t (*dfu_bank_activate_t)(void); |
Vincent Coubard |
0:f2542974c862 | 74 | |
Vincent Coubard |
0:f2542974c862 | 75 | /**@brief Structure for holding of function pointers for needed prepare and activate procedure for |
Vincent Coubard |
0:f2542974c862 | 76 | * the requested update procedure. |
Vincent Coubard |
0:f2542974c862 | 77 | */ |
Vincent Coubard |
0:f2542974c862 | 78 | typedef struct |
Vincent Coubard |
0:f2542974c862 | 79 | { |
Vincent Coubard |
0:f2542974c862 | 80 | dfu_bank_prepare_t prepare; /**< Function pointer to the prepare function called on start of update procedure. */ |
Vincent Coubard |
0:f2542974c862 | 81 | dfu_bank_cleared_t cleared; /**< Function pointer to the cleared function called after prepare function completes. */ |
Vincent Coubard |
0:f2542974c862 | 82 | dfu_bank_activate_t activate; /**< Function pointer to the activate function called on finalizing the update procedure. */ |
Vincent Coubard |
0:f2542974c862 | 83 | } dfu_bank_func_t; |
Vincent Coubard |
0:f2542974c862 | 84 | |
Vincent Coubard |
0:f2542974c862 | 85 | #endif // DFU_BANK_INTERNAL_H__ |
Vincent Coubard |
0:f2542974c862 | 86 | |
vcoubard | 1:ebc0e0ef0a11 | 87 | /** @} */ |