sdk_errors.h 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. /**
  2. * Copyright (c) 2013 - 2020, Nordic Semiconductor ASA
  3. *
  4. * All rights reserved.
  5. *
  6. * Redistribution and use in source and binary forms, with or without modification,
  7. * are permitted provided that the following conditions are met:
  8. *
  9. * 1. Redistributions of source code must retain the above copyright notice, this
  10. * list of conditions and the following disclaimer.
  11. *
  12. * 2. Redistributions in binary form, except as embedded into a Nordic
  13. * Semiconductor ASA integrated circuit in a product or a software update for
  14. * such product, must reproduce the above copyright notice, this list of
  15. * conditions and the following disclaimer in the documentation and/or other
  16. * materials provided with the distribution.
  17. *
  18. * 3. Neither the name of Nordic Semiconductor ASA nor the names of its
  19. * contributors may be used to endorse or promote products derived from this
  20. * software without specific prior written permission.
  21. *
  22. * 4. This software, with or without modification, must only be used with a
  23. * Nordic Semiconductor ASA integrated circuit.
  24. *
  25. * 5. Any software provided in binary form under this license must not be reverse
  26. * engineered, decompiled, modified and/or disassembled.
  27. *
  28. * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
  29. * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  30. * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
  31. * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
  32. * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  33. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
  34. * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  35. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  36. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  37. * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  38. *
  39. */
  40. /**@file
  41. *
  42. * @defgroup sdk_error SDK Error codes
  43. * @{
  44. * @ingroup app_common
  45. * @{
  46. * @details Error codes are 32-bit unsigned integers with the most significant 16-bit reserved for
  47. * identifying the module where the error occurred while the least least significant LSB
  48. * are used to provide the cause or nature of error. Each module is assigned a 16-bit
  49. * unsigned integer. Which it will use to identify all errors that occurred in it. 16-bit
  50. * LSB range is with module id as the MSB in the 32-bit error code is reserved for the
  51. * module. As an example, if 0x8800 identifies a certain SDK module, all values from
  52. * 0x88000000 - 0x8800FFFF are reserved for this module.
  53. * It should be noted that common error reasons have been assigned values to make it
  54. * possible to decode error reason easily. As an example, lets module uninitialized has
  55. * been assigned an error code 0x000A0. Then, if application encounters an error code
  56. * 0xZZZZ00A0, it knows that it accessing a certain module without initializing it.
  57. * Apart from this, each module is allowed to define error codes that are not covered by
  58. * the common ones, however, these values are defined in a range that does not conflict
  59. * with common error values. For module, specific error however, it is possible that the
  60. * same error value is used by two different modules to indicated errors of very different
  61. * nature. If error is already defined by the NRF common error codes, these are reused.
  62. * A range is reserved for application as well, it can use this range for defining
  63. * application specific errors.
  64. *
  65. * @note Success code, NRF_SUCCESS, does not include any module identifier.
  66. */
  67. #ifndef SDK_ERRORS_H__
  68. #define SDK_ERRORS_H__
  69. #include <stdint.h>
  70. #include "nrf_error.h"
  71. #ifdef __cplusplus
  72. extern "C" {
  73. #endif
  74. /**
  75. * @defgroup sdk_err_base Base defined for SDK Modules
  76. * @{
  77. */
  78. #define NRF_ERROR_SDK_ERROR_BASE (NRF_ERROR_BASE_NUM + 0x8000) /**< Base value defined for SDK module identifiers. */
  79. #define NRF_ERROR_SDK_COMMON_ERROR_BASE (NRF_ERROR_BASE_NUM + 0x0080) /**< Base error value to be used for SDK error values. */
  80. /** @} */
  81. /**
  82. * @defgroup sdk_module_codes Codes reserved as identification for module where the error occurred.
  83. * @{
  84. */
  85. #define NRF_ERROR_MEMORY_MANAGER_ERR_BASE (0x8100) /**< Base address for Memory Manager related errors. */
  86. #define NRF_ERROR_PERIPH_DRIVERS_ERR_BASE (0x8200) /**< Base address for Peripheral drivers related errors. */
  87. #define NRF_ERROR_GAZELLE_ERR_BASE (0x8300) /**< Base address for Gazelle related errors. */
  88. #define NRF_ERROR_BLE_IPSP_ERR_BASE (0x8400) /**< Base address for BLE IPSP related errors. */
  89. #define NRF_ERROR_CRYPTO_ERR_BASE (0x8500) /**< Base address for crypto related errors. */
  90. #define NRF_ERROR_FDS_ERR_BASE (0x8600) /**< Base address for FDS related errors. */
  91. /** @} */
  92. /**
  93. * @defgroup sdk_iot_errors Codes reserved as identification for IoT errors.
  94. * @{
  95. */
  96. #define NRF_ERROR_IOT_ERR_BASE_START (0xA000)
  97. #define NRF_ERROR_IOT_ERR_BASE_STOP (0xAFFF)
  98. /** @} */
  99. /**
  100. * @defgroup sdk_common_errors Codes reserved as identification for common errors.
  101. * @{
  102. */
  103. #define NRF_ERROR_MODULE_NOT_INITIALIZED (NRF_ERROR_SDK_COMMON_ERROR_BASE + 0x0000) ///< Module not initialized
  104. #define NRF_ERROR_MUTEX_INIT_FAILED (NRF_ERROR_SDK_COMMON_ERROR_BASE + 0x0001) ///< Mutex initialization failed
  105. #define NRF_ERROR_MUTEX_LOCK_FAILED (NRF_ERROR_SDK_COMMON_ERROR_BASE + 0x0002) ///< Mutex lock failed
  106. #define NRF_ERROR_MUTEX_UNLOCK_FAILED (NRF_ERROR_SDK_COMMON_ERROR_BASE + 0x0003) ///< Mutex unlock failed
  107. #define NRF_ERROR_MUTEX_COND_INIT_FAILED (NRF_ERROR_SDK_COMMON_ERROR_BASE + 0x0004) ///< Mutex conditional initialization failed
  108. #define NRF_ERROR_MODULE_ALREADY_INITIALIZED (NRF_ERROR_SDK_COMMON_ERROR_BASE + 0x0005) ///< Module already initialized
  109. #define NRF_ERROR_STORAGE_FULL (NRF_ERROR_SDK_COMMON_ERROR_BASE + 0x0006) ///< Storage full
  110. #define NRF_ERROR_API_NOT_IMPLEMENTED (NRF_ERROR_SDK_COMMON_ERROR_BASE + 0x0010) ///< API not implemented
  111. #define NRF_ERROR_FEATURE_NOT_ENABLED (NRF_ERROR_SDK_COMMON_ERROR_BASE + 0x0011) ///< Feature not enabled
  112. #define NRF_ERROR_IO_PENDING (NRF_ERROR_SDK_COMMON_ERROR_BASE + 0x0012) ///< Input/Output pending
  113. /** @} */
  114. /**
  115. * @defgroup drv_specific_errors Error / status codes specific to drivers.
  116. * @{
  117. */
  118. #define NRF_ERROR_DRV_TWI_ERR_OVERRUN (NRF_ERROR_PERIPH_DRIVERS_ERR_BASE + 0x0000)
  119. #define NRF_ERROR_DRV_TWI_ERR_ANACK (NRF_ERROR_PERIPH_DRIVERS_ERR_BASE + 0x0001)
  120. #define NRF_ERROR_DRV_TWI_ERR_DNACK (NRF_ERROR_PERIPH_DRIVERS_ERR_BASE + 0x0002)
  121. /** @} */
  122. /**
  123. * @defgroup ble_ipsp_errors IPSP codes
  124. * @brief Error and status codes specific to IPSP.
  125. * @{
  126. */
  127. #define NRF_ERROR_BLE_IPSP_RX_PKT_TRUNCATED (NRF_ERROR_BLE_IPSP_ERR_BASE + 0x0000)
  128. #define NRF_ERROR_BLE_IPSP_CHANNEL_ALREADY_EXISTS (NRF_ERROR_BLE_IPSP_ERR_BASE + 0x0001)
  129. #define NRF_ERROR_BLE_IPSP_LINK_DISCONNECTED (NRF_ERROR_BLE_IPSP_ERR_BASE + 0x0002)
  130. #define NRF_ERROR_BLE_IPSP_PEER_REJECTED (NRF_ERROR_BLE_IPSP_ERR_BASE + 0x0003)
  131. /* @} */
  132. /**
  133. * @brief API Result.
  134. *
  135. * @details Indicates success or failure of an API procedure. In case of failure, a comprehensive
  136. * error code indicating cause or reason for failure is provided.
  137. *
  138. * Though called an API result, it could used in Asynchronous notifications callback along
  139. * with asynchronous callback as event result. This mechanism is employed when an event
  140. * marks the end of procedure initiated using API. API result, in this case, will only be
  141. * an indicative of whether the procedure has been requested successfully.
  142. */
  143. typedef uint32_t ret_code_t;
  144. /** @} */
  145. /** @} */
  146. #ifdef __cplusplus
  147. }
  148. #endif
  149. #endif // SDK_ERRORS_H__