dfu.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. /* Copyright (c) 2013 Nordic Semiconductor. All Rights Reserved.
  2. *
  3. * The information contained herein is property of Nordic Semiconductor ASA.
  4. * Terms and conditions of usage are described in detail in NORDIC
  5. * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
  6. *
  7. * Licensees are granted free, non-transferable use of the information. NO
  8. * WARRANTY of ANY KIND is provided. This heading must NOT be removed from
  9. * the file.
  10. *
  11. */
  12. /**@file
  13. *
  14. * @defgroup nrf_dfu Device Firmware Update API.
  15. * @{
  16. *
  17. * @brief Device Firmware Update module interface.
  18. */
  19. #ifndef DFU_H__
  20. #define DFU_H__
  21. #include <dfu_types.h>
  22. #include <stdbool.h>
  23. #include <stdint.h>
  24. /**@brief DFU event callback for asynchronous calls.
  25. *
  26. * @param[in] result Operation result code. NRF_SUCCESS when a queued operation was successful.
  27. * @param[in] p_data Pointer to the data to which the operation is related.
  28. */
  29. typedef void (*dfu_callback_t)(uint32_t result, uint8_t * p_data);
  30. /**@brief Function for initializing the Device Firmware Update module.
  31. *
  32. * @return NRF_SUCCESS on success, an error_code otherwise.
  33. */
  34. uint32_t dfu_init(void);
  35. /**@brief Function for registering a callback listener for \ref dfu_data_pkt_handle callbacks.
  36. */
  37. void dfu_register_callback(dfu_callback_t callback_handler);
  38. /**@brief Function for setting the DFU image size.
  39. *
  40. * @details Function sets the DFU image size. This function must be called when an update is started
  41. * in order to notify the DFU of the new image size. If multiple images are to be
  42. * transferred within the same update context then this function must be called with size
  43. * information for each image being transfered.
  44. * If an image type is not being transfered, e.g. SoftDevice but no Application , then the
  45. * image size for application must be zero.
  46. *
  47. * @param[in] p_packet Pointer to the DFU packet containing information on DFU update process to be started.
  48. *
  49. * @return NRF_SUCCESS on success, an error_code otherwise.
  50. */
  51. uint32_t dfu_start_pkt_handle(dfu_update_packet_t * p_packet);
  52. /**@brief Function for handling DFU data packets.
  53. *
  54. * @param[in] p_packet Pointer to the DFU packet.
  55. *
  56. * @return NRF_SUCCESS on success, an error_code otherwise.
  57. */
  58. uint32_t dfu_data_pkt_handle(dfu_update_packet_t * p_packet);
  59. /**@brief Function for handling DFU init packets.
  60. *
  61. * @return NRF_SUCCESS on success, an error_code otherwise.
  62. */
  63. uint32_t dfu_init_pkt_handle(dfu_update_packet_t * p_packet);
  64. /**@brief Function for validating a transferred image after the transfer has completed.
  65. *
  66. * @return NRF_SUCCESS on success, an error_code otherwise.
  67. */
  68. uint32_t dfu_image_validate(uint16_t crc_seed);
  69. /**@brief Function for activating the transfered image after validation has successfully completed.
  70. *
  71. * @return NRF_SUCCESS on success, an error_code otherwise.
  72. */
  73. uint32_t dfu_image_activate(void);
  74. /**@brief Function for reseting the current update procedure and return to initial state.
  75. *
  76. * @details This function call will result in a system reset to ensure correct system behavior.
  77. * The reset will might be scheduled to execute at a later point in time to ensure pending
  78. * flash operations has completed.
  79. *
  80. */
  81. void dfu_reset(void);
  82. uint32_t dfu_bl_image_validate(void);
  83. uint32_t dfu_sd_image_validate(void);
  84. uint32_t dfu_bl_image_swap(void);
  85. uint32_t dfu_sd_image_swap(void);
  86. uint32_t dfu_ap_image_swap(void);
  87. uint32_t dfu_storage_start_address_get(void);
  88. #endif // DFU_H__
  89. /** @} */