Trial code integration web page update with analogue data and ntp support

Dependencies:   NTPClient_NetServices mbed

Committer:
pmr1
Date:
Fri Aug 06 17:57:45 2010 +0000
Revision:
0:8cc2035bebfc

        

Who changed what in which revision?

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