status_codes.h 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. /**
  2. * \file
  3. *
  4. * \brief Status code definitions.
  5. *
  6. * This file defines various status codes returned by functions,
  7. * indicating success or failure as well as what kind of failure.
  8. *
  9. * Copyright (C) 2012-2015 Atmel Corporation. All rights reserved.
  10. *
  11. * \asf_license_start
  12. *
  13. * \page License
  14. *
  15. * Redistribution and use in source and binary forms, with or without
  16. * modification, are permitted provided that the following conditions are met:
  17. *
  18. * 1. Redistributions of source code must retain the above copyright notice,
  19. * this list of conditions and the following disclaimer.
  20. *
  21. * 2. Redistributions in binary form must reproduce the above copyright notice,
  22. * this list of conditions and the following disclaimer in the documentation
  23. * and/or other materials provided with the distribution.
  24. *
  25. * 3. The name of Atmel may not be used to endorse or promote products derived
  26. * from this software without specific prior written permission.
  27. *
  28. * 4. This software may only be redistributed and used in connection with an
  29. * Atmel microcontroller product.
  30. *
  31. * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
  32. * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  33. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
  34. * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
  35. * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  36. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  37. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  38. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  39. * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
  40. * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  41. * POSSIBILITY OF SUCH DAMAGE.
  42. *
  43. * \asf_license_stop
  44. *
  45. */
  46. /*
  47. * Support and FAQ: visit <a href="http://www.atmel.com/design-support/">Atmel Support</a>
  48. */
  49. #ifndef STATUS_CODES_H_INCLUDED
  50. #define STATUS_CODES_H_INCLUDED
  51. #include <stdint.h>
  52. /**
  53. * \defgroup group_sam0_utils_status_codes Status Codes
  54. *
  55. * \ingroup group_sam0_utils
  56. *
  57. * @{
  58. */
  59. /** Mask to retrieve the error category of a status code. */
  60. #define STATUS_CATEGORY_MASK 0xF0
  61. /** Mask to retrieve the error code within the category of a status code. */
  62. #define STATUS_ERROR_MASK 0x0F
  63. /** Status code error categories. */
  64. enum status_categories {
  65. STATUS_CATEGORY_OK = 0x00,
  66. STATUS_CATEGORY_COMMON = 0x10,
  67. STATUS_CATEGORY_ANALOG = 0x30,
  68. STATUS_CATEGORY_COM = 0x40,
  69. STATUS_CATEGORY_IO = 0x50,
  70. };
  71. /**
  72. * Status code that may be returned by shell commands and protocol
  73. * implementations.
  74. *
  75. * \note Any change to these status codes and the corresponding
  76. * message strings is strictly forbidden. New codes can be added,
  77. * however, but make sure that any message string tables are updated
  78. * at the same time.
  79. */
  80. enum status_code {
  81. STATUS_OK = STATUS_CATEGORY_OK | 0x00,
  82. STATUS_VALID_DATA = STATUS_CATEGORY_OK | 0x01,
  83. STATUS_NO_CHANGE = STATUS_CATEGORY_OK | 0x02,
  84. STATUS_ABORTED = STATUS_CATEGORY_OK | 0x04,
  85. STATUS_BUSY = STATUS_CATEGORY_OK | 0x05,
  86. STATUS_SUSPEND = STATUS_CATEGORY_OK | 0x06,
  87. STATUS_ERR_IO = STATUS_CATEGORY_COMMON | 0x00,
  88. STATUS_ERR_REQ_FLUSHED = STATUS_CATEGORY_COMMON | 0x01,
  89. STATUS_ERR_TIMEOUT = STATUS_CATEGORY_COMMON | 0x02,
  90. STATUS_ERR_BAD_DATA = STATUS_CATEGORY_COMMON | 0x03,
  91. STATUS_ERR_NOT_FOUND = STATUS_CATEGORY_COMMON | 0x04,
  92. STATUS_ERR_UNSUPPORTED_DEV = STATUS_CATEGORY_COMMON | 0x05,
  93. STATUS_ERR_NO_MEMORY = STATUS_CATEGORY_COMMON | 0x06,
  94. STATUS_ERR_INVALID_ARG = STATUS_CATEGORY_COMMON | 0x07,
  95. STATUS_ERR_BAD_ADDRESS = STATUS_CATEGORY_COMMON | 0x08,
  96. STATUS_ERR_BAD_FORMAT = STATUS_CATEGORY_COMMON | 0x0A,
  97. STATUS_ERR_BAD_FRQ = STATUS_CATEGORY_COMMON | 0x0B,
  98. STATUS_ERR_DENIED = STATUS_CATEGORY_COMMON | 0x0c,
  99. STATUS_ERR_ALREADY_INITIALIZED = STATUS_CATEGORY_COMMON | 0x0d,
  100. STATUS_ERR_OVERFLOW = STATUS_CATEGORY_COMMON | 0x0e,
  101. STATUS_ERR_NOT_INITIALIZED = STATUS_CATEGORY_COMMON | 0x0f,
  102. STATUS_ERR_SAMPLERATE_UNAVAILABLE = STATUS_CATEGORY_ANALOG | 0x00,
  103. STATUS_ERR_RESOLUTION_UNAVAILABLE = STATUS_CATEGORY_ANALOG | 0x01,
  104. STATUS_ERR_BAUDRATE_UNAVAILABLE = STATUS_CATEGORY_COM | 0x00,
  105. STATUS_ERR_PACKET_COLLISION = STATUS_CATEGORY_COM | 0x01,
  106. STATUS_ERR_PROTOCOL = STATUS_CATEGORY_COM | 0x02,
  107. STATUS_ERR_PIN_MUX_INVALID = STATUS_CATEGORY_IO | 0x00,
  108. };
  109. typedef enum status_code status_code_genare_t;
  110. /**
  111. Status codes used by MAC stack.
  112. */
  113. enum status_code_wireless {
  114. //STATUS_OK = 0, //!< Success
  115. ERR_IO_ERROR = -1, //!< I/O error
  116. ERR_FLUSHED = -2, //!< Request flushed from queue
  117. ERR_TIMEOUT = -3, //!< Operation timed out
  118. ERR_BAD_DATA = -4, //!< Data integrity check failed
  119. ERR_PROTOCOL = -5, //!< Protocol error
  120. ERR_UNSUPPORTED_DEV = -6, //!< Unsupported device
  121. ERR_NO_MEMORY = -7, //!< Insufficient memory
  122. ERR_INVALID_ARG = -8, //!< Invalid argument
  123. ERR_BAD_ADDRESS = -9, //!< Bad address
  124. ERR_BUSY = -10, //!< Resource is busy
  125. ERR_BAD_FORMAT = -11, //!< Data format not recognized
  126. ERR_NO_TIMER = -12, //!< No timer available
  127. ERR_TIMER_ALREADY_RUNNING = -13, //!< Timer already running
  128. ERR_TIMER_NOT_RUNNING = -14, //!< Timer not running
  129. /**
  130. * \brief Operation in progress
  131. *
  132. * This status code is for driver-internal use when an operation
  133. * is currently being performed.
  134. *
  135. * \note Drivers should never return this status code to any
  136. * callers. It is strictly for internal use.
  137. */
  138. OPERATION_IN_PROGRESS = -128,
  139. };
  140. typedef enum status_code_wireless status_code_t;
  141. /** @} */
  142. #endif /* STATUS_CODES_H_INCLUDED */