Dependents:   SNMPAgent HTTPServer think_speak_a cyassl-client ... more

Committer:
mamezu
Date:
Thu Dec 09 01:33:56 2010 +0000
Revision:
0:0f6c82fcde82

        

Who changed what in which revision?

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