Rewrite from scratch a TCP/IP stack for mbed. So far the following parts are usable: Drivers: - EMAC driver (from CMSIS 2.0) Protocols: - Ethernet protocol - ARP over ethernet for IPv4 - IPv4 over Ethernet - ICMPv4 over IPv4 - UDPv4 over IPv4 APIs: - Sockets for UDPv4 The structure of this stack is designed to be very modular. Each protocol can register one or more protocol to handle its payload, and in each protocol, an API can be hooked (like Sockets for example). This is an early release.

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Debug.h Source File

Debug.h

00001 /*
00002  * $Id: Debug.h 24 2011-06-07 15:51:50Z benoit $
00003  * $Author: benoit $
00004  * $Date: 2011-06-07 17:51:50 +0200 (mar., 07 juin 2011) $
00005  * $Rev: 24 $
00006  * 
00007  * 
00008  * 
00009  * 
00010  * 
00011  */
00012  
00013 #ifndef __DEBUG_H__
00014 #define    __DEBUG_H__
00015 
00016 #include "mbedNet.h"
00017 #include <stdio.h>
00018 #include <stdint.h>
00019 
00020 #define    DEBUG_BUFFER_DUMP_LINE_LEN        16
00021 
00022 
00023 #define    DEBUG_LEVEL_INFO        0x00000001ul
00024 #define    DEBUG_LEVEL_WARNING        0x00000002ul
00025 #define    DEBUG_LEVEL_ERROR        0x00000004ul
00026 #define    DEBUG_LEVEL_PANIC        0x00000008ul
00027 #define    DEBUG_LEVEL_VERBOSE0    0x00000010ul
00028 #define    DEBUG_LEVEL_VERBOSE1    0x00000020ul
00029 #define    DEBUG_LEVEL_VERBOSE2    0x00000040ul
00030 #define    DEBUG_LEVEL_ALL            0xFFFFFFFFul
00031 
00032 typedef uint32_t Debug_LevelMask_t;
00033 
00034 
00035 #define    DEBUG_MODULE_MBEDNETIF    0x00000001ul
00036 #define    DEBUG_MODULE_NETIF        0x00000002ul
00037 #define    DEBUG_MODULE_ARP        0x00000004ul
00038 #define    DEBUG_MODULE_ETHERNET    0x00000008ul
00039 #define    DEBUG_MODULE_IPV4        0x00000010ul
00040 #define    DEBUG_MODULE_ICMPV4        0x00000020ul
00041 #define    DEBUG_MODULE_UDPV4        0x00000040ul
00042 #define    DEBUG_MODULE_TCPV4        0x00000080ul
00043 #define    DEBUG_MODULE_SOCKETS    0x00000100ul
00044 #define    DEBUG_MODULE_QUEUE        0x00000200ul
00045 #define    DEBUG_MODULE_ALL        0xFFFFFFFFul
00046 
00047 
00048 #ifndef DEBUG_ON
00049 
00050 #define    DEBUG_SOURCE(level, x)
00051 #define    DEBUG_MODULE(level, x)
00052 #define    DEBUG(level, x)        
00053 #define    DEBUG_NOCRLF(level, x)
00054 #define    DEBUG_CLEAR()        
00055 #define    DEBUG_RAW(x)        
00056 #define    DEBUG_RAW_NOCRLF(x)    
00057 #define    DEBUG_BLOCK(x)
00058 
00059 #else    /* DEBUG_ON */
00060 
00061 #define    DEBUG_CONDITION(level)    (((DEBUG_CURRENT_MODULE_ID & debug_ModuleMask) != 0) && ((level & debug_LevelMask)) != 0)
00062 
00063 #define    DEBUG_SOURCE(level, x)    if DEBUG_CONDITION(level) \
00064                                 { \
00065                                     printf("%10s: [%10s] %s:%d %s():", \
00066                                     DEBUG_CURRENT_MODULE_NAME, \
00067                                     Debug_GetText(level), \
00068                                     __FILE__, __LINE__, __FUNCTION__); \
00069                                     printf x; printf("\r\n"); \
00070                                 }
00071                                     
00072 #define    DEBUG_MODULE(level, x)    if DEBUG_CONDITION(level) { printf("[%-10s] %10s: ", Debug_GetText(level), DEBUG_CURRENT_MODULE_NAME); printf x; printf("\r\n"); }
00073 #define    DEBUG(level, x)            if DEBUG_CONDITION(level) { printf x; printf("\r\n") }
00074 #define    DEBUG_NOCRLF(level, x)    if DEBUG_CONDITION(level) { printf x; }
00075 #define DEBUG_CLEAR()            printf("%c", 12)
00076 #define    DEBUG_RAW(x)            printf x; printf("\r\n")
00077 #define    DEBUG_RAW_NOCRLF(x)        printf x
00078 
00079 
00080 #define    DEBUG_BLOCK(level)    if DEBUG_CONDITION(level)
00081 
00082 
00083 #endif    /* DEBUG_ON */
00084 
00085 
00086 typedef uint32_t Debug_ModuleMask_t;
00087 
00088 
00089 extern Debug_LevelMask_t    debug_LevelMask;
00090 extern Debug_ModuleMask_t    debug_ModuleMask;
00091 
00092 
00093 
00094 const char *Debug_GetText(uint32_t level);
00095 void Debug_DumpBufferHex(uint8_t *buffer, int32_t length);
00096 void Debug_SetMasks(Debug_ModuleMask_t moduleMask, Debug_LevelMask_t levelMask);
00097 
00098 #endif  /* __DEBUG_H__ */