To get started with Seeed Tiny BLE, include detecting motion, button and battery level.
Dependencies: BLE_API eMPL_MPU6050 mbed nRF51822
nRF51822/nordic-sdk/components/libraries/bootloader_dfu/dfu_bank_internal.h@2:b61ddbb8528e, 2015-11-05 (annotated)
- Committer:
- yihui
- Date:
- Thu Nov 05 02:46:37 2015 +0000
- Revision:
- 2:b61ddbb8528e
- Parent:
- 1:fc2f9d636751
able to recover from i2c bus fault
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
yihui | 1:fc2f9d636751 | 1 | /* Copyright (c) 2014 Nordic Semiconductor. All Rights Reserved. |
yihui | 1:fc2f9d636751 | 2 | * |
yihui | 1:fc2f9d636751 | 3 | * The information contained herein is property of Nordic Semiconductor ASA. |
yihui | 1:fc2f9d636751 | 4 | * Terms and conditions of usage are described in detail in NORDIC |
yihui | 1:fc2f9d636751 | 5 | * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. |
yihui | 1:fc2f9d636751 | 6 | * |
yihui | 1:fc2f9d636751 | 7 | * Licensees are granted free, non-transferable use of the information. NO |
yihui | 1:fc2f9d636751 | 8 | * WARRANTY of ANY KIND is provided. This heading must NOT be removed from |
yihui | 1:fc2f9d636751 | 9 | * the file. |
yihui | 1:fc2f9d636751 | 10 | * |
yihui | 1:fc2f9d636751 | 11 | */ |
yihui | 1:fc2f9d636751 | 12 | |
yihui | 1:fc2f9d636751 | 13 | /**@file |
yihui | 1:fc2f9d636751 | 14 | * |
yihui | 1:fc2f9d636751 | 15 | * @defgroup dfu_bank_internal Device Firmware Update internal header for bank handling in DFU. |
yihui | 1:fc2f9d636751 | 16 | * @{ |
yihui | 1:fc2f9d636751 | 17 | * |
yihui | 1:fc2f9d636751 | 18 | * @brief Device Firmware Update Bank handling module interface. |
yihui | 1:fc2f9d636751 | 19 | * |
yihui | 1:fc2f9d636751 | 20 | * @details This header is intended for shared definition and functions between single and dual bank |
yihui | 1:fc2f9d636751 | 21 | * implementations used for DFU support. It is not supposed to be used for external access |
yihui | 1:fc2f9d636751 | 22 | * to the DFU module. |
yihui | 1:fc2f9d636751 | 23 | * |
yihui | 1:fc2f9d636751 | 24 | */ |
yihui | 1:fc2f9d636751 | 25 | #ifndef DFU_BANK_INTERNAL_H__ |
yihui | 1:fc2f9d636751 | 26 | #define DFU_BANK_INTERNAL_H__ |
yihui | 1:fc2f9d636751 | 27 | |
yihui | 1:fc2f9d636751 | 28 | #include "dfu_types.h" |
yihui | 1:fc2f9d636751 | 29 | |
yihui | 1:fc2f9d636751 | 30 | /**@brief States of the DFU state machine. */ |
yihui | 1:fc2f9d636751 | 31 | typedef enum |
yihui | 1:fc2f9d636751 | 32 | { |
yihui | 1:fc2f9d636751 | 33 | DFU_STATE_INIT_ERROR, /**< State for: dfu_init(...) error. */ |
yihui | 1:fc2f9d636751 | 34 | DFU_STATE_IDLE, /**< State for: idle. */ |
yihui | 1:fc2f9d636751 | 35 | DFU_STATE_PREPARING, /**< State for: preparing, indicates that the flash is being erased and no data packets can be processed. */ |
yihui | 1:fc2f9d636751 | 36 | DFU_STATE_RDY, /**< State for: ready. */ |
yihui | 1:fc2f9d636751 | 37 | DFU_STATE_RX_INIT_PKT, /**< State for: receiving initialization packet. */ |
yihui | 1:fc2f9d636751 | 38 | DFU_STATE_RX_DATA_PKT, /**< State for: receiving data packet. */ |
yihui | 1:fc2f9d636751 | 39 | DFU_STATE_VALIDATE, /**< State for: validate. */ |
yihui | 1:fc2f9d636751 | 40 | DFU_STATE_WAIT_4_ACTIVATE /**< State for: waiting for dfu_image_activate(). */ |
yihui | 1:fc2f9d636751 | 41 | } dfu_state_t; |
yihui | 1:fc2f9d636751 | 42 | |
yihui | 1:fc2f9d636751 | 43 | #define APP_TIMER_PRESCALER 0 /**< Value of the RTC1 PRESCALER register. */ |
yihui | 1:fc2f9d636751 | 44 | #define DFU_TIMEOUT_INTERVAL APP_TIMER_TICKS(120000, APP_TIMER_PRESCALER) /**< DFU timeout interval in units of timer ticks. */ |
yihui | 1:fc2f9d636751 | 45 | |
yihui | 1:fc2f9d636751 | 46 | #define IS_UPDATING_SD(START_PKT) ((START_PKT).dfu_update_mode & DFU_UPDATE_SD) /**< Macro for determining if a SoftDevice update is ongoing. */ |
yihui | 1:fc2f9d636751 | 47 | #define IS_UPDATING_BL(START_PKT) ((START_PKT).dfu_update_mode & DFU_UPDATE_BL) /**< Macro for determining if a Bootloader update is ongoing. */ |
yihui | 1:fc2f9d636751 | 48 | #define IS_UPDATING_APP(START_PKT) ((START_PKT).dfu_update_mode & DFU_UPDATE_APP) /**< Macro for determining if a Application update is ongoing. */ |
yihui | 1:fc2f9d636751 | 49 | #define IMAGE_WRITE_IN_PROGRESS() (m_data_received > 0) /**< Macro for determining is image write in progress. */ |
yihui | 1:fc2f9d636751 | 50 | #define IS_WORD_SIZED(SIZE) ((SIZE & (sizeof(uint32_t) - 1)) == 0) /**< Macro for checking that the provided is word sized. */ |
yihui | 1:fc2f9d636751 | 51 | |
yihui | 1:fc2f9d636751 | 52 | static uint32_t m_data_received; /**< Amount of received data. */ |
yihui | 1:fc2f9d636751 | 53 | |
yihui | 1:fc2f9d636751 | 54 | /**@brief Type definition of function used for preparing of the bank before receiving of a |
yihui | 1:fc2f9d636751 | 55 | * software image. |
yihui | 1:fc2f9d636751 | 56 | * |
yihui | 1:fc2f9d636751 | 57 | * @param[in] image_size Size of software image being received. |
yihui | 1:fc2f9d636751 | 58 | */ |
yihui | 1:fc2f9d636751 | 59 | typedef void (*dfu_bank_prepare_t)(uint32_t image_size); |
yihui | 1:fc2f9d636751 | 60 | |
yihui | 1:fc2f9d636751 | 61 | /**@brief Type definition of function used for handling clear complete of the bank before |
yihui | 1:fc2f9d636751 | 62 | * receiving of a software image. |
yihui | 1:fc2f9d636751 | 63 | */ |
yihui | 1:fc2f9d636751 | 64 | typedef void (*dfu_bank_cleared_t)(void); |
yihui | 1:fc2f9d636751 | 65 | |
yihui | 1:fc2f9d636751 | 66 | /**@brief Type definition of function used for activating of the software image received. |
yihui | 1:fc2f9d636751 | 67 | * |
yihui | 1:fc2f9d636751 | 68 | * @return NRF_SUCCESS If the image has been successfully activated any other NRF_ERROR code in |
yihui | 1:fc2f9d636751 | 69 | * case of a failure. |
yihui | 1:fc2f9d636751 | 70 | */ |
yihui | 1:fc2f9d636751 | 71 | typedef uint32_t (*dfu_bank_activate_t)(void); |
yihui | 1:fc2f9d636751 | 72 | |
yihui | 1:fc2f9d636751 | 73 | /**@brief Structure for holding of function pointers for needed prepare and activate procedure for |
yihui | 1:fc2f9d636751 | 74 | * the requested update procedure. |
yihui | 1:fc2f9d636751 | 75 | */ |
yihui | 1:fc2f9d636751 | 76 | typedef struct |
yihui | 1:fc2f9d636751 | 77 | { |
yihui | 1:fc2f9d636751 | 78 | dfu_bank_prepare_t prepare; /**< Function pointer to the prepare function called on start of update procedure. */ |
yihui | 1:fc2f9d636751 | 79 | dfu_bank_cleared_t cleared; /**< Function pointer to the cleared function called after prepare function completes. */ |
yihui | 1:fc2f9d636751 | 80 | dfu_bank_activate_t activate; /**< Function pointer to the activate function called on finalizing the update procedure. */ |
yihui | 1:fc2f9d636751 | 81 | } dfu_bank_func_t; |
yihui | 1:fc2f9d636751 | 82 | |
yihui | 1:fc2f9d636751 | 83 | #endif // DFU_BANK_INTERNAL_H__ |
yihui | 1:fc2f9d636751 | 84 | |
yihui | 1:fc2f9d636751 | 85 | /** @} */ |