The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.

Dependents:   hello SerialTestv11 SerialTestv12 Sierpinski ... more

mbed 2

This is the mbed 2 library. If you'd like to learn about Mbed OS please see the mbed-os docs.

Committer:
AnnaBridge
Date:
Wed Feb 20 20:53:29 2019 +0000
Revision:
172:65be27845400
Parent:
171:3a7713b1edbc
mbed library release version 165

Who changed what in which revision?

UserRevisionLine numberNew contents of line
AnnaBridge 143:86740a56073b 1 /*
AnnaBridge 143:86740a56073b 2 * Copyright (c) 2012 Nordic Semiconductor ASA
AnnaBridge 143:86740a56073b 3 * All rights reserved.
AnnaBridge 143:86740a56073b 4 *
AnnaBridge 143:86740a56073b 5 * Redistribution and use in source and binary forms, with or without modification,
AnnaBridge 143:86740a56073b 6 * are permitted provided that the following conditions are met:
AnnaBridge 143:86740a56073b 7 *
AnnaBridge 143:86740a56073b 8 * 1. Redistributions of source code must retain the above copyright notice, this list
AnnaBridge 143:86740a56073b 9 * of conditions and the following disclaimer.
AnnaBridge 143:86740a56073b 10 *
AnnaBridge 143:86740a56073b 11 * 2. Redistributions in binary form, except as embedded into a Nordic Semiconductor ASA
AnnaBridge 143:86740a56073b 12 * integrated circuit in a product or a software update for such product, must reproduce
AnnaBridge 143:86740a56073b 13 * the above copyright notice, this list of conditions and the following disclaimer in
AnnaBridge 143:86740a56073b 14 * the documentation and/or other materials provided with the distribution.
AnnaBridge 143:86740a56073b 15 *
AnnaBridge 143:86740a56073b 16 * 3. Neither the name of Nordic Semiconductor ASA nor the names of its contributors may be
AnnaBridge 143:86740a56073b 17 * used to endorse or promote products derived from this software without specific prior
AnnaBridge 143:86740a56073b 18 * written permission.
AnnaBridge 143:86740a56073b 19 *
AnnaBridge 143:86740a56073b 20 * 4. This software, with or without modification, must only be used with a
AnnaBridge 143:86740a56073b 21 * Nordic Semiconductor ASA integrated circuit.
AnnaBridge 143:86740a56073b 22 *
AnnaBridge 143:86740a56073b 23 * 5. Any software provided in binary or object form under this license must not be reverse
AnnaBridge 143:86740a56073b 24 * engineered, decompiled, modified and/or disassembled.
AnnaBridge 143:86740a56073b 25 *
AnnaBridge 143:86740a56073b 26 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
AnnaBridge 143:86740a56073b 27 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
AnnaBridge 143:86740a56073b 28 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
AnnaBridge 143:86740a56073b 29 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
AnnaBridge 143:86740a56073b 30 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
AnnaBridge 143:86740a56073b 31 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
AnnaBridge 143:86740a56073b 32 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
AnnaBridge 143:86740a56073b 33 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
AnnaBridge 143:86740a56073b 34 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
AnnaBridge 143:86740a56073b 35 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
AnnaBridge 143:86740a56073b 36 *
AnnaBridge 143:86740a56073b 37 */
AnnaBridge 143:86740a56073b 38
AnnaBridge 143:86740a56073b 39
AnnaBridge 143:86740a56073b 40 /** @file
AnnaBridge 143:86740a56073b 41 *
AnnaBridge 143:86740a56073b 42 * @defgroup ble_error_log_module Error Log Module
AnnaBridge 143:86740a56073b 43 * @{
AnnaBridge 143:86740a56073b 44 * @ingroup ble_sdk_lib
AnnaBridge 143:86740a56073b 45 * @brief Module for writing error and stack to flash memory.
AnnaBridge 143:86740a56073b 46 *
AnnaBridge 143:86740a56073b 47 * @details It contains functions for writing an error code, line number, filename/message and
AnnaBridge 143:86740a56073b 48 * the stack to the flash during an error, e.g. in the assert handler.
AnnaBridge 143:86740a56073b 49 *
AnnaBridge 143:86740a56073b 50 */
AnnaBridge 143:86740a56073b 51 #ifndef BLE_ERROR_LOG_H__
AnnaBridge 143:86740a56073b 52 #define BLE_ERROR_LOG_H__
AnnaBridge 143:86740a56073b 53
AnnaBridge 143:86740a56073b 54 #include <stdint.h>
AnnaBridge 143:86740a56073b 55 #include <stdbool.h>
AnnaBridge 143:86740a56073b 56 #include "ble_flash.h"
AnnaBridge 143:86740a56073b 57
AnnaBridge 143:86740a56073b 58 #define ERROR_MESSAGE_LENGTH 128 /**< Length of error message to stored. */
AnnaBridge 143:86740a56073b 59 #define STACK_DUMP_LENGTH 256 /**< Length of stack to be stored at max: 64 entries of 4 bytes each. */
AnnaBridge 143:86740a56073b 60 #define FLASH_PAGE_ERROR_LOG (BLE_FLASH_PAGE_END - 2) /**< Address in flash where stack trace can be stored. */
AnnaBridge 143:86740a56073b 61
AnnaBridge 143:86740a56073b 62 /**@brief Error Log Data structure.
AnnaBridge 143:86740a56073b 63 *
AnnaBridge 143:86740a56073b 64 * @details The structure contains the error, message/filename, line number as well as the current
AnnaBridge 143:86740a56073b 65 * stack, at the time where an error occured.
AnnaBridge 143:86740a56073b 66 */
AnnaBridge 143:86740a56073b 67 typedef struct
AnnaBridge 143:86740a56073b 68 {
AnnaBridge 143:86740a56073b 69 uint16_t failure; /**< Indication that a major failure has occurred during last execution of the application. */
AnnaBridge 143:86740a56073b 70 uint16_t line_number; /**< Line number indicating at which line the failure occurred. */
AnnaBridge 143:86740a56073b 71 uint32_t err_code; /**< Error code when failure occurred. */
AnnaBridge 143:86740a56073b 72 uint8_t message[ERROR_MESSAGE_LENGTH]; /**< Will just use the first 128 bytes of filename to store for debugging purposes. */
AnnaBridge 143:86740a56073b 73 uint32_t stack_info[STACK_DUMP_LENGTH / 4]; /**< Will contain stack information, can be manually unwinded for debug purposes. */
AnnaBridge 143:86740a56073b 74 } ble_error_log_data_t;
AnnaBridge 143:86740a56073b 75
AnnaBridge 143:86740a56073b 76
AnnaBridge 143:86740a56073b 77 /**@brief Function for writing the file name/message, line number, and current program stack
AnnaBridge 143:86740a56073b 78 * to flash.
AnnaBridge 143:86740a56073b 79 *
AnnaBridge 143:86740a56073b 80 * @note This function will force the writing to flash, and disregard any radio communication.
AnnaBridge 143:86740a56073b 81 * USE THIS FUNCTION WITH CARE.
AnnaBridge 143:86740a56073b 82 *
AnnaBridge 143:86740a56073b 83 * @param[in] err_code Error code to be logged.
AnnaBridge 143:86740a56073b 84 * @param[in] p_message Message to be written to the flash together with stack dump, usually
AnnaBridge 143:86740a56073b 85 * the file name where the error occured.
AnnaBridge 143:86740a56073b 86 * @param[in] line_number Line number where the error occured.
AnnaBridge 143:86740a56073b 87 *
AnnaBridge 143:86740a56073b 88 * @return NRF_SUCCESS on successful writing of the error log.
AnnaBridge 143:86740a56073b 89 *
AnnaBridge 143:86740a56073b 90 */
AnnaBridge 143:86740a56073b 91 uint32_t ble_error_log_write(uint32_t err_code, const uint8_t * p_message, uint16_t line_number);
AnnaBridge 143:86740a56073b 92
AnnaBridge 143:86740a56073b 93
AnnaBridge 143:86740a56073b 94 #endif /* BLE_ERROR_LOG_H__ */
AnnaBridge 143:86740a56073b 95
AnnaBridge 143:86740a56073b 96 /** @} */