![](/media/cache/profiles/3f4243a6f681f2920ac3e95a63517274.50x50_q85.jpg)
code that uses Watchdog to reset Mbed every 30seconds. After 30-60mins, the ethernet interface fails to setup() after WatchDog reset.
EthernetNetIf/LPC2368/lwip/include/lwip/def.h@0:0ce833f21e63, 2012-06-07 (annotated)
- Committer:
- eqon
- Date:
- Thu Jun 07 05:44:29 2012 +0000
- Revision:
- 0:0ce833f21e63
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
eqon | 0:0ce833f21e63 | 1 | /* |
eqon | 0:0ce833f21e63 | 2 | * Copyright (c) 2001-2004 Swedish Institute of Computer Science. |
eqon | 0:0ce833f21e63 | 3 | * All rights reserved. |
eqon | 0:0ce833f21e63 | 4 | * |
eqon | 0:0ce833f21e63 | 5 | * Redistribution and use in source and binary forms, with or without modification, |
eqon | 0:0ce833f21e63 | 6 | * are permitted provided that the following conditions are met: |
eqon | 0:0ce833f21e63 | 7 | * |
eqon | 0:0ce833f21e63 | 8 | * 1. Redistributions of source code must retain the above copyright notice, |
eqon | 0:0ce833f21e63 | 9 | * this list of conditions and the following disclaimer. |
eqon | 0:0ce833f21e63 | 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
eqon | 0:0ce833f21e63 | 11 | * this list of conditions and the following disclaimer in the documentation |
eqon | 0:0ce833f21e63 | 12 | * and/or other materials provided with the distribution. |
eqon | 0:0ce833f21e63 | 13 | * 3. The name of the author may not be used to endorse or promote products |
eqon | 0:0ce833f21e63 | 14 | * derived from this software without specific prior written permission. |
eqon | 0:0ce833f21e63 | 15 | * |
eqon | 0:0ce833f21e63 | 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED |
eqon | 0:0ce833f21e63 | 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
eqon | 0:0ce833f21e63 | 18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT |
eqon | 0:0ce833f21e63 | 19 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
eqon | 0:0ce833f21e63 | 20 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT |
eqon | 0:0ce833f21e63 | 21 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
eqon | 0:0ce833f21e63 | 22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
eqon | 0:0ce833f21e63 | 23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING |
eqon | 0:0ce833f21e63 | 24 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY |
eqon | 0:0ce833f21e63 | 25 | * OF SUCH DAMAGE. |
eqon | 0:0ce833f21e63 | 26 | * |
eqon | 0:0ce833f21e63 | 27 | * This file is part of the lwIP TCP/IP stack. |
eqon | 0:0ce833f21e63 | 28 | * |
eqon | 0:0ce833f21e63 | 29 | * Author: Adam Dunkels <adam@sics.se> |
eqon | 0:0ce833f21e63 | 30 | * |
eqon | 0:0ce833f21e63 | 31 | */ |
eqon | 0:0ce833f21e63 | 32 | #ifndef __LWIP_DEF_H__ |
eqon | 0:0ce833f21e63 | 33 | #define __LWIP_DEF_H__ |
eqon | 0:0ce833f21e63 | 34 | |
eqon | 0:0ce833f21e63 | 35 | /* arch.h might define NULL already */ |
eqon | 0:0ce833f21e63 | 36 | #include "lwip/arch.h" |
eqon | 0:0ce833f21e63 | 37 | #include "lwip/opt.h" |
eqon | 0:0ce833f21e63 | 38 | |
eqon | 0:0ce833f21e63 | 39 | #ifdef __cplusplus |
eqon | 0:0ce833f21e63 | 40 | extern "C" { |
eqon | 0:0ce833f21e63 | 41 | #endif |
eqon | 0:0ce833f21e63 | 42 | |
eqon | 0:0ce833f21e63 | 43 | #define LWIP_MAX(x , y) (((x) > (y)) ? (x) : (y)) |
eqon | 0:0ce833f21e63 | 44 | #define LWIP_MIN(x , y) (((x) < (y)) ? (x) : (y)) |
eqon | 0:0ce833f21e63 | 45 | |
eqon | 0:0ce833f21e63 | 46 | #ifndef NULL |
eqon | 0:0ce833f21e63 | 47 | #define NULL ((void *)0) |
eqon | 0:0ce833f21e63 | 48 | #endif |
eqon | 0:0ce833f21e63 | 49 | |
eqon | 0:0ce833f21e63 | 50 | /** Get the absolute difference between 2 u32_t values (correcting overflows) |
eqon | 0:0ce833f21e63 | 51 | * 'a' is expected to be 'higher' (without overflow) than 'b'. */ |
eqon | 0:0ce833f21e63 | 52 | #define LWIP_U32_DIFF(a, b) (((a) >= (b)) ? ((a) - (b)) : (((a) + ((b) ^ 0xFFFFFFFF) + 1))) |
eqon | 0:0ce833f21e63 | 53 | |
eqon | 0:0ce833f21e63 | 54 | /* Endianess-optimized shifting of two u8_t to create one u16_t */ |
eqon | 0:0ce833f21e63 | 55 | #if BYTE_ORDER == LITTLE_ENDIAN |
eqon | 0:0ce833f21e63 | 56 | #define LWIP_MAKE_U16(a, b) ((a << 8) | b) |
eqon | 0:0ce833f21e63 | 57 | #else |
eqon | 0:0ce833f21e63 | 58 | #define LWIP_MAKE_U16(a, b) ((b << 8) | a) |
eqon | 0:0ce833f21e63 | 59 | #endif |
eqon | 0:0ce833f21e63 | 60 | |
eqon | 0:0ce833f21e63 | 61 | #ifndef LWIP_PLATFORM_BYTESWAP |
eqon | 0:0ce833f21e63 | 62 | #define LWIP_PLATFORM_BYTESWAP 0 |
eqon | 0:0ce833f21e63 | 63 | #endif |
eqon | 0:0ce833f21e63 | 64 | |
eqon | 0:0ce833f21e63 | 65 | #ifndef LWIP_PREFIX_BYTEORDER_FUNCS |
eqon | 0:0ce833f21e63 | 66 | /* workaround for naming collisions on some platforms */ |
eqon | 0:0ce833f21e63 | 67 | |
eqon | 0:0ce833f21e63 | 68 | #ifdef htons |
eqon | 0:0ce833f21e63 | 69 | #undef htons |
eqon | 0:0ce833f21e63 | 70 | #endif /* htons */ |
eqon | 0:0ce833f21e63 | 71 | #ifdef htonl |
eqon | 0:0ce833f21e63 | 72 | #undef htonl |
eqon | 0:0ce833f21e63 | 73 | #endif /* htonl */ |
eqon | 0:0ce833f21e63 | 74 | #ifdef ntohs |
eqon | 0:0ce833f21e63 | 75 | #undef ntohs |
eqon | 0:0ce833f21e63 | 76 | #endif /* ntohs */ |
eqon | 0:0ce833f21e63 | 77 | #ifdef ntohl |
eqon | 0:0ce833f21e63 | 78 | #undef ntohl |
eqon | 0:0ce833f21e63 | 79 | #endif /* ntohl */ |
eqon | 0:0ce833f21e63 | 80 | |
eqon | 0:0ce833f21e63 | 81 | #define htons(x) lwip_htons(x) |
eqon | 0:0ce833f21e63 | 82 | #define ntohs(x) lwip_ntohs(x) |
eqon | 0:0ce833f21e63 | 83 | #define htonl(x) lwip_htonl(x) |
eqon | 0:0ce833f21e63 | 84 | #define ntohl(x) lwip_ntohl(x) |
eqon | 0:0ce833f21e63 | 85 | #endif /* LWIP_PREFIX_BYTEORDER_FUNCS */ |
eqon | 0:0ce833f21e63 | 86 | |
eqon | 0:0ce833f21e63 | 87 | #if BYTE_ORDER == BIG_ENDIAN |
eqon | 0:0ce833f21e63 | 88 | #define lwip_htons(x) (x) |
eqon | 0:0ce833f21e63 | 89 | #define lwip_ntohs(x) (x) |
eqon | 0:0ce833f21e63 | 90 | #define lwip_htonl(x) (x) |
eqon | 0:0ce833f21e63 | 91 | #define lwip_ntohl(x) (x) |
eqon | 0:0ce833f21e63 | 92 | #define PP_HTONS(x) (x) |
eqon | 0:0ce833f21e63 | 93 | #define PP_NTOHS(x) (x) |
eqon | 0:0ce833f21e63 | 94 | #define PP_HTONL(x) (x) |
eqon | 0:0ce833f21e63 | 95 | #define PP_NTOHL(x) (x) |
eqon | 0:0ce833f21e63 | 96 | #else /* BYTE_ORDER != BIG_ENDIAN */ |
eqon | 0:0ce833f21e63 | 97 | #if LWIP_PLATFORM_BYTESWAP |
eqon | 0:0ce833f21e63 | 98 | #define lwip_htons(x) LWIP_PLATFORM_HTONS(x) |
eqon | 0:0ce833f21e63 | 99 | #define lwip_ntohs(x) LWIP_PLATFORM_HTONS(x) |
eqon | 0:0ce833f21e63 | 100 | #define lwip_htonl(x) LWIP_PLATFORM_HTONL(x) |
eqon | 0:0ce833f21e63 | 101 | #define lwip_ntohl(x) LWIP_PLATFORM_HTONL(x) |
eqon | 0:0ce833f21e63 | 102 | #else /* LWIP_PLATFORM_BYTESWAP */ |
eqon | 0:0ce833f21e63 | 103 | u16_t lwip_htons(u16_t x); |
eqon | 0:0ce833f21e63 | 104 | u16_t lwip_ntohs(u16_t x); |
eqon | 0:0ce833f21e63 | 105 | u32_t lwip_htonl(u32_t x); |
eqon | 0:0ce833f21e63 | 106 | u32_t lwip_ntohl(u32_t x); |
eqon | 0:0ce833f21e63 | 107 | #endif /* LWIP_PLATFORM_BYTESWAP */ |
eqon | 0:0ce833f21e63 | 108 | |
eqon | 0:0ce833f21e63 | 109 | /* These macros should be calculated by the preprocessor and are used |
eqon | 0:0ce833f21e63 | 110 | with compile-time constants only (so that there is no little-endian |
eqon | 0:0ce833f21e63 | 111 | overhead at runtime). */ |
eqon | 0:0ce833f21e63 | 112 | #define PP_HTONS(x) ((((x) & 0xff) << 8) | (((x) & 0xff00) >> 8)) |
eqon | 0:0ce833f21e63 | 113 | #define PP_NTOHS(x) PP_HTONS(x) |
eqon | 0:0ce833f21e63 | 114 | #define PP_HTONL(x) ((((x) & 0xff) << 24) | \ |
eqon | 0:0ce833f21e63 | 115 | (((x) & 0xff00) << 8) | \ |
eqon | 0:0ce833f21e63 | 116 | (((x) & 0xff0000UL) >> 8) | \ |
eqon | 0:0ce833f21e63 | 117 | (((x) & 0xff000000UL) >> 24)) |
eqon | 0:0ce833f21e63 | 118 | #define PP_NTOHL(x) PP_HTONL(x) |
eqon | 0:0ce833f21e63 | 119 | |
eqon | 0:0ce833f21e63 | 120 | #endif /* BYTE_ORDER == BIG_ENDIAN */ |
eqon | 0:0ce833f21e63 | 121 | |
eqon | 0:0ce833f21e63 | 122 | #ifdef __cplusplus |
eqon | 0:0ce833f21e63 | 123 | } |
eqon | 0:0ce833f21e63 | 124 | #endif |
eqon | 0:0ce833f21e63 | 125 | |
eqon | 0:0ce833f21e63 | 126 | #endif /* __LWIP_DEF_H__ */ |
eqon | 0:0ce833f21e63 | 127 |