Dependents:   TimeZoneDemo EthernetJackTestCode MMEx_Challenge ntp_mem ... more

Committer:
segundo
Date:
Tue Nov 09 20:54:15 2010 +0000
Revision:
0:ac1725ba162c

        

Who changed what in which revision?

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