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