テスト用

Fork of nRF51822 by Nordic Semiconductor

Committer:
bogdanm
Date:
Wed Mar 26 14:38:17 2014 +0000
Revision:
0:eff01767de02
Initial import of the nRF51822 code

Who changed what in which revision?

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