Nordic stack and drivers for the mbed BLE API

Dependents:   BLE_Health_Thermometer2

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) 2012 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 <string.h>
bogdanm 0:eff01767de02 14 #include <stdint.h>
bogdanm 0:eff01767de02 15 #include <stdbool.h>
bogdanm 0:eff01767de02 16 #include <nrf51.h>
bogdanm 0:eff01767de02 17 #include "ble_error_log.h"
bogdanm 0:eff01767de02 18 #include "app_util.h"
bogdanm 0:eff01767de02 19 #include "app_error.h"
bogdanm 0:eff01767de02 20 #include "nrf_gpio.h"
bogdanm 0:eff01767de02 21 #include "pstorage.h"
bogdanm 0:eff01767de02 22
bogdanm 0:eff01767de02 23
bogdanm 0:eff01767de02 24 // Made static to avoid the error_log to go on the stack.
bogdanm 0:eff01767de02 25 static ble_error_log_data_t m_ble_error_log; /**< . */
bogdanm 0:eff01767de02 26 //lint -esym(526,__Vectors)
bogdanm 0:eff01767de02 27 extern uint32_t * __Vectors; /**< The initialization vector holds the address to __initial_sp that will be used when fetching the stack. */
bogdanm 0:eff01767de02 28
bogdanm 0:eff01767de02 29 static void fetch_stack(ble_error_log_data_t * error_log)
bogdanm 0:eff01767de02 30 {
bogdanm 0:eff01767de02 31 // KTOWN: Temporarily removed 06022014
bogdanm 0:eff01767de02 32 /*
bogdanm 0:eff01767de02 33 uint32_t * p_stack;
bogdanm 0:eff01767de02 34 uint32_t * initial_sp;
bogdanm 0:eff01767de02 35 uint32_t length;
bogdanm 0:eff01767de02 36
bogdanm 0:eff01767de02 37 initial_sp = (uint32_t *) __Vectors;
bogdanm 0:eff01767de02 38 p_stack = (uint32_t *) GET_SP();
bogdanm 0:eff01767de02 39
bogdanm 0:eff01767de02 40 length = ((uint32_t) initial_sp) - ((uint32_t) p_stack);
bogdanm 0:eff01767de02 41 memcpy(error_log->stack_info,
bogdanm 0:eff01767de02 42 p_stack,
bogdanm 0:eff01767de02 43 (length > STACK_DUMP_LENGTH) ? STACK_DUMP_LENGTH : length);
bogdanm 0:eff01767de02 44 */
bogdanm 0:eff01767de02 45 }
bogdanm 0:eff01767de02 46
bogdanm 0:eff01767de02 47 uint32_t ble_error_log_write(uint32_t err_code, const uint8_t * p_message, uint16_t line_number)
bogdanm 0:eff01767de02 48 {
bogdanm 0:eff01767de02 49 m_ble_error_log.failure = true;
bogdanm 0:eff01767de02 50 m_ble_error_log.err_code = err_code;
bogdanm 0:eff01767de02 51 m_ble_error_log.line_number = line_number;
bogdanm 0:eff01767de02 52
bogdanm 0:eff01767de02 53 strncpy((char *)m_ble_error_log.message, (const char *)p_message, ERROR_MESSAGE_LENGTH - 1);
bogdanm 0:eff01767de02 54 m_ble_error_log.message[ERROR_MESSAGE_LENGTH - 1] = '\0';
bogdanm 0:eff01767de02 55
bogdanm 0:eff01767de02 56 fetch_stack(&m_ble_error_log);
bogdanm 0:eff01767de02 57
bogdanm 0:eff01767de02 58 // Write to flash removed, to be redone.
bogdanm 0:eff01767de02 59
bogdanm 0:eff01767de02 60 return NRF_SUCCESS;
bogdanm 0:eff01767de02 61 }