ChibiOS 21.11.4
hal_buffered_sio.h
Go to the documentation of this file.
1/*
2 ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio
3
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15*/
16
17/**
18 * @file hal_buffered_sio.h
19 * @brief Buffered SIO Driver macros and structures.
20 *
21 * @addtogroup HAL_BUFFERED_SIO
22 * @{
23 */
24
25#ifndef HAL_BUFFERED_SIO_H
26#define HAL_BUFFERED_SIO_H
27
28#include "hal.h"
29
30#if (HAL_USE_SIO == TRUE) || defined(__DOXYGEN__)
31
32/*===========================================================================*/
33/* Driver constants. */
34/*===========================================================================*/
35
36/*===========================================================================*/
37/* Driver pre-compile time settings. */
38/*===========================================================================*/
39
40/*===========================================================================*/
41/* Derived constants and error checks. */
42/*===========================================================================*/
43
44/*===========================================================================*/
45/* Driver data structures and types. */
46/*===========================================================================*/
47
48/**
49 * @brief @p BufferedSIODriver specific methods.
50 */
51#define __buffered_sio_driver_methods \
52 __buffered_serial_methods
53
54/**
55 * @extends BufferedSerialVMT
56 *
57 * @brief @p BufferedSIODriver virtual methods table.
58 */
62
63/**
64 * @brief @p SerialDriver specific data.
65 */
66#define __buffered_sio_driver_data \
67 __buffered_serial_data \
68 SIODriver *siop;
69
70/**
71 * @extends BufferedSerial
72 *
73 * @brief Buffered SIO driver class.
74 */
76 /** @brief Virtual Methods Table.*/
80
81/**
82 * @brief Type of a buffered SIO configuration.
83 */
85
86/*===========================================================================*/
87/* Driver macros. */
88/*===========================================================================*/
89
90/**
91 * @name Macro Functions
92 * @{
93 */
94/**
95 * @brief Direct write to a @p BufferedSIODriver.
96 * @note This function bypasses the indirect access to the channel and
97 * writes directly on the output queue. This is faster but cannot
98 * be used to write to different channels implementations.
99 *
100 * @iclass
101 */
102#define bsioPutI(bsiop, b) oqPutI(&(bsiop)->oqueue, b)
103
104/**
105 * @brief Direct write to a @p BufferedSIODriver.
106 * @note This function bypasses the indirect access to the channel and
107 * writes directly on the output queue. This is faster but cannot
108 * be used to write to different channels implementations.
109 *
110 * @api
111 */
112#define bsioPut(bsiop, b) oqPut(&(bsiop)->oqueue, b)
113
114/**
115 * @brief Direct write to a @p BufferedSIODriver with timeout specification.
116 * @note This function bypasses the indirect access to the channel and
117 * writes directly on the output queue. This is faster but cannot
118 * be used to write to different channels implementations.
119 *
120 * @api
121 */
122#define bsioPutTimeout(bsiop, b, t) oqPutTimeout(&(bsiop)->oqueue, b, t)
123
124/**
125 * @brief Direct read from a @p BufferedSIODriver.
126 * @note This function bypasses the indirect access to the channel and
127 * reads directly from the input queue. This is faster but cannot
128 * be used to read from different channels implementations.
129 *
130 * @iclass
131 */
132#define bsioGetI(bsiop) iqGetI(&(bsiop)->iqueue)
133
134/**
135 * @brief Direct read from a @p BufferedSIODriver.
136 * @note This function bypasses the indirect access to the channel and
137 * reads directly from the input queue. This is faster but cannot
138 * be used to read from different channels implementations.
139 *
140 * @api
141 */
142#define bsioGet(bsiop) iqGet(&(bsiop)->iqueue)
143
144/**
145 * @brief Direct read from a @p BufferedSIODriver with timeout specification.
146 * @note This function bypasses the indirect access to the channel and
147 * reads directly from the input queue. This is faster but cannot
148 * be used to read from different channels implementations.
149 *
150 * @api
151 */
152#define bsioGetTimeout(bsiop, t) iqGetTimeout(&(bsiop)->iqueue, t)
153
154/**
155 * @brief Direct blocking write to a @p BufferedSIODriver.
156 * @note This function bypasses the indirect access to the channel and
157 * writes directly to the output queue. This is faster but cannot
158 * be used to write from different channels implementations.
159 *
160 * @iclass
161 */
162#define bsioWriteI(bsiop, b, n) oqWriteI(&(bsiop)->oqueue, b, n)
163
164/**
165 * @brief Direct blocking write to a @p BufferedSIODriver.
166 * @note This function bypasses the indirect access to the channel and
167 * writes directly to the output queue. This is faster but cannot
168 * be used to write from different channels implementations.
169 *
170 * @api
171 */
172#define bsioWrite(bsiop, b, n) oqWriteTimeout(&(bsiop)->oqueue, b, n, TIME_INFINITE)
173
174/**
175 * @brief Direct blocking write to a @p BufferedSIODriver with timeout
176 * specification.
177 * @note This function bypasses the indirect access to the channel and
178 * writes directly to the output queue. This is faster but cannot
179 * be used to write to different channels implementations.
180 *
181 * @api
182 */
183#define bsioWriteTimeout(bsiop, b, n, t) \
184 oqWriteTimeout(&(bsiop)->oqueue, b, n, t)
185
186/**
187 * @brief Direct non-blocking write to a @p BufferedSIODriver.
188 * @note This function bypasses the indirect access to the channel and
189 * writes directly to the output queue. This is faster but cannot
190 * be used to write to different channels implementations.
191 *
192 * @api
193 */
194#define bsioAsynchronousWrite(bsiop, b, n) \
195 oqWriteTimeout(&(bsiop)->oqueue, b, n, TIME_IMMEDIATE)
196
197/**
198 * @brief Direct blocking read from a @p BufferedSIODriver.
199 * @note This function bypasses the indirect access to the channel and
200 * reads directly from the input queue. This is faster but cannot
201 * be used to read from different channels implementations.
202 *
203 * @iclass
204 */
205#define bsioReadI(bsiop, b, n) iqReadI(&(bsiop)->iqueue, b, n, TIME_INFINITE)
206
207/**
208 * @brief Direct blocking read from a @p BufferedSIODriver.
209 * @note This function bypasses the indirect access to the channel and
210 * reads directly from the input queue. This is faster but cannot
211 * be used to read from different channels implementations.
212 *
213 * @api
214 */
215#define bsioRead(bsiop, b, n) iqReadTimeout(&(bsiop)->iqueue, b, n, TIME_INFINITE)
216
217/**
218 * @brief Direct blocking read from a @p BufferedSIODriver with timeout
219 * specification.
220 * @note This function bypasses the indirect access to the channel and
221 * reads directly from the input queue. This is faster but cannot
222 * be used to read from different channels implementations.
223 *
224 * @api
225 */
226#define bsioReadTimeout(bsiop, b, n, t) iqReadTimeout(&(bsiop)->iqueue, b, n, t)
227
228/**
229 * @brief Direct non-blocking read from a @p BufferedSIODriver.
230 * @note This function bypasses the indirect access to the channel and
231 * reads directly from the input queue. This is faster but cannot
232 * be used to read from different channels implementations.
233 *
234 * @api
235 */
236#define bsioAsynchronousRead(bsiop, b, n) \
237 iqReadTimeout(&(bsiop)->iqueue, b, n, TIME_IMMEDIATE)
238/** @} */
239
240/*===========================================================================*/
241/* External declarations. */
242/*===========================================================================*/
243
244#ifdef __cplusplus
245extern "C" {
246#endif
247 void bsioObjectInit(BufferedSIODriver *bsiop, SIODriver *siop,
248 uint8_t *ib, size_t ibsize,
249 uint8_t *ob, size_t obsize);
250 msg_t bsioStart(BufferedSIODriver *bsiop, const BufferedSIOConfig *config);
251 void bsioStop(BufferedSIODriver *bsiop);
252#ifdef __cplusplus
253}
254#endif
255
256#endif /* HAL_USE_SIO == TRUE */
257
258#endif /* HAL_BUFFERED_SIO */
259
260/** @} */
#define __buffered_sio_driver_data
SerialDriver specific data.
struct hal_buffered_siol_driver BufferedSIODriver
Buffered SIO driver class.
SIOConfig BufferedSIOConfig
Type of a buffered SIO configuration.
void bsioObjectInit(BufferedSIODriver *bsiop, SIODriver *siop, uint8_t *ib, size_t ibsize, uint8_t *ob, size_t obsize)
Initializes a generic serial driver object.
void bsioStop(BufferedSIODriver *bsiop)
Stops the driver.
#define __buffered_sio_driver_methods
BufferedSIODriver specific methods.
msg_t bsioStart(BufferedSIODriver *bsiop, const BufferedSIOConfig *config)
Configures and starts the driver.
struct hal_sio_config SIOConfig
Type of structure representing a SIO configuration.
Definition hal_sio.h:143
struct hal_sio_driver SIODriver
Type of structure representing a SIO driver.
Definition hal_sio.h:138
int32_t msg_t
Definition chearly.h:88
HAL subsystem header.
BufferedSIODriver virtual methods table.
Buffered SIO driver class.
const struct BufferedSIODriverVMT * vmt
Virtual Methods Table.