Port to C027 (using AppShield and Ethernet)

Dependencies:   C12832 EthernetInterface LM75B MMA7660 MQTT mbed-rtos mbed

Fork of IBMIoTClientEthernetExample by IBM Watson IoT

Committer:
samdanbury
Date:
Wed Aug 20 12:45:14 2014 +0000
Revision:
6:37b6d0d56190
Code completely changed to improve the structure, flow and memory usage of the application

Who changed what in which revision?

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