ChibiOS/HAL 9.0.0
bufstreams.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 This file was contributed by Alex Lewontin.
19 */
20
21/**
22 * @file bufstreams.h
23 * @brief Buffered streams structures and macros.
24
25 * @addtogroup HAL_BUFFERED_STREAMS
26 * @{
27 */
28
29#ifndef BUFSTREAMS_H
30#define BUFSTREAMS_H
31
32/*===========================================================================*/
33/* Driver constants. */
34/*===========================================================================*/
35
36/**
37 * @brief Buffer size for unget.
38 */
39#if !defined(BUFSTREAM_BUFFER_SIZE) || defined(__DOXYGEN__)
40#define BUFSTREAM_BUFFER_SIZE 1
41#endif
42
43/*===========================================================================*/
44/* Driver pre-compile time settings. */
45/*===========================================================================*/
46
47/*===========================================================================*/
48/* Derived constants and error checks. */
49/*===========================================================================*/
50
51/*===========================================================================*/
52/* Driver data structures and types. */
53/*===========================================================================*/
54
55/**
56 * @brief @p BufferedStreamAdapter specific data.
57 */
58#define _buffered_stream_adapter_data \
59 _base_buffered_stream_data \
60 /* Pointer to a wrapped BaseSequentialStream object */ \
61 BaseSequentialStream* bssp; \
62 /* Stream buffer */ \
63 uint8_t buffer[BUFSTREAM_BUFFER_SIZE]; \
64 /* Index in the stream buffer */ \
65 size_t ndx;
66
67/**
68 * @brief @p BufferedStreamAdapter virtual methods table.
69 */
73
74/**
75 * @extends BufferedStream
76 *
77 * @brief Buffered stream adapter object.
78 */
79typedef struct {
80 /** @brief Virtual Methods Table.*/
84
85/*===========================================================================*/
86/* Driver macros. */
87/*===========================================================================*/
88
89/*===========================================================================*/
90/* External declarations. */
91/*===========================================================================*/
92
93#ifdef __cplusplus
94extern "C" {
95#endif
97#ifdef __cplusplus
98}
99#endif
100
101#endif /* MEMSTREAMS_H */
102
103/** @} */
void bsaObjectInit(BufferedStreamAdapter *bsap, BaseSequentialStream *bssp)
Buffered stream adapter object initialization.
Definition bufstreams.c:115
#define _buffered_stream_adapter_data
BufferedStreamAdapter specific data.
Definition bufstreams.h:58
#define _base_buffered_stream_methods
BaseBufferedStream specific methods.
Base stream class.
Definition hal_streams.h:90
Buffered stream adapter object.
Definition bufstreams.h:79
const struct BufferedStreamAdapterVMT * vmt
Virtual Methods Table.
Definition bufstreams.h:81
BufferedStreamAdapter virtual methods table.
Definition bufstreams.h:70