test

Fork of nRF51822 by Nordic Semiconductor

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers sdk_errors.h Source File

sdk_errors.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) Nordic Semiconductor ASA
00003  * All rights reserved.
00004  *
00005  * Redistribution and use in source and binary forms, with or without modification,
00006  * are permitted provided that the following conditions are met:
00007  *
00008  *   1. Redistributions of source code must retain the above copyright notice, this
00009  *   list of conditions and the following disclaimer.
00010  *
00011  *   2. Redistributions in binary form must reproduce the above copyright notice, this
00012  *   list of conditions and the following disclaimer in the documentation and/or
00013  *   other materials provided with the distribution.
00014  *
00015  *   3. Neither the name of Nordic Semiconductor ASA nor the names of other
00016  *   contributors to this software may be used to endorse or promote products
00017  *   derived from this software without specific prior written permission.
00018  *
00019  *
00020  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
00021  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
00022  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00023  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
00024  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
00025  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00026  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
00027  * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00028  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00029  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00030  *
00031  */
00032 
00033 /**@file
00034  *
00035  * @defgroup sdk_error SDK Error codes
00036  * @{
00037  * @ingroup app_common
00038  * @{
00039  * @details Error codes are 32-bit unsigned integers with the most significant 16-bit reserved for
00040  *          identifying the module where the error occurred while the least least significant LSB
00041  *          are used to provide the cause or nature of error. Each module is assigned a 16-bit
00042  *          unsigned integer. Which it will use to identify all errors that occurred in it. 16-bit
00043  *          LSB range is with module id as the MSB in the 32-bit error code is reserved for the
00044  *          module. As an example, if 0x8800 identifies a certain SDK module, all values from 
00045  *          0x88000000 - 0x8800FFFF are reserved for this module.
00046  *          It should be noted that common error reasons have been assigned values to make it 
00047  *          possible to decode error reason easily. As an example, lets module uninitialized has
00048  *          been assigned an error code 0x000A0. Then, if application encounters an error code
00049  *          0xZZZZ00A0, it knows that it accessing a certain module without initializing it.
00050  *          Apart from this, each module is allowed to define error codes that are not covered by
00051  *          the common ones, however, these values are defined in a range that does not conflict
00052  *          with common error values. For module, specific error however, it is possible that the
00053  *          same error value is used by two different modules to indicated errors of very different
00054  *          nature. If error is already defined by the NRF common error codes, these are reused.
00055  *          A range is reserved for application as well, it can use this range for defining
00056  *          application specific errors.
00057  *
00058  * @note Success code, NRF_SUCCESS, does not include any module identifier.          
00059 
00060  */
00061 
00062 #ifndef SDK_ERRORS_H__
00063 #define SDK_ERRORS_H__
00064 
00065 #include "nrf_error.h"
00066 
00067 /**
00068  * @defgroup sdk_err_base Base defined for SDK Modules
00069  * @{
00070  */
00071 #define SDK_ERROR_BASE         (NRF_ERROR_BASE_NUM + 0x8000)   /**< Base value defined for SDK module identifiers. */
00072 #define SDK_COMMON_ERROR_BASE  (NRF_ERROR_BASE_NUM + 0x0080)   /**< Base error value to be used for SDK error values. */
00073 /* @} */
00074 
00075 /**
00076  * @defgroup sdk_module_codes Codes reserved as identification for module where the error occurred.
00077  * @{
00078  */
00079 #define DEVICE_MANAGER_ERR_BASE   (0x8000)
00080 /* @} */
00081 
00082 /**
00083  * @defgroup sdk_common_errors Codes reserved as identification for common errors.
00084  * @{
00085  */
00086 #define MODULE_NOT_INITIALZED      (SDK_COMMON_ERROR_BASE+0x0000)
00087 #define MUTEX_INIT_FAILED          (SDK_COMMON_ERROR_BASE+0x0001)
00088 #define MUTEX_LOCK_FAILED          (SDK_COMMON_ERROR_BASE+0x0002)
00089 #define MUTEX_UNLOCK_FAILED        (SDK_COMMON_ERROR_BASE+0x0003)
00090 #define MUTEX_COND_INIT_FAILED     (SDK_COMMON_ERROR_BASE+0x0004)
00091 #define API_NOT_IMPLEMENTED        (SDK_COMMON_ERROR_BASE+0x0010)
00092 #define FEATURE_NOT_ENABLED        (SDK_COMMON_ERROR_BASE+0x0011)
00093 /* @} */
00094 
00095 
00096 /**
00097  * @defgroup dm_specific_errors Error / status codes specific to device manager.
00098  * @{
00099  */
00100 #define DM_NO_APP_CONTEXT                (DEVICE_MANAGER_ERR_BASE+0x0040)
00101 #define DM_SERVICE_CONTEXT_NOT_APPLIED   (DEVICE_MANAGER_ERR_BASE+0x0041)
00102 #define DM_CONTEXT_INFO_LOST             (DEVICE_MANAGER_ERR_BASE+0x0042)
00103 #define DM_DEVICE_CONTEXT_FULL           (DEVICE_MANAGER_ERR_BASE+0x0043)
00104 /* @} */
00105 
00106 /**
00107  * @brief API Result.
00108  *
00109  * @details Indicates success or failure of an API procedure. In case of failure, a comprehensive
00110  *          error code indicating cause or reason for failure is provided.
00111  *
00112  *          Though called an API result, it could used in Asynchronous notifications callback along
00113  *          with asynchronous callback as event result. This mechanism is employed when an event
00114  *          marks the end of procedure initiated using API. API result, in this case, will only be
00115  *          an indicative of whether the procedure has been requested successfully.
00116  */
00117 typedef uint32_t ret_code_t;
00118 /** @} */
00119 /** @} */
00120 
00121 #endif // SDK_ERRORS_H__