NetServices Stack source

Dependents:   HelloWorld ServoInterfaceBoardExample1 4180_Lab4

Committer:
donatien
Date:
Fri Jun 11 16:05:15 2010 +0000
Revision:
0:632c9925f013

        

Who changed what in which revision?

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