ProjetoBB

Dependencies:   F7_Ethernet WebSocketClient mbed mcp3008

Fork of Nucleo_F746ZG_Ethernet by Dieter Graef

Committer:
DieterGraef
Date:
Sat Jun 18 10:49:12 2016 +0000
Revision:
0:f9b6112278fe
Ethernet for the NUCLEO STM32F746 Board Testprogram uses DHCP and NTP to set the clock

Who changed what in which revision?

UserRevisionLine numberNew contents of line
DieterGraef 0:f9b6112278fe 1 /**
DieterGraef 0:f9b6112278fe 2 * @file
DieterGraef 0:f9b6112278fe 3 * Common functions used throughout the stack.
DieterGraef 0:f9b6112278fe 4 *
DieterGraef 0:f9b6112278fe 5 */
DieterGraef 0:f9b6112278fe 6
DieterGraef 0:f9b6112278fe 7 /*
DieterGraef 0:f9b6112278fe 8 * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
DieterGraef 0:f9b6112278fe 9 * All rights reserved.
DieterGraef 0:f9b6112278fe 10 *
DieterGraef 0:f9b6112278fe 11 * Redistribution and use in source and binary forms, with or without modification,
DieterGraef 0:f9b6112278fe 12 * are permitted provided that the following conditions are met:
DieterGraef 0:f9b6112278fe 13 *
DieterGraef 0:f9b6112278fe 14 * 1. Redistributions of source code must retain the above copyright notice,
DieterGraef 0:f9b6112278fe 15 * this list of conditions and the following disclaimer.
DieterGraef 0:f9b6112278fe 16 * 2. Redistributions in binary form must reproduce the above copyright notice,
DieterGraef 0:f9b6112278fe 17 * this list of conditions and the following disclaimer in the documentation
DieterGraef 0:f9b6112278fe 18 * and/or other materials provided with the distribution.
DieterGraef 0:f9b6112278fe 19 * 3. The name of the author may not be used to endorse or promote products
DieterGraef 0:f9b6112278fe 20 * derived from this software without specific prior written permission.
DieterGraef 0:f9b6112278fe 21 *
DieterGraef 0:f9b6112278fe 22 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
DieterGraef 0:f9b6112278fe 23 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
DieterGraef 0:f9b6112278fe 24 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
DieterGraef 0:f9b6112278fe 25 * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
DieterGraef 0:f9b6112278fe 26 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
DieterGraef 0:f9b6112278fe 27 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
DieterGraef 0:f9b6112278fe 28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
DieterGraef 0:f9b6112278fe 29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
DieterGraef 0:f9b6112278fe 30 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
DieterGraef 0:f9b6112278fe 31 * OF SUCH DAMAGE.
DieterGraef 0:f9b6112278fe 32 *
DieterGraef 0:f9b6112278fe 33 * This file is part of the lwIP TCP/IP stack.
DieterGraef 0:f9b6112278fe 34 *
DieterGraef 0:f9b6112278fe 35 * Author: Simon Goldschmidt
DieterGraef 0:f9b6112278fe 36 *
DieterGraef 0:f9b6112278fe 37 */
DieterGraef 0:f9b6112278fe 38
DieterGraef 0:f9b6112278fe 39 #include "lwip/opt.h"
DieterGraef 0:f9b6112278fe 40 #include "lwip/def.h"
DieterGraef 0:f9b6112278fe 41
DieterGraef 0:f9b6112278fe 42 /**
DieterGraef 0:f9b6112278fe 43 * These are reference implementations of the byte swapping functions.
DieterGraef 0:f9b6112278fe 44 * Again with the aim of being simple, correct and fully portable.
DieterGraef 0:f9b6112278fe 45 * Byte swapping is the second thing you would want to optimize. You will
DieterGraef 0:f9b6112278fe 46 * need to port it to your architecture and in your cc.h:
DieterGraef 0:f9b6112278fe 47 *
DieterGraef 0:f9b6112278fe 48 * #define LWIP_PLATFORM_BYTESWAP 1
DieterGraef 0:f9b6112278fe 49 * #define LWIP_PLATFORM_HTONS(x) <your_htons>
DieterGraef 0:f9b6112278fe 50 * #define LWIP_PLATFORM_HTONL(x) <your_htonl>
DieterGraef 0:f9b6112278fe 51 *
DieterGraef 0:f9b6112278fe 52 * Note ntohs() and ntohl() are merely references to the htonx counterparts.
DieterGraef 0:f9b6112278fe 53 */
DieterGraef 0:f9b6112278fe 54
DieterGraef 0:f9b6112278fe 55 #if (LWIP_PLATFORM_BYTESWAP == 0) && (BYTE_ORDER == LITTLE_ENDIAN)
DieterGraef 0:f9b6112278fe 56
DieterGraef 0:f9b6112278fe 57 /**
DieterGraef 0:f9b6112278fe 58 * Convert an u16_t from host- to network byte order.
DieterGraef 0:f9b6112278fe 59 *
DieterGraef 0:f9b6112278fe 60 * @param n u16_t in host byte order
DieterGraef 0:f9b6112278fe 61 * @return n in network byte order
DieterGraef 0:f9b6112278fe 62 */
DieterGraef 0:f9b6112278fe 63 u16_t
DieterGraef 0:f9b6112278fe 64 lwip_htons(u16_t n)
DieterGraef 0:f9b6112278fe 65 {
DieterGraef 0:f9b6112278fe 66 return ((n & 0xff) << 8) | ((n & 0xff00) >> 8);
DieterGraef 0:f9b6112278fe 67 }
DieterGraef 0:f9b6112278fe 68
DieterGraef 0:f9b6112278fe 69 /**
DieterGraef 0:f9b6112278fe 70 * Convert an u16_t from network- to host byte order.
DieterGraef 0:f9b6112278fe 71 *
DieterGraef 0:f9b6112278fe 72 * @param n u16_t in network byte order
DieterGraef 0:f9b6112278fe 73 * @return n in host byte order
DieterGraef 0:f9b6112278fe 74 */
DieterGraef 0:f9b6112278fe 75 u16_t
DieterGraef 0:f9b6112278fe 76 lwip_ntohs(u16_t n)
DieterGraef 0:f9b6112278fe 77 {
DieterGraef 0:f9b6112278fe 78 return lwip_htons(n);
DieterGraef 0:f9b6112278fe 79 }
DieterGraef 0:f9b6112278fe 80
DieterGraef 0:f9b6112278fe 81 /**
DieterGraef 0:f9b6112278fe 82 * Convert an u32_t from host- to network byte order.
DieterGraef 0:f9b6112278fe 83 *
DieterGraef 0:f9b6112278fe 84 * @param n u32_t in host byte order
DieterGraef 0:f9b6112278fe 85 * @return n in network byte order
DieterGraef 0:f9b6112278fe 86 */
DieterGraef 0:f9b6112278fe 87 u32_t
DieterGraef 0:f9b6112278fe 88 lwip_htonl(u32_t n)
DieterGraef 0:f9b6112278fe 89 {
DieterGraef 0:f9b6112278fe 90 return ((n & 0xff) << 24) |
DieterGraef 0:f9b6112278fe 91 ((n & 0xff00) << 8) |
DieterGraef 0:f9b6112278fe 92 ((n & 0xff0000UL) >> 8) |
DieterGraef 0:f9b6112278fe 93 ((n & 0xff000000UL) >> 24);
DieterGraef 0:f9b6112278fe 94 }
DieterGraef 0:f9b6112278fe 95
DieterGraef 0:f9b6112278fe 96 /**
DieterGraef 0:f9b6112278fe 97 * Convert an u32_t from network- to host byte order.
DieterGraef 0:f9b6112278fe 98 *
DieterGraef 0:f9b6112278fe 99 * @param n u32_t in network byte order
DieterGraef 0:f9b6112278fe 100 * @return n in host byte order
DieterGraef 0:f9b6112278fe 101 */
DieterGraef 0:f9b6112278fe 102 u32_t
DieterGraef 0:f9b6112278fe 103 lwip_ntohl(u32_t n)
DieterGraef 0:f9b6112278fe 104 {
DieterGraef 0:f9b6112278fe 105 return lwip_htonl(n);
DieterGraef 0:f9b6112278fe 106 }
DieterGraef 0:f9b6112278fe 107
DieterGraef 0:f9b6112278fe 108 #endif /* (LWIP_PLATFORM_BYTESWAP == 0) && (BYTE_ORDER == LITTLE_ENDIAN) */