BLE FOTA APP

Dependencies:   BLE_API mbed

It doesn't work with the default FOTA bootloader. It use NVIC_SystemReset() to enter a bootloader.

Committer:
yihui
Date:
Fri Oct 10 03:36:28 2014 +0000
Revision:
1:a607cd9655d7
use NVIC_SystemReset() to run bootloader

Who changed what in which revision?

UserRevisionLine numberNew contents of line
yihui 1:a607cd9655d7 1 /* Copyright (c) 2013 Nordic Semiconductor. All Rights Reserved.
yihui 1:a607cd9655d7 2 *
yihui 1:a607cd9655d7 3 * The information contained herein is property of Nordic Semiconductor ASA.
yihui 1:a607cd9655d7 4 * Terms and conditions of usage are described in detail in NORDIC
yihui 1:a607cd9655d7 5 * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
yihui 1:a607cd9655d7 6 *
yihui 1:a607cd9655d7 7 * Licensees are granted free, non-transferable use of the information. NO
yihui 1:a607cd9655d7 8 * WARRANTY of ANY KIND is provided. This heading must NOT be removed from
yihui 1:a607cd9655d7 9 * the file.
yihui 1:a607cd9655d7 10 *
yihui 1:a607cd9655d7 11 */
yihui 1:a607cd9655d7 12
yihui 1:a607cd9655d7 13 #include "ble_debug_assert_handler.h"
yihui 1:a607cd9655d7 14 #include <string.h>
yihui 1:a607cd9655d7 15 #include "nrf51.h"
yihui 1:a607cd9655d7 16 #include "ble_error_log.h"
yihui 1:a607cd9655d7 17 #include "nordic_common.h"
yihui 1:a607cd9655d7 18
yihui 1:a607cd9655d7 19 #define MAX_LENGTH_FILENAME 128 /**< Max length of filename to copy for the debug error handlier. */
yihui 1:a607cd9655d7 20
yihui 1:a607cd9655d7 21
yihui 1:a607cd9655d7 22 // WARNING - DO NOT USE THIS FUNCTION IN END PRODUCT. - WARNING
yihui 1:a607cd9655d7 23 // WARNING - FOR DEBUG PURPOSES ONLY. - WARNING
yihui 1:a607cd9655d7 24 void ble_debug_assert_handler(uint32_t error_code, uint32_t line_num, const uint8_t * p_file_name)
yihui 1:a607cd9655d7 25 {
yihui 1:a607cd9655d7 26 // Copying parameters to static variables because parameters may not be accessible in debugger.
yihui 1:a607cd9655d7 27 static volatile uint8_t s_file_name[MAX_LENGTH_FILENAME];
yihui 1:a607cd9655d7 28 static volatile uint16_t s_line_num;
yihui 1:a607cd9655d7 29 static volatile uint32_t s_error_code;
yihui 1:a607cd9655d7 30
yihui 1:a607cd9655d7 31 strncpy((char *)s_file_name, (const char *)p_file_name, MAX_LENGTH_FILENAME - 1);
yihui 1:a607cd9655d7 32 s_file_name[MAX_LENGTH_FILENAME - 1] = '\0';
yihui 1:a607cd9655d7 33 s_line_num = line_num;
yihui 1:a607cd9655d7 34 s_error_code = error_code;
yihui 1:a607cd9655d7 35 UNUSED_VARIABLE(s_file_name);
yihui 1:a607cd9655d7 36 UNUSED_VARIABLE(s_line_num);
yihui 1:a607cd9655d7 37 UNUSED_VARIABLE(s_error_code);
yihui 1:a607cd9655d7 38
yihui 1:a607cd9655d7 39 // WARNING: The PRIMASK register is set to disable ALL interrups during writing the error log.
yihui 1:a607cd9655d7 40 //
yihui 1:a607cd9655d7 41 // Do not use __disable_irq() in normal operation.
yihui 1:a607cd9655d7 42 __disable_irq();
yihui 1:a607cd9655d7 43
yihui 1:a607cd9655d7 44 // This function will write error code, filename, and line number to the flash.
yihui 1:a607cd9655d7 45 // In addition, the Cortex-M0 stack memory will also be written to the flash.
yihui 1:a607cd9655d7 46 //(void) ble_error_log_write(error_code, p_file_name, line_num);
yihui 1:a607cd9655d7 47
yihui 1:a607cd9655d7 48 // For debug purposes, this function never returns.
yihui 1:a607cd9655d7 49 // Attach a debugger for tracing the error cause.
yihui 1:a607cd9655d7 50 for (;;)
yihui 1:a607cd9655d7 51 {
yihui 1:a607cd9655d7 52 // Do nothing.
yihui 1:a607cd9655d7 53 }
yihui 1:a607cd9655d7 54 }
yihui 1:a607cd9655d7 55