err.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. // Avoid circular/nested/mulitple inclusion
  2. #ifndef ERR_H_
  3. #define ERR_H_
  4. //----------------------------------------------------------------------------- ----------------------------------------
  5. // Application name
  6. //
  7. static const char* const appName = "Wii_i2c"; //$ Name used in log files
  8. //----------------------------------------------------------------------------- ----------------------------------------
  9. // Error codes and messages
  10. //
  11. // You should only ever (need to) edit this list
  12. // ...Watch out for extraneous whitespace after the terminating backslashes
  13. #define FOREACH_ES(esPrial) \
  14. /* The first line MUST define 'ERR_OK = 0' */ \
  15. esPrial(0, ERR_OK, "OK (no error)") \
  16. \
  17. esPrial(1, ERR_MALLOC_QUEUE, "malloc() fail - queue") esPrial( \
  18. 2, \
  19. ERR_MALLOC_STATE, \
  20. "malloc() fail - state") esPrial(3, ERR_MALLOC_TEXT, "malloc() fail - text") \
  21. esPrial(4, ERR_MALLOC_VIEW, "malloc() fail - viewport") esPrial( \
  22. 5, ERR_NO_MUTEX, "Cannot create mutex") esPrial(6, ERR_NO_GUI, "Cannot open GUI") \
  23. esPrial(7, ERR_NO_TIMER, "Cannot create timer") esPrial( \
  24. 8, ERR_NO_NOTIFY, "Cannot acquire notifications handle") \
  25. \
  26. esPrial(10, ERR_MUTEX_BLOCK, "Mutex block failed") esPrial( \
  27. 11, ERR_MUTEX_RELEASE, "Mutex release failed") \
  28. \
  29. esPrial(20, ERR_QUEUE_RTOS, "queue - Undefined RTOS error") \
  30. esPrial(21, DEBUG_QUEUE_TIMEOUT, "queue - Timeout") esPrial( \
  31. 22, ERR_QUEUE_RESOURCE, "queue - Resource not available") \
  32. esPrial(23, ERR_QUEUE_BADPRM, "queue - Bad parameter") esPrial( \
  33. 24, ERR_QUEUE_NOMEM, "queue - Out of memory") \
  34. esPrial(25, ERR_QUEUE_ISR, "queue - Banned in ISR") esPrial( \
  35. 26, ERR_QUEUE_UNK, "queue - Unknown") \
  36. \
  37. esPrial(30, WARN_SCAN_START, "Scan - Already started") \
  38. esPrial(31, WARN_SCAN_STOP, "Scan - Already stopped") \
  39. esPrial( \
  40. 32, \
  41. ERR_TIMER_START, \
  42. "Scan - Cannot start timer") \
  43. esPrial( \
  44. 33, \
  45. ERR_TIMER_STOP, \
  46. "Scan - Cannot stop timer") //[EOT]
  47. // Declare list extraction macros
  48. #define ES_ENUM(num, ename, string) ename = num,
  49. #define ES_STRING(num, ename, string) string "\r\n",
  50. // Build the enum
  51. typedef enum err { FOREACH_ES(ES_ENUM) } err_t;
  52. // You need to '#define ERR_C_' in precisely ONE source file
  53. #ifdef ERR_C_
  54. // Build the string list
  55. const char* const wii_errs[] = {FOREACH_ES(ES_STRING)};
  56. #else
  57. // Give access to string list
  58. extern const char* const wii_errs[];
  59. #endif
  60. // This is a header file, clean up
  61. #undef ES_ENUM
  62. #undef ES_STRING
  63. #undef FOREACH_ES
  64. #endif // ERR_H_