Yihui Xiong / Mbed 2 deprecated BLE_Default_APP

Dependencies:   BLE_API mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers dfu_app_handler.c Source File

dfu_app_handler.c

00001 /* Copyright (c) 2012 Nordic Semiconductor. All Rights Reserved.
00002  *
00003  * The information contained herein is property of Nordic Semiconductor ASA.
00004  * Terms and conditions of usage are described in detail in NORDIC
00005  * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
00006  *
00007  * Licensees are granted free, non-transferable use of the information. NO
00008  * WARRANTY of ANY KIND is provided. This heading must NOT be removed from
00009  * the file.
00010  *
00011  */
00012 
00013 #include "dfu_app_handler.h "
00014 #include "bootloader_util.h "
00015 #include "nrf_sdm.h"
00016 #include "app_error.h "
00017 
00018 #define IRQ_ENABLED             0x01                                            /**< Field identifying if an interrupt is enabled. */
00019 #define MAX_NUMBER_INTERRUPTS   32                                              /**< Maximum number of interrupts available. */
00020 
00021 static void                     dfu_app_reset_prepare(void);                    /**< Forward declare of default reset handler. */
00022 static dfu_app_reset_prepare_t  m_reset_prepare = dfu_app_reset_prepare;        /**< Callback function to application to prepare for system reset. Allows application to cleanup of service and memory prior to reset. */
00023 
00024 
00025 /**@brief Default reset prepare handler if application hasn't registered a handler.
00026  */
00027 static void dfu_app_reset_prepare(void)
00028 {
00029     // Reset prepare should be handled by application.
00030     // This function can be extended to include default handling if application does not implement
00031     // own handler.
00032 }
00033 
00034 /**@brief Function for preparing the reset, disabling SoftDevice and jump to the bootloader.
00035  */
00036 void bootloader_start(void)
00037 {
00038     m_reset_prepare();
00039 
00040     uint32_t err_code = sd_power_gpregret_set(BOOTLOADER_DFU_START);
00041     APP_ERROR_CHECK(err_code);
00042 
00043     NVIC_SystemReset();
00044 }
00045 
00046 
00047 
00048 void dfu_app_reset_prepare_set(dfu_app_reset_prepare_t reset_prepare_func)
00049 {
00050     m_reset_prepare = reset_prepare_func;
00051 }