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