err.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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") \
  18. esPrial( 2, ERR_MALLOC_STATE , "malloc() fail - state") \
  19. esPrial( 3, ERR_MALLOC_TEXT , "malloc() fail - text") \
  20. esPrial( 4, ERR_MALLOC_VIEW , "malloc() fail - viewport") \
  21. esPrial( 5, ERR_NO_MUTEX , "Cannot create mutex") \
  22. esPrial( 6, ERR_NO_GUI , "Cannot open GUI") \
  23. esPrial( 7, ERR_NO_TIMER , "Cannot create timer") \
  24. esPrial( 8, ERR_NO_NOTIFY , "Cannot acquire notifications handle") \
  25. \
  26. esPrial(10, ERR_MUTEX_BLOCK , "Mutex block failed") \
  27. esPrial(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") \
  31. esPrial(22, ERR_QUEUE_RESOURCE , "queue - Resource not available") \
  32. esPrial(23, ERR_QUEUE_BADPRM , "queue - Bad parameter") \
  33. esPrial(24, ERR_QUEUE_NOMEM , "queue - Out of memory") \
  34. esPrial(25, ERR_QUEUE_ISR , "queue - Banned in ISR") \
  35. esPrial(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(32, ERR_TIMER_START , "Scan - Cannot start timer") \
  40. esPrial(33, ERR_TIMER_STOP , "Scan - Cannot stop timer") \
  41. //[EOT]
  42. // Declare list extraction macros
  43. #define ES_ENUM(num, ename, string) ename = num,
  44. #define ES_STRING(num, ename, string) string"\r\n",
  45. // Build the enum
  46. typedef
  47. enum err { FOREACH_ES(ES_ENUM) }
  48. err_t ;
  49. // You need to '#define ERR_C_' in precisely ONE source file
  50. #ifdef ERR_C_
  51. // Build the string list
  52. const char* const wii_errs[] = { FOREACH_ES(ES_STRING) };
  53. #else
  54. // Give access to string list
  55. extern const char* const wii_errs[];
  56. #endif
  57. // This is a header file, clean up
  58. #undef ES_ENUM
  59. #undef ES_STRING
  60. #undef FOREACH_ES
  61. #endif // ERR_H_