This library is deprecated.

Dependents:   HTTPClientStreamingExample HTTPClientExample HTTPServerExample HTTPServerHelloWorld ... more

Committer:
donatien
Date:
Fri Jun 11 16:25:22 2010 +0000
Revision:
0:422060928e37

        

Who changed what in which revision?

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