Nordic stack and drivers for the mbed BLE API

Fork of nRF51822 by Nordic Semiconductor

Committer:
Vincent Coubard
Date:
Wed Sep 14 14:39:43 2016 +0100
Revision:
640:c90ae1400bf2
Sync with bdab10dc0f90748b6989c8b577771bb403ca6bd8 from ARMmbed/mbed-os.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Vincent Coubard 640:c90ae1400bf2 1 /*
Vincent Coubard 640:c90ae1400bf2 2 * Copyright (c) Nordic Semiconductor ASA
Vincent Coubard 640:c90ae1400bf2 3 * All rights reserved.
Vincent Coubard 640:c90ae1400bf2 4 *
Vincent Coubard 640:c90ae1400bf2 5 * Redistribution and use in source and binary forms, with or without modification,
Vincent Coubard 640:c90ae1400bf2 6 * are permitted provided that the following conditions are met:
Vincent Coubard 640:c90ae1400bf2 7 *
Vincent Coubard 640:c90ae1400bf2 8 * 1. Redistributions of source code must retain the above copyright notice, this
Vincent Coubard 640:c90ae1400bf2 9 * list of conditions and the following disclaimer.
Vincent Coubard 640:c90ae1400bf2 10 *
Vincent Coubard 640:c90ae1400bf2 11 * 2. Redistributions in binary form must reproduce the above copyright notice, this
Vincent Coubard 640:c90ae1400bf2 12 * list of conditions and the following disclaimer in the documentation and/or
Vincent Coubard 640:c90ae1400bf2 13 * other materials provided with the distribution.
Vincent Coubard 640:c90ae1400bf2 14 *
Vincent Coubard 640:c90ae1400bf2 15 * 3. Neither the name of Nordic Semiconductor ASA nor the names of other
Vincent Coubard 640:c90ae1400bf2 16 * contributors to this software may be used to endorse or promote products
Vincent Coubard 640:c90ae1400bf2 17 * derived from this software without specific prior written permission.
Vincent Coubard 640:c90ae1400bf2 18 *
Vincent Coubard 640:c90ae1400bf2 19 *
Vincent Coubard 640:c90ae1400bf2 20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
Vincent Coubard 640:c90ae1400bf2 21 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
Vincent Coubard 640:c90ae1400bf2 22 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
Vincent Coubard 640:c90ae1400bf2 23 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
Vincent Coubard 640:c90ae1400bf2 24 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
Vincent Coubard 640:c90ae1400bf2 25 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
Vincent Coubard 640:c90ae1400bf2 26 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
Vincent Coubard 640:c90ae1400bf2 27 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
Vincent Coubard 640:c90ae1400bf2 28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
Vincent Coubard 640:c90ae1400bf2 29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Vincent Coubard 640:c90ae1400bf2 30 *
Vincent Coubard 640:c90ae1400bf2 31 */
Vincent Coubard 640:c90ae1400bf2 32
Vincent Coubard 640:c90ae1400bf2 33 /** @file
Vincent Coubard 640:c90ae1400bf2 34 *
Vincent Coubard 640:c90ae1400bf2 35 * @defgroup app_error Common application error handler
Vincent Coubard 640:c90ae1400bf2 36 * @{
Vincent Coubard 640:c90ae1400bf2 37 * @ingroup app_common
Vincent Coubard 640:c90ae1400bf2 38 *
Vincent Coubard 640:c90ae1400bf2 39 * @brief Common application error handler.
Vincent Coubard 640:c90ae1400bf2 40 */
Vincent Coubard 640:c90ae1400bf2 41
Vincent Coubard 640:c90ae1400bf2 42 #include "nrf.h"
Vincent Coubard 640:c90ae1400bf2 43 #include "app_error.h"
Vincent Coubard 640:c90ae1400bf2 44 #include "compiler_abstraction.h"
Vincent Coubard 640:c90ae1400bf2 45 #include "nordic_common.h"
Vincent Coubard 640:c90ae1400bf2 46 #ifdef DEBUG
Vincent Coubard 640:c90ae1400bf2 47 #include "bsp.h"
Vincent Coubard 640:c90ae1400bf2 48
Vincent Coubard 640:c90ae1400bf2 49 /* global error variables - in order to prevent removal by optimizers */
Vincent Coubard 640:c90ae1400bf2 50 uint32_t m_error_code;
Vincent Coubard 640:c90ae1400bf2 51 uint32_t m_line_num;
Vincent Coubard 640:c90ae1400bf2 52 const uint8_t * m_p_file_name;
Vincent Coubard 640:c90ae1400bf2 53 #endif
Vincent Coubard 640:c90ae1400bf2 54
Vincent Coubard 640:c90ae1400bf2 55 /**@brief Function for error handling, which is called when an error has occurred.
Vincent Coubard 640:c90ae1400bf2 56 *
Vincent Coubard 640:c90ae1400bf2 57 * @warning This handler is an example only and does not fit a final product. You need to analyze
Vincent Coubard 640:c90ae1400bf2 58 * how your product is supposed to react in case of error.
Vincent Coubard 640:c90ae1400bf2 59 *
Vincent Coubard 640:c90ae1400bf2 60 * @param[in] error_code Error code supplied to the handler.
Vincent Coubard 640:c90ae1400bf2 61 * @param[in] line_num Line number where the handler is called.
Vincent Coubard 640:c90ae1400bf2 62 * @param[in] p_file_name Pointer to the file name.
Vincent Coubard 640:c90ae1400bf2 63 *
Vincent Coubard 640:c90ae1400bf2 64 * Function is implemented as weak so that it can be overwritten by custom application error handler
Vincent Coubard 640:c90ae1400bf2 65 * when needed.
Vincent Coubard 640:c90ae1400bf2 66 */
Vincent Coubard 640:c90ae1400bf2 67
Vincent Coubard 640:c90ae1400bf2 68 /*lint -save -e14 */
Vincent Coubard 640:c90ae1400bf2 69 __WEAK void app_error_handler(uint32_t error_code, uint32_t line_num, const uint8_t * p_file_name)
Vincent Coubard 640:c90ae1400bf2 70 {
Vincent Coubard 640:c90ae1400bf2 71 // On assert, the system can only recover with a reset.
Vincent Coubard 640:c90ae1400bf2 72 #ifndef DEBUG
Vincent Coubard 640:c90ae1400bf2 73 NVIC_SystemReset();
Vincent Coubard 640:c90ae1400bf2 74 #else
Vincent Coubard 640:c90ae1400bf2 75
Vincent Coubard 640:c90ae1400bf2 76 #ifdef BSP_DEFINES_ONLY
Vincent Coubard 640:c90ae1400bf2 77 LEDS_ON(LEDS_MASK);
Vincent Coubard 640:c90ae1400bf2 78 #else
Vincent Coubard 640:c90ae1400bf2 79 UNUSED_VARIABLE(bsp_indication_set(BSP_INDICATE_FATAL_ERROR));
Vincent Coubard 640:c90ae1400bf2 80 // This call can be used for debug purposes during application development.
Vincent Coubard 640:c90ae1400bf2 81 // @note CAUTION: Activating this code will write the stack to flash on an error.
Vincent Coubard 640:c90ae1400bf2 82 // This function should NOT be used in a final product.
Vincent Coubard 640:c90ae1400bf2 83 // It is intended STRICTLY for development/debugging purposes.
Vincent Coubard 640:c90ae1400bf2 84 // The flash write will happen EVEN if the radio is active, thus interrupting
Vincent Coubard 640:c90ae1400bf2 85 // any communication.
Vincent Coubard 640:c90ae1400bf2 86 // Use with care. Uncomment the line below to use.
Vincent Coubard 640:c90ae1400bf2 87 //ble_debug_assert_handler(error_code, line_num, p_file_name);
Vincent Coubard 640:c90ae1400bf2 88 #endif // BSP_DEFINES_ONLY
Vincent Coubard 640:c90ae1400bf2 89
Vincent Coubard 640:c90ae1400bf2 90 // The following variable helps Keil keep the call stack visible, in addition, it can be set to
Vincent Coubard 640:c90ae1400bf2 91 // 0 in the debugger to continue executing code after the error check.
Vincent Coubard 640:c90ae1400bf2 92 volatile bool loop = true;
Vincent Coubard 640:c90ae1400bf2 93 UNUSED_VARIABLE(loop);
Vincent Coubard 640:c90ae1400bf2 94
Vincent Coubard 640:c90ae1400bf2 95 m_error_code = error_code;
Vincent Coubard 640:c90ae1400bf2 96 m_line_num = line_num;
Vincent Coubard 640:c90ae1400bf2 97 m_p_file_name = p_file_name;
Vincent Coubard 640:c90ae1400bf2 98
Vincent Coubard 640:c90ae1400bf2 99 UNUSED_VARIABLE(m_error_code);
Vincent Coubard 640:c90ae1400bf2 100 UNUSED_VARIABLE(m_line_num);
Vincent Coubard 640:c90ae1400bf2 101 UNUSED_VARIABLE(m_p_file_name);
Vincent Coubard 640:c90ae1400bf2 102 __disable_irq();
Vincent Coubard 640:c90ae1400bf2 103
Vincent Coubard 640:c90ae1400bf2 104 while(loop);
Vincent Coubard 640:c90ae1400bf2 105 #endif // DEBUG
Vincent Coubard 640:c90ae1400bf2 106 }
Vincent Coubard 640:c90ae1400bf2 107 /*lint -restore */