Version of http://mbed.org/cookbook/NetServicesTribute with setting set the same for LPC2368

Dependents:   UDPSocketExample 24LCxx_I2CApp WeatherPlatform_pachube HvZServerLib ... more

Committer:
simon
Date:
Tue Nov 23 14:15:36 2010 +0000
Revision:
0:350011bf8be7
Experimental version for testing UDP

Who changed what in which revision?

UserRevisionLine numberNew contents of line
simon 0:350011bf8be7 1 /*
simon 0:350011bf8be7 2 * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
simon 0:350011bf8be7 3 * All rights reserved.
simon 0:350011bf8be7 4 *
simon 0:350011bf8be7 5 * Redistribution and use in source and binary forms, with or without modification,
simon 0:350011bf8be7 6 * are permitted provided that the following conditions are met:
simon 0:350011bf8be7 7 *
simon 0:350011bf8be7 8 * 1. Redistributions of source code must retain the above copyright notice,
simon 0:350011bf8be7 9 * this list of conditions and the following disclaimer.
simon 0:350011bf8be7 10 * 2. Redistributions in binary form must reproduce the above copyright notice,
simon 0:350011bf8be7 11 * this list of conditions and the following disclaimer in the documentation
simon 0:350011bf8be7 12 * and/or other materials provided with the distribution.
simon 0:350011bf8be7 13 * 3. The name of the author may not be used to endorse or promote products
simon 0:350011bf8be7 14 * derived from this software without specific prior written permission.
simon 0:350011bf8be7 15 *
simon 0:350011bf8be7 16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
simon 0:350011bf8be7 17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
simon 0:350011bf8be7 18 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
simon 0:350011bf8be7 19 * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
simon 0:350011bf8be7 20 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
simon 0:350011bf8be7 21 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
simon 0:350011bf8be7 22 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
simon 0:350011bf8be7 23 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
simon 0:350011bf8be7 24 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
simon 0:350011bf8be7 25 * OF SUCH DAMAGE.
simon 0:350011bf8be7 26 *
simon 0:350011bf8be7 27 * This file is part of the lwIP TCP/IP stack.
simon 0:350011bf8be7 28 */
simon 0:350011bf8be7 29
simon 0:350011bf8be7 30 /*
simon 0:350011bf8be7 31 * This is the interface to the platform specific serial IO module
simon 0:350011bf8be7 32 * It needs to be implemented by those platforms which need SLIP or PPP
simon 0:350011bf8be7 33 */
simon 0:350011bf8be7 34
simon 0:350011bf8be7 35 #ifndef __SIO_H__
simon 0:350011bf8be7 36 #define __SIO_H__
simon 0:350011bf8be7 37
simon 0:350011bf8be7 38 #include "lwip/arch.h"
simon 0:350011bf8be7 39
simon 0:350011bf8be7 40 #ifdef __cplusplus
simon 0:350011bf8be7 41 extern "C" {
simon 0:350011bf8be7 42 #endif
simon 0:350011bf8be7 43
simon 0:350011bf8be7 44 /* If you want to define sio_fd_t elsewhere or differently,
simon 0:350011bf8be7 45 define this in your cc.h file. */
simon 0:350011bf8be7 46 #ifndef __sio_fd_t_defined
simon 0:350011bf8be7 47 typedef void * sio_fd_t;
simon 0:350011bf8be7 48 #endif
simon 0:350011bf8be7 49
simon 0:350011bf8be7 50 /* The following functions can be defined to something else in your cc.h file
simon 0:350011bf8be7 51 or be implemented in your custom sio.c file. */
simon 0:350011bf8be7 52
simon 0:350011bf8be7 53 #ifndef sio_open
simon 0:350011bf8be7 54 /**
simon 0:350011bf8be7 55 * Opens a serial device for communication.
simon 0:350011bf8be7 56 *
simon 0:350011bf8be7 57 * @param devnum device number
simon 0:350011bf8be7 58 * @return handle to serial device if successful, NULL otherwise
simon 0:350011bf8be7 59 */
simon 0:350011bf8be7 60 sio_fd_t sio_open(u8_t devnum);
simon 0:350011bf8be7 61 #endif
simon 0:350011bf8be7 62
simon 0:350011bf8be7 63 #ifndef sio_send
simon 0:350011bf8be7 64 /**
simon 0:350011bf8be7 65 * Sends a single character to the serial device.
simon 0:350011bf8be7 66 *
simon 0:350011bf8be7 67 * @param c character to send
simon 0:350011bf8be7 68 * @param fd serial device handle
simon 0:350011bf8be7 69 *
simon 0:350011bf8be7 70 * @note This function will block until the character can be sent.
simon 0:350011bf8be7 71 */
simon 0:350011bf8be7 72 void sio_send(u8_t c, sio_fd_t fd);
simon 0:350011bf8be7 73 #endif
simon 0:350011bf8be7 74
simon 0:350011bf8be7 75 #ifndef sio_recv
simon 0:350011bf8be7 76 /**
simon 0:350011bf8be7 77 * Receives a single character from the serial device.
simon 0:350011bf8be7 78 *
simon 0:350011bf8be7 79 * @param fd serial device handle
simon 0:350011bf8be7 80 *
simon 0:350011bf8be7 81 * @note This function will block until a character is received.
simon 0:350011bf8be7 82 */
simon 0:350011bf8be7 83 u8_t sio_recv(sio_fd_t fd);
simon 0:350011bf8be7 84 #endif
simon 0:350011bf8be7 85
simon 0:350011bf8be7 86 #ifndef sio_read
simon 0:350011bf8be7 87 /**
simon 0:350011bf8be7 88 * Reads from the serial device.
simon 0:350011bf8be7 89 *
simon 0:350011bf8be7 90 * @param fd serial device handle
simon 0:350011bf8be7 91 * @param data pointer to data buffer for receiving
simon 0:350011bf8be7 92 * @param len maximum length (in bytes) of data to receive
simon 0:350011bf8be7 93 * @return number of bytes actually received - may be 0 if aborted by sio_read_abort
simon 0:350011bf8be7 94 *
simon 0:350011bf8be7 95 * @note This function will block until data can be received. The blocking
simon 0:350011bf8be7 96 * can be cancelled by calling sio_read_abort().
simon 0:350011bf8be7 97 */
simon 0:350011bf8be7 98 u32_t sio_read(sio_fd_t fd, u8_t *data, u32_t len);
simon 0:350011bf8be7 99 #endif
simon 0:350011bf8be7 100
simon 0:350011bf8be7 101 #ifndef sio_tryread
simon 0:350011bf8be7 102 /**
simon 0:350011bf8be7 103 * Tries to read from the serial device. Same as sio_read but returns
simon 0:350011bf8be7 104 * immediately if no data is available and never blocks.
simon 0:350011bf8be7 105 *
simon 0:350011bf8be7 106 * @param fd serial device handle
simon 0:350011bf8be7 107 * @param data pointer to data buffer for receiving
simon 0:350011bf8be7 108 * @param len maximum length (in bytes) of data to receive
simon 0:350011bf8be7 109 * @return number of bytes actually received
simon 0:350011bf8be7 110 */
simon 0:350011bf8be7 111 u32_t sio_tryread(sio_fd_t fd, u8_t *data, u32_t len);
simon 0:350011bf8be7 112 #endif
simon 0:350011bf8be7 113
simon 0:350011bf8be7 114 #ifndef sio_write
simon 0:350011bf8be7 115 /**
simon 0:350011bf8be7 116 * Writes to the serial device.
simon 0:350011bf8be7 117 *
simon 0:350011bf8be7 118 * @param fd serial device handle
simon 0:350011bf8be7 119 * @param data pointer to data to send
simon 0:350011bf8be7 120 * @param len length (in bytes) of data to send
simon 0:350011bf8be7 121 * @return number of bytes actually sent
simon 0:350011bf8be7 122 *
simon 0:350011bf8be7 123 * @note This function will block until all data can be sent.
simon 0:350011bf8be7 124 */
simon 0:350011bf8be7 125 u32_t sio_write(sio_fd_t fd, u8_t *data, u32_t len);
simon 0:350011bf8be7 126 #endif
simon 0:350011bf8be7 127
simon 0:350011bf8be7 128 #ifndef sio_read_abort
simon 0:350011bf8be7 129 /**
simon 0:350011bf8be7 130 * Aborts a blocking sio_read() call.
simon 0:350011bf8be7 131 *
simon 0:350011bf8be7 132 * @param fd serial device handle
simon 0:350011bf8be7 133 */
simon 0:350011bf8be7 134 void sio_read_abort(sio_fd_t fd);
simon 0:350011bf8be7 135 #endif
simon 0:350011bf8be7 136
simon 0:350011bf8be7 137 #ifdef __cplusplus
simon 0:350011bf8be7 138 }
simon 0:350011bf8be7 139 #endif
simon 0:350011bf8be7 140
simon 0:350011bf8be7 141 #endif /* __SIO_H__ */