Geiger counter http://geigermaps.jp/Create/Tutorials/mbed_geiger/ja

Dependencies:   mbed

Committer:
okini3939
Date:
Fri Apr 15 16:51:30 2011 +0000
Revision:
0:5b2e60110d9b

        

Who changed what in which revision?

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