Back to home page

Quest Cross Reference

 
 

    


Warning, cross-references for /kernel/include/lwip/sio.h need to be fixed.

0001 /*
0002  * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
0003  * All rights reserved. 
0004  * 
0005  * Redistribution and use in source and binary forms, with or without modification, 
0006  * are permitted provided that the following conditions are met:
0007  *
0008  * 1. Redistributions of source code must retain the above copyright notice,
0009  *    this list of conditions and the following disclaimer.
0010  * 2. Redistributions in binary form must reproduce the above copyright notice,
0011  *    this list of conditions and the following disclaimer in the documentation
0012  *    and/or other materials provided with the distribution.
0013  * 3. The name of the author may not be used to endorse or promote products
0014  *    derived from this software without specific prior written permission. 
0015  *
0016  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 
0017  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
0018  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 
0019  * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
0020  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 
0021  * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
0022  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
0023  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 
0024  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 
0025  * OF SUCH DAMAGE.
0026  *
0027  * This file is part of the lwIP TCP/IP stack.
0028  */
0029 
0030 /*
0031  * This is the interface to the platform specific serial IO module
0032  * It needs to be implemented by those platforms which need SLIP or PPP
0033  */
0034 
0035 #ifndef __SIO_H__
0036 #define __SIO_H__
0037 
0038 #include "lwip/arch.h"
0039 
0040 #ifdef __cplusplus
0041 extern "C" {
0042 #endif
0043 
0044 /* If you want to define sio_fd_t elsewhere or differently,
0045    define this in your cc.h file. */
0046 #ifndef __sio_fd_t_defined
0047 typedef void * sio_fd_t;
0048 #endif
0049 
0050 /* The following functions can be defined to something else in your cc.h file
0051    or be implemented in your custom sio.c file. */
0052 
0053 #ifndef sio_open
0054 /**
0055  * Opens a serial device for communication.
0056  * 
0057  * @param devnum device number
0058  * @return handle to serial device if successful, NULL otherwise
0059  */
0060 sio_fd_t sio_open(u8_t devnum);
0061 #endif
0062 
0063 #ifndef sio_send
0064 /**
0065  * Sends a single character to the serial device.
0066  * 
0067  * @param c character to send
0068  * @param fd serial device handle
0069  * 
0070  * @note This function will block until the character can be sent.
0071  */
0072 void sio_send(u8_t c, sio_fd_t fd);
0073 #endif
0074 
0075 #ifndef sio_recv
0076 /**
0077  * Receives a single character from the serial device.
0078  * 
0079  * @param fd serial device handle
0080  * 
0081  * @note This function will block until a character is received.
0082  */
0083 u8_t sio_recv(sio_fd_t fd);
0084 #endif
0085 
0086 #ifndef sio_read
0087 /**
0088  * Reads from the serial device.
0089  * 
0090  * @param fd serial device handle
0091  * @param data pointer to data buffer for receiving
0092  * @param len maximum length (in bytes) of data to receive
0093  * @return number of bytes actually received - may be 0 if aborted by sio_read_abort
0094  * 
0095  * @note This function will block until data can be received. The blocking
0096  * can be cancelled by calling sio_read_abort().
0097  */
0098 u32_t sio_read(sio_fd_t fd, u8_t *data, u32_t len);
0099 #endif
0100 
0101 #ifndef sio_tryread
0102 /**
0103  * Tries to read from the serial device. Same as sio_read but returns
0104  * immediately if no data is available and never blocks.
0105  * 
0106  * @param fd serial device handle
0107  * @param data pointer to data buffer for receiving
0108  * @param len maximum length (in bytes) of data to receive
0109  * @return number of bytes actually received
0110  */
0111 u32_t sio_tryread(sio_fd_t fd, u8_t *data, u32_t len);
0112 #endif
0113 
0114 #ifndef sio_write
0115 /**
0116  * Writes to the serial device.
0117  * 
0118  * @param fd serial device handle
0119  * @param data pointer to data to send
0120  * @param len length (in bytes) of data to send
0121  * @return number of bytes actually sent
0122  * 
0123  * @note This function will block until all data can be sent.
0124  */
0125 u32_t sio_write(sio_fd_t fd, u8_t *data, u32_t len);
0126 #endif
0127 
0128 #ifndef sio_read_abort
0129 /**
0130  * Aborts a blocking sio_read() call.
0131  * 
0132  * @param fd serial device handle
0133  */
0134 void sio_read_abort(sio_fd_t fd);
0135 #endif
0136 
0137 #ifdef __cplusplus
0138 }
0139 #endif
0140 
0141 #endif /* __SIO_H__ */