Control a robot over the internet using UDP and a Ethernet interface.

Dependencies:   EthernetInterface Motor TextLCD mbed-rtos mbed Socket lwip-eth lwip-sys lwip

Committer:
apatel336
Date:
Thu Oct 17 13:26:38 2013 +0000
Revision:
0:1496281373a5
Initial Release

Who changed what in which revision?

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