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 * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
DieterGraef 0:f9b6112278fe 3 * All rights reserved.
DieterGraef 0:f9b6112278fe 4 *
DieterGraef 0:f9b6112278fe 5 * Redistribution and use in source and binary forms, with or without modification,
DieterGraef 0:f9b6112278fe 6 * are permitted provided that the following conditions are met:
DieterGraef 0:f9b6112278fe 7 *
DieterGraef 0:f9b6112278fe 8 * 1. Redistributions of source code must retain the above copyright notice,
DieterGraef 0:f9b6112278fe 9 * this list of conditions and the following disclaimer.
DieterGraef 0:f9b6112278fe 10 * 2. Redistributions in binary form must reproduce the above copyright notice,
DieterGraef 0:f9b6112278fe 11 * this list of conditions and the following disclaimer in the documentation
DieterGraef 0:f9b6112278fe 12 * and/or other materials provided with the distribution.
DieterGraef 0:f9b6112278fe 13 * 3. The name of the author may not be used to endorse or promote products
DieterGraef 0:f9b6112278fe 14 * derived from this software without specific prior written permission.
DieterGraef 0:f9b6112278fe 15 *
DieterGraef 0:f9b6112278fe 16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
DieterGraef 0:f9b6112278fe 17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
DieterGraef 0:f9b6112278fe 18 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
DieterGraef 0:f9b6112278fe 19 * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
DieterGraef 0:f9b6112278fe 20 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
DieterGraef 0:f9b6112278fe 21 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
DieterGraef 0:f9b6112278fe 22 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
DieterGraef 0:f9b6112278fe 23 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
DieterGraef 0:f9b6112278fe 24 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
DieterGraef 0:f9b6112278fe 25 * OF SUCH DAMAGE.
DieterGraef 0:f9b6112278fe 26 *
DieterGraef 0:f9b6112278fe 27 * This file is part of the lwIP TCP/IP stack.
DieterGraef 0:f9b6112278fe 28 *
DieterGraef 0:f9b6112278fe 29 * Author: Adam Dunkels <adam@sics.se>
DieterGraef 0:f9b6112278fe 30 *
DieterGraef 0:f9b6112278fe 31 */
DieterGraef 0:f9b6112278fe 32 #ifndef __LWIP_TCPIP_H__
DieterGraef 0:f9b6112278fe 33 #define __LWIP_TCPIP_H__
DieterGraef 0:f9b6112278fe 34
DieterGraef 0:f9b6112278fe 35 #include "lwip/opt.h"
DieterGraef 0:f9b6112278fe 36
DieterGraef 0:f9b6112278fe 37 #if !NO_SYS /* don't build if not configured for use in lwipopts.h */
DieterGraef 0:f9b6112278fe 38
DieterGraef 0:f9b6112278fe 39 #include "lwip/api_msg.h"
DieterGraef 0:f9b6112278fe 40 #include "lwip/netifapi.h"
DieterGraef 0:f9b6112278fe 41 #include "lwip/pbuf.h"
DieterGraef 0:f9b6112278fe 42 #include "lwip/api.h"
DieterGraef 0:f9b6112278fe 43 #include "lwip/sys.h"
DieterGraef 0:f9b6112278fe 44 #include "lwip/timers.h"
DieterGraef 0:f9b6112278fe 45 #include "lwip/netif.h"
DieterGraef 0:f9b6112278fe 46
DieterGraef 0:f9b6112278fe 47 #ifdef __cplusplus
DieterGraef 0:f9b6112278fe 48 extern "C" {
DieterGraef 0:f9b6112278fe 49 #endif
DieterGraef 0:f9b6112278fe 50
DieterGraef 0:f9b6112278fe 51 /** Define this to something that triggers a watchdog. This is called from
DieterGraef 0:f9b6112278fe 52 * tcpip_thread after processing a message. */
DieterGraef 0:f9b6112278fe 53 #ifndef LWIP_TCPIP_THREAD_ALIVE
DieterGraef 0:f9b6112278fe 54 #define LWIP_TCPIP_THREAD_ALIVE()
DieterGraef 0:f9b6112278fe 55 #endif
DieterGraef 0:f9b6112278fe 56
DieterGraef 0:f9b6112278fe 57 #if LWIP_TCPIP_CORE_LOCKING
DieterGraef 0:f9b6112278fe 58 /** The global semaphore to lock the stack. */
DieterGraef 0:f9b6112278fe 59 extern sys_mutex_t lock_tcpip_core;
DieterGraef 0:f9b6112278fe 60 #define LOCK_TCPIP_CORE() sys_mutex_lock(&lock_tcpip_core)
DieterGraef 0:f9b6112278fe 61 #define UNLOCK_TCPIP_CORE() sys_mutex_unlock(&lock_tcpip_core)
DieterGraef 0:f9b6112278fe 62 #define TCPIP_APIMSG(m) tcpip_apimsg_lock(m)
DieterGraef 0:f9b6112278fe 63 #define TCPIP_APIMSG_ACK(m)
DieterGraef 0:f9b6112278fe 64 #define TCPIP_NETIFAPI(m) tcpip_netifapi_lock(m)
DieterGraef 0:f9b6112278fe 65 #define TCPIP_NETIFAPI_ACK(m)
DieterGraef 0:f9b6112278fe 66 #else /* LWIP_TCPIP_CORE_LOCKING */
DieterGraef 0:f9b6112278fe 67 #define LOCK_TCPIP_CORE()
DieterGraef 0:f9b6112278fe 68 #define UNLOCK_TCPIP_CORE()
DieterGraef 0:f9b6112278fe 69 #define TCPIP_APIMSG(m) tcpip_apimsg(m)
DieterGraef 0:f9b6112278fe 70 #define TCPIP_APIMSG_ACK(m) sys_sem_signal(&m->conn->op_completed)
DieterGraef 0:f9b6112278fe 71 #define TCPIP_NETIFAPI(m) tcpip_netifapi(m)
DieterGraef 0:f9b6112278fe 72 #define TCPIP_NETIFAPI_ACK(m) sys_sem_signal(&m->sem)
DieterGraef 0:f9b6112278fe 73 #endif /* LWIP_TCPIP_CORE_LOCKING */
DieterGraef 0:f9b6112278fe 74
DieterGraef 0:f9b6112278fe 75 /** Function prototype for the init_done function passed to tcpip_init */
DieterGraef 0:f9b6112278fe 76 typedef void (*tcpip_init_done_fn)(void *arg);
DieterGraef 0:f9b6112278fe 77 /** Function prototype for functions passed to tcpip_callback() */
DieterGraef 0:f9b6112278fe 78 typedef void (*tcpip_callback_fn)(void *ctx);
DieterGraef 0:f9b6112278fe 79
DieterGraef 0:f9b6112278fe 80 /* Forward declarations */
DieterGraef 0:f9b6112278fe 81 struct tcpip_callback_msg;
DieterGraef 0:f9b6112278fe 82
DieterGraef 0:f9b6112278fe 83 void tcpip_init(tcpip_init_done_fn tcpip_init_done, void *arg);
DieterGraef 0:f9b6112278fe 84
DieterGraef 0:f9b6112278fe 85 //[MS_CHANGE]
DieterGraef 0:f9b6112278fe 86 err_t tcpip_shutdown();
DieterGraef 0:f9b6112278fe 87 //[END_MS_CHANGE]
DieterGraef 0:f9b6112278fe 88
DieterGraef 0:f9b6112278fe 89 #if LWIP_NETCONN
DieterGraef 0:f9b6112278fe 90 err_t tcpip_apimsg(struct api_msg *apimsg);
DieterGraef 0:f9b6112278fe 91 #if LWIP_TCPIP_CORE_LOCKING
DieterGraef 0:f9b6112278fe 92 err_t tcpip_apimsg_lock(struct api_msg *apimsg);
DieterGraef 0:f9b6112278fe 93 #endif /* LWIP_TCPIP_CORE_LOCKING */
DieterGraef 0:f9b6112278fe 94 #endif /* LWIP_NETCONN */
DieterGraef 0:f9b6112278fe 95
DieterGraef 0:f9b6112278fe 96 err_t tcpip_input(struct pbuf *p, struct netif *inp);
DieterGraef 0:f9b6112278fe 97
DieterGraef 0:f9b6112278fe 98 #if LWIP_NETIF_API
DieterGraef 0:f9b6112278fe 99 err_t tcpip_netifapi(struct netifapi_msg *netifapimsg);
DieterGraef 0:f9b6112278fe 100 #if LWIP_TCPIP_CORE_LOCKING
DieterGraef 0:f9b6112278fe 101 err_t tcpip_netifapi_lock(struct netifapi_msg *netifapimsg);
DieterGraef 0:f9b6112278fe 102 #endif /* LWIP_TCPIP_CORE_LOCKING */
DieterGraef 0:f9b6112278fe 103 #endif /* LWIP_NETIF_API */
DieterGraef 0:f9b6112278fe 104
DieterGraef 0:f9b6112278fe 105 err_t tcpip_callback_with_block(tcpip_callback_fn function, void *ctx, u8_t block);
DieterGraef 0:f9b6112278fe 106 #define tcpip_callback(f, ctx) tcpip_callback_with_block(f, ctx, 1)
DieterGraef 0:f9b6112278fe 107
DieterGraef 0:f9b6112278fe 108 struct tcpip_callback_msg* tcpip_callbackmsg_new(tcpip_callback_fn function, void *ctx);
DieterGraef 0:f9b6112278fe 109 void tcpip_callbackmsg_delete(struct tcpip_callback_msg* msg);
DieterGraef 0:f9b6112278fe 110 err_t tcpip_trycallback(struct tcpip_callback_msg* msg);
DieterGraef 0:f9b6112278fe 111
DieterGraef 0:f9b6112278fe 112 /* free pbufs or heap memory from another context without blocking */
DieterGraef 0:f9b6112278fe 113 err_t pbuf_free_callback(struct pbuf *p);
DieterGraef 0:f9b6112278fe 114 err_t mem_free_callback(void *m);
DieterGraef 0:f9b6112278fe 115
DieterGraef 0:f9b6112278fe 116 #if LWIP_TCPIP_TIMEOUT
DieterGraef 0:f9b6112278fe 117 err_t tcpip_timeout(u32_t msecs, sys_timeout_handler h, void *arg);
DieterGraef 0:f9b6112278fe 118 err_t tcpip_untimeout(sys_timeout_handler h, void *arg);
DieterGraef 0:f9b6112278fe 119 #endif /* LWIP_TCPIP_TIMEOUT */
DieterGraef 0:f9b6112278fe 120
DieterGraef 0:f9b6112278fe 121 enum tcpip_msg_type {
DieterGraef 0:f9b6112278fe 122 #if LWIP_NETCONN
DieterGraef 0:f9b6112278fe 123 TCPIP_MSG_API,
DieterGraef 0:f9b6112278fe 124 #endif /* LWIP_NETCONN */
DieterGraef 0:f9b6112278fe 125 TCPIP_MSG_INPKT,
DieterGraef 0:f9b6112278fe 126 #if LWIP_NETIF_API
DieterGraef 0:f9b6112278fe 127 TCPIP_MSG_NETIFAPI,
DieterGraef 0:f9b6112278fe 128 #endif /* LWIP_NETIF_API */
DieterGraef 0:f9b6112278fe 129 #if LWIP_TCPIP_TIMEOUT
DieterGraef 0:f9b6112278fe 130 TCPIP_MSG_TIMEOUT,
DieterGraef 0:f9b6112278fe 131 TCPIP_MSG_UNTIMEOUT,
DieterGraef 0:f9b6112278fe 132 #endif /* LWIP_TCPIP_TIMEOUT */
DieterGraef 0:f9b6112278fe 133 TCPIP_MSG_CALLBACK,
DieterGraef 0:f9b6112278fe 134 TCPIP_MSG_CALLBACK_STATIC,
DieterGraef 0:f9b6112278fe 135 //[MS_CHANGE]
DieterGraef 0:f9b6112278fe 136 TCPIP_MSG_SHUTDOWN
DieterGraef 0:f9b6112278fe 137 //[END_MS_CHANGE]
DieterGraef 0:f9b6112278fe 138 };
DieterGraef 0:f9b6112278fe 139
DieterGraef 0:f9b6112278fe 140 struct tcpip_msg {
DieterGraef 0:f9b6112278fe 141 enum tcpip_msg_type type;
DieterGraef 0:f9b6112278fe 142 sys_sem_t *sem;
DieterGraef 0:f9b6112278fe 143 union {
DieterGraef 0:f9b6112278fe 144 #if LWIP_NETCONN
DieterGraef 0:f9b6112278fe 145 struct api_msg *apimsg;
DieterGraef 0:f9b6112278fe 146 #endif /* LWIP_NETCONN */
DieterGraef 0:f9b6112278fe 147 #if LWIP_NETIF_API
DieterGraef 0:f9b6112278fe 148 struct netifapi_msg *netifapimsg;
DieterGraef 0:f9b6112278fe 149 #endif /* LWIP_NETIF_API */
DieterGraef 0:f9b6112278fe 150 struct {
DieterGraef 0:f9b6112278fe 151 struct pbuf *p;
DieterGraef 0:f9b6112278fe 152 struct netif *netif;
DieterGraef 0:f9b6112278fe 153 } inp;
DieterGraef 0:f9b6112278fe 154 struct {
DieterGraef 0:f9b6112278fe 155 tcpip_callback_fn function;
DieterGraef 0:f9b6112278fe 156 void *ctx;
DieterGraef 0:f9b6112278fe 157 } cb;
DieterGraef 0:f9b6112278fe 158 #if LWIP_TCPIP_TIMEOUT
DieterGraef 0:f9b6112278fe 159 struct {
DieterGraef 0:f9b6112278fe 160 u32_t msecs;
DieterGraef 0:f9b6112278fe 161 sys_timeout_handler h;
DieterGraef 0:f9b6112278fe 162 void *arg;
DieterGraef 0:f9b6112278fe 163 } tmo;
DieterGraef 0:f9b6112278fe 164 #endif /* LWIP_TCPIP_TIMEOUT */
DieterGraef 0:f9b6112278fe 165 } msg;
DieterGraef 0:f9b6112278fe 166 };
DieterGraef 0:f9b6112278fe 167
DieterGraef 0:f9b6112278fe 168 #ifdef __cplusplus
DieterGraef 0:f9b6112278fe 169 }
DieterGraef 0:f9b6112278fe 170 #endif
DieterGraef 0:f9b6112278fe 171
DieterGraef 0:f9b6112278fe 172 #endif /* !NO_SYS */
DieterGraef 0:f9b6112278fe 173
DieterGraef 0:f9b6112278fe 174 #endif /* __LWIP_TCPIP_H__ */