Onenet

Dependents:   K64F_eCompass_OneNET_JW

Committer:
robert_jw
Date:
Mon Jun 20 01:40:20 2016 +0000
Revision:
0:b2805b6888dc
ADS

Who changed what in which revision?

UserRevisionLine numberNew contents of line
robert_jw 0:b2805b6888dc 1 /*
robert_jw 0:b2805b6888dc 2 * Copyright (c) 2001-2003 Swedish Institute of Computer Science.
robert_jw 0:b2805b6888dc 3 * All rights reserved.
robert_jw 0:b2805b6888dc 4 *
robert_jw 0:b2805b6888dc 5 * Redistribution and use in source and binary forms, with or without modification,
robert_jw 0:b2805b6888dc 6 * are permitted provided that the following conditions are met:
robert_jw 0:b2805b6888dc 7 *
robert_jw 0:b2805b6888dc 8 * 1. Redistributions of source code must retain the above copyright notice,
robert_jw 0:b2805b6888dc 9 * this list of conditions and the following disclaimer.
robert_jw 0:b2805b6888dc 10 * 2. Redistributions in binary form must reproduce the above copyright notice,
robert_jw 0:b2805b6888dc 11 * this list of conditions and the following disclaimer in the documentation
robert_jw 0:b2805b6888dc 12 * and/or other materials provided with the distribution.
robert_jw 0:b2805b6888dc 13 * 3. The name of the author may not be used to endorse or promote products
robert_jw 0:b2805b6888dc 14 * derived from this software without specific prior written permission.
robert_jw 0:b2805b6888dc 15 *
robert_jw 0:b2805b6888dc 16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
robert_jw 0:b2805b6888dc 17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
robert_jw 0:b2805b6888dc 18 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
robert_jw 0:b2805b6888dc 19 * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
robert_jw 0:b2805b6888dc 20 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
robert_jw 0:b2805b6888dc 21 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
robert_jw 0:b2805b6888dc 22 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
robert_jw 0:b2805b6888dc 23 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
robert_jw 0:b2805b6888dc 24 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
robert_jw 0:b2805b6888dc 25 * OF SUCH DAMAGE.
robert_jw 0:b2805b6888dc 26 *
robert_jw 0:b2805b6888dc 27 * This file is part of the lwIP TCP/IP stack.
robert_jw 0:b2805b6888dc 28 *
robert_jw 0:b2805b6888dc 29 * Author: Adam Dunkels <adam@sics.se>
robert_jw 0:b2805b6888dc 30 *
robert_jw 0:b2805b6888dc 31 */
robert_jw 0:b2805b6888dc 32 #ifndef __CC_H__
robert_jw 0:b2805b6888dc 33 #define __CC_H__
robert_jw 0:b2805b6888dc 34
robert_jw 0:b2805b6888dc 35 #include <stdint.h>
robert_jw 0:b2805b6888dc 36
robert_jw 0:b2805b6888dc 37 /* Types based on stdint.h */
robert_jw 0:b2805b6888dc 38 typedef uint8_t u8_t;
robert_jw 0:b2805b6888dc 39 typedef int8_t s8_t;
robert_jw 0:b2805b6888dc 40 typedef uint16_t u16_t;
robert_jw 0:b2805b6888dc 41 typedef int16_t s16_t;
robert_jw 0:b2805b6888dc 42 typedef uint32_t u32_t;
robert_jw 0:b2805b6888dc 43 typedef int32_t s32_t;
robert_jw 0:b2805b6888dc 44 typedef uintptr_t mem_ptr_t;
robert_jw 0:b2805b6888dc 45
robert_jw 0:b2805b6888dc 46 /* Define (sn)printf formatters for these lwIP types */
robert_jw 0:b2805b6888dc 47 #define U16_F "hu"
robert_jw 0:b2805b6888dc 48 #define S16_F "hd"
robert_jw 0:b2805b6888dc 49 #define X16_F "hx"
robert_jw 0:b2805b6888dc 50 #define U32_F "lu"
robert_jw 0:b2805b6888dc 51 #define S32_F "ld"
robert_jw 0:b2805b6888dc 52 #define X32_F "lx"
robert_jw 0:b2805b6888dc 53 #define SZT_F "uz"
robert_jw 0:b2805b6888dc 54
robert_jw 0:b2805b6888dc 55 /* ARM/LPC17xx is little endian only */
robert_jw 0:b2805b6888dc 56 #define BYTE_ORDER LITTLE_ENDIAN
robert_jw 0:b2805b6888dc 57
robert_jw 0:b2805b6888dc 58 /* Use LWIP error codes */
robert_jw 0:b2805b6888dc 59 #define LWIP_PROVIDE_ERRNO
robert_jw 0:b2805b6888dc 60
robert_jw 0:b2805b6888dc 61 #if defined(__arm__) && defined(__ARMCC_VERSION)
robert_jw 0:b2805b6888dc 62 /* Keil uVision4 tools */
robert_jw 0:b2805b6888dc 63 #define PACK_STRUCT_BEGIN __packed
robert_jw 0:b2805b6888dc 64 #define PACK_STRUCT_STRUCT
robert_jw 0:b2805b6888dc 65 #define PACK_STRUCT_END
robert_jw 0:b2805b6888dc 66 #define PACK_STRUCT_FIELD(fld) fld
robert_jw 0:b2805b6888dc 67 #define ALIGNED(n) __align(n)
robert_jw 0:b2805b6888dc 68 #elif defined (__IAR_SYSTEMS_ICC__)
robert_jw 0:b2805b6888dc 69 /* IAR Embedded Workbench tools */
robert_jw 0:b2805b6888dc 70 #define PACK_STRUCT_BEGIN __packed
robert_jw 0:b2805b6888dc 71 #define PACK_STRUCT_STRUCT
robert_jw 0:b2805b6888dc 72 #define PACK_STRUCT_END
robert_jw 0:b2805b6888dc 73 #define PACK_STRUCT_FIELD(fld) fld
robert_jw 0:b2805b6888dc 74 #define IAR_STR(a) #a
robert_jw 0:b2805b6888dc 75 #define ALIGNED(n) _Pragma(IAR_STR(data_alignment= ## n ##))
robert_jw 0:b2805b6888dc 76 #else
robert_jw 0:b2805b6888dc 77 /* GCC tools (CodeSourcery) */
robert_jw 0:b2805b6888dc 78 #define PACK_STRUCT_BEGIN
robert_jw 0:b2805b6888dc 79 #define PACK_STRUCT_STRUCT __attribute__ ((__packed__))
robert_jw 0:b2805b6888dc 80 #define PACK_STRUCT_END
robert_jw 0:b2805b6888dc 81 #define PACK_STRUCT_FIELD(fld) fld
robert_jw 0:b2805b6888dc 82 #define ALIGNED(n) __attribute__((aligned (n)))
robert_jw 0:b2805b6888dc 83 #endif
robert_jw 0:b2805b6888dc 84
robert_jw 0:b2805b6888dc 85 /* Provide Thumb-2 routines for GCC to improve performance */
robert_jw 0:b2805b6888dc 86 #if defined(TOOLCHAIN_GCC) && defined(__thumb2__)
robert_jw 0:b2805b6888dc 87 #define MEMCPY(dst,src,len) thumb2_memcpy(dst,src,len)
robert_jw 0:b2805b6888dc 88 #define LWIP_CHKSUM thumb2_checksum
robert_jw 0:b2805b6888dc 89 /* Set algorithm to 0 so that unused lwip_standard_chksum function
robert_jw 0:b2805b6888dc 90 doesn't generate compiler warning */
robert_jw 0:b2805b6888dc 91 #define LWIP_CHKSUM_ALGORITHM 0
robert_jw 0:b2805b6888dc 92
robert_jw 0:b2805b6888dc 93 void* thumb2_memcpy(void* pDest, const void* pSource, size_t length);
robert_jw 0:b2805b6888dc 94 u16_t thumb2_checksum(void* pData, int length);
robert_jw 0:b2805b6888dc 95 #else
robert_jw 0:b2805b6888dc 96 /* Used with IP headers only */
robert_jw 0:b2805b6888dc 97 #define LWIP_CHKSUM_ALGORITHM 1
robert_jw 0:b2805b6888dc 98 #endif
robert_jw 0:b2805b6888dc 99
robert_jw 0:b2805b6888dc 100
robert_jw 0:b2805b6888dc 101 #ifdef LWIP_DEBUG
robert_jw 0:b2805b6888dc 102
robert_jw 0:b2805b6888dc 103 #include "stdio.h"
robert_jw 0:b2805b6888dc 104
robert_jw 0:b2805b6888dc 105 void assert_printf(char *msg, int line, char *file);
robert_jw 0:b2805b6888dc 106
robert_jw 0:b2805b6888dc 107 /* Plaform specific diagnostic output */
robert_jw 0:b2805b6888dc 108 #define LWIP_PLATFORM_DIAG(vars) printf vars
robert_jw 0:b2805b6888dc 109 #define LWIP_PLATFORM_ASSERT(flag) { assert_printf((flag), __LINE__, __FILE__); }
robert_jw 0:b2805b6888dc 110 #else
robert_jw 0:b2805b6888dc 111 #define LWIP_PLATFORM_DIAG(msg) { ; }
robert_jw 0:b2805b6888dc 112 #define LWIP_PLATFORM_ASSERT(flag) { ; }
robert_jw 0:b2805b6888dc 113 #endif
robert_jw 0:b2805b6888dc 114
robert_jw 0:b2805b6888dc 115 #include "cmsis.h"
robert_jw 0:b2805b6888dc 116 #define LWIP_PLATFORM_HTONS(x) __REV16(x)
robert_jw 0:b2805b6888dc 117 #define LWIP_PLATFORM_HTONL(x) __REV(x)
robert_jw 0:b2805b6888dc 118
robert_jw 0:b2805b6888dc 119 #endif /* __CC_H__ */