ioLibrary for Cortex M series
Main Page
Related Pages
Modules
Classes
Files
File List
File Members
ioLibrary
common
common.h
Go to the documentation of this file.
1
14
#ifndef _COMMON_H
15
#define _COMMON_H
16
17
18
//-------------------------------------- Host Definition --------------------------------------
19
#include "xhw_types.h"
20
#include "xcore.h"
21
#include "xhw_memmap.h"
22
#include "xsysctl.h"
23
#include "xhw_spi.h"
24
#include "xgpio.h"
25
#include "xuart.h"
26
#include "xspi.h"
27
28
//-------------------------------------- Common Includes ----------------------------------------
29
#include <stdio.h>
30
#include <stdlib.h>
31
#include <string.h>
32
#include <ctype.h>
33
#include <stdint.h>
34
35
#include "
common/util.h
"
36
#include "
ethernet/wizchip_conf.h
"
37
#include "
ethernet/netctrl.h
"
38
#include "
ethernet/socket.h
"
39
#include "
ethernet/sockutil.h
"
40
41
#include "
host/Nuvoton_M051/Cookie/cookie_evb.h
"
42
#include "
host/wizplatform.h
"
43
44
#define RET_FAIL 1
45
#define RET_OK 0
46
#define RET_NOK -1
47
48
#define VAL_HIGH 1
49
#define VAL_LOW 0
50
51
#define VAL_TOG 2
52
#define VAL_ON 1
53
#define VAL_OFF 0
54
55
#define VAL_SET 1
56
#define VAL_CLEAR 0
57
58
#define VAL_TRUE 1
59
#define VAL_FALSE 0
60
61
#define VAL_ENABLE 1
62
#define VAL_DISABLE 0
63
64
#define VAL_NONE -1
65
#define VAL_INVALID -2
66
67
//------------------------------------------- LOG ---------------------------------------------
68
#if !defined(WIZ_LOG_LEVEL) || (WIZ_LOG_LEVEL < 0) || (WIZ_LOG_LEVEL > 3)
69
#define WIZ_LOG_LEVEL 2
70
#endif
71
72
#if (WIZ_LOG_LEVEL > 0) && defined(PRINT_TIME_LOG) && !defined(FILE_LOG_SILENCE)
73
#define ERR(fmt) do { printf("### ERROR ### [%5d.%03d] %s(%d): "fmt"\r\n", \
74
wizpf_get_systick()/1000, wizpf_get_systick()%1000, __FUNCTION__, __LINE__); } while(0)
75
#define ERRA(fmt, ...) do { printf("### ERROR ### [%5d.%03d] %s(%d): "fmt"\r\n", \
76
wizpf_get_systick()/1000, wizpf_get_systick()%1000, __FUNCTION__, __LINE__, __VA_ARGS__); } while(0)
77
#define ERRF(fmt) do { printf("### ERROR ### [%5d.%03d] %s(%d): "fmt, \
78
wizpf_get_systick()/1000, wizpf_get_systick()%1000, __FUNCTION__, __LINE__); } while(0)
79
#define ERRFA(fmt, ...) do { printf("### ERROR ### [%5d.%03d] %s(%d): "fmt, \
80
wizpf_get_systick()/1000, wizpf_get_systick()%1000, __FUNCTION__, __LINE__, __VA_ARGS__); } while(0)
81
#elif (WIZ_LOG_LEVEL > 0) && !defined(PRINT_TIME_LOG) && !defined(FILE_LOG_SILENCE)
82
#define ERR(fmt) do { printf("### ERROR ### %s(%d): "fmt"\r\n", __FUNCTION__, __LINE__); } while(0)
83
#define ERRA(fmt, ...) do { printf("### ERROR ### %s(%d): "fmt"\r\n", __FUNCTION__, __LINE__, __VA_ARGS__); } while(0)
84
#define ERRF(fmt) do { printf("### ERROR ### %s(%d): "fmt, __FUNCTION__, __LINE__); } while(0)
85
#define ERRFA(fmt, ...) do { printf("### ERROR ### %s(%d): "fmt, __FUNCTION__, __LINE__, __VA_ARGS__); } while(0)
86
#else
87
#define ERR(fmt)
88
#define ERRA(fmt, ...)
89
#define ERRF(fmt)
90
#define ERRFA(fmt, ...)
91
#endif
92
93
#if (WIZ_LOG_LEVEL > 1) && defined(PRINT_TIME_LOG) && !defined(FILE_LOG_SILENCE)
94
#define LOG(fmt) do { printf("[%5d.%03d] "fmt"\r\n", \
95
wizpf_get_systick()/1000, wizpf_get_systick()%1000); } while(0)
96
#define LOGA(fmt, ...) do { printf("[%5d.%03d] "fmt"\r\n", \
97
wizpf_get_systick()/1000, wizpf_get_systick()%1000, __VA_ARGS__); } while(0)
98
#define LOGF(fmt) do { printf("[%5d.%03d] "fmt, \
99
wizpf_get_systick()/1000, wizpf_get_systick()%1000); } while(0)
100
#define LOGFA(fmt, ...) do { printf("[%5d.%03d] "fmt, \
101
wizpf_get_systick()/1000, wizpf_get_systick()%1000, __VA_ARGS__); } while(0)
102
#elif (WIZ_LOG_LEVEL > 1) && !defined(PRINT_TIME_LOG) && !defined(FILE_LOG_SILENCE)
103
#define LOG(fmt) do { printf(fmt"\r\n"); } while(0)
104
#define LOGA(fmt, ...) do { printf(fmt"\r\n", __VA_ARGS__); } while(0)
105
#define LOGF(fmt) do { printf(fmt); } while(0)
106
#define LOGFA(fmt, ...) do { printf(fmt, __VA_ARGS__); } while(0)
107
#else
108
#define LOG(fmt)
109
#define LOGA(fmt, ...)
110
#define LOGF(fmt)
111
#define LOGFA(fmt, ...)
112
#endif
113
114
#if (WIZ_LOG_LEVEL > 2) && defined(PRINT_TIME_LOG) && !defined(FILE_LOG_SILENCE)
115
#define DBG(fmt) do { printf("[D] [%5d.%03d] %s(%d): "fmt"\r\n", \
116
wizpf_get_systick()/1000, wizpf_get_systick()%1000, __FUNCTION__, __LINE__); } while(0)
117
#define DBGA(fmt, ...) do { printf("[D] [%5d.%03d] %s(%d): "fmt"\r\n", \
118
wizpf_get_systick()/1000, wizpf_get_systick()%1000, __FUNCTION__, __LINE__, __VA_ARGS__); } while(0)
119
#define DBGF(fmt) do { printf("[D] [%5d.%03d] %s(%d): "fmt, \
120
wizpf_get_systick()/1000, wizpf_get_systick()%1000, __FUNCTION__, __LINE__); } while(0)
121
#define DBGFA(fmt, ...) do { printf("[D] [%5d.%03d] %s(%d): "fmt, \
122
wizpf_get_systick()/1000, wizpf_get_systick()%1000, __FUNCTION__, __LINE__, __VA_ARGS__); } while(0)
123
#elif (WIZ_LOG_LEVEL > 2) && !defined(PRINT_TIME_LOG) && !defined(FILE_LOG_SILENCE)
124
#define DBG(fmt) do { printf("[D] %s(%d): "fmt"\r\n", __FUNCTION__, __LINE__); } while(0)
125
#define DBGA(fmt, ...) do { printf("[D] %s(%d): "fmt"\r\n", __FUNCTION__, __LINE__, __VA_ARGS__); } while(0)
126
#define DBGF(fmt) do { printf("[D] %s(%d): "fmt, __FUNCTION__, __LINE__); } while(0)
127
#define DBGFA(fmt, ...) do { printf("[D] %s(%d): "fmt, __FUNCTION__, __LINE__, __VA_ARGS__); } while(0)
128
#else
129
#define DBG(fmt)
130
#define DBGA(fmt, ...)
131
#define DBGF(fmt)
132
#define DBGFA(fmt, ...)
133
#endif
134
135
#if (WIZ_LOG_LEVEL > 2) && !defined(FILE_LOG_SILENCE)
136
#define DBGCRTC(cond_v, fmt) do { if(cond_v) {ERR(fmt); while(1); } } while(0)
137
#define DBGCRTCA(cond_v, fmt, ...) do { if(cond_v) {ERRA(fmt, __VA_ARGS__); while(1); } } while(0)
138
#define DBGDUMP(data_p, len_v) print_dump(data_p, len_v)
139
#define DBGFUNC(func_p) func_p
140
#else
141
#define DBGCRTC(cond_v, fmt)
142
#define DBGCRTCA(cond_v, fmt, ...)
143
#define DBGDUMP(data_p, len_v)
144
#define DBGFUNC(func_p)
145
#endif
146
147
#if (WIZ_LOG_LEVEL > 0) && !defined(FILE_LOG_SILENCE)
148
#define NL1 printf("\r\n")
149
#define NL2 printf("\r\n\r\n")
150
#define NL3 printf("\r\n\r\n\r\n")
151
#else
152
#define NL1
153
#define NL2
154
#define NL3
155
#endif
156
157
//-------------------------------------------------------------------------------------------
158
159
160
161
#endif //_COMMON_H
162
Generated on Tue Sep 3 2013 15:36:42 for ioLibrary for Cortex M series by
1.8.4