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