WIZlib Library API
ver 1.0
WIZlib Library API User Menual
Main Page
Modules
Data Structures
Files
File List
Globals
All
Data Structures
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Groups
Pages
library
common
common.h
Go to the documentation of this file.
1
14
#ifndef _COMMON_H
15
#define _COMMON_H
16
17
18
#include "
wizconfig.h
"
19
20
21
//-------------------------------------- Compiler Definition --------------------------------------
22
#ifdef COMPILER_IAR_EWARM
23
#ifndef COMPILER_DEF_DONE
24
#define COMPILER_DEF_DONE
25
#else
26
#error Duplicate definition of COMPILER
27
#endif
28
29
//Todo
30
31
#endif
32
33
//------------------------------------------
34
#ifdef COMPILER_GCC_ARM
35
#ifndef COMPILER_DEF_DONE
36
#define COMPILER_DEF_DONE
37
#else
38
#error Duplicate definition of COMPILER
39
#endif
40
41
//Todo
42
43
#endif
44
45
//-------------------------------------- Platform Definition --------------------------------------
46
#ifdef PLATFORM_W5200_EVB
47
#ifndef PLATFORM_DEF_DONE
48
#define PLATFORM_DEF_DONE
49
#else
50
#error Duplicate definition of PLATFORM
51
#endif
52
53
#define HOST_STM32F10X
54
#define DEVICE_W5200
55
#include "
host/STM32F10x/WIZ_W5200/w5200_evb.h
"
56
57
#endif
58
59
//------------------------------------------
60
#ifdef PLATFORM_W7200_EVB
61
#ifndef PLATFORM_DEF_DONE
62
#define PLATFORM_DEF_DONE
63
#else
64
#error Duplicate definition of PLATFORM
65
#endif
66
67
#define HOST_STM32F10X
68
#define DEVICE_W5200
69
#include "
host/STM32F10x/WIZ_W7200/w7200_evb.h
"
70
71
#endif
72
73
//------------------------------------------
74
#ifdef PLATFORM_W5500_EVB
75
#ifndef PLATFORM_DEF_DONE
76
#define PLATFORM_DEF_DONE
77
#else
78
#error Duplicate definition of PLATFORM
79
#endif
80
81
#define HOST_STM32F10X
82
#define DEVICE_W5500
83
#include "
host/STM32F10x/WIZ_W5500/w5500_evb.h
"
84
85
#endif
86
87
//-------------------------------------- Host Definition --------------------------------------
88
#ifdef HOST_8051
89
#ifndef HOST_DEF_DONE
90
#define HOST_DEF_DONE
91
#else
92
#error Duplicate definition of HOST
93
#endif
94
95
//Todo
96
97
#endif
98
99
//------------------------------------------
100
#ifdef HOST_STM32F10X
101
#ifndef HOST_DEF_DONE
102
#define HOST_DEF_DONE
103
#else
104
#error Duplicate definition of HOST
105
#endif
106
107
#include "stm32f10x.h"
108
#include "
host/wizspi.h
"
109
110
#endif
111
112
//-------------------------------------- Device Definition --------------------------------------
113
#ifdef DEVICE_W5100
114
#ifndef DEVICE_DEF_DONE
115
#define DEVICE_DEF_DONE
116
#else
117
#error Duplicate definition of DEVICE
118
#endif
119
120
//Todo
121
122
#endif
123
124
//------------------------------------------
125
#ifdef DEVICE_W5200
126
#ifndef DEVICE_DEF_DONE
127
#define DEVICE_DEF_DONE
128
#else
129
#error Duplicate definition of DEVICE
130
#endif
131
132
#define TOTAL_SOCK_NUM 8 // Maxmium number of socket
133
#define TOTAL_SOCK_MEM 32 // Total Tx/Rx Buffer Memory (KB)
134
#include "
device/w5200/w5200.h
"
135
136
#endif
137
138
//------------------------------------------
139
#ifdef DEVICE_W5300
140
#ifndef DEVICE_DEF_DONE
141
#define DEVICE_DEF_DONE
142
#else
143
#error Duplicate definition of DEVICE
144
#endif
145
146
//Todo
147
148
#endif
149
150
//------------------------------------------
151
#ifdef DEVICE_W5500
152
#ifndef DEVICE_DEF_DONE
153
#define DEVICE_DEF_DONE
154
#else
155
#error Duplicate definition of DEVICE
156
#endif
157
158
#define TOTAL_SOCK_NUM 8 // Maxmium number of socket
159
#define TOTAL_SOCK_MEM 32 // Total Tx/Rx Buffer Memory (KB)
160
#include "
device/w5500/w5500.h
"
161
162
#endif
163
164
//-------------------------------------- Definition Check ----------------------------------------
165
#ifndef COMPILER_DEF_DONE
166
#error COMPILER Not defined
167
#endif
168
169
#ifndef PLATFORM_DEF_DONE
170
#error PLATFORM Not defined
171
#endif
172
173
#ifndef HOST_DEF_DONE
174
#error HOST Not defined
175
#endif
176
177
#ifndef DEVICE_DEF_DONE
178
#error DEVICE Not defined
179
#endif
180
181
#ifndef USE_DHCP
182
#define USE_DHCP VAL_DISABLE
183
#endif
184
185
#if (defined(SYSTEM_LITTLE_ENDIAN) && defined(SYSTEM_BIG_ENDIAN)) || \
186
(!defined(SYSTEM_LITTLE_ENDIAN) && !defined(SYSTEM_BIG_ENDIAN))
187
#error Endian define error
188
#endif
189
190
//-------------------------------------- Common Includes ----------------------------------------
191
#include <stdio.h>
192
#include <stdlib.h>
193
#include <string.h>
194
#include <ctype.h>
195
196
#include "
common/util.h
"
197
#include "
device/socket.h
"
198
#include "
device/sockutil.h
"
199
#include "
host/wizplatform.h
"
200
#if (USE_DHCP == VAL_ENABLE)
201
#include "
protocol/DHCP/dhcp.h
"
202
#else
203
#define dhcp_init(sock, ip_update_hook, ip_conflict_hook, def) RET_NOK
204
#define dhcp_manual(action, renew, rebind) RET_OK
205
#define dhcp_get_state() DHCP_STATE_INIT
206
#define dhcp_set_storage(net)
207
#define dhcp_get_storage(net)
208
#define dhcp_static_mode(net)
209
#define dhcp_auto_start()
210
#endif
211
212
//------------------------------------------- LOG ---------------------------------------------
213
#if !defined(WIZ_LOG_LEVEL) || (WIZ_LOG_LEVEL < 0) || (WIZ_LOG_LEVEL > 3)
214
#define WIZ_LOG_LEVEL 2
215
#endif
216
217
#if (WIZ_LOG_LEVEL > 0) && defined(PRINT_TIME_LOG) && !defined(FILE_LOG_SILENCE)
218
#define ERR(fmt) do { printf("### ERROR ### [%5d.%03d] %s(%d): "fmt"\r\n", \
219
wizpf_get_systick()/1000, wizpf_get_systick()%1000, __FUNCTION__, __LINE__); } while(0)
220
#define ERRA(fmt, ...) do { printf("### ERROR ### [%5d.%03d] %s(%d): "fmt"\r\n", \
221
wizpf_get_systick()/1000, wizpf_get_systick()%1000, __FUNCTION__, __LINE__, __VA_ARGS__); } while(0)
222
#define ERRF(fmt) do { printf("### ERROR ### [%5d.%03d] %s(%d): "fmt, \
223
wizpf_get_systick()/1000, wizpf_get_systick()%1000, __FUNCTION__, __LINE__); } while(0)
224
#define ERRFA(fmt, ...) do { printf("### ERROR ### [%5d.%03d] %s(%d): "fmt, \
225
wizpf_get_systick()/1000, wizpf_get_systick()%1000, __FUNCTION__, __LINE__, __VA_ARGS__); } while(0)
226
#elif (WIZ_LOG_LEVEL > 0) && !defined(PRINT_TIME_LOG) && !defined(FILE_LOG_SILENCE)
227
#define ERR(fmt) do { printf("### ERROR ### %s(%d): "fmt"\r\n", __FUNCTION__, __LINE__); } while(0)
228
#define ERRA(fmt, ...) do { printf("### ERROR ### %s(%d): "fmt"\r\n", __FUNCTION__, __LINE__, __VA_ARGS__); } while(0)
229
#define ERRF(fmt) do { printf("### ERROR ### %s(%d): "fmt, __FUNCTION__, __LINE__); } while(0)
230
#define ERRFA(fmt, ...) do { printf("### ERROR ### %s(%d): "fmt, __FUNCTION__, __LINE__, __VA_ARGS__); } while(0)
231
#else
232
#define ERR(fmt)
233
#define ERRA(fmt, ...)
234
#define ERRF(fmt)
235
#define ERRFA(fmt, ...)
236
#endif
237
238
#if (WIZ_LOG_LEVEL > 1) && defined(PRINT_TIME_LOG) && !defined(FILE_LOG_SILENCE)
239
#define LOG(fmt) do { printf("[%5d.%03d] "fmt"\r\n", \
240
wizpf_get_systick()/1000, wizpf_get_systick()%1000); } while(0)
241
#define LOGA(fmt, ...) do { printf("[%5d.%03d] "fmt"\r\n", \
242
wizpf_get_systick()/1000, wizpf_get_systick()%1000, __VA_ARGS__); } while(0)
243
#define LOGF(fmt) do { printf("[%5d.%03d] "fmt, \
244
wizpf_get_systick()/1000, wizpf_get_systick()%1000); } while(0)
245
#define LOGFA(fmt, ...) do { printf("[%5d.%03d] "fmt, \
246
wizpf_get_systick()/1000, wizpf_get_systick()%1000, __VA_ARGS__); } while(0)
247
#elif (WIZ_LOG_LEVEL > 1) && !defined(PRINT_TIME_LOG) && !defined(FILE_LOG_SILENCE)
248
#define LOG(fmt) do { printf(fmt"\r\n"); } while(0)
249
#define LOGA(fmt, ...) do { printf(fmt"\r\n", __VA_ARGS__); } while(0)
250
#define LOGF(fmt) do { printf(fmt); } while(0)
251
#define LOGFA(fmt, ...) do { printf(fmt, __VA_ARGS__); } while(0)
252
#else
253
#define LOG(fmt)
254
#define LOGA(fmt, ...)
255
#define LOGF(fmt)
256
#define LOGFA(fmt, ...)
257
#endif
258
259
#if (WIZ_LOG_LEVEL > 2) && defined(PRINT_TIME_LOG) && !defined(FILE_LOG_SILENCE)
260
#define DBG(fmt) do { printf("[D] [%5d.%03d] %s(%d): "fmt"\r\n", \
261
wizpf_get_systick()/1000, wizpf_get_systick()%1000, __FUNCTION__, __LINE__); } while(0)
262
#define DBGA(fmt, ...) do { printf("[D] [%5d.%03d] %s(%d): "fmt"\r\n", \
263
wizpf_get_systick()/1000, wizpf_get_systick()%1000, __FUNCTION__, __LINE__, __VA_ARGS__); } while(0)
264
#define DBGF(fmt) do { printf("[D] [%5d.%03d] %s(%d): "fmt, \
265
wizpf_get_systick()/1000, wizpf_get_systick()%1000, __FUNCTION__, __LINE__); } while(0)
266
#define DBGFA(fmt, ...) do { printf("[D] [%5d.%03d] %s(%d): "fmt, \
267
wizpf_get_systick()/1000, wizpf_get_systick()%1000, __FUNCTION__, __LINE__, __VA_ARGS__); } while(0)
268
#elif (WIZ_LOG_LEVEL > 2) && !defined(PRINT_TIME_LOG) && !defined(FILE_LOG_SILENCE)
269
#define DBG(fmt) do { printf("[D] %s(%d): "fmt"\r\n", __FUNCTION__, __LINE__); } while(0)
270
#define DBGA(fmt, ...) do { printf("[D] %s(%d): "fmt"\r\n", __FUNCTION__, __LINE__, __VA_ARGS__); } while(0)
271
#define DBGF(fmt) do { printf("[D] %s(%d): "fmt, __FUNCTION__, __LINE__); } while(0)
272
#define DBGFA(fmt, ...) do { printf("[D] %s(%d): "fmt, __FUNCTION__, __LINE__, __VA_ARGS__); } while(0)
273
#else
274
#define DBG(fmt)
275
#define DBGA(fmt, ...)
276
#define DBGF(fmt)
277
#define DBGFA(fmt, ...)
278
#endif
279
280
#if (WIZ_LOG_LEVEL > 2) && !defined(FILE_LOG_SILENCE)
281
#define DBGCRTC(cond_v, fmt) do { if(cond_v) {ERR(fmt); while(1); } } while(0)
282
#define DBGCRTCA(cond_v, fmt, ...) do { if(cond_v) {ERRA(fmt, __VA_ARGS__); while(1); } } while(0)
283
#define DBGDUMP(data_p, len_v) print_dump(data_p, len_v)
284
#define DBGFUNC(func_p) func_p
285
#else
286
#define DBGCRTC(cond_v, fmt)
287
#define DBGCRTCA(cond_v, fmt, ...)
288
#define DBGDUMP(data_p, len_v)
289
#define DBGFUNC(func_p)
290
#endif
291
292
#if (WIZ_LOG_LEVEL > 0) && !defined(FILE_LOG_SILENCE)
293
#define NL1 printf("\r\n")
294
#define NL2 printf("\r\n\r\n")
295
#define NL3 printf("\r\n\r\n\r\n")
296
#else
297
#define NL1
298
#define NL2
299
#define NL3
300
#endif
301
302
//-------------------------------------------------------------------------------------------
303
304
305
306
#endif //_COMMON_H
307
Generated on Wed Mar 13 2013 16:12:38 for WIZlib Library API by
1.8.3.1