A version of LWIP, provided for backwards compatibility.

Dependents:   AA_DemoBoard DemoBoard HelloServerDemo DemoBoard_RangeIndicator ... more

Committer:
root@mbed.org
Date:
Tue May 08 15:32:10 2012 +0100
Revision:
0:5e1631496985
initial commit

Who changed what in which revision?

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