st_errno.h 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. /******************************************************************************
  2. * @attention
  3. *
  4. * <h2><center>&copy; COPYRIGHT 2018 STMicroelectronics</center></h2>
  5. *
  6. * Licensed under ST MYLIBERTY SOFTWARE LICENSE AGREEMENT (the "License");
  7. * You may not use this file except in compliance with the License.
  8. * You may obtain a copy of the License at:
  9. *
  10. * http://www.st.com/myliberty
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
  15. * AND SPECIFICALLY DISCLAIMING THE IMPLIED WARRANTIES OF MERCHANTABILITY,
  16. * FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
  17. * See the License for the specific language governing permissions and
  18. * limitations under the License.
  19. *
  20. ******************************************************************************/
  21. /*
  22. * PROJECT: STxxxx firmware
  23. * LANGUAGE: ISO C99
  24. */
  25. /*! \file st_errno.h
  26. *
  27. * \author
  28. *
  29. * \brief Main error codes
  30. *
  31. */
  32. #ifndef ST_ERRNO_H
  33. #define ST_ERRNO_H
  34. /*
  35. ******************************************************************************
  36. * INCLUDES
  37. ******************************************************************************
  38. */
  39. #include <stdint.h>
  40. /*
  41. ******************************************************************************
  42. * GLOBAL DATA TYPES
  43. ******************************************************************************
  44. */
  45. typedef uint16_t ReturnCode; /*!< Standard Return Code type from function. */
  46. /*
  47. ******************************************************************************
  48. * DEFINES
  49. ******************************************************************************
  50. */
  51. /*
  52. * Error codes to be used within the application.
  53. * They are represented by an uint8_t
  54. */
  55. enum {
  56. ERR_NONE = 0, /*!< no error occurred */
  57. ERR_NOMEM = 1, /*!< not enough memory to perform the requested operation */
  58. ERR_BUSY = 2, /*!< device or resource busy */
  59. ERR_IO = 3, /*!< generic IO error */
  60. ERR_TIMEOUT = 4, /*!< error due to timeout */
  61. ERR_REQUEST = 5, /*!< invalid request or requested function can't be executed at the moment */
  62. ERR_NOMSG = 6, /*!< No message of desired type */
  63. ERR_PARAM = 7, /*!< Parameter error */
  64. ERR_SYSTEM = 8, /*!< System error */
  65. ERR_FRAMING = 9, /*!< Framing error */
  66. ERR_OVERRUN = 10, /*!< lost one or more received bytes */
  67. ERR_PROTO = 11, /*!< protocol error */
  68. ERR_INTERNAL = 12, /*!< Internal Error */
  69. ERR_AGAIN = 13, /*!< Call again */
  70. ERR_MEM_CORRUPT = 14, /*!< memory corruption */
  71. ERR_NOT_IMPLEMENTED = 15, /*!< not implemented */
  72. ERR_PC_CORRUPT =
  73. 16, /*!< Program Counter has been manipulated or spike/noise trigger illegal operation */
  74. ERR_SEND = 17, /*!< error sending*/
  75. ERR_IGNORE = 18, /*!< indicates error detected but to be ignored */
  76. ERR_SEMANTIC = 19, /*!< indicates error in state machine (unexpected cmd) */
  77. ERR_SYNTAX = 20, /*!< indicates error in state machine (unknown cmd) */
  78. ERR_CRC = 21, /*!< crc error */
  79. ERR_NOTFOUND = 22, /*!< transponder not found */
  80. ERR_NOTUNIQUE = 23, /*!< transponder not unique - more than one transponder in field */
  81. ERR_NOTSUPP = 24, /*!< requested operation not supported */
  82. ERR_WRITE = 25, /*!< write error */
  83. ERR_FIFO = 26, /*!< fifo over or underflow error */
  84. ERR_PAR = 27, /*!< parity error */
  85. ERR_DONE = 28, /*!< transfer has already finished */
  86. ERR_RF_COLLISION =
  87. 29, /*!< collision error (Bit Collision or during RF Collision avoidance ) */
  88. ERR_HW_OVERRUN = 30, /*!< lost one or more received bytes */
  89. ERR_RELEASE_REQ = 31, /*!< device requested release */
  90. ERR_SLEEP_REQ = 32, /*!< device requested sleep */
  91. ERR_WRONG_STATE = 33, /*!< incorrent state for requested operation */
  92. ERR_MAX_RERUNS = 34, /*!< blocking procedure reached maximum runs */
  93. ERR_DISABLED = 35, /*!< operation aborted due to disabled configuration */
  94. ERR_HW_MISMATCH = 36, /*!< expected hw do not match */
  95. ERR_LINK_LOSS =
  96. 37, /*!< Other device's field didn't behave as expected: turned off by Initiator in Passive mode, or AP2P did not turn on field */
  97. ERR_INVALID_HANDLE = 38, /*!< invalid or not initalized device handle */
  98. ERR_INCOMPLETE_BYTE = 40, /*!< Incomplete byte rcvd */
  99. ERR_INCOMPLETE_BYTE_01 = 41, /*!< Incomplete byte rcvd - 1 bit */
  100. ERR_INCOMPLETE_BYTE_02 = 42, /*!< Incomplete byte rcvd - 2 bit */
  101. ERR_INCOMPLETE_BYTE_03 = 43, /*!< Incomplete byte rcvd - 3 bit */
  102. ERR_INCOMPLETE_BYTE_04 = 44, /*!< Incomplete byte rcvd - 4 bit */
  103. ERR_INCOMPLETE_BYTE_05 = 45, /*!< Incomplete byte rcvd - 5 bit */
  104. ERR_INCOMPLETE_BYTE_06 = 46, /*!< Incomplete byte rcvd - 6 bit */
  105. ERR_INCOMPLETE_BYTE_07 = 47, /*!< Incomplete byte rcvd - 7 bit */
  106. };
  107. /* General Sub-category number */
  108. #define ERR_GENERIC_GRP (0x0000) /*!< Reserved value for generic error no */
  109. #define ERR_WARN_GRP (0x0100) /*!< Errors which are not expected in normal operation */
  110. #define ERR_PROCESS_GRP (0x0200) /*!< Processes management errors */
  111. #define ERR_SIO_GRP (0x0800) /*!< SIO errors due to logging */
  112. #define ERR_RINGBUF_GRP (0x0900) /*!< Ring Buffer errors */
  113. #define ERR_MQ_GRP (0x0A00) /*!< MQ errors */
  114. #define ERR_TIMER_GRP (0x0B00) /*!< Timer errors */
  115. #define ERR_RFAL_GRP (0x0C00) /*!< RFAL errors */
  116. #define ERR_UART_GRP (0x0D00) /*!< UART errors */
  117. #define ERR_SPI_GRP (0x0E00) /*!< SPI errors */
  118. #define ERR_I2C_GRP (0x0F00) /*!< I2c errors */
  119. #define ERR_INSERT_SIO_GRP(x) (ERR_SIO_GRP | x) /*!< Insert the SIO grp */
  120. #define ERR_INSERT_RINGBUF_GRP(x) (ERR_RINGBUF_GRP | x) /*!< Insert the Ring Buffer grp */
  121. #define ERR_INSERT_RFAL_GRP(x) (ERR_RFAL_GRP | x) /*!< Insert the RFAL grp */
  122. #define ERR_INSERT_SPI_GRP(x) (ERR_SPI_GRP | x) /*!< Insert the spi grp */
  123. #define ERR_INSERT_I2C_GRP(x) (ERR_I2C_GRP | x) /*!< Insert the i2c grp */
  124. #define ERR_INSERT_UART_GRP(x) (ERR_UART_GRP | x) /*!< Insert the uart grp */
  125. #define ERR_INSERT_TIMER_GRP(x) (ERR_TIMER_GRP | x) /*!< Insert the timer grp */
  126. #define ERR_INSERT_MQ_GRP(x) (ERR_MQ_GRP | x) /*!< Insert the mq grp */
  127. #define ERR_INSERT_PROCESS_GRP(x) (ERR_PROCESS_GRP | x) /*!< Insert the process grp */
  128. #define ERR_INSERT_WARN_GRP(x) (ERR_WARN_GRP | x) /*!< Insert the i2c grp */
  129. #define ERR_INSERT_GENERIC_GRP(x) (ERR_GENERIC_GRP | x) /*!< Insert the generic grp */
  130. /*
  131. ******************************************************************************
  132. * GLOBAL MACROS
  133. ******************************************************************************
  134. */
  135. #define ERR_NO_MASK(x) (x & 0x00FF) /*!< Mask the error number */
  136. /*! Common code to exit a function with the error if function f return error */
  137. #define EXIT_ON_ERR(r, f) \
  138. if(ERR_NONE != (r = f)) { \
  139. return r; \
  140. }
  141. #endif /* ST_ERRNO_H */