Dependents:   RTnoV3 RTnoV3_LED RTnoV3_Template RTnoV3_ADC ... more

Committer:
sherckuith
Date:
Sat Dec 31 11:25:27 2011 +0000
Revision:
0:479ce5546098
Ethernet

Who changed what in which revision?

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