gm_debug.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. /*!
  2. *******************************************************************************
  3. **
  4. ** \file gm_debug.h
  5. **
  6. ** \brief Debug support module.
  7. **
  8. ** This file implements the public functions for a terminal utility
  9. ** (basic functions only). You can use them for printf/scanf style
  10. ** debug functions on a terminal or via OSD.
  11. **
  12. ** Note that if you want to use the almighty printf/scanf you have to
  13. ** include the C-Lib (consumes about 25kB memory). If not
  14. ** you can compile the module with DEBUG_NO_CLIB, then only
  15. ** the simple functions are available.
  16. **
  17. ** Copyright: 2012 - 2013 (C) GoKe Microelectronics ShangHai Branch
  18. **
  19. ** \attention THIS SAMPLE CODE IS PROVIDED AS IS. GOKE MICROELECTRONICS
  20. ** ACCEPTS NO RESPONSIBILITY OR LIABILITY FOR ANY ERRORS OR
  21. ** OMMISSIONS.
  22. **
  23. ** \version
  24. **
  25. ******************************************************************************/
  26. #ifndef _GM_DEBUG_H_
  27. #define _GM_DEBUG_H_
  28. #include <gtypes.h>
  29. #include <gmodids.h>
  30. /*---------------------------------------------------------------------------*/
  31. /* constants and macros */
  32. /*---------------------------------------------------------------------------*/
  33. #define UTIL_MAX_STR_LEN 40 //20 //Jennifer modified 20090422
  34. #define GM_DEBUG_ERR_BASE (GM_DEBUG_MODULE_ID<<16)
  35. #define GM_DEBUG_DISABLE 0
  36. #define GM_DEBUG_TTY 1
  37. #define GM_DEBUG_OSD 2
  38. #define GM_DEBUG_MEM 4
  39. /*---------------------------------------------------------------------------*/
  40. /* Display attributes and color codes */
  41. /*---------------------------------------------------------------------------*/
  42. /* foreground colours */
  43. #define GM_DGREY ""
  44. #define GM_RED ""
  45. #define GM_GREEN ""
  46. #define GM_YELLOW ""
  47. #define GM_BLUE ""
  48. #define GM_MAGENTA ""
  49. #define GM_CYAN ""
  50. #define GM_WHITE ""
  51. #define GM_BLACK "" /* low intensity */
  52. #define GM_DRED ""
  53. #define GM_DGREEN ""
  54. #define GM_DYELLOW ""
  55. #define GM_DBLUE ""
  56. #define GM_DMAGENTA ""
  57. #define GM_DCYAN ""
  58. #define GM_GREY ""
  59. /* background colours */
  60. #define GM_BG_DGREY ""
  61. #define GM_BG_RED ""
  62. #define GM_BG_GREEN ""
  63. #define GM_BG_YELLOW ""
  64. #define GM_BG_BLUE ""
  65. #define GM_BG_MAGENTA ""
  66. #define GM_BG_CYAN ""
  67. #define GM_BG_WHITE ""
  68. #define GM_BG_BLACK "" /* low intensity */
  69. #define GM_BG_DRED ""
  70. #define GM_BG_DGREEN ""
  71. #define GM_BG_DYELLOW ""
  72. #define GM_BG_DBLUE ""
  73. #define GM_BG_DMAGENTA ""
  74. #define GM_BG_DCYAN ""
  75. #define GM_BG_GREY ""
  76. /* display attributes */
  77. #define GM_DISP_RESET "" /* default settings (color + attributes) */
  78. #define GM_DISP_UNDERLINE "" /* cursor underline */
  79. #define GM_DISP_REVERSE "" /* reverse display */
  80. #define GM_DISP_BLINK "" /* cursor blink */
  81. #define GM_DISP_INVISIBLE "" /* cursor invisible */
  82. /*---------------------------------------------------------------------------*/
  83. /* types, enums and structures */
  84. /*---------------------------------------------------------------------------*/
  85. typedef struct
  86. {
  87. U8 dispDevice; /* or'ed combination of GM_DEBUG_TTY, GM_DEBUG_OSD, */
  88. /* GM_DEBUG_MEM or GM_DEBUG_DISABLE */
  89. S8 gpioRxPin;
  90. S8 gpioTxPin;
  91. U8 interruptEnable;
  92. } GM_DEBUG_INIT_PARAMS_S;
  93. typedef void (*out_put_device)(const char );
  94. /*---------------------------------------------------------------------------*/
  95. /* function prototypes */
  96. /*---------------------------------------------------------------------------*/
  97. #ifdef __cplusplus
  98. extern "C" {
  99. #endif
  100. GERR GM_DEBUG_Init(GM_DEBUG_INIT_PARAMS_S *paramsP);
  101. int GM_Printf(const char *__format, ...);
  102. int GM_Scanf(const char *__format, ...);
  103. U8 GM_DEBUG_GetOutputDevice(void);
  104. GERR GM_DEBUG_SetOutputDevice(out_put_device fun);
  105. U8 GM_DEBUG_ReadChar(void);
  106. GBOOL GM_DEBUG_CheckRxBuffer(void);
  107. void GM_PrintfSeperator1(void);
  108. void GM_PrintfSeperator2(void);
  109. /* just a few simple terminal functions if you don't like to include the huge*/
  110. /* printf/scanf from standard C-Lib. If you only like to use these functions */
  111. /* make sure to compile this module with the precompiler flag DEBUG_NO_CLIB */
  112. /* to reduce memory amount. */
  113. void GM_PrStrStr(const char *str1P, char *str2P);
  114. void GM_PrStr(const char *strP);
  115. void GM_PrHex(int data, int len);
  116. void GM_PrInt(int data);
  117. void GM_PrU32(U32 data);
  118. void GM_PrCStrHex2(const char *strP, U32 data);
  119. void GM_PrCStrHex4(const char *strP, S16 data);
  120. void GM_PrCStrHex8(const char *strP, U32 data);
  121. void GM_PrintChar(char cx);
  122. char GM_ReceiveChar(void);
  123. void GM_ScanStr(char *pDest);
  124. void GM_LimScanStr(char *pDest, U32 length);
  125. int GM_ScanNum (const char *Format , U32 *pValue);
  126. #ifdef __cplusplus
  127. }
  128. #endif
  129. #endif /* _GM_DEBUG_H_ */
  130. /* end of gm_debug.h */